home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / WEBSERVE / SAMBAR / DATA.1 / sambar.h < prev    next >
C/C++ Source or Header  |  1997-07-31  |  12KB  |  469 lines

  1. /*
  2. ** SAMBAR.H
  3. **
  4. **      This is the public WIN32 header file for the Sambar 
  5. **        Server application.
  6. **
  7. **        Confidential Property of Tod Sambar
  8. **        (c) Copyright Tod Sambar 1996-1997
  9. **        All rights reserved.
  10. **
  11. **
  12. ** History:
  13. ** Chg#    Date    Description                                                Resp
  14. ** ----    -------    -------------------------------------------------------    ----
  15. **        10AUG96    Created                                                    sambar
  16. **        11APR97    Added server start/stop APIs                            sambar
  17. */
  18.  
  19. #if     !defined(__SAMBAR_H__)
  20. #define __SAMBAR_H__
  21.  
  22. /*
  23. ** Types
  24. */
  25. typedef int                            SA_RETCODE;
  26. typedef long                        SA_INT;
  27. typedef int                            SA_BOOL;
  28. typedef void                        SA_VOID;
  29. typedef unsigned char                SA_BYTE;
  30. typedef char                        SA_CHAR;
  31.  
  32. #ifndef TEXT
  33. #define TEXT(x)                        (x)
  34. #endif
  35.  
  36. #ifndef MAX
  37. #define MAX(a,b)                    ((SA_INT)(a) > (SA_INT)(b) ? (a) : (b))
  38. #endif
  39.  
  40. #ifndef MIN
  41. #define MIN(a,b)                    ((SA_INT)(a) < (SA_INT)(b) ? (a) : (b))
  42. #endif
  43.  
  44. /*
  45. ** Public Structures
  46. */
  47. #define SA_CTX                        SA_VOID
  48. #define SA_CONN                        SA_VOID
  49. #define SA_PARAMS                    SA_VOID
  50. #define SA_REC                        SA_VOID
  51.  
  52.  
  53. /*
  54. ** Return Codes
  55. */
  56. #define SA_SUCCEED                    1
  57. #define SA_FAIL                        0
  58.  
  59.  
  60. /*
  61. ** Error Codes
  62. */
  63. #define SA_E_INTERNALSYSTEM            (SA_INT)0
  64. #define SA_E_ALREADYLOGGEDIN        (SA_INT)1
  65. #define SA_E_BADCOOKIE                (SA_INT)2
  66. #define SA_E_INVALIDLOGIN            (SA_INT)3
  67. #define SA_E_MAXLOGINS                (SA_INT)4
  68. #define SA_E_ALREADYDEFINED            (SA_INT)5
  69. #define SA_E_INVALIDDATA            (SA_INT)6
  70. #define SA_E_NOTIMPLEMENTED            (SA_INT)7
  71. #define SA_E_FORBIDDEN                (SA_INT)8
  72. #define SA_E_NOTFOUND                (SA_INT)9
  73. #define SA_E_DUPLICATE                (SA_INT)10
  74. #define SA_E_DBOPFAILED                (SA_INT)11
  75. #define SA_E_BADGATEWAY                (SA_INT)12
  76. #define SA_E_REDIRECT                (SA_INT)13
  77. #define SA_E_USRDEF1                (SA_INT)14
  78. #define SA_E_USRDEF2                (SA_INT)15
  79. #define SA_E_USRDEF3                (SA_INT)16
  80. #define SA_E_USRDEF4                (SA_INT)17
  81. #define SA_E_USRDEF5                (SA_INT)18
  82. #define SA_E_USRDEF6                (SA_INT)19
  83. #define SA_E_USRDEF7                (SA_INT)20
  84. #define SA_E_USRDEF8                (SA_INT)21
  85. #define SA_E_USRDEF9                (SA_INT)22
  86. #define SA_E_USRDEF10                (SA_INT)23
  87. #define SA_E_USRDEF11                (SA_INT)24
  88. #define SA_E_USRDEF12                (SA_INT)25
  89. #define SA_E_USRDEF13                (SA_INT)26
  90. #define SA_E_USRDEF14                (SA_INT)27
  91. #define SA_E_USRDEF15                (SA_INT)28
  92. #define SA_E_USRDEF16                (SA_INT)29
  93. #define SA_E_USRDEF17                (SA_INT)30
  94. #define SA_E_USRDEF18                (SA_INT)31
  95. #define SA_E_USRDEF19                (SA_INT)32
  96. #define SA_E_USRDEF20                (SA_INT)33
  97. #define SA_E_TIMEOUT                (SA_INT)34
  98. #define SA_E_SHUTDOWN                (SA_INT)35
  99. #define SA_E_SERVERDOWN                (SA_INT)36
  100.  
  101.  
  102. /*
  103. ** Actions
  104. */
  105. #define    SA_GET                        (SA_INT)1
  106. #define    SA_SET                        (SA_INT)2
  107. #define    SA_CLEAR                    (SA_INT)3
  108.  
  109. /*
  110. ** Misc Defines
  111. */
  112. #define SA_NULLTERM                    (SA_INT)-3
  113.  
  114. /*
  115. ** Context Properties
  116. */
  117. #define SA_CTXPROP_SYSADMIN            (SA_INT)1
  118. #define SA_CTXPROP_HOMEDIR            (SA_INT)2
  119. #define SA_CTXPROP_LOGDIR            (SA_INT)3
  120. #define SA_CTXPROP_DBNAME            (SA_INT)4
  121. #define SA_CTXPROP_DBUSER            (SA_INT)5
  122. #define SA_CTXPROP_DBPASSWORD        (SA_INT)6
  123. #define SA_CTXPROP_SERVERSW            (SA_INT)7
  124. #define SA_CTXPROP_SERVERPORT        (SA_INT)8
  125. #define SA_CTXPROP_SERVERNAME        (SA_INT)9
  126.  
  127. /*
  128. ** Connection Properties
  129. */
  130. #define SA_CONNPROP_HOST            (SA_INT)1
  131. #define SA_CONNPROP_AGENT            (SA_INT)2
  132. #define SA_CONNPROP_REFERER            (SA_INT)3
  133. #define SA_CONNPROP_REQUEST            (SA_INT)4
  134. #define SA_CONNPROP_REQUESTMETHOD    (SA_INT)5
  135. #define SA_CONNPROP_USERNAME        (SA_INT)6
  136. #define SA_CONNPROP_NAME            (SA_INT)7
  137. #define SA_CONNPROP_PASSWORD        (SA_INT)8
  138.  
  139. /*
  140. ** Next Page Argument
  141. */
  142. #define SA_PAGE_ARG                    TEXT("RCpage")
  143.  
  144. /*
  145. ** System Administrator Folder
  146. */
  147. #define SA_ADMIN_FOLDER                TEXT("sysadmin")
  148.  
  149. /*
  150. ** RPC authorization types
  151. */
  152. #define SA_AUTHORIZATION_ALL        (SA_INT)0        /* All clients */
  153. #define SA_AUTHORIZATION_USER        (SA_INT)1        /* Logged in users only */
  154. #define SA_AUTHORIZATION_ADMIN        (SA_INT)2        /* Admin only */
  155.  
  156. /*
  157. ** Password Management
  158. */
  159. #define SA_PASSWD_FILE                TEXT("passwd")
  160. #define SA_MAX_NAME                    (SA_INT)64
  161.  
  162. typedef struct sa__ftp
  163. {
  164.     SA_INT        privs;                                    /* FTP access */
  165.     SA_INT        dirlen;
  166.     SA_CHAR        dir[SA_MAX_NAME + 1];                    /* FTP root dir */
  167. } SA_FTP;
  168.  
  169. typedef struct sa__passwd
  170. {
  171.     SA_INT        ftpprivs;                                /* FTP priviledges */
  172.     SA_INT        nntpprivs;                                /* NNTP priviledges */
  173.     SA_INT        dirlen;
  174.     SA_INT        namelen;
  175.     SA_INT        grouplen;
  176.     SA_INT        passwordlen;
  177.     SA_CHAR        name[SA_MAX_NAME + 1];                    /* Symbolic name */
  178.     SA_CHAR        group[SA_MAX_NAME + 1];
  179.     SA_CHAR        password[SA_MAX_NAME + 1];
  180.     SA_CHAR        dir[SA_MAX_NAME + 1];                    /* FTP dir */
  181.  
  182. } SA_PASSWD;
  183.  
  184. typedef struct sa__passwduser
  185. {
  186.     SA_INT        usernamelen;
  187.     SA_CHAR        username[SA_MAX_NAME + 1];
  188. } SA_PASSWDUSER;
  189.  
  190. /*
  191. ** FTP Priviledges
  192. */
  193. #define SA_PRIV_NOACCESS            (SA_INT)0
  194. #define SA_PRIV_READONLY            (SA_INT)1
  195. #define SA_PRIV_READWRITE            (SA_INT)2
  196.  
  197. /*
  198. ** Server Types
  199. */
  200. #define SA_SERVERTYPE_HTTP            (SA_INT)100        /* Includes HTTP Proxy */
  201. #define SA_SERVERTYPE_FTP            (SA_INT)101
  202. #define SA_SERVERTYPE_SMTPPROXY        (SA_INT)102
  203. #define SA_SERVERTYPE_POP3PROXY        (SA_INT)103
  204. #define SA_SERVERTYPE_IMAP4PROXY    (SA_INT)104
  205. #define SA_SERVERTYPE_NNTP            (SA_INT)105
  206.  
  207. /*
  208. ** Record Flags
  209. */ 
  210. #define SA_REC_CREATE                (SA_INT)0x0001
  211. #define SA_REC_DELETE                (SA_INT)0x0002
  212.  
  213.  
  214. /*
  215. ** Sambar Server callbacks
  216. */
  217. typedef SA_RETCODE                (* SA_INITFUNC)(SA_CTX *ctx);
  218. typedef SA_RETCODE                (* SA_EXITFUNC)(SA_CTX *ctx);
  219. typedef SA_RETCODE                (* SA_LOGINFUNC)(SA_CTX *ctx, SA_CONN *conn, 
  220.                                     SA_CHAR *username, SA_INT usernamelen, 
  221.                                     SA_CHAR *password, SA_INT passwordlen, 
  222.                                     SA_INT *infop);
  223. typedef SA_RETCODE                (* SA_LOGOUTFUNC)(SA_CTX *ctx, SA_CONN *conn);
  224. typedef SA_RETCODE                (* SA_PROFILEFUNC)(SA_CTX *ctx, SA_CONN *conn,
  225.                                     SA_CHAR *buffer, SA_INT buflen, 
  226.                                     SA_CHAR *data);
  227. typedef SA_RETCODE                (* SA_REQUESTFUNC)(SA_CTX *ctx, SA_CONN *conn,
  228.                                     SA_CHAR *uri, SA_INT urilen, 
  229.                                     SA_PARAMS *params, SA_INT *infop);
  230. typedef SA_RETCODE                (* SA_RPCFUNC)(SA_CTX *ctx, SA_CONN *conn,
  231.                                     SA_PARAMS *params, SA_INT *infop);
  232. typedef SA_RETCODE                (* SA_PROPFUNC)(SA_CTX *ctx, SA_VOID *argp, 
  233.                                     SA_CHAR *name, SA_CHAR *value);
  234. typedef SA_RETCODE                (* SA_FTPFUNC)(SA_CTX *ctx, SA_CHAR *name,
  235.                                     SA_INT namelen, SA_CHAR *password, 
  236.                                     SA_INT passwordlen, SA_FTP *ftpresp);
  237. typedef SA_RETCODE                (* SA_NETCONNECTFUNC)(SA_CTX *ctx, 
  238.                                     SA_CHAR *ipaddr, SA_INT servertype);
  239. typedef SA_RETCODE                (* SA_HTTPPROXYFUNC)(SA_CTX *ctx, SA_CONN *conn,
  240.                                     SA_CHAR *host, SA_INT hostlen,
  241.                                     SA_CHAR *url, SA_INT urllen);
  242. typedef SA_RETCODE                (* SA_ENVTFUNC)(SA_CTX *ctx, SA_CONN *conn,
  243.                                     SA_CHAR *buffer, SA_INT buflen, 
  244.                                     SA_CHAR *data);
  245.  
  246.  
  247. /*
  248. ** Sambar Server Function Prototypes
  249. */
  250.  
  251. #define SA_PUBLIC                __cdecl
  252. #define SA_EXPORT                __declspec(dllexport)
  253.  
  254. #if defined(__cplusplus)
  255. extern "C" {
  256. #endif    /* defined(__cplusplus) */
  257.  
  258. /*
  259. ** Sambar Server startup/shutdown
  260. */
  261. extern SA_RETCODE SA_EXPORT        sa_server(
  262.                                 SA_VOID            *hWnd
  263.                                 );
  264. extern SA_RETCODE SA_EXPORT        sa_shutdown(
  265.                                 void
  266.                                 );
  267. /*
  268. ** General Functions
  269. */
  270.  
  271. extern SA_RETCODE SA_EXPORT        sa_cmd_init(
  272.                                 SA_CTX            *ctx,
  273.                                 SA_CHAR            *name,
  274.                                 SA_INT            authorization,
  275.                                 SA_CHAR            *descr,
  276.                                 SA_RPCFUNC        funcp
  277.                                 );
  278. extern SA_RETCODE SA_EXPORT        sa_props_load(
  279.                                 SA_CTX            *ctx,
  280.                                 SA_CHAR            *filename,
  281.                                 SA_CHAR            *section,
  282.                                 SA_VOID            *argp,
  283.                                 SA_PROPFUNC        funcp
  284.                                 );
  285. extern SA_RETCODE SA_EXPORT        sa_send_file(
  286.                                 SA_CONN            *conn,
  287.                                 SA_CHAR            *filename
  288.                                 );
  289. extern SA_RETCODE SA_EXPORT        sa_send_macro(
  290.                                 SA_CONN            *conn,
  291.                                 SA_CHAR            *macroname
  292.                                 );
  293. extern SA_RETCODE SA_EXPORT        sa_send_header(
  294.                                 SA_CONN            *conn,
  295.                                 SA_CHAR            *buffer,
  296.                                 SA_INT            buflen
  297.                                 );
  298. extern SA_RETCODE SA_EXPORT        sa_param(
  299.                                 SA_CTX            *ctx,
  300.                                 SA_PARAMS        *params,
  301.                                 SA_CHAR            *name,
  302.                                 SA_CHAR            **valuep,
  303.                                 SA_INT            *valuelenp
  304.                                 );
  305. extern SA_VOID SA_EXPORT        sa_log(
  306.                                 SA_CTX            *ctx,
  307.                                 SA_CHAR            *buffer
  308.                                 );
  309. extern SA_VOID SA_EXPORT        sa_observe(
  310.                                 SA_CTX            *ctx,
  311.                                 SA_CHAR            *buffer
  312.                                 );
  313. extern SA_RETCODE SA_EXPORT        sa_smtpmail(
  314.                                 SA_CTX            *ctx,
  315.                                 SA_CHAR            *from,
  316.                                 SA_CHAR            *tolist,
  317.                                 SA_CHAR            *cclist,
  318.                                 SA_CHAR            *bcclist,
  319.                                 SA_CHAR            *subject,
  320.                                 SA_CHAR            *message,
  321.                                 SA_CHAR            *attachment
  322.                                 );
  323. extern SA_RETCODE SA_EXPORT        sa_get_macro(
  324.                                 SA_CTX            *ctx,
  325.                                 SA_CHAR            *macroname,
  326.                                 SA_CHAR            **macrop,
  327.                                 SA_INT            *macrolenp
  328.                                 );
  329. extern SA_INT SA_EXPORT            sa_wildcmp(
  330.                                 SA_CTX            *ctx,
  331.                                 SA_CHAR            *wildstr,
  332.                                 SA_INT            wildstrlen,
  333.                                 SA_CHAR            *arg,
  334.                                 SA_INT            arglen
  335.                                 );
  336.                                 
  337.  
  338. /*
  339. ** Context Functions
  340. */
  341. extern SA_RETCODE SA_EXPORT        sa_ctx_global(
  342.                                 SA_CTX            **ctxp
  343.                                 );
  344. extern SA_RETCODE SA_EXPORT        sa_ctx_key(
  345.                                 SA_CTX            *ctx,
  346.                                 SA_INT            action,
  347.                                 SA_CHAR            *key,
  348.                                 SA_VOID            **valuep
  349.                                 );
  350. extern SA_RETCODE SA_EXPORT        sa_ctx_props(
  351.                                 SA_CTX            *ctx,
  352.                                 SA_INT            action,
  353.                                 SA_INT            property,
  354.                                 SA_BYTE            *buffer,
  355.                                 SA_INT            buflen,
  356.                                 SA_INT            *outlenp
  357.                                 );
  358.  
  359. /*
  360. ** Connection Functions
  361. */
  362. extern SA_RETCODE SA_EXPORT        sa_conn_key(
  363.                                 SA_CONN            *conn,
  364.                                 SA_INT            action,
  365.                                 SA_CHAR            *key,
  366.                                 SA_VOID            **valuep
  367.                                 );
  368. extern SA_RETCODE SA_EXPORT        sa_conn_props(
  369.                                 SA_CONN            *conn,
  370.                                 SA_INT            action,
  371.                                 SA_INT            property,
  372.                                 SA_BYTE            *buffer,
  373.                                 SA_INT            buflen,
  374.                                 SA_INT            *outlenp
  375.                                 );
  376. extern SA_RETCODE SA_EXPORT        sa_conn_send(
  377.                                 SA_CONN            *conn,
  378.                                 SA_CHAR            *buffer,
  379.                                 SA_INT            buflen
  380.                                 );
  381. extern SA_RETCODE SA_EXPORT        sa_conn_flush(
  382.                                 SA_CONN            *conn
  383.                                 );
  384. extern SA_RETCODE SA_EXPORT        sa_conn_redirect(
  385.                                 SA_CONN            *conn,
  386.                                 SA_CHAR            *location,
  387.                                 SA_CHAR            *buffer,
  388.                                 SA_INT            buflen
  389.                                 );
  390.  
  391. /*
  392. ** Password Management Routines
  393. */
  394. extern SA_RETCODE SA_EXPORT        sa_passwd_lookup(
  395.                                 SA_CTX            *ctx,
  396.                                 SA_CHAR            *username,
  397.                                 SA_INT            usernamelen,
  398.                                 SA_PASSWD        *passwd
  399.                                 );
  400. extern SA_RETCODE SA_EXPORT        sa_passwd_add(
  401.                                 SA_CTX            *ctx,
  402.                                 SA_CHAR            *username,
  403.                                 SA_INT            usernamelen,
  404.                                 SA_PASSWD        *passwd
  405.                                 );
  406. extern SA_RETCODE SA_EXPORT        sa_passwd_update(
  407.                                 SA_CTX            *ctx,
  408.                                 SA_CHAR            *username,
  409.                                 SA_INT            usernamelen,
  410.                                 SA_PASSWD        *passwd
  411.                                 );
  412. extern SA_RETCODE SA_EXPORT        sa_passwd_delete(
  413.                                 SA_CTX            *ctx,
  414.                                 SA_CHAR            *username,
  415.                                 SA_INT            usernamelen
  416.                                 );
  417. extern SA_RETCODE SA_EXPORT        sa_passwd_list(
  418.                                 SA_CTX            *ctx,
  419.                                 SA_PASSWDUSER    *users,
  420.                                 SA_INT            numusers,
  421.                                 SA_INT            *countp
  422.                                 );
  423.  
  424. /*
  425. ** Record Functions
  426. */
  427. extern SA_RETCODE SA_EXPORT        sa_rec_init(
  428.                                 SA_CTX            *ctx,
  429.                                 SA_CHAR            *filename,
  430.                                 SA_INT            flags,
  431.                                 SA_INT            reclen,
  432.                                 SA_REC            **recp
  433.                                 );
  434. extern SA_RETCODE SA_EXPORT        sa_rec_exit(
  435.                                 SA_REC            *rec,
  436.                                 SA_INT            flags
  437.                                 );
  438. extern SA_RETCODE SA_EXPORT        sa_rec_insert(
  439.                                 SA_REC            *rec,
  440.                                 SA_BYTE            *data,
  441.                                 SA_INT            *idp
  442.                                 );
  443. extern SA_RETCODE SA_EXPORT        sa_rec_update(
  444.                                 SA_REC            *rec,
  445.                                 SA_INT            id,
  446.                                 SA_BYTE            *data
  447.                                 );
  448. extern SA_RETCODE SA_EXPORT        sa_rec_delete(
  449.                                 SA_REC            *rec,
  450.                                 SA_INT            id
  451.                                 );
  452. extern SA_RETCODE SA_EXPORT        sa_rec_fetch(
  453.                                 SA_REC            *rec,
  454.                                 SA_INT            id,
  455.                                 SA_BYTE            *data
  456.                                 );
  457. extern SA_RETCODE SA_EXPORT        sa_rec_next(
  458.                                 SA_REC            *rec,
  459.                                 SA_INT            lastid,
  460.                                 SA_BYTE            *data,
  461.                                 SA_INT            *idp
  462.                                 );
  463.  
  464. #if defined(__cplusplus)
  465. }
  466. #endif    /* defined(__cplusplus) */
  467.  
  468. #endif /* __SAMBAR_H__ */
  469.