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
d92ba3d36d 2019-05-08 7:
77b31a15c4 2020-04-17 8: #ifdef __cplusplus
77b31a15c4 2020-04-17 9: extern "C" {
77b31a15c4 2020-04-17 10: #endif
77b31a15c4 2020-04-17 11:
32b55a907b 2019-05-02 12: typedef const char **(*xvfs_proc_getChildren_t)(const char *path, Tcl_WideInt *count);
32b55a907b 2019-05-02 13: typedef const unsigned char *(*xvfs_proc_getData_t)(const char *path, Tcl_WideInt start, Tcl_WideInt *length);
daf25f5222 2019-05-03 14: typedef int (*xvfs_proc_getStat_t)(const char *path, Tcl_StatBuf *statBuf);
e5b6962adf 2019-05-02 15:
149aa89b7d 2019-09-13 16: /*
149aa89b7d 2019-09-13 17: * Interface for the filesystem to fill out before registering.
149aa89b7d 2019-09-13 18: * The protocolVersion is provided first so that if this
149aa89b7d 2019-09-13 19: * needs to change over time it can be appropriately handled.
149aa89b7d 2019-09-13 20: */
e5b6962adf 2019-05-02 21: struct Xvfs_FSInfo {
e5b6962adf 2019-05-02 22: int protocolVersion;
d121970301 2019-05-02 23: const char *name;
e5b6962adf 2019-05-02 24: xvfs_proc_getChildren_t getChildrenProc;
e5b6962adf 2019-05-02 25: xvfs_proc_getData_t getDataProc;
daf25f5222 2019-05-03 26: xvfs_proc_getStat_t getStatProc;
e5b6962adf 2019-05-02 27: };
149aa89b7d 2019-09-13 28:
149aa89b7d 2019-09-13 29: /*
149aa89b7d 2019-09-13 30: * Error codes for various calls. This is part of the ABI and must
149aa89b7d 2019-09-13 31: * not be changed.
149aa89b7d 2019-09-13 32: */
149aa89b7d 2019-09-13 33: #define XVFS_RV_ERR_ENOENT (-8192)
149aa89b7d 2019-09-13 34: #define XVFS_RV_ERR_EINVAL (-8193)
149aa89b7d 2019-09-13 35: #define XVFS_RV_ERR_EISDIR (-8194)
149aa89b7d 2019-09-13 36: #define XVFS_RV_ERR_ENOTDIR (-8195)
149aa89b7d 2019-09-13 37: #define XVFS_RV_ERR_EFAULT (-8196)
10f67b2ced 2019-09-16 38: #define XVFS_RV_ERR_EROFS (-8197)
5583d77f1c 2019-09-14 39: #define XVFS_RV_ERR_INTERNAL (-16383)
3e44e1def1 2019-05-02 40:
3e44e1def1 2019-05-02 41: #define XVFS_REGISTER_INTERFACE(name) int name(Tcl_Interp *interp, struct Xvfs_FSInfo *fsInfo);
3e44e1def1 2019-05-02 42:
3e44e1def1 2019-05-02 43: #if defined(XVFS_MODE_STANDALONE)
3e44e1def1 2019-05-02 44: /*
3e44e1def1 2019-05-02 45: * In standalone mode, we just redefine calls to
3e44e1def1 2019-05-02 46: * Xvfs_Register() to go to the xvfs_standalone_register()
3e44e1def1 2019-05-02 47: * function
3e44e1def1 2019-05-02 48: */
3e44e1def1 2019-05-02 49: # define Xvfs_Register xvfs_standalone_register
b8cca3a6b4 2019-05-08 50: static XVFS_REGISTER_INTERFACE(Xvfs_Register)
3e44e1def1 2019-05-02 51:
3e44e1def1 2019-05-02 52: #elif defined(XVFS_MODE_FLEXIBLE)
3e44e1def1 2019-05-02 53: /*
b8cca3a6b4 2019-05-08 54: * In flexible mode, we just redefine calls to
b8cca3a6b4 2019-05-08 55: * Xvfs_Register() to go to the xvfs_flexible_register()
b8cca3a6b4 2019-05-08 56: * function which will either dispatch to a common
b8cca3a6b4 2019-05-08 57: * core XVFS or use the xvfs_standalone_register()
b8cca3a6b4 2019-05-08 58: * function as a standalone would.
3e44e1def1 2019-05-02 59: */
3e44e1def1 2019-05-02 60: # define Xvfs_Register xvfs_flexible_register
b8cca3a6b4 2019-05-08 61: static XVFS_REGISTER_INTERFACE(Xvfs_Register)
3e44e1def1 2019-05-02 62:
3e44e1def1 2019-05-02 63: #elif defined(XVFS_MODE_CLIENT)
3e44e1def1 2019-05-02 64: /*
3e44e1def1 2019-05-02 65: * In client mode we declare an external symbol named
3e44e1def1 2019-05-02 66: * Xvfs_Register() that must be provided by the environment
3e44e1def1 2019-05-02 67: * we are loaded into
3e44e1def1 2019-05-02 68: */
3e44e1def1 2019-05-02 69: extern XVFS_REGISTER_INTERFACE(Xvfs_Register)
3e44e1def1 2019-05-02 70:
3e44e1def1 2019-05-02 71: #elif defined(XVFS_MODE_SERVER)
3e44e1def1 2019-05-02 72: /*
3e44e1def1 2019-05-02 73: * In server mode we are going to implementing Xvfs_Register()
3e44e1def1 2019-05-02 74: * for flexible/client modes, just forward declare it
3e44e1def1 2019-05-02 75: */
3e44e1def1 2019-05-02 76: XVFS_REGISTER_INTERFACE(Xvfs_Register)
f1d16a3958 2019-09-17 77: int Xvfs_Init(Tcl_Interp *interp);
3e44e1def1 2019-05-02 78:
3e44e1def1 2019-05-02 79: #else
3e44e1def1 2019-05-02 80: # error Unsupported XVFS_MODE
3e44e1def1 2019-05-02 81: #endif
5f2895faba 2019-09-17 82: #undef XVFS_REGISTER_INTERFACE
b8cca3a6b4 2019-05-08 83:
b8cca3a6b4 2019-05-08 84: /*
b8cca3a6b4 2019-05-08 85: * In flexible or standalone mode, directly include what
b8cca3a6b4 2019-05-08 86: * would otherwise be a separate translation unit, to
b8cca3a6b4 2019-05-08 87: * avoid symbols leaking
b8cca3a6b4 2019-05-08 88: */
b8cca3a6b4 2019-05-08 89: #if defined(XVFS_MODE_FLEXIBLE) || defined(XVFS_MODE_STANDALONE)
b8cca3a6b4 2019-05-08 90: #include <xvfs-core.c>
b8cca3a6b4 2019-05-08 91: #endif
3e44e1def1 2019-05-02 92:
77b31a15c4 2020-04-17 93: #endif
77b31a15c4 2020-04-17 94:
77b31a15c4 2020-04-17 95: #ifdef __cplusplus
77b31a15c4 2020-04-17 96: }
1ecab39ce5 2019-05-02 97: #endif