home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / CMDS / less_332.lzh / less_332 / less.h < prev    next >
Text File  |  1998-03-03  |  7KB  |  320 lines

  1. /*
  2.  * Copyright (c) 1984,1985,1989,1994,1995,1996  Mark Nudelman
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice in the documentation and/or other materials provided with 
  12.  *    the distribution.
  13.  *
  14.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
  15.  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
  17.  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
  18.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
  19.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
  20.  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
  21.  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
  22.  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
  23.  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 
  24.  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25.  */
  26.  
  27.  
  28. /*
  29.  * Standard include file for "less".
  30.  */
  31.  
  32. /*
  33.  * Defines for MSDOS_COMPILER.
  34.  */
  35. #define    MSOFTC        1    /* Microsoft C */
  36. #define    BORLANDC    2    /* Borland C */
  37. #define    WIN32C        3    /* Windows (Borland C or Microsoft C) */
  38. #define    DJGPPC        4    /* DJGPP C */
  39.  
  40. /*
  41.  * Include the file of compile-time options.
  42.  * The <> make cc search for it in -I., not srcdir.
  43.  */
  44. #include <defines.h>
  45.  
  46. #ifdef _SEQUENT_
  47. /*
  48.  * Kludge for Sequent Dynix systems that have sigsetmask, but
  49.  * it's not compatible with the way less calls it.
  50.  * {{ Do other systems need this? }}
  51.  */
  52. #undef HAVE_SIGSETMASK
  53. #endif
  54.  
  55. /*
  56.  * Language details.
  57.  */
  58. #if HAVE_VOID
  59. #define    VOID_POINTER    void *
  60. #else
  61. #define    VOID_POINTER    char *
  62. #define    void  int
  63. #endif
  64. #if HAVE_CONST
  65. #define    constant    const
  66. #else
  67. #define    constant
  68. #endif
  69.  
  70. #define    public        /* PUBLIC FUNCTION */
  71.  
  72. /* Library function declarations */
  73.  
  74. #if HAVE_SYS_TYPES_H
  75. #include <sys/types.h>
  76. #endif
  77. #if HAVE_STDIO_H
  78. #include <stdio.h>
  79. #endif
  80. #if HAVE_FCNTL_H
  81. #include <fcntl.h>
  82. #endif
  83. #if HAVE_UNISTD_H
  84. #include <unistd.h>
  85. #endif
  86. #if HAVE_CTYPE_H
  87. #include <ctype.h>
  88. #endif
  89. #if STDC_HEADERS
  90. #include <stdlib.h>
  91. #include <string.h>
  92. #endif
  93. #ifdef _OSK
  94. #include <modes.h>
  95. #include <strings.h>
  96. #endif
  97. #if MSDOS_COMPILER==WIN32C || MSDOS_COMPILER==DJGPPC
  98. #include <io.h>
  99. #endif
  100.  
  101. #if !STDC_HEADERS
  102. char *getenv();
  103. off_t lseek();
  104. #if !OSK
  105. VOID_POINTER calloc();
  106. void free();
  107. #else
  108. char * calloc();
  109. int free();
  110. #endif
  111. #endif
  112.  
  113. #if !HAVE_UPPER_LOWER
  114. #define    isupper(c)    ((c) >= 'A' && (c) <= 'Z')
  115. #define    islower(c)    ((c) >= 'a' && (c) <= 'z')
  116. #define    toupper(c)    ((c) - 'a' + 'A')
  117. #define    tolower(c)    ((c) - 'A' + 'a')
  118. #endif
  119.  
  120. #ifndef NULL
  121. #define    NULL    0
  122. #endif
  123.  
  124. #ifndef TRUE
  125. #define    TRUE        1
  126. #endif
  127. #ifndef FALSE
  128. #define    FALSE        0
  129. #endif
  130.  
  131. #define    OPT_OFF        0
  132. #define    OPT_ON        1
  133. #define    OPT_ONPLUS    2
  134.  
  135. #if !HAVE_MEMCPY
  136. #ifndef memcpy
  137. #define    memcpy(to,from,len)    bcopy((from),(to),(len))
  138. #endif
  139. #endif
  140.  
  141. #define    BAD_LSEEK    ((off_t)-1)
  142.  
  143. /*
  144.  * Special types and constants.
  145.  */
  146. typedef long        POSITION;
  147. /*
  148.  * {{ Warning: if POSITION is changed to other than "long",
  149.  *    you may have to change some of the printfs which use "%ld"
  150.  *    to print a variable of type POSITION. }}
  151.  */
  152.  
  153. #define    NULL_POSITION    ((POSITION)(-1))
  154.  
  155. /*
  156.  * Flags for open()
  157.  */
  158. #if MSDOS_COMPILER || OS2
  159. #define    OPEN_READ    (O_RDONLY|O_BINARY)
  160. #else
  161. #ifdef _OSK
  162. #define    OPEN_READ    (S_IREAD)
  163. #else
  164. #ifdef O_RDONLY
  165. #define    OPEN_READ    (O_RDONLY)
  166. #else
  167. #define    OPEN_READ    (0)
  168. #endif
  169. #endif
  170. #endif
  171.  
  172. #if defined(O_WRONLY) && defined(O_APPEND)
  173. #define    OPEN_APPEND    (O_APPEND|O_WRONLY)
  174. #else
  175. #ifdef _OSK
  176. #define OPEN_APPEND    (S_IWRITE)
  177. #else
  178. #define    OPEN_APPEND    (1)
  179. #endif
  180. #endif
  181.  
  182. /*
  183.  * Set a file descriptor to binary mode.
  184.  */
  185. #if MSDOS_COMPILER==MSOFTC
  186. #define    SET_BINARY(f)    _setmode(f, _O_BINARY);
  187. #else
  188. #if MSDOS_COMPILER
  189. #define    SET_BINARY(f)    setmode(f, O_BINARY)
  190. #else
  191. #define    SET_BINARY(f)
  192. #endif
  193. #endif
  194.  
  195. /*
  196.  * Does the shell treat "?" as a metacharacter?
  197.  */
  198. #if MSDOS_COMPILER || OS2 || _OSK
  199. #define    SHELL_META_QUEST 0
  200. #else
  201. #define    SHELL_META_QUEST 1
  202. #endif
  203.  
  204. #define    SPACES_IN_FILENAMES 1
  205.  
  206. /*
  207.  * An IFILE represents an input file.
  208.  */
  209. #define    IFILE        VOID_POINTER
  210. #define    NULL_IFILE    ((IFILE)NULL)
  211.  
  212. /*
  213.  * The structure used to represent a "screen position".
  214.  * This consists of a file position, and a screen line number.
  215.  * The meaning is that the line starting at the given file
  216.  * position is displayed on the ln-th line of the screen.
  217.  * (Screen lines before ln are empty.)
  218.  */
  219. struct scrpos
  220. {
  221.     POSITION pos;
  222.     int ln;
  223. };
  224.  
  225. typedef union parg
  226. {
  227.     char *p_string;
  228.     int p_int;
  229. } PARG;
  230.  
  231. #define    NULL_PARG    ((PARG *)NULL)
  232.  
  233. struct textlist
  234. {
  235.     char *string;
  236.     char *endstring;
  237. };
  238.  
  239. #define    EOI        (-1)
  240.  
  241. #define    READ_INTR    (-2)
  242.  
  243. /* How quiet should we be? */
  244. #define    NOT_QUIET    0    /* Ring bell at eof and for errors */
  245. #define    LITTLE_QUIET    1    /* Ring bell only for errors */
  246. #define    VERY_QUIET    2    /* Never ring bell */
  247.  
  248. /* How should we prompt? */
  249. #define    PR_SHORT    0    /* Prompt with colon */
  250. #define    PR_MEDIUM    1    /* Prompt with message */
  251. #define    PR_LONG        2    /* Prompt with longer message */
  252.  
  253. /* How should we handle backspaces? */
  254. #define    BS_SPECIAL    0    /* Do special things for underlining and bold */
  255. #define    BS_NORMAL    1    /* \b treated as normal char; actually output */
  256. #define    BS_CONTROL    2    /* \b treated as control char; prints as ^H */
  257.  
  258. /* How should we search? */
  259. #define    SRCH_FORW    000001    /* Search forward from current position */
  260. #define    SRCH_BACK    000002    /* Search backward from current position */
  261. #define    SRCH_NO_MOVE    000004    /* Highlight, but don't move */
  262. #define    SRCH_FIND_ALL    000010    /* Find and highlight all matches */
  263. #define    SRCH_NO_MATCH    000100    /* Search for non-matching lines */
  264. #define    SRCH_PAST_EOF    000200    /* Search past end-of-file, into next file */
  265. #define    SRCH_FIRST_FILE    000400    /* Search starting at the first file */
  266. #define    SRCH_NO_REGEX    001000    /* Don't use regular expressions */
  267.  
  268. #define    SRCH_REVERSE(t)    (((t) & SRCH_FORW) ? \
  269.                 (((t) & ~SRCH_FORW) | SRCH_BACK) : \
  270.                 (((t) & ~SRCH_BACK) | SRCH_FORW))
  271.  
  272. /* */
  273. #define    NO_MCA        0
  274. #define    MCA_DONE    1
  275. #define    MCA_MORE    2
  276.  
  277. #define    CC_OK        0    /* Char was accepted & processed */
  278. #define    CC_QUIT        1    /* Char was a request to abort current cmd */
  279. #define    CC_ERROR    2    /* Char could not be accepted due to error */
  280. #define    CC_PASS        3    /* Char was rejected (internal) */
  281.  
  282. /* Special chars used to tell put_line() to do something special */
  283. #define    AT_NORMAL    (0)
  284. #define    AT_UNDERLINE    (1)
  285. #define    AT_BOLD        (2)
  286. #define    AT_BLINK    (3)
  287. #define    AT_INVIS    (4)
  288. #define    AT_STANDOUT    (5)
  289.  
  290. #define    CONTROL(c)    ((c)&037)
  291. #define    ESC        CONTROL('[')
  292.  
  293. #if _OSK_MWC32
  294. #define    LSIGNAL(sig,func)    os9_signal(sig,func)
  295. #else
  296. #define    LSIGNAL(sig,func)    signal(sig,func)
  297. #endif
  298.  
  299. #define    S_INTERRUPT    01
  300. #define    S_STOP        02
  301. #define S_WINCH        04
  302. #define    ABORT_SIGS()    (sigs & (S_INTERRUPT|S_STOP))
  303.  
  304. #define    QUIT_OK        0
  305. #define    QUIT_ERROR    1
  306. #define    QUIT_SAVED_STATUS (-1)
  307.  
  308. /* filestate flags */
  309. #define    CH_CANSEEK    001
  310. #define    CH_KEEPOPEN    002
  311. #define    CH_POPENED    004
  312. #define    CH_HELPFILE    010
  313.  
  314. #define    ch_zero()    ((POSITION)0)
  315.  
  316. #define    FAKE_HELPFILE    "@/\\less/\\help/\\file/\\@"
  317.  
  318. #include "funcs.h"
  319.  
  320.