3e44e1def1 2019-05-02 1: #ifndef XVFS_CORE_H_1B4B28D60EBAA11D5FF85642FA7CA22C29E8E817
3e44e1def1 2019-05-02 2: #define XVFS_CORE_H_1B4B28D60EBAA11D5FF85642FA7CA22C29E8E817 1
f74a2e47ab 2019-05-02 3:
f74a2e47ab 2019-05-02 4: #include <tcl.h>
1ecab39ce5 2019-05-02 5:
1ecab39ce5 2019-05-02 6: #define XVFS_PROTOCOL_VERSION 1
f74a2e47ab 2019-05-02 7:
32b55a907b 2019-05-02 8: typedef const char **(*xvfs_proc_getChildren_t)(const char *path, Tcl_WideInt *count);
32b55a907b 2019-05-02 9: typedef const unsigned char *(*xvfs_proc_getData_t)(const char *path, Tcl_WideInt start, Tcl_WideInt *length);
daf25f5222 2019-05-03 10: typedef int (*xvfs_proc_getStat_t)(const char *path, Tcl_StatBuf *statBuf);
e5b6962adf 2019-05-02 11:
e5b6962adf 2019-05-02 12: struct Xvfs_FSInfo {
e5b6962adf 2019-05-02 13: int protocolVersion;
d121970301 2019-05-02 14: const char *name;
e5b6962adf 2019-05-02 15: xvfs_proc_getChildren_t getChildrenProc;
e5b6962adf 2019-05-02 16: xvfs_proc_getData_t getDataProc;
daf25f5222 2019-05-03 17: xvfs_proc_getStat_t getStatProc;
e5b6962adf 2019-05-02 18: };
e5b6962adf 2019-05-02 19:
3e44e1def1 2019-05-02 20: #define XVFS_REGISTER_INTERFACE(name) int name(Tcl_Interp *interp, struct Xvfs_FSInfo *fsInfo);
3e44e1def1 2019-05-02 21:
3e44e1def1 2019-05-02 22: #if defined(XVFS_MODE_STANDALONE)
3e44e1def1 2019-05-02 23: /*
3e44e1def1 2019-05-02 24: * In standalone mode, we just redefine calls to
3e44e1def1 2019-05-02 25: * Xvfs_Register() to go to the xvfs_standalone_register()
3e44e1def1 2019-05-02 26: * function
3e44e1def1 2019-05-02 27: */
3e44e1def1 2019-05-02 28: # define Xvfs_Register xvfs_standalone_register
b8cca3a6b4 2019-05-08 29: static XVFS_REGISTER_INTERFACE(Xvfs_Register)
3e44e1def1 2019-05-02 30:
3e44e1def1 2019-05-02 31: #elif defined(XVFS_MODE_FLEXIBLE)
3e44e1def1 2019-05-02 32: /*
b8cca3a6b4 2019-05-08 33: * In flexible mode, we just redefine calls to
b8cca3a6b4 2019-05-08 34: * Xvfs_Register() to go to the xvfs_flexible_register()
b8cca3a6b4 2019-05-08 35: * function which will either dispatch to a common
b8cca3a6b4 2019-05-08 36: * core XVFS or use the xvfs_standalone_register()
b8cca3a6b4 2019-05-08 37: * function as a standalone would.
3e44e1def1 2019-05-02 38: */
3e44e1def1 2019-05-02 39: # define Xvfs_Register xvfs_flexible_register
b8cca3a6b4 2019-05-08 40: static XVFS_REGISTER_INTERFACE(Xvfs_Register)
3e44e1def1 2019-05-02 41:
3e44e1def1 2019-05-02 42: #elif defined(XVFS_MODE_CLIENT)
3e44e1def1 2019-05-02 43: /*
3e44e1def1 2019-05-02 44: * In client mode we declare an external symbol named
3e44e1def1 2019-05-02 45: * Xvfs_Register() that must be provided by the environment
3e44e1def1 2019-05-02 46: * we are loaded into
3e44e1def1 2019-05-02 47: */
3e44e1def1 2019-05-02 48: extern XVFS_REGISTER_INTERFACE(Xvfs_Register)
3e44e1def1 2019-05-02 49:
3e44e1def1 2019-05-02 50: #elif defined(XVFS_MODE_SERVER)
3e44e1def1 2019-05-02 51: /*
3e44e1def1 2019-05-02 52: * In server mode we are going to implementing Xvfs_Register()
3e44e1def1 2019-05-02 53: * for flexible/client modes, just forward declare it
3e44e1def1 2019-05-02 54: */
3e44e1def1 2019-05-02 55: XVFS_REGISTER_INTERFACE(Xvfs_Register)
3e44e1def1 2019-05-02 56:
3e44e1def1 2019-05-02 57: #else
3e44e1def1 2019-05-02 58: # error Unsupported XVFS_MODE
acfc5037c6 2019-05-02 59: #endif
acfc5037c6 2019-05-02 60:
b8cca3a6b4 2019-05-08 61: /*
b8cca3a6b4 2019-05-08 62: * In flexible or standalone mode, directly include what
b8cca3a6b4 2019-05-08 63: * would otherwise be a separate translation unit, to
b8cca3a6b4 2019-05-08 64: * avoid symbols leaking
b8cca3a6b4 2019-05-08 65: */
b8cca3a6b4 2019-05-08 66: #if defined(XVFS_MODE_FLEXIBLE) || defined(XVFS_MODE_STANDALONE)
b8cca3a6b4 2019-05-08 67: #include <xvfs-core.c>
b8cca3a6b4 2019-05-08 68: #endif
1ecab39ce5 2019-05-02 69:
1ecab39ce5 2019-05-02 70: #endif