3e44e1def1 2019-05-02 rkeene: #ifndef XVFS_CORE_H_1B4B28D60EBAA11D5FF85642FA7CA22C29E8E817
3e44e1def1 2019-05-02 rkeene: #define XVFS_CORE_H_1B4B28D60EBAA11D5FF85642FA7CA22C29E8E817 1
f74a2e47ab 2019-05-02 rkeene:
f74a2e47ab 2019-05-02 rkeene: #include <tcl.h>
1ecab39ce5 2019-05-02 rkeene:
1ecab39ce5 2019-05-02 rkeene: #define XVFS_PROTOCOL_VERSION 1
f74a2e47ab 2019-05-02 rkeene:
32b55a907b 2019-05-02 rkeene: typedef const char **(*xvfs_proc_getChildren_t)(const char *path, Tcl_WideInt *count);
32b55a907b 2019-05-02 rkeene: typedef const unsigned char *(*xvfs_proc_getData_t)(const char *path, Tcl_WideInt start, Tcl_WideInt *length);
daf25f5222 2019-05-03 rkeene: typedef int (*xvfs_proc_getStat_t)(const char *path, Tcl_StatBuf *statBuf);
e5b6962adf 2019-05-02 rkeene:
149aa89b7d 2019-09-13 rkeene: /*
149aa89b7d 2019-09-13 rkeene: * Interface for the filesystem to fill out before registering.
149aa89b7d 2019-09-13 rkeene: * The protocolVersion is provided first so that if this
149aa89b7d 2019-09-13 rkeene: * needs to change over time it can be appropriately handled.
149aa89b7d 2019-09-13 rkeene: */
e5b6962adf 2019-05-02 rkeene: struct Xvfs_FSInfo {
e5b6962adf 2019-05-02 rkeene: int protocolVersion;
d121970301 2019-05-02 rkeene: const char *name;
e5b6962adf 2019-05-02 rkeene: xvfs_proc_getChildren_t getChildrenProc;
e5b6962adf 2019-05-02 rkeene: xvfs_proc_getData_t getDataProc;
daf25f5222 2019-05-03 rkeene: xvfs_proc_getStat_t getStatProc;
e5b6962adf 2019-05-02 rkeene: };
149aa89b7d 2019-09-13 rkeene:
149aa89b7d 2019-09-13 rkeene: /*
149aa89b7d 2019-09-13 rkeene: * Error codes for various calls. This is part of the ABI and must
149aa89b7d 2019-09-13 rkeene: * not be changed.
149aa89b7d 2019-09-13 rkeene: */
149aa89b7d 2019-09-13 rkeene: #define XVFS_RV_ERR_ENOENT (-8192)
149aa89b7d 2019-09-13 rkeene: #define XVFS_RV_ERR_EINVAL (-8193)
149aa89b7d 2019-09-13 rkeene: #define XVFS_RV_ERR_EISDIR (-8194)
149aa89b7d 2019-09-13 rkeene: #define XVFS_RV_ERR_ENOTDIR (-8195)
149aa89b7d 2019-09-13 rkeene: #define XVFS_RV_ERR_EFAULT (-8196)
3e44e1def1 2019-05-02 rkeene:
3e44e1def1 2019-05-02 rkeene: #define XVFS_REGISTER_INTERFACE(name) int name(Tcl_Interp *interp, struct Xvfs_FSInfo *fsInfo);
3e44e1def1 2019-05-02 rkeene:
3e44e1def1 2019-05-02 rkeene: #if defined(XVFS_MODE_STANDALONE)
3e44e1def1 2019-05-02 rkeene: /*
3e44e1def1 2019-05-02 rkeene: * In standalone mode, we just redefine calls to
3e44e1def1 2019-05-02 rkeene: * Xvfs_Register() to go to the xvfs_standalone_register()
3e44e1def1 2019-05-02 rkeene: * function
3e44e1def1 2019-05-02 rkeene: */
3e44e1def1 2019-05-02 rkeene: # define Xvfs_Register xvfs_standalone_register
b8cca3a6b4 2019-05-08 rkeene: static XVFS_REGISTER_INTERFACE(Xvfs_Register)
3e44e1def1 2019-05-02 rkeene:
3e44e1def1 2019-05-02 rkeene: #elif defined(XVFS_MODE_FLEXIBLE)
3e44e1def1 2019-05-02 rkeene: /*
b8cca3a6b4 2019-05-08 rkeene: * In flexible mode, we just redefine calls to
b8cca3a6b4 2019-05-08 rkeene: * Xvfs_Register() to go to the xvfs_flexible_register()
b8cca3a6b4 2019-05-08 rkeene: * function which will either dispatch to a common
b8cca3a6b4 2019-05-08 rkeene: * core XVFS or use the xvfs_standalone_register()
b8cca3a6b4 2019-05-08 rkeene: * function as a standalone would.
3e44e1def1 2019-05-02 rkeene: */
3e44e1def1 2019-05-02 rkeene: # define Xvfs_Register xvfs_flexible_register
b8cca3a6b4 2019-05-08 rkeene: static XVFS_REGISTER_INTERFACE(Xvfs_Register)
3e44e1def1 2019-05-02 rkeene:
3e44e1def1 2019-05-02 rkeene: #elif defined(XVFS_MODE_CLIENT)
3e44e1def1 2019-05-02 rkeene: /*
3e44e1def1 2019-05-02 rkeene: * In client mode we declare an external symbol named
3e44e1def1 2019-05-02 rkeene: * Xvfs_Register() that must be provided by the environment
3e44e1def1 2019-05-02 rkeene: * we are loaded into
3e44e1def1 2019-05-02 rkeene: */
3e44e1def1 2019-05-02 rkeene: extern XVFS_REGISTER_INTERFACE(Xvfs_Register)
3e44e1def1 2019-05-02 rkeene:
3e44e1def1 2019-05-02 rkeene: #elif defined(XVFS_MODE_SERVER)
3e44e1def1 2019-05-02 rkeene: /*
3e44e1def1 2019-05-02 rkeene: * In server mode we are going to implementing Xvfs_Register()
3e44e1def1 2019-05-02 rkeene: * for flexible/client modes, just forward declare it
3e44e1def1 2019-05-02 rkeene: */
3e44e1def1 2019-05-02 rkeene: XVFS_REGISTER_INTERFACE(Xvfs_Register)
3e44e1def1 2019-05-02 rkeene:
3e44e1def1 2019-05-02 rkeene: #else
3e44e1def1 2019-05-02 rkeene: # error Unsupported XVFS_MODE
acfc5037c6 2019-05-02 rkeene: #endif
acfc5037c6 2019-05-02 rkeene:
b8cca3a6b4 2019-05-08 rkeene: /*
b8cca3a6b4 2019-05-08 rkeene: * In flexible or standalone mode, directly include what
b8cca3a6b4 2019-05-08 rkeene: * would otherwise be a separate translation unit, to
b8cca3a6b4 2019-05-08 rkeene: * avoid symbols leaking
b8cca3a6b4 2019-05-08 rkeene: */
b8cca3a6b4 2019-05-08 rkeene: #if defined(XVFS_MODE_FLEXIBLE) || defined(XVFS_MODE_STANDALONE)
b8cca3a6b4 2019-05-08 rkeene: #include <xvfs-core.c>
b8cca3a6b4 2019-05-08 rkeene: #endif
1ecab39ce5 2019-05-02 rkeene:
1ecab39ce5 2019-05-02 rkeene: #endif