home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 9 / CD_ASCQ_09_1193.iso / maj / 1668 / woio.h < prev    next >
C/C++ Source or Header  |  1993-09-29  |  11KB  |  261 lines

  1. /******************************************************************\
  2. *                                                                  *
  3. *           w       w                oooo                           *
  4. *           w       w  iii  n   n   o    o   n   n  eeee            *
  5. *           w       w   i   nn  n  o      o  nn  n  e               *
  6. *           w   w   w   i   n n n  o      o  n n n  eee             *
  7. *              w w w w    i   n  nn   o    o   n  nn  e               *
  8. *              w   w    iii  n   n    oooo    n   n  eeee            *
  9. *                                                                      *
  10. *     C o m m a n d   L a n g u a g e   I n t e r p r e t e r      *
  11. *                                                                      *
  12. *                                                                      *
  13. *    Written by Lucien Cinc                                         *
  14. *    Copyright (c) 1992, 1993                                       *
  15. *                                                                   *
  16. *    This library allows programs to preform I/O functions that     *
  17. *    intract with the main WinOne window. Some programs will only   *
  18. *    need to be modified to include this library to compile,          *
  19. *    however this will NOT generally be the case. When a program    *
  20. *    uses the FILE streams to write to stdin or stdout, the          *
  21. *    output will most likely end up writing to the desktop window.  *
  22. *                                                                  *
  23. *    For example:-                                                  *
  24. *                                                                  *
  25. *        fputc(c, stdout) or putc(c)                                *
  26. *                                                                  *
  27. *    will not write to the main WinOne window, but will still       *    
  28. *    compile, even though it will not produce the desired result.   *
  29. *    Programs should NOT use any f... stream functions, because     *
  30. *    they do NOT allow windows to multi-task when used inside a     *
  31. *    windows program, that is, functions that use FILE *stream       *
  32. *    (eg. fopen, fread, fwrite, fclose, fprintf, etc...).           *
  33. *                                                                  *
  34. *    The I/O functions provided in this library attempt to mimic    *
  35. *    the standard I/O functions as accurately as possible. There    *
  36. *    are also many functions in this library that greatly           *    
  37. *    simplifies the task of programming commands.                   *
  38. *                                                                   *
  39. *    The entry function main does not include argc and argv         *
  40. *    arguments, these arguments are implemented as functions.       *
  41. *    The arg... functions provided in this library greatly          *
  42. *    simplify the processing of command line arguments.             *
  43. *                                                                  *
  44. *    A module definition file (ie. .DEF file) needs to be           *
  45. *    created. WinOne uses the DESCRIPTION field in the .DEF file       *    
  46. *    to determine whether a program is an external command. For     *
  47. *    example, consider the following sample .DEF file :-            *
  48. *                                                                  *
  49. *        NAME               XXXX                                       *
  50. *        DESCRIPTION        'WinOne Command XXXX - Copyright etc...'   *
  51. *        EXETYPE            WINDOWS                                    *
  52. *        CODE            PRELOAD MOVEABLE                           *
  53. *        DATA            PRELOAD MOVEABLE MULTIPLE                  *
  54. *        HEAPSIZE        37888                                      *
  55. *        STACKSIZE        6144                                       *
  56. *                                                                  *
  57. *    The DESCRIPTION field must start with 'WinOne Command'. This   *    
  58. *    string is case sensitive. The 'XXXX' part of this field is     *
  59. *    not currently checked, but will be in latter releases of       *
  60. *    WinOne, so please include it, in capital letters. The rest     *
  61. *    of the string is ignored.                                        *
  62. *                                                                  *
  63. *    The library is compiled using the MEDIUM memory model. This       *    
  64. *    allows both FAR and NEAR pointers to be used, so compile       *
  65. *    your programs using the MEDIUM memory model.                    *    
  66. *                                                                  *
  67. *    A sample program :-                                              *
  68. *                                                                  *
  69. *        #include "woio.h"                                          *
  70. *                                                                  *
  71. *        void main(void)                                            *
  72. *        {                                                          *
  73. *            printf("Hello, World\n");                              *
  74. *        }                                                          *
  75. *                                                                  *
  76. *                                                                   *
  77. *                                                                   *    
  78. *    Note: When typing this file out from the WinOne prompt, use    *
  79. *          the /4 switch, since I set tabs to be only 4 space       *
  80. *          characters. For example :-                               *
  81. *                                                                  *
  82. *                type woio.h /4                                     *
  83. *                                                                  *
  84. \******************************************************************/
  85.  
  86. #ifndef __WOIO_H
  87. #define __WOIO_H
  88.  
  89. #include <windows.h>
  90.  
  91. /*
  92.     include stdio.h here so that the macros putchar
  93.     and getchar    can be removed!
  94. */
  95.  
  96. #include <stdio.h>
  97.  
  98. #ifdef putchar
  99. #undef putchar
  100. #endif    /* putchar */
  101.  
  102. #ifdef getchar
  103. #undef getchar
  104. #endif    /* getchar */
  105.  
  106. #ifdef __cplusplus
  107. extern "C" {
  108. #endif  /* __cplusplus */
  109.  
  110. #define BLACK            (char )128   /* text colours */
  111. #define    RED             (char )129
  112. #define GREEN            (char )130
  113. #define BLUE            (char )131
  114. #define YELLOW             (char )132
  115. #define MAGENTA            (char )133
  116. #define CYAN            (char )134
  117. #define WHITE            (char )135
  118. #define LIGHTGRAY        (char )136
  119. #define LIGHTRED        (char )137
  120. #define LIGHTGREEN        (char )138
  121. #define LIGHTBLUE        (char )139
  122. #define BROWN            (char )140
  123. #define LIGHTMAGENTA    (char )141
  124. #define LIGHTCYAN        (char )142
  125. #define DARKGRAY        (char )143
  126.  
  127. /*******************************\
  128. *                                *
  129. *        Control Functions        *
  130. *                                *
  131. \*******************************/
  132.  
  133. void more(BOOL flag);                    /* buffered screen output */
  134. BOOL isbreak(void);                        /* ^C pressed check */
  135.  
  136. /*******************************\
  137. *                                *
  138. *     Screen Output Functions    *
  139. *                                *
  140. \*******************************/
  141.  
  142. int  printf(const char *fmt, ...);      /* printf formated output */
  143. int  puts(const char *s);                /* string output + CR-LF */
  144. int  putchar(const int c);                /* character output    */
  145. int  putch(int c);                        /* character output    */
  146. void perror(const char *msg);            /* display an error message    */
  147. void textcolor(int col);                /* set the text colour */
  148.  
  149. void clrscr(void);                        /* clear the screen */
  150. void clreol(void);                        /* clear till end of line */
  151. void gotoxy(int x, int y);                /* position cursor on screen */
  152. int  wherex(void);                        /* location of caret (horizontal) */
  153. int  wherey(void);                        /* location of caret (vertical) */
  154.  
  155. int scrwidth(void);                        /* screen width in characters */
  156. int scrheight(void);                    /* screen height in character */
  157.  
  158. /*******************************\
  159. *                                *
  160. *         Input Functions        *
  161. *                                *
  162. \*******************************/
  163.  
  164. int  scanf(const char *fmt, ...);        /* scanf formated input    */
  165. char *gets(char *s);                    /* get a string    */
  166. int  getchar(void);                        /* get a character */
  167. int  getch(void);                        /* get a character no echo */
  168.  
  169. /*******************************\
  170. *                                *
  171. *     Command Line Functions        *
  172. *                                *
  173. \*******************************/
  174.  
  175. int  argc(void);                        /* number of arguments */
  176. char *argv(int index);                     /* get an argument */
  177. int  argn(void);                        /* number of switches */
  178. char *args(void);                        /* get all switches */
  179.  
  180. char *argpath(int index);                /* get path argument */
  181. char *argabs(int index);                /* get absolute path argument */
  182. char *argtail(void);                    /* get command line tail */
  183. char *argstr(int index);                /* get command line string */
  184. int  argnstr(void);                        /* number of command line strings */
  185. BOOL isargstr(int index);                /* is an argument a string */
  186.  
  187. /*******************************\
  188. *                                *
  189. *       Status Bar Functions        *
  190. *                                *
  191. \*******************************/
  192.  
  193. void limit(unsigned long upper);        /* status bar upper limit */
  194. void inc(unsigned long value);            /* status bar increment by value */
  195. void empty(void);                        /* empty status bar */
  196.  
  197. /*******************************\
  198. *                                *
  199. *          File Functions            *
  200. *                                *
  201. \*******************************/
  202.  
  203. #define ATT_RHSDA     (unsigned int )(FA_RDONLY|FA_HIDDEN|FA_SYSTEM|FA_DIREC|FA_ARCH)
  204. #define ATT_RHSA     (unsigned int )(FA_RDONLY|FA_HIDDEN|FA_SYSTEM|FA_ARCH)
  205.  
  206. int fillfile(char *path, unsigned int attr);    /* block file fill */
  207. BOOL getfile(int index, struct ffblk *pff);        /* get file ffblk */
  208. char *getfilepath(int index);                     /* get file path, may not be a fully qualified path */
  209. char *getfilename(int index);                    /* get file name */
  210. char *padfilename(char *path);                  /* pad a filename for displaying */
  211.  
  212. /*******************************\
  213. *                                *
  214. *          Path Functions            *
  215. *                                *
  216. \*******************************/
  217.  
  218. int fillpath(char *path);                /* block path fill */
  219. int fillpathall(void);                    /* block path fill for all drives */
  220. void freepaths(void);                    /* free paths */
  221. char *getpath(int index);                /* get a path */
  222. int totalfiles(void);                    /* total number of files in paths */
  223.  
  224. /*******************************\
  225. *                                *
  226. *   Unix conversion functions   *
  227. *                                *
  228. \*******************************/
  229.  
  230. char *unixpath(char *path);                /* convert dos path to unix */
  231. char *unixcmd(char *cmd);                /* convert dos command to unix */
  232. int isunix(void);                        /* unix mode flag */
  233. char *todospath(char *path);            /* convert unix path to dos */
  234. char *todoscmd(char *cmd);                /* convert unix command to dos */
  235.  
  236. /*******************************\
  237. *                                *
  238. *    Environment Functions        *
  239. *                                *
  240. \*******************************/
  241.  
  242. char *getenvironment(char *name);        /* get WinOne environment variable */
  243. int putenvironment(char *name);            /* set WinOne environment variable */
  244.  
  245. /*******************************\
  246. *                                *
  247. *       Global Variables        *
  248. *                                *
  249. \*******************************/
  250.  
  251. extern char *arg_v[];            /* argv */
  252. extern int arg_c;                /* argc */
  253.  
  254. extern int main(void);    /* program entry point */
  255.  
  256. #ifdef __cplusplus
  257. }
  258. #endif  /* __cplusplus */
  259.  
  260. #endif    /* __WOIO_H */
  261.