home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Texteditors / Origami / Sources / src / h / os.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-27  |  13.2 KB  |  334 lines

  1. /* os specific stuff which will be included in every module */
  2. #ifndef OS_H_READ
  3. #  define OS_H_READ
  4.    /*{{{}}}*/
  5.    /*{{{  MS/PC DOS*/
  6. #   ifdef DOS
  7. #     include <h/dos.h>
  8. #   endif
  9.    /*}}}  */
  10.    /*{{{  ATARI TOS*/
  11. #   ifdef TOS
  12. #     include "../tos/tos_os.h"
  13. #   endif
  14.    /*}}}  */
  15.    /*{{{  AMIGA OS*/
  16. #   ifdef AMIGA
  17. #     include <origami:amiga/h/amiga.h>
  18. #   endif
  19.    /*}}}  */
  20.    /*{{{  operating systems*/
  21. #   if (!(defined(TOS)||defined(DOS)||defined(AMIGA)))
  22.      /*{{{  keybind knows all mouse ports*/
  23. #     ifdef ALL_MICE
  24. #       ifndef MGR
  25. #          define MGR
  26. #       endif
  27. #       ifndef XTERM
  28. #          define XTERM
  29. #       endif
  30. #     endif
  31.      /*}}}  */
  32.      /*{{{  stdio-stuff*/
  33. #     ifdef LINT
  34. #       define NEVER (scrout-scrout)
  35. #     else
  36. #       define NEVER 0
  37. #     endif
  38.  
  39. #     define oputs(x) do if (scrout) fputs((char*)(x),scrout); while (NEVER)
  40. #     define oputc(x) do if (scrout) fputc((char)(x),scrout); while (NEVER)
  41. #     define oflush   do if (scrout) fflush(scrout); while (NEVER)
  42. #     define eputs(x) fputs((char*)x,stderr)
  43. #     define eputc(x) fputc((char)x,stderr)
  44.      /*}}}  */
  45.      /*{{{  mouse and windowing*/
  46.      /*{{{  xterm-support*/
  47. #     ifdef XTERM
  48. #       ifndef MOUSY
  49. #          define MOUSY
  50. #       endif
  51. #       define XTERM_MOUSE_NAME "xterm"
  52. #       define XTERM_MOUSE_COUNT 10
  53. #       define XTERM_MOUSE_NAMES                                                \
  54.           {"Button1","Button2","Button3","Button4","Button5",                   \
  55.            "Button6","Button7","Button8","Button9","Button10"}
  56.         /* use the MIT-mouse row/column and button information, send when button
  57.          * pressed! Switching the mouse to 'send-position' ''is done, if the
  58.          * environment-variable TERM is set to 'xterm'.
  59.          */
  60. #       define XTERM_MOUSE_UP(b) 1
  61. #       ifndef XTERM_MOUSE_LG
  62. #          define XTERM_MOUSE_LG       3
  63. #       endif
  64. #       ifndef XTERM_MOUSE_CODE
  65. #          define XTERM_MOUSE_CODE  "\033[M"
  66. #       endif
  67. #       ifndef DEFAULT_MOUSE
  68. #          define DEFAULT_MOUSE XTERM_MOUSE_NAME
  69. #       endif
  70.         /*{{{  strings to de-/activate the send-mouse-position-mode*/
  71. #        ifndef XTERM_START_BP                 /* send mouse-position on click */
  72. #           define XTERM_START_BP "\033[?9h"
  73. #        endif
  74. #        ifndef XTERM_END_BP                   /* do action on mouse-click     */
  75. #           define XTERM_END_BP   "\033[?9l"
  76. #        endif
  77.         /*}}}  */
  78.         /*{{{  strings to get window size*/
  79. #        define XTERM_GET_SIZE "\0337\033[r\033[999;999H\033[6n\0338"
  80. #        define XTERM_SIZE_HEAD "\033["
  81. #        define XTERM_SIZE_MID ";"
  82. #        define XTERM_SIZE_END "R"
  83.         /*}}}  */
  84.         /*{{{  xterm change title*/
  85. #        ifndef XTERM_CHGNAME
  86. #           define XTERM_CHGNAME(s) \
  87.               (fputc(0x1b,stdout),fputs("]0;",stdout),fputs(s,stdout),fputc(0x7,stdout))
  88. #        endif
  89. #        ifndef XTERM_DEFAULT_TITLE
  90. #           define XTERM_DEFAULT_TITLE XTERM_MOUSE_NAME
  91. #        endif
  92. #        ifndef WINDOW_TITLE_CHANGE
  93. #           define WINDOW_TITLE_CHANGE
  94. #        endif
  95.         /*}}}  */
  96. #     endif
  97.      /*}}}  */
  98.      /*{{{  mgr-support*/
  99. #     ifdef MGR
  100. #        ifndef MOUSY
  101. #           define MOUSY
  102. #        endif
  103. #        ifndef MGR_MOUSE_NAME
  104. #          define MGR_MOUSE_NAME "mgr"
  105. #        endif
  106. #        define MGR_MOUSE_COUNT 10
  107. #        define MGR_MOUSE_NAMES                                                   \
  108.            {"Button1","Button2","Button3","Button4","Button5",                    \
  109.             "Button1Down","Button2Down","Button3Down","Button4Down","Button5Down"}
  110. #        define MGR_MOUSE_UP(b) ((b)<=5)
  111. #        ifndef XTERM
  112. #           define MGR_MOUSE_LG 3
  113. #           define MGR_MOUSE_CODE "\033[M"
  114. #        else
  115. #           define MGR_MOUSE_LG XTERM_MOUSE_LG
  116. #           define MGR_MOUSE_CODE XTERM_MOUSE_CODE
  117. #        endif
  118. #        ifndef DEFAULT_MOUSE
  119. #           define DEFAULT_MOUSE MGR_MOUSE_NAME
  120. #        endif
  121. #     endif
  122.      /*}}}  */
  123.      /*{{{  OS-MOUSE-Hooks*/
  124. #     if 0
  125.         /* maybe add some definitions in the following style */
  126. #        define OS_MOUSE_TAG    dummy     /* entry in the mouse-typ enum  */
  127. #        define OS_MOUSE_NAME   "dummy"   /* name for the mouse-support,  *
  128.                                            * for -M.. usage in keybind    */
  129. #        define OS_MOUSE_COUNT  2         /* number of mouse-buttons,     *
  130.                                            * needed for the bindinglist   */
  131. #        define OS_MOUSE_NAMES  { "left","right" }
  132.                                           /* names of the buttons, needed *
  133.                                            * for the bindinglist          */
  134. #        define OS_MOUSE_UP(b)  expression
  135.                                           /* must evaluate to 0, if b is  *
  136.                                            * not a button-down-event      */
  137. #        define OS_MOUSE_CODE   "\033\0"  /* if your mouse sends a char-  *
  138. #        define OS_MOUSE_LG     2          * sequence to stdin, define    *
  139.                                            * here this header and its     *
  140.                                            * length.                      */
  141.         /* in origami/keyboard.c you have to add the code for activating  *
  142.          * and scanning the mouse. Look at the mgr- and xterm-support, if *
  143.          * you need a example.                                            */
  144. #     endif
  145.      /*}}}  */
  146.      /*{{{  DEFAULT_MOUSE*/
  147. #     ifndef DEFAULT_MOUSE
  148. #        define DEFAULT_MOUSE "no-mouse"
  149. #     endif
  150.      /*}}}  */
  151.      /*}}}  */
  152.      /*{{{  VIRTUAL_C*/
  153. #     ifdef VIRTUAL_C
  154. #       ifdef VIRTUAL
  155. #         define BLOCK_SIZE         90
  156.                                     /* mininum is 4*sizeof(int)                */
  157.                                     /* maximum is MAX_FIELD_SIZE+sizeof(int)   */
  158. #         define FIXED              8
  159.                                     /* number of secure lines in memory        */
  160.                                     /* the minum is 8 (number of lines needed  */
  161.                                     /* for internal expressions). You can use  */
  162.                                     /* greater values (screensize for example) */
  163. #       endif
  164. #     endif
  165.      /*}}}  */
  166.      /*{{{  ORIEDT*/
  167. #     ifdef ORIEDT_C
  168. #       define BASIC_ELEMENTS   2048   /* number of first element's block */
  169. #       define NEW_ELEMENT_LIMIT  16   /* minimum number of malloced      */
  170.                                        /* element's block.                */
  171.                                        /* if malloc cannot return a block */
  172.                                        /* of NEW_ELEMENT_LIMIT elements,  */
  173.                                        /* a `not enough memory' warning   */
  174.                                        /* appears!                        */
  175. #       define NEW_ELEMENT_MAX   128   /* maximum number of malloced      */
  176.                                        /* element's block (used if lines  */
  177.                                        /* are handled virtuell)           */
  178. #     endif
  179.      /*}}}  */
  180.      /*{{{  scan_abort_key*/
  181. #     define scan_abort_key()
  182.      /*}}}  */
  183.      /*{{{  MAIN_C*/
  184. #     ifdef MAIN_C
  185. #       define os_init() scrout=stdout
  186. #       define os_init_args_read()
  187. #       define os_init_rc_read()
  188. #     endif
  189.      /*}}}  */
  190.      /*{{{  KEYBIND_C*/
  191. #     ifdef KEYBIND_C
  192.        /*{{{  SORTCMD*/
  193. #       define SORTCMD "sort -t"REF_LIM_QUOTED_TXT" +1 -o %s"
  194.        /*}}}  */
  195. #     endif
  196.      /*}}}  */
  197.      /*{{{  GETTK_C*/
  198. #     ifdef GETTK_C
  199. #       define chartest if (ch=='\0' || ch=='\n') ch=O_NOP;
  200. #     endif
  201.      /*}}}  */
  202.      /*{{{  LOOP_C*/
  203. #     ifdef LOOP_C
  204. #       ifndef NO_MAIL
  205.            /*{{{  maybe set up mailcommand*/
  206. #           ifdef MAIL_SENDMAIL
  207.             /*{{{  MAILDATA for sendmail*/
  208. #            define MAIL_DATA FILE*mail=0;
  209.             /*}}}  */
  210.             /*{{{  MAILOPEN for sendmail*/
  211. #            define MAIL_OPEN(subj)                                              \
  212.              do { struct passwd *pw_entry;                                       \
  213.                mail=0;                                                           \
  214.                if (  (pw_entry=getpwuid(getuid()))                               \
  215.                    && pw_entry->pw_name                                          \
  216.                    &&(mail=popen(MAIL_SENDMAIL" -t -oi","w"))                    \
  217.                ) { fputs("To: ",mail);                                           \
  218.                    fputs(pw_entry->pw_name,mail);                                \
  219.                    fputs("\nSubject: ",mail);                                    \
  220.                    fputs(subj,mail);                                             \
  221.                    fputs("\n\n",mail);                                           \
  222.                }                                                                 \
  223.              } while (NEVER)
  224.             /*}}}  */
  225. #           else
  226.             /*{{{  MAILDATA for mail [-s]*/
  227. #            ifndef MAILCMDSIZE
  228. #              define MAILCMDSIZE 256
  229. #            endif
  230. #            define MAIL_DATA FILE*mail=0;char cmd[MAILCMDSIZE];
  231.             /*}}}  */
  232.             /*{{{  MAILOPEN for mail [-s]*/
  233. #            ifndef MAILCMD
  234.              /*{{{  use default MAILCMD*/
  235. #             ifndef MAIL_NO_S
  236. #              define MAILCMD(buff,subj)                                         \
  237.                 do { struct passwd *pw_entry;                                    \
  238.                  if ((pw_entry=getpwuid(getuid())) && pw_entry->pw_name)         \
  239.                   {strcpy(buff,"mail -s '");strcat(buff,subj);strcat(buff,"' "); \
  240.                    strcat(buff,pw_entry->pw_name);                               \
  241.                   }                                                              \
  242.                  else                                                            \
  243.                     buff[0]='\0';                                                \
  244.                 } while (NEVER)
  245. #             else
  246. #              define MAILCMD(buff,subj)                                         \
  247.                 do { struct passwd *pw_entry;                                    \
  248.                   if ((pw_entry=getpwuid(getuid())) && pw_entry->pw_name)        \
  249.                    { strcpy(buff,"mail ");strcat(buff,pw_entry->pw_name); }      \
  250.                   else                                                           \
  251.                      buff[0]='\0';                                               \
  252.                 } while (NEVER)
  253. #             endif
  254.              /*}}}  */
  255. #            endif
  256. #            define MAIL_OPEN(subj) \
  257.               do { MAILCMD(cmd,subj);mail=cmd[0]?popen(cmd,"w"):0; } while (NEVER)
  258.             /*}}}  */
  259. #           endif
  260. #           define MAIL_PUT(s) do if(mail){fputs(s,mail);fflush(mail);}while(NEVER)
  261. #           define MAIL_CLOSE() do if(mail)pclose(mail);while(NEVER)
  262.            /*}}}  */
  263. #       endif
  264. #     endif
  265.      /*}}}  */
  266.      /*{{{  READFOLDS_C*/
  267. #     ifdef READFOLDS_C
  268. #        define PIPE_FILENAME OS_NULL_DEVICE
  269. #     endif
  270.      /*}}}  */
  271.      /*{{{  SCANNER_C*/
  272. #     ifdef SCANNER_C
  273. #        define OS_USINGS
  274. #     endif
  275.      /*}}}  */
  276.      /*{{{  formats for rc/help-filenames*/
  277. #     define STD_BASENAME ".origami"
  278. #     define BASENAMEF ".%s"
  279.      /*}}}  */
  280.      /*{{{  add missing prototypes for os*/
  281. #     ifdef STRERROR_MIS
  282. #      undef STRERROR_MIS
  283.        char *strerror(int errno);
  284. #     endif
  285. #     ifdef USLEEP_MIS
  286. #      undef USLEEP_MIS
  287.        int usleep(unsigned long);
  288. #     endif
  289. #     ifdef POPEN_MIS
  290. #      undef POPEN_MIS
  291.        FILE *popen(const char *, const char *);
  292. #     endif
  293. #     ifdef PCLOSE_MIS
  294. #      undef PCLOSE_MIS
  295.        int pclose(FILE*);
  296. #     endif
  297. #     ifdef GETPWENT_MIS
  298. #      undef GETPWENT_MIS
  299. #      ifdef TILDE_C
  300.          struct passwd *getpwent(void);
  301. #      endif
  302. #     endif
  303.      /*}}}  */
  304.      /*{{{  dir_edit*/
  305. #     ifdef DIREDT
  306. #        ifndef DIR_CMD
  307. #         define DC_OPT_F " \"-M%s%s%s%s\" \"-f%s\" \"-F%s\" -s%c -- %s"
  308. #         define DC_OPT_ARG(na,long,ma,noma)                                  \
  309.            bd.f.str.open_f,bd.f.str.file_f,bd.f.str.line_f,bd.f.str.close_f,  \
  310.            ma,noma,(long?'l':' '),na
  311. #         ifdef DIREDT_PATH
  312. #          define DIR_CMD(name,long,match,nomatch)                            \
  313.             home_expand                                                       \
  314.              ( (char*)get_msg                                                 \
  315.                        ( MSG_ARG_FORMAT,                                      \
  316.                          DIREDT_PATH PATH_SEP "dirfold" DC_OPT_F,             \
  317.                          DC_OPT_ARG(name,long,match,nomatch)                  \
  318.                        )                                                      \
  319.              )
  320. #         else
  321. #          define DIR_CMD(name,long,match,nomatch)                            \
  322.             (char*)get_msg                                                    \
  323.                     ( MSG_ARG_FORMAT,                                         \
  324.                       "dirfold" DC_OPT_F,                                     \
  325.                       DC_OPT_ARG(name,long,match,nomatch)                     \
  326.                     )
  327. #         endif
  328. #        endif
  329. #     endif
  330.      /*}}}  */
  331. #   endif
  332.    /*}}}  */
  333. #endif
  334.