home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 August / PCWorld_2001-08_cd.bin / Komunikace / sambar / _setup.1 / cspublic.h < prev    next >
C/C++ Source or Header  |  2001-04-10  |  6KB  |  272 lines

  1. /*
  2. **  CSPUBLIC.H
  3. **
  4. **    CScript Engine Public Header
  5. **
  6. **
  7. ** History:
  8. ** Chg# Date    Description                                             Resp
  9. ** ---- ------- ------------------------------------------------------- ----
  10. **      4JAN98    Created                                                 sambar
  11. */
  12.  
  13. #if     !defined(__CSPUBLIC_H__)
  14. #define __CSPUBLIC_H__
  15.  
  16. /*
  17. ** CScript Types
  18. */
  19. typedef short                    CS_RETCODE;
  20.  
  21. /*
  22. ** CScript Defines
  23. */
  24. #define CS_CTX                    void
  25. #define CS_PROG                    void
  26. #define CS_MAIN                    void
  27. #define CS_STACK                void
  28. #define CS_ARGS                    void
  29. #define CS_RESULT                void
  30.  
  31. #define CS_FAIL                 0
  32. #define CS_SUCCEED                 1
  33.  
  34. /*
  35. ** CScript Filetype Defines
  36. */
  37. #define CS_PARSEFLAGS_ASP        0x0001
  38.  
  39. /*
  40. ** CScript Error Defines
  41. */
  42. #define CS_ERRORFLAGS_TRYCATCH    0x0001
  43.  
  44. #define CS_SEVERITY_FATAL        999
  45. #define CS_SEVERITY_ERROR        1
  46. #define CS_SEVERITY_INFO        0
  47.  
  48. typedef struct cs__error
  49. {
  50.     int                e_flags;
  51.     int                e_severity;
  52.     char            *e_msg;
  53.     char            *i_func;
  54.     char            *i_filename;
  55.     int                i_linenum;
  56.     char            *p_filename;
  57.     char            *p_func;
  58.     int                p_linenum;
  59. } CS_ERROR;
  60.  
  61. typedef struct cs__constdefn
  62. {
  63.     char            *cd_name;
  64.     int                cd_type;
  65.     void            *cd_obj;
  66.     char            *cd_string;
  67.     long            cd_int;
  68.     double            cd_double;
  69.  
  70. } CS_CONSTDEFN;
  71.  
  72. typedef struct cs__funcarg
  73. {
  74.     char            *fa_name;
  75.     int                fa_datatype;
  76.     int                fa_min;
  77.     int                fa_max;
  78.     char            *fa_pattern;
  79.     char            *fa_desc;
  80. } CS_FUNCARG;
  81.  
  82. typedef CS_RETCODE    (* CS_USERFUNC)(CS_CTX *ctx, void *sactx, void *saconn, 
  83.                         CS_STACK *stack, CS_ARGS *args, int numargs, 
  84.                         CS_RESULT *result);
  85.  
  86. typedef struct cs__funcdefn
  87. {
  88.     char            *fd_name;
  89.     CS_USERFUNC        fd_func;
  90.     int                fd_returntype;
  91.     int                fd_flags;
  92.     int                fd_numargs;
  93.     CS_FUNCARG        *fd_args;
  94.     char            *fd_desc;
  95. } CS_FUNCDEFN;
  96.  
  97. #define CS_FUNCARGS_UNLIMITED    -1
  98.  
  99. #define CS_DATATYPE_UNDEFINED    0
  100. #define CS_DATATYPE_NUMBER        1            /* double */
  101. #define CS_DATATYPE_INT            2            /* int */
  102. #define CS_DATATYPE_STRING        3            /* char * */
  103. #define CS_DATATYPE_VOID        4
  104. #define CS_DATATYPE_OBJECT        5            /* void * */
  105. #define CS_DATATYPE_ARRAY        6
  106. #define CS_DATATYPE_NULL        7
  107.  
  108. #define CS_FUNCFLAGS_EXCEPTION    0x0001        /* Function throws exception */
  109.  
  110. typedef void        (* CS_ERRORFUNC)(CS_CTX *ctx, CS_PROG *prog, 
  111.                         void *sactx, void *saconn, CS_ERROR *error);
  112. typedef void        (* CS_FREEFUNC)(CS_CTX *ctx, void *sactx, void *saconn, 
  113.                         void *obj);
  114.  
  115.  
  116. /*
  117. ** CScript Function Prototypes
  118. */
  119. #ifdef    WIN32
  120. #define CS_PUBLIC        __cdecl
  121. #define CS_EXPORT        __declspec(dllexport)
  122. #else    /* UNIX */
  123. #define CS_PUBLIC
  124. #define CS_EXPORT
  125. #endif
  126.  
  127. #if defined(__cplusplus)
  128. extern "C" {
  129. #endif
  130.  
  131. extern CS_RETCODE CS_EXPORT     cs_ctx_init(
  132.                                 void                *cmctx,
  133.                                 CS_CTX                 **csctxp,
  134.                                 int                    *infop
  135.                                 );
  136. extern CS_RETCODE CS_EXPORT     cs_ctx_library(
  137.                                 CS_CTX                 *csctx,
  138.                                 CS_ERRORFUNC        errfunc,
  139.                                 void                *sactx
  140.                                 );
  141. extern CS_RETCODE CS_EXPORT     cs_ctx_global(
  142.                                 CS_CTX                 **csctxp
  143.                                 );
  144. extern CS_RETCODE CS_EXPORT        cs_ctx_exit(
  145.                                 CS_CTX                 *csctx
  146.                                 );
  147.  
  148.  
  149. extern CS_RETCODE CS_EXPORT        cs_package_define(
  150.                                 CS_CTX                 *csctx,
  151.                                 char                *package,
  152.                                 char                *desc,
  153.                                 CS_FUNCDEFN            *funcs,
  154.                                 int                    numfuncs,
  155.                                 CS_CONSTDEFN        *consts,
  156.                                 int                    numconsts
  157.                                 );
  158.  
  159. extern void CS_EXPORT            cs_throw(
  160.                                 CS_STACK            *csstack,
  161.                                 char                *msg
  162.                                 );
  163.  
  164. extern CS_RETCODE CS_EXPORT        cs_object_clear(
  165.                                 CS_STACK            *csstack,
  166.                                 void                *obj,
  167.                                 int                    objid
  168.                                 );
  169.  
  170. extern CS_RETCODE CS_EXPORT        cs_result_void(
  171.                                 CS_STACK            *csstack,
  172.                                 CS_RESULT            *result
  173.                                 );
  174. extern CS_RETCODE CS_EXPORT        cs_result_array(
  175.                                 CS_STACK            *csstack,
  176.                                 CS_RESULT            *result
  177.                                 );
  178. extern CS_RETCODE CS_EXPORT        cs_result_int(
  179.                                 CS_STACK            *csstack,
  180.                                 CS_RESULT            *result,
  181.                                 int                    arraypos,
  182.                                 long                data
  183.                                 );
  184. extern CS_RETCODE CS_EXPORT        cs_result_number(
  185.                                 CS_STACK            *csstack,
  186.                                 CS_RESULT            *result,
  187.                                 int                    arraypos,
  188.                                 double                data
  189.                                 );
  190. extern CS_RETCODE CS_EXPORT        cs_result_string(
  191.                                 CS_STACK            *csstack,
  192.                                 CS_RESULT            *result,
  193.                                 int                    arraypos,
  194.                                 char                *data,
  195.                                 int                    copy
  196.                                 );
  197. extern CS_RETCODE CS_EXPORT        cs_result_object(
  198.                                 CS_STACK            *csstack,
  199.                                 CS_RESULT            *result,
  200.                                 int                    arraypos,
  201.                                 void                *obj,
  202.                                 int                    objid,
  203.                                 CS_FREEFUNC            freefunc
  204.                                 );
  205.  
  206. extern CS_RETCODE CS_EXPORT        cs_arg_get(
  207.                                 CS_STACK            *csstack,
  208.                                 CS_ARGS                *args,
  209.                                 int                    argnum,
  210.                                 int                    *datatypep,
  211.                                 void                **valuep
  212.                                 );
  213. extern CS_RETCODE CS_EXPORT        cs_arg_set(
  214.                                 CS_STACK             *csstack,
  215.                                 CS_ARGS                *args,
  216.                                 int                    argnum,
  217.                                 int                    datatype,
  218.                                 void                *value
  219.                                 );
  220.  
  221. extern CS_RETCODE CS_EXPORT     cs_prog_alloc(
  222.                                 CS_CTX                 *csctx,
  223.                                 CS_ERRORFUNC        errfunc,
  224.                                 void                *sactx,
  225.                                 void                *saconn,
  226.                                 CS_PROG                **csprogp
  227.                                 );
  228. extern CS_RETCODE CS_EXPORT     cs_prog_free(
  229.                                 CS_CTX                 *csctx,
  230.                                 CS_PROG                *csprog
  231.                                 );
  232.  
  233. extern CS_RETCODE CS_EXPORT     cs_prog_parsefile(
  234.                                 CS_CTX                 *csctx,
  235.                                 CS_PROG                *csprog,
  236.                                 char                *filename,
  237.                                 int                    flags
  238.                                 );
  239. extern CS_RETCODE CS_EXPORT     cs_prog_parsebuf(
  240.                                 CS_CTX                 *csctx,
  241.                                 CS_PROG                *csprog,
  242.                                 char                *buffer,
  243.                                 int                    buflen
  244.                                 );
  245.  
  246. extern CS_RETCODE CS_EXPORT     cs_prog_prepare(
  247.                                 CS_CTX                 *csctx,
  248.                                 CS_PROG                *csprog,
  249.                                 void                *saconn,
  250.                                 CS_MAIN                **csmain
  251.                                 );
  252.  
  253. extern CS_RETCODE CS_EXPORT     cs_main_var(
  254.                                 CS_MAIN                *csmain,
  255.                                 char                *name,
  256.                                 int                    namelen,
  257.                                 int                    type,
  258.                                 int                    id,
  259.                                 void                *data,
  260.                                 int                    datalen,
  261.                                 int                    copybuf
  262.                                 );
  263. extern CS_RETCODE CS_EXPORT     cs_main_run(
  264.                                 CS_MAIN                *csmain
  265.                                 );
  266.  
  267. #if defined(__cplusplus)
  268. }
  269. #endif
  270.                 
  271. #endif /* __CSPUBLIC_H__ */
  272.