home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / nShell™ 1.0.3 / src / lib / nshc.h < prev    next >
Encoding:
Text File  |  1994-08-25  |  2.9 KB  |  99 lines  |  [TEXT/KAHL]

  1. HC_VERSION    10            // version of this header file
  2.  
  3. #define MAX_ARGS        100            // maximum value of argc
  4. #define LINE_MAX        2048        // maximum input line to be expected by all cmds
  5.  
  6. typedef enum { nsh_idle, nsh_start, nsh_continue, nsh_stop } t_nsh_state;
  7.  
  8. /* ======== Define some common return values ======== */
  9.  
  10. #define    NSHC_NO_ERR             0        // success
  11. #define    NSHC_ERR_GENERAL    -1        // unspecified error
  12. #define    NSHC_ERR_VERSION    -2        // NSHC_VERSION of application and command don't match
  13. #define    NSHC_ERR_PARMS        -3        // parameters don't match command definition
  14. #define    NSHC_ERR_MEMORY        -4        // memory allocation error
  15. #define    NSHC_ERR_FILE        -5        // file access error
  16.  
  17. /* ========== The Data Communication Block ========== */
  18.  
  19. typedef struct {
  20.  
  21.     // version is always first, so it can be used to detect a mismatch.
  22.  
  23.     int        version;
  24.     
  25.     // requested actions
  26.     
  27.     t_nsh_state    action;
  28.     
  29.     // returned status
  30.     
  31.     int        result;
  32.     
  33.     // passed parameters
  34.     
  35.     int        argc;
  36.     int        argv[MAX_ARGS];
  37.     char    arg_buf[LINE_MAX];
  38.     
  39.     // a handle at which the command may allocate (AND DISPOSE) storage
  40.     
  41.     Handle    data;
  42.     
  43. } t_nshc_parms;
  44.  
  45. /* ========== The Call-Back Communication Block ========== */
  46.  
  47. typedef struct {
  48.  
  49.     // NSH_putErrStr is always first, so it can be used to notify the operator
  50.     // of a version mismatch. NO OTHER CALLS ARE GUARANTEED ACROSS REVSIONS.
  51.  
  52.     void     (*NSH_putStr_err)(Str255 s);
  53.     
  54.     // output to stderr
  55.     
  56.     void     (*NSH_putchar_err)(char c);
  57.     void     (*NSH_puts_err)(char *);
  58.     void    (*NSH_printf_err)(const char *fmt, ...);
  59.     
  60.     // output to stdout
  61.     
  62.     void     (*NSH_putchar)(char c);
  63.     void     (*NSH_puts)(char *);
  64.     void     (*NSH_putStr)(Str255 s);
  65.     void    (*NSH_printf)(const char *fmt, ...);
  66.     
  67.     // input from stdin
  68.     
  69.     int     (*NSH_getchar)(void);
  70.     int     (*NSH_gets)(char *s, int max_len);
  71.     int     (*NSH_getStr)(Str255 s);
  72.     
  73.     // variable access functions
  74.     
  75.     int        (*NSH_var_set)(Str32 name, Str255 value);
  76.     int        (*NSH_var_unset)(Str32 name);
  77.     int        (*NSH_var_env)(Str32 name, Str255 value);
  78.     
  79.     // path expansion functions
  80.     
  81.     int        (*NSH_path_expand)(Str255 path);
  82.     int        (*NSH_path_to_FSSpec)( Str255 pathname, FSSpec *spec );
  83.     int        (*NSH_path_which)(Str255 path);
  84.     
  85.     // dialog functions
  86.     
  87.     void     (*NSH_notify)(Str255 s, int size);
  88.     int     (*NSH_ask)(Str255 s, int size);
  89.  
  90.     // misc
  91.     
  92.     int     (*NSH_match)( Str255 pattern, Str255 target );
  93.  
  94. } t_nshc_calls;
  95.  
  96. /* ========== The External Command Definition ========== */
  97.  
  98. typedef void (**nshc_hdl)(t_nshc_parms *nshc_parms, t_nshc_calls *nshc_calls);
  99.