home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / trn_12.zip / src / common.h < prev    next >
C/C++ Source or Header  |  1993-12-05  |  28KB  |  969 lines

  1. /* $Id: common.h,v 4.4.4.1 1992/02/23 21:25:39 sob PATCH_4 sob $
  2.  * 
  3.  * $Log: common.h,v $
  4.  * Revision 4.4.4.1  1992/02/23  21:25:39  sob
  5.  * Patch level 4
  6.  *
  7.  * Revision 4.4.3.1  1992/02/01  03:09:32  sob
  8.  * Release 4.4 Patchlevel 3
  9.  *
  10.  * Revision 4.4.2.1  1991/12/01  18:05:42  sob
  11.  * Patchlevel 2 changes
  12.  *
  13.  * Revision 4.4  1991/09/09  20:18:23  sob
  14.  * release 4.4
  15.  *
  16.  *
  17.  *
  18.  */
  19. /* This software is Copyright 1991 by Stan Barber. 
  20.  *
  21.  * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  22.  * use this software as long as: there is no monetary profit gained
  23.  * specifically from the use or reproduction of this software, it is not
  24.  * sold, rented, traded or otherwise marketed, and this copyright notice is
  25.  * included prominently in any copy made. 
  26.  *
  27.  * The author make no claims as to the fitness or correctness of this software
  28.  * for any use whatsoever, and it is provided as is. Any use of this software
  29.  * is at the user's own risk. 
  30.  */
  31.  
  32. #include <stdio.h>
  33. #include <sys/types.h>
  34. #include <sys/stat.h>
  35. #include <ctype.h>
  36.  
  37. /*** OS2: to extract the global settings out of the
  38.           rc-files of uupc, we need the header file
  39.           os2patch.h.                      ***/
  40. #include "os2patch.h"
  41.  
  42. #include "config.h" /* generated by installation script */
  43. #ifdef WHOAMI
  44. #    include <whoami.h>
  45. #endif
  46. #ifndef isalnum
  47. #   define isalnum(c) (isalpha(c) || isdigit(c))
  48. #endif
  49.  
  50. #include <errno.h>
  51. #include <signal.h>
  52. #ifdef IOCTL
  53. #include <sys/ioctl.h>
  54. #endif
  55. #ifdef SUNOS4
  56. # ifdef sparc        /* needed to support vfork call on sparc machines */
  57. #  include <vfork.h>
  58. # endif
  59. #endif
  60.  
  61. #ifdef FCNTL
  62. #   include <fcntl.h>
  63. #endif
  64.  
  65. #ifdef TERMIO
  66. #   include <termio.h>
  67. #else
  68. # ifdef TERMIOS
  69. #   include <termios.h>
  70. # else
  71. #   include <sgtty.h>
  72. # endif
  73. #endif
  74.  
  75. #ifdef GETPWENT
  76. #   include <pwd.h>
  77. #endif
  78.  
  79. #ifdef PTEM
  80. #include <sys/stream.h>
  81. #include <sys/ptem.h>
  82. #endif
  83.  
  84. #ifdef TZSET
  85. # include <time.h>
  86. #else
  87. # include <sys/time.h>
  88. # include <sys/timeb.h>
  89. #endif
  90.  
  91. #define BITSPERBYTE 8
  92. #ifdef pdp11
  93. #define LBUFLEN 512    /* line buffer length */
  94. #else
  95. #define LBUFLEN 1024    /* line buffer length */
  96. #endif
  97.             /* (don't worry, .newsrc lines can exceed this) */
  98. #ifdef pdp11
  99. #   define CBUFLEN 256    /* command buffer length */
  100. #   define PUSHSIZE 128
  101. #else
  102. #   define CBUFLEN 512    /* command buffer length */
  103. #   define PUSHSIZE 256
  104. #endif
  105. #ifdef pdp11
  106. #   define MAXFILENAME 128
  107. #else
  108. #   define MAXFILENAME 512
  109. #endif
  110. #define LONGKEY 15    /* longest keyword: currently "posting-version" */
  111. #define FINISHCMD 0177
  112.  
  113. /* some handy defs */
  114.  
  115. /*** OS2: in os2patch, we also need a bool, but we don't
  116.           want to include common.h   ***/
  117. #ifndef BOOL_DEFINED
  118. #define BOOL_DEFINED
  119. #define bool char
  120. #define bool_int int
  121. #endif
  122.  
  123. #define char_int int
  124. #ifndef TRUE
  125. #define TRUE (1)
  126. #endif
  127. #ifndef FALSE
  128. #define FALSE (0)
  129. #endif
  130. #define Null(t) ((t)0)
  131. #define Nullch Null(char *)
  132. #define Nullfp Null(FILE *)
  133.  
  134. #define Ctl(ch) (ch & 037)
  135.  
  136. #define strNE(s1,s2) (strcmp(s1,s2))
  137. #define strEQ(s1,s2) (!strcmp(s1,s2))
  138. #define strnNE(s1,s2,l) (strncmp(s1,s2,l))
  139. #define strnEQ(s1,s2,l) (!strncmp(s1,s2,l))
  140.  
  141. /* Things we can figure out ourselves */
  142.  
  143. #ifdef SIGTSTP
  144. #   define BERKELEY     /* include job control signals? */
  145. #endif
  146.  
  147. #ifdef FIONREAD
  148. #   define PENDING
  149. #else
  150. #   ifdef O_NDELAY
  151. #    define PENDING
  152. #   endif
  153. #endif
  154.  
  155. #ifdef EUNICE
  156. #   define LINKART        /* add 1 level of possible indirection */
  157. #   define UNLINK(victim) while (!unlink(victim))
  158. #else
  159. #   define UNLINK(victim) unlink(victim)
  160. #endif
  161.  
  162. /* Valid substitutions for strings marked with % comment are:
  163.  *    %a    Current article number
  164.  *    %A    Full name of current article (%P/%c/%a)
  165.  *        (if LINKART defined, is the name of the real article)
  166.  *    %b    Destination of a save command, a mailbox or command
  167.  *    %B    The byte offset to the beginning of the article for saves
  168.  *        with or without the header
  169.  *    %c    Current newsgroup, directory form
  170.  *    %C    Current newsgroup, dot form
  171.  *    %d    %P/%c
  172.  *    %D    Old Distribution: line
  173.  *    %e    Extract program
  174.  *    %E    Extract destination directory
  175.  *    %f    Old From: line or Reply-To: line
  176.  *    %F    Newsgroups to followup to from Newsgroups: and Followup-To:
  177.  *    %h    Name of header file to pass to mail or news poster
  178.  *    %H    Host name (yours)
  179.  *    %i    Old Message-I.D.: line, with <>
  180.  *    %I    Inclusion indicator
  181.  *    %l    News administrator login name
  182.  *    %L    Login name (yours)
  183.  *    %M    Number of articles marked with M
  184.  *    %n    Newsgroups from source article
  185.  *    %N    Full name (yours)
  186.  *    %o    Organization (yours)
  187.  *    %O    Original working directory (where you ran rn from)
  188.  *    %p    Your private news directory (-d switch)
  189.  *    %P    Public news spool directory (SPOOLDIR)
  190.  *    %r    Last reference (parent article id)
  191.  *    %R    New references list
  192.  *    %s    Subject, with all Re's and (nf)'s stripped off
  193.  *    %S    Subject, with one Re stripped off
  194.  *    %t    New To: line derived from From: and Reply-To (Internet always)
  195.  *    %T    New To: line derived from Path:
  196.  *    %u    Number of unread articles
  197.  *    %U    Number of unread articles disregarding current article
  198.  *    %v    Number of unselected articles disregarding current article
  199.  *    %w    Mthreads' tmp directory
  200.  *    %W    The thread directory root
  201.  *    %x    News library directory, usually /usr/lib/news
  202.  *    %X    Rn library directory, usually %x/rn
  203.  *    %z    Size of current article in bytes.
  204.  *    %Z    Number of selected threads.
  205.  *    %~    Home directory
  206.  *    %.    Directory containing . files
  207.  *    %#    count of articles saved in current command (from 1 to n)
  208.  *    %$    current process number
  209.  *    %{name} Environment variable "name".  %{name-default} form allowed.
  210.  *    %[name]    Header line beginning with "Name: ", without "Name: " 
  211.  *    %"prompt"
  212.  *        Print prompt and insert what is typed.
  213.  *    %`command`
  214.  *        Insert output of command.
  215.  *    %(test_text=pattern?if_text:else_text)
  216.  *        Substitute if_text if test_text matches pattern, otherwise
  217.  *        substitute else_text.  Use != for negated match.
  218.  *        % substitutions are done on test_text, if_text, and else_text.
  219.  *        (Note: %() only works if CONDSUB defined.)
  220.  *    %digit    Substitute the text matched by the nth bracket in the last
  221.  *        pattern that had brackets.  %0 matches the last bracket
  222.  *        matched, in case you had alternatives.
  223.  *
  224.  *    Put ^ in the middle to capitalize the first letter: %^C = Net.jokes
  225.  *    Put _ in the middle to capitalize last component: %_c = net/Jokes
  226.  *
  227.  *    ~ interpretation in filename expansion happens after % expansion, so
  228.  *    you could put ~%{NEWSLOGNAME-news} and it will expand correctly.
  229.  */
  230.  
  231. /* *** System Dependent Stuff *** */
  232.  
  233. /* NOTE: many of these are defined in the config.h file */
  234.  
  235. /* name of organization */
  236. #ifndef ORGNAME
  237. #   define ORGNAME uupc_rc_settings.organization
  238. #endif
  239.  
  240. #ifndef MBOXCHAR
  241. #   define MBOXCHAR 'F'    /* how to recognize a mailbox by 1st char */
  242. #endif
  243.  
  244. #ifndef ROOTID
  245. #   define ROOTID 0        /* uid of superuser */
  246. #endif
  247.  
  248. #ifdef NORMSIG
  249. #   define sigset signal
  250. #   define sigignore(sig) signal(sig,SIG_IGN)
  251. #endif
  252.  
  253. #ifndef LOGDIRFIELD
  254. #   define LOGDIRFIELD 6        /* Which field (origin 1) is the */
  255.                     /* login directory in /etc/passwd? */
  256.                     /* (If it is not kept in passwd, */
  257.                     /* but getpwnam() returns it, */
  258.                     /* define the symbol GETPWENT) */
  259. #endif
  260. #ifndef GCOSFIELD
  261. #   define GCOSFIELD 5
  262. #endif
  263.  
  264. #ifndef NEGCHAR
  265. #   define NEGCHAR '!'
  266. #endif
  267.  
  268. /* Space conservation section */
  269.  
  270. /* To save D space, cut down size of NGMAX and  VARYSIZE. */
  271. #define NGMAX 100    /* number of newsgroups allowed on command line */
  272.             /* undefine ONLY symbol to disable "only" feature */
  273. #define VARYSIZE 256    /* this makes a block 1024 bytes long in DECville */
  274.             /* (used by virtual array routines) */
  275.  
  276. /* Undefine any of the following features to save both I and D space */
  277. /* In general, earlier ones are easier to get along without */
  278. /* Pdp11's without split I and D may have to undefine them all */
  279. #define DEBUGGING    /* include debugging code */
  280. #define USETHREADS    /* Add article-thread following */
  281. #define CUSTOMLINES    /* include code for HIDELINE and PAGESTOP */
  282. #define PUSHBACK    /* macros and keymaps using pushback buffer */
  283. #define SPEEDOVERMEM    /* use more memory to run faster */
  284. #define WORDERASE    /* enable ^W to erase a word */
  285. /*#undef MAILCALL    /* check periodically for mail */
  286. #define CLEAREOL    /* use clear to end-of-line instead of clear screen */
  287. #define NOFIREWORKS    /* keep whole screen from flashing on certain */
  288.             /* terminals such as older Televideos */
  289. #define VERIFY        /* echo the command they just typed */
  290. #define HASHNG        /* hash newsgroup lines for fast lookup-- */
  291.             /* linear search used if not defined */
  292. #define CONDSUB        /* allow %(cond?text:text) */
  293. /*** OS2: No, that could cause to big problems, e.g. date ***/
  294. /*#undef BACKTICK    /* allow %`command` */
  295. #define PROMPTTTY    /* allow %"prompt" */
  296. #define ULSMARTS    /* catch _^H in text and do underlining */
  297. #define TERMMOD        /* allow terminal type modifier on switches */
  298. #define BAUDMOD        /* allow baudrate modifier on switches */
  299. #define GETLOGIN    /* use getlogin() routine as backup to environment */
  300.             /* variables USER or LOGNAME */
  301. #define ORGFILE        /* if organization begins with /, look up in file */
  302. #define TILDENAME    /* allow ~logname expansion */
  303. #define SETENV        /* allow command line environment variable setting */
  304. #define MAKEDIR        /* use our makedir() instead of shell script */
  305. #define MEMHELP        /* keep help messages in memory */
  306. #define VERBOSE        /* compile in more informative messages */
  307. #define TERSE        /* compile in shorter messages */
  308.             /* (Note: both VERBOSE and TERSE can be defined; -t
  309.              * sets terse mode.  One or the other MUST be defined.
  310.              */
  311. #ifndef pdp11
  312. #   define CACHESUBJ    /* cache subject lines in memory */
  313.             /* without this ^N still works but runs really slow */
  314.             /* but you save lots and lots of D space */
  315. #   define CACHEFIRST    /* keep absolute first article numbers in memory */
  316.             /* cost: about 2k */
  317. #endif
  318. #define ROTATION    /* enable x, X and ^X commands to work */
  319. #define DELBOGUS    /* ask if bogus newsgroups should be deleted */
  320. #define RELOCATE    /* allow newsgroup rearranging */
  321. #define ESCSUBS        /* escape substitutions in multi-character commands */
  322. #define DELAYMARK    /* allow articles to be temporarily marked as read */
  323.             /* until exit from current newsgroup or Y command */
  324. #undef MCHASE        /* unmark xrefed articles on m or M */
  325. #define MUNGHEADER    /* allow alternate header formatting via */
  326.             /* environment variable ALTHEADER (not impl) */
  327. #define ASYNC_PARSE    /* allow parsing headers asyncronously to reading */
  328.             /* used by MCHASE and MUNGHEADER */
  329. #define FINDNEWNG    /* check for new newsgroups on startup */
  330. #define FASTNEW        /* do optimizations on FINDNEWNG for faster startup */
  331.             /* (this optimization can make occasional mistakes */
  332.             /* if a group is removed and another group of the */
  333.             /* same length is added, and if no softpointers are */
  334.             /* affected by said change.) */
  335. #define INNERSEARCH    /* search command 'g' with article */
  336. #define CATCHUP        /* catchup command at newsgroup level */
  337. #define NGSEARCH    /* newsgroup pattern matching */
  338. #define ONLY        /* newsgroup restrictions by pattern */
  339. #define KILLFILES    /* automatic article killer files */
  340. #define ARTSEARCH    /* pattern searches among articles */
  341.             /* /, ?, ^N, ^P, k, K */
  342.  
  343. /* some dependencies among options */
  344.  
  345. #ifndef ARTSEARCH
  346. #   undef KILLFILES
  347. #   undef INNERSEARCH
  348. #   undef CACHESUBJ
  349. #endif
  350.  
  351. #ifndef DELAYMARK
  352. #   ifndef MCHASE
  353. #    ifndef MUNGHEADER
  354. #        undef ASYNC_PARSE
  355. #    endif
  356. #   endif
  357. #endif
  358.  
  359. #ifndef SETUIDGID
  360. #   define eaccess access
  361. #endif
  362.  
  363. #ifdef ONLY                /* idiot lint doesn't grok #if */
  364. #   define NGSORONLY
  365. #else
  366. #   ifdef NGSEARCH
  367. #    define NGSORONLY
  368. #   endif
  369. #endif
  370.  
  371. #ifdef VERBOSE
  372. #   ifdef TERSE
  373. #    define IF(c) if (c)
  374. #    define ELSE else
  375. #   else
  376. #    define IF(c)
  377. #    define ELSE
  378. #   endif
  379. #else /* !VERBOSE */
  380. #   ifndef TERSE
  381. #    define TERSE
  382. #   endif
  383. #   define IF(c) "IF" outside of VERBOSE???
  384. #   define ELSE "ELSE" outside of VERBOSE???
  385. #endif
  386.  
  387. #ifdef DEBUGGING
  388. #   define assert(ex) {if (!(ex)){fprintf(stderr,"Assertion failed: file %s, line %d\n", __FILE__, __LINE__);sig_catcher(0);}}
  389. #else
  390. #   define assert(ex) ;
  391. #endif
  392.  
  393. #ifdef SPEEDOVERMEM
  394. #   define OFFSET(x) (x)
  395. #else
  396. #   define OFFSET(x) ((x)-absfirst)
  397. #endif
  398.  
  399. /* If you're strapped for space use the help messages in shell scripts */
  400. /* if {NG,ART,PAGER,SUBS}HELP is undefined, help messages are in memory */
  401. #ifdef MEMHELP  /* undef MEMHELP above to get them all as sh scripts */
  402. #   undef NGHELP
  403. #   undef ARTHELP
  404. #   undef PAGERHELP
  405. #   undef SUBSHELP
  406. #else
  407. #   ifndef NGHELP            /* % and ~ */
  408. #    define NGHELP "%X/ng.help"
  409. #   endif
  410. #   ifndef ARTHELP            /* % and ~ */
  411. #    define ARTHELP "%X/art.help"
  412. #   endif
  413. #   ifndef PAGERHELP        /* % and ~ */
  414. #    define PAGERHELP "%X/pager.help"
  415. #   endif
  416. #   ifndef SUBSHELP        /* % and ~ */
  417. #    define SUBSHELP "%X/subs.help"
  418. #   endif
  419. #endif
  420.  
  421. #ifdef CLEAREOL
  422. #   define TCSIZE 512    /* capacity for termcap strings */
  423. #else
  424. #   ifdef pdp11
  425. #    define TCSIZE 256    /* capacity for termcap strings */
  426. #   else
  427. #    define TCSIZE 512    /* capacity for termcap srings */
  428. #   endif
  429. #endif
  430.  
  431. /* Additional ideas:
  432.  *    Make the do_newsgroup() routine a separate process.
  433.  *    Keep .newsrc on disk instead of in memory.
  434.  *    Overlays, if you have them.
  435.  *    Get a bigger machine.
  436.  */
  437.  
  438. /* End of Space Conservation Section */
  439.  
  440. /* More System Dependencies */
  441.  
  442. /* news library */
  443. #ifndef LIB        /* ~ and %l only ("~%l" is permissable) */
  444. #   define LIB uupc_rc_settings.trnlib
  445. #endif
  446.  
  447. /* path to private executables */
  448. #ifndef RNLIB        /* ~, %x and %l only */
  449. #   define RNLIB uupc_rc_settings.trnlib
  450. #endif
  451.  
  452. /* system-wide RNINIT switches */
  453. #ifndef GLOBINIT
  454. #   define GLOBINIT "%X/INIT"
  455. #endif
  456.  
  457. /* where to find news files */
  458. #ifndef SPOOL            /* % and ~ */
  459. #   define SPOOL uupc_rc_settings.news_dir
  460. #endif
  461.  
  462. #ifdef USETHREADS
  463. # ifdef THREAD_DIR
  464. #   ifdef LONG_THREAD_NAMES
  465. #    undef SUFFIX
  466. #   else
  467. #     ifndef SUFFIX
  468. #    define SUFFIX ".th"
  469. #     endif
  470. #   endif
  471. # else
  472. #   define THREAD_DIR    SPOOL
  473. #   ifndef SUFFIX
  474. #     define SUFFIX    "/.thread"
  475. #   endif
  476. #   undef LONG_THREAD_NAMES
  477. # endif
  478. # ifndef NEW_THREAD
  479. #   define NEW_THREAD ".new"
  480. # endif
  481. #endif
  482.  
  483. /* default characters to use in the selection menu */
  484. #ifndef SELECTCHARS
  485. #   define SELECTCHARS "abdefgijlorstuvwxz1234567890"
  486. #endif
  487.  
  488. /* file containing list of active newsgroups and max article numbers */
  489. #ifndef ACTIVE            /* % and ~ */
  490. #   define ACTIVE uupc_rc_settings.active
  491. #endif
  492. #ifndef ACTIVE_OPT            /* % and ~ */
  493. #   define ACTIVE_OPT uupc_rc_settings.active_opt
  494. #endif
  495. #ifdef SERVER
  496. #   ifndef ACTIVE1
  497. #    define ACTIVE1 "%w/active1"
  498. #   endif
  499. #endif
  500. #ifndef ACTIVE2
  501. #   define ACTIVE2 "%w/active2"
  502. /*** OS2: this additional define (ACTIVE2OLD) is done for
  503.           the patch in mthreads.c, where the active2-file
  504.           was opened two times, and now the file is copied
  505.           to active2.old first, the then this new file is
  506.           opened.  ***/
  507. #   define ACTIVE2OLD "%w/active2.old"
  508. #endif
  509. #ifndef DBINIT
  510. #   define DBINIT "%W/db.init"
  511. #endif
  512. #ifndef MTPRELOCK
  513. #   define MTPRELOCK "%w/LOCK"
  514. #endif
  515. #ifndef MTLOCK
  516. #   define MTLOCK "%w/LOCKmthreads"
  517. #endif
  518. #ifndef MTDLOCK
  519. #   define MTDLOCK "%w/LOCKmtdaemon"
  520. #endif
  521. #ifndef MTLOG
  522. #   define MTLOG "%w/mt.log"
  523. #endif
  524.  
  525. #if !defined(SERVER) && defined(XTHREAD)
  526. #   undef XTHREAD
  527. #endif
  528.  
  529. /* location of history file */
  530. #ifndef ARTFILE            /* % and ~ */
  531. #    define ARTFILE "%x/history"
  532. #endif
  533.  
  534. /* command to setup a new .newsrc */
  535. #ifndef NEWSETUP        /* % and ~ */
  536. #   define NEWSETUP "newsetup"
  537. #endif
  538.  
  539. /* command to display a list of un-subscribed-to newsgroups */
  540. #ifndef NEWSGROUPS        /* % and ~ */
  541. #   define NEWSGROUPS "newsgroups"
  542. #endif
  543.  
  544. /* preferred shell for use in doshell routine */
  545. /*  ksh or sh would be okay here */
  546. #ifndef PREFSHELL
  547. #   define PREFSHELL uupc_rc_settings.prefshell
  548. #endif
  549.  
  550. /* path to fastest starting shell */
  551. #ifndef SH
  552. #   define SH uupc_rc_settings.prefshell
  553. #endif
  554.  
  555. /* default unshar'ing program */
  556. #ifndef UNSHAR
  557. #   define UNSHAR "unshar"
  558. #endif
  559.  
  560. /* path to default editor */
  561. #ifndef DEFEDITOR
  562. #   define DEFEDITOR uupc_rc_settings.editor
  563. #endif
  564.  
  565. /* location of macro file */
  566. #ifndef RNMACRO
  567. #   ifdef PUSHBACK
  568. #    define RNMACRO "%./.rnmac"
  569. #   endif
  570. #endif
  571.  
  572. /* location of full name */
  573. #ifndef FULLNAMEFILE
  574. #   ifndef PASSNAMES
  575. #    define FULLNAMEFILE "%./.fullname"
  576. #   endif
  577. #endif
  578.  
  579. /* virtual array file name template */
  580. #ifndef VARYNAME        /* % and ~ */
  581. #   define VARYNAME "/tmp/rnvary.%$"
  582. #endif
  583.  
  584. /* where to compile a new newsgroup list */
  585. #ifndef RNEWNAME
  586. #   define RNEWNAME "/tmp/rnew.%$"
  587. #endif
  588.  
  589. /* file to pass header to followup article poster */
  590. #ifndef HEADNAME        /* % and ~ */
  591. #   define HEADNAME "%./head.rn"
  592. /* or alternately #define HEADNAME "/tmp/rnhead.%$" */
  593. #endif
  594.  
  595. #ifndef MAKEDIR
  596. /* shell script to make n-deep subdirectories */
  597. #   ifndef DIRMAKER        /* % and ~ */
  598. #    define DIRMAKER "%X/makedir"
  599. #   endif
  600. #endif
  601.  
  602. /* location of newsrc file */
  603. #ifndef RCNAME        /* % and ~ */
  604. #   define RCNAME "%./.newsrc"
  605. #endif
  606.  
  607. /* temporary newsrc file in case we crash while writing out */
  608. #ifndef RCTNAME        /* % and ~ */
  609. #   define RCTNAME "%./.newnewsrc"
  610. #endif
  611.  
  612. /* newsrc file at the beginning of this session */
  613. #ifndef RCBNAME        /* % and ~ */
  614. #   define RCBNAME "%./.oldnewsrc"
  615. #endif
  616.  
  617. /* if existent, contains process number of current or crashed rn */
  618. #ifndef LOCKNAME        /* % and ~ */
  619. #   define LOCKNAME "%./.rnlock"
  620. #endif
  621.  
  622. /* information from last invocation of rn */
  623. #ifndef LASTNAME        /* % and ~ */
  624. #   define LASTNAME "%./.rnlast"
  625. #endif
  626.  
  627. /* file with soft pointers into the active file */
  628. #ifndef SOFTNAME        /* % and ~ */
  629. #   define SOFTNAME "%./.rnsoft"
  630. #endif
  631.  
  632. /* list of article numbers to mark as unread later (see M and Y cmmands) */
  633. #ifndef RNDELNAME        /* % and ~ */
  634. #   define RNDELNAME "%./.rndelay"
  635. #endif
  636.  
  637. /* a motd-like file for rn */
  638. #ifndef NEWSNEWSNAME        /* % and ~ */
  639. #   define NEWSNEWSNAME "%X/newsnews"
  640. #endif
  641.  
  642. /* command to send a reply */
  643. #ifndef MAILPOSTER        /* % and ~ */
  644. #   define MAILPOSTER "Rnmail -h %h"
  645. #endif
  646.  
  647. #ifdef INTERNET
  648. #   ifndef MAILHEADER        /* % */
  649. #    ifdef CONDSUB
  650. #        define MAILHEADER "To: %t\nSubject: Re: %S\n%(%{REPLYTO}=^$?:Reply-To: %{REPLYTO}\n)Newsgroups: %n\nIn-Reply-To: %i\n%(%[references]!=^$?References\\: %[references]\n)Organization: %o\nCc: \nBcc: \n\n"
  651. #    else
  652. #        define MAILHEADER "To: %t\nSubject: Re: %S\nNewsgroups: %n\nIn-Reply-To: %i\nReferences: %[references]\nCc: \nBcc: \n\n"
  653. #    endif
  654. #   endif
  655. #else
  656. #   ifndef MAILHEADER        /* % */
  657. #    ifdef CONDSUB
  658. #        define MAILHEADER "To: %T\nSubject: %(%i=^$?:Re: %S\nNewsgroups: %n\nIn-Reply-To: %i)\n%(%[references]!=^$?References\\: %[references]\n)Organization: %o\nCc: \nBcc: \n\n"
  659. #    else
  660. #        define MAILHEADER "To: %T\nSubject: Re: %S\nNewsgroups: %n\nIn-Reply-To: %i\nReferences: %[references]\nCc: \nBcc: \n\n"
  661. #    endif
  662. #   endif
  663. #endif
  664.  
  665. #ifndef YOUSAID            /* % */
  666. #   define YOUSAID "In article %i you write:"
  667. #endif
  668.  
  669. /* command to submit a followup article */
  670. #ifndef NEWSPOSTER        /* % and ~ */
  671. #   define NEWSPOSTER "Pnews -h %h"
  672. #endif
  673.  
  674. #ifndef NEWSHEADER        /* % */
  675. #   ifdef CONDSUB
  676. #    define NEWSHEADER "Newsgroups: %(%F=^$?%C:%F)\nSubject: %(%S=^$?%\"\n\nSubject: \":Re: %S)\nSummary: \nExpires: \n%(%R=^$?:References: %R\n)Sender: \nFollowup-To: \n%(%{REPLYTO}=^$?:Reply-To: %{REPLYTO}\n)Distribution: %(%i=^$?%\"Distribution: \":%D)\nOrganization: %o\nX-Newsreader: TRN for OS/2\nKeywords: %[keywords]\n\n"
  677. #   else
  678. #       define NEWSHEADER "Newsgroups: %F\nSubject: Re: %S\nSummary: \nExpires: \nReferences: %R\nFollowup-To: \nDistribution: %D\nOrganization: %o\nX-Newsreader: TRN for OS/2\nKeywords: %[keywords]\n\n"
  679. #   endif
  680. #endif
  681.  
  682. #ifndef ATTRIBUTION        /* % */
  683. #   define ATTRIBUTION "In article %i %f writes:"
  684. #endif
  685.  
  686. #ifndef PIPESAVER        /* % */
  687. #   ifdef CONDSUB
  688. /*** OS2: We have to use another pipesaver ***/
  689. /*#       define PIPESAVER "%(%B=^0$?<%A:tail +%Bc %A |) %b"   */
  690. #       define PIPESAVER "tail +%Bc %A | %b"
  691. #   else
  692. #    define PIPESAVER "tail +%Bc %A | %b"
  693. #   endif
  694. #endif
  695.  
  696. #ifndef EXSAVER
  697. #    define EXSAVER "tail +%Bc %A | %e"
  698. #endif
  699.  
  700. #ifndef NORMSAVER        /* % and ~ */
  701. #       define NORMSAVER "%X/norm.saver %A %P %c %a %B %C \"%b\""
  702. #endif
  703.  
  704. #ifndef MBOXSAVER        /* % and ~ */
  705. #   ifdef MININACT        /* 2.10.2 site? */
  706. #       define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %`LANG= date`\""
  707. #   else
  708. #    ifdef CONDSUB
  709. #           define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %(%[date]=^\\(\\w*\\), \\(\\w*\\)-\\(\\w*\\)-\\(\\w*\\) \\([^ ]*\\)?%1 %3 %(%2=..?%2: %2) %5 19%4)\""
  710.                     /* header munging with a vengeance */
  711. #    else
  712. #           define MBOXSAVER "%X/mbox.saver %A %P %c %a %B %C \"%b\" \"From %T %[posted]\""
  713. #    endif
  714. #   endif
  715. #endif
  716.  
  717. #ifdef MKDIRS
  718.  
  719. #   ifndef SAVEDIR            /* % and ~ */
  720. #    define SAVEDIR "%p/%c"
  721. #   endif
  722. #   ifndef SAVENAME        /* % */
  723. #    define SAVENAME "%a"
  724. #   endif
  725.  
  726. #else
  727.  
  728. #   ifndef SAVEDIR            /* % and ~ */
  729. #    define SAVEDIR "%p"
  730. #   endif
  731. #   ifndef SAVENAME        /* % */
  732. #    define SAVENAME "%^C"
  733. #   endif
  734.  
  735. #endif
  736.  
  737. #ifndef KILLGLOBAL        /* % and ~ */
  738. #   define KILLGLOBAL "%p/KILL"
  739. #endif
  740. #ifndef KILLGLOBALOLD      /* % and ~ */
  741. #   define KILLGLOBALOLD "%p/KILL.old"
  742. #endif
  743.  
  744. #ifndef KILLLOCAL        /* % and ~ */
  745. #   define KILLLOCAL "%p/%c/KILL"
  746. #endif
  747. #ifndef KILLLOCALOLD       /* % and ~ */
  748. #   define KILLLOCALOLD "%p/%c/KILL.old"
  749. #endif
  750.  
  751. /* how to cancel an article */
  752. #ifndef CANCEL
  753. #   ifdef MININACT            /* 2.10.2 ? */
  754. #    define CANCEL "%x/inews -h < %h"
  755. #   else
  756. #    define CANCEL "inews -h < %h"
  757. #   endif
  758. #endif
  759.  
  760. /* how to cancel an article, continued */
  761. #ifndef CANCELHEADER
  762. #   define CANCELHEADER "Newsgroups: %n\nSubject: cmsg cancel %i\nReferences: %R\nDistribution: %D\nOrganization: %o\n\n%i was cancelled from within trn.\n"
  763. #endif
  764.  
  765. /* how to supersede an article */
  766. #ifndef SUPERSEDEHEADER
  767. #   define SUPERSEDEHEADER "Newsgroups: %n\nSubject: %S\nSummary: %[summary]\nExpires: %[expires]\nReferences: %[references]\nSupersedes: %i\nSender: %[sender]\nFollowup-To: %[followup-to]\nDistribution: %D\nOrganization: %o\nKeywords: %[keywords]\n\n"
  768. #endif
  769.  
  770. #ifndef LOCALTIMEFMT
  771. #   define LOCALTIMEFMT "%a %b %d %X %Z %Y"
  772. #endif
  773.  
  774. /* where to find the mail file */
  775. #ifndef MAILFILE
  776. #   define MAILFILE uupc_rc_settings.mailfile
  777. #endif
  778.  
  779. /* how to open binary format files */
  780. #ifndef FOPEN_RB
  781. #   define FOPEN_RB "r"
  782. #endif
  783. #ifndef FOPEN_WB
  784. #   define FOPEN_WB "w"
  785. #endif
  786.  
  787. /* what to do with ansi prototypes -- '()' == ignore, 'x' == use */
  788. #ifndef ANSI
  789. #   ifdef __STDC__
  790. #    define ANSI(x) x
  791. #   else
  792. #    define ANSI(x) ()
  793. #   endif
  794. #endif
  795.  
  796. /* how many characters is a newline in a text file? */
  797. #ifndef NL_SIZE
  798. #   define NL_SIZE 1
  799. #endif
  800.  
  801. /* some important types */
  802.  
  803. typedef int        NG_NUM;        /* newsgroup number */
  804. typedef long        ART_NUM;    /* article number */
  805. #ifdef pdp11
  806.     typedef short    ART_UNREAD;    /* ordinarily this should be long */
  807.                     /* like ART_NUM, but assuming that */
  808.                     /* we stay less than 32767 articles */
  809.                     /* behind saves a lot of space. */
  810.                     /* NOTE: do not make unsigned. */
  811. #else
  812.     typedef long    ART_UNREAD;
  813. #endif
  814. #ifdef SERVER
  815. typedef int        ART_PART;    /* for passing to nntpopen() */
  816. #endif
  817. typedef long        ART_POS;    /* char position in article file */
  818. typedef int        ART_LINE;    /* line position in article file */
  819. typedef long        ACT_POS;    /* char position in active file */
  820. typedef unsigned int    MEM_SIZE;    /* for passing to malloc */
  821.  
  822.  
  823. /* *** end of the machine dependent stuff *** */
  824.  
  825. /* GLOBAL THINGS */
  826.  
  827. /* file statistics area */
  828.  
  829. EXT struct stat filestat;
  830.  
  831. /* various things of type char */
  832.  
  833. char    *index();
  834. char    *rindex();
  835. char    *getenv();
  836. char    *strcat();
  837. char    *strcpy();
  838.  
  839. EXT char buf[LBUFLEN+1];    /* general purpose line buffer */
  840. EXT char cmd_buf[CBUFLEN];    /* buffer for formatting system commands */
  841. EXT char *indstr INIT(">");    /* indent for old article embedded in followup */
  842.  
  843. EXT char *cwd INIT(Nullch);        /* current working directory */
  844. EXT char *dfltcmd INIT(Nullch);    /* 1st char is default command */
  845.  
  846. /* switches */
  847.  
  848. #ifdef DEBUGGING
  849.     EXT int debug INIT(0);                /* -D */
  850. #   define DEB_NNTP 16 
  851. #   define DEB_INNERSRCH 32 
  852. #   define DEB_FILEXP 64 
  853. #   define DEB_HASH 128
  854. #   define DEB_XREF_MARKER 256
  855. #   define DEB_CTLAREA_BITMAP 512
  856. #   define DEB_SOFT_POINTERS 1024
  857. #   define DEB_NEWSRC_LINE 2048
  858. #   define DEB_SEARCH_AHEAD 4096
  859. #   define DEB_CHECKPOINTING 8192
  860. #   define DEB_FEED_XREF 16384
  861. #endif
  862.  
  863. #ifdef ARTSEARCH
  864.     EXT int scanon INIT(0);                /* -S */
  865. #endif
  866.  
  867. #ifdef USETHREADS
  868.     EXT bool use_threads INIT(THREAD_INIT);        /* -x */
  869.     EXT int max_tree_lines INIT(6);
  870.     EXT char select_order[4] INIT("lsm");
  871.     EXT int select_on INIT(SELECT_INIT);        /* -X */
  872.     EXT char end_select INIT('Z');
  873.     EXT char page_select INIT('>');
  874. #endif
  875.  
  876. EXT bool dont_filter_control INIT(FALSE);        /* -j */
  877. EXT bool mbox_always INIT(FALSE);            /* -M */
  878. EXT bool norm_always INIT(FALSE);            /* -N */
  879. EXT bool thread_always INIT(FALSE);            /* -a */
  880. EXT bool breadth_first INIT(FALSE);            /* -b */
  881. EXT bool olden_days INIT(FALSE);            /* -o */
  882. EXT bool checkflag INIT(FALSE);                /* -c */
  883. EXT bool suppress_cn INIT(FALSE);            /* -s */
  884. EXT int countdown INIT(5);    /* how many lines to list before invoking -s */
  885. EXT bool muck_up_clear INIT(FALSE);            /* -loco */
  886. EXT bool erase_screen INIT(FALSE);            /* -e */
  887. #if defined(CLEAREOL) || defined(USETHREADS)
  888. EXT bool can_home INIT(FALSE);
  889. #endif
  890. #ifdef CLEAREOL
  891. EXT bool can_home_clear INIT(FALSE);        /* fancy -e */
  892. #endif
  893. EXT bool findlast INIT(FALSE);            /* -r */
  894. EXT bool typeahead INIT(FALSE);            /* -T */
  895. #ifdef VERBOSE
  896. #   ifdef TERSE
  897.     EXT bool verbose INIT(TRUE);            /* +t */
  898. #   endif
  899. #endif
  900. #ifdef VERIFY
  901.     EXT bool verify INIT(FALSE);            /* -v */
  902. #endif
  903.     EXT bool quickstart INIT(FALSE);            /* -q */
  904.  
  905. #define NOMARKING 0
  906. #define STANDOUT 1
  907. #define UNDERLINE 2
  908. EXT int marking INIT(NOMARKING);            /* -m */
  909.  
  910. EXT ART_LINE initlines INIT(0);        /* -i */
  911. EXT bool initlines_specified INIT(FALSE);
  912.  
  913. /* miscellania */
  914.  
  915. int fseek();
  916. long atol(), ftell();
  917. EXT bool in_ng INIT(FALSE);        /* current state of rn */
  918. EXT char mode INIT('i');        /* current state of rn */
  919.  
  920. EXT FILE *tmpfp INIT(Nullfp);    /* scratch fp used for .rnlock, .rnlast, etc. */
  921.  
  922. EXT NG_NUM nextrcline INIT(0);    /* 1st unused slot in rcline array */
  923.             /* startup to avoid checking twice in a row */
  924.  
  925. extern errno;
  926. /* Factored strings */
  927.  
  928. EXT char nullstr[1] INIT("");
  929. /*EXT char sh[] INIT(SH);*/
  930. #ifdef INTERN_H_INCLUDED            /*** OS2: Patch ***/
  931. EXT char *sh = uupc_rc_settings.prefshell;
  932. #else
  933. EXT char *sh;
  934. #endif
  935. /*EXT char defeditor[] INIT(DEFEDITOR);*/
  936. #ifdef INTERN_H_INCLUDED            /*** OS2: Patch ***/
  937. EXT char *defeditor = uupc_rc_settings.editor;
  938. #else
  939. EXT char *defeditor;
  940. #endif
  941. EXT char hforhelp[] INIT("Type h for help.\n");
  942. #ifdef STRICTCR
  943. EXT char badcr[] INIT("\nUnnecessary CR ignored.\n");
  944. #endif
  945. EXT char readerr[] INIT("rn read error");
  946. EXT char unsubto[] INIT("\n\nUnsubscribed to newsgroup %s\n");
  947. EXT char cantopen[] INIT("Can't open %s\n");
  948. EXT char cantcreate[] INIT("Can't create %s\n");
  949. EXT char cantrecreate[] INIT("Can't recreate %s -- restoring older version.\n");
  950.  
  951. #ifdef VERBOSE
  952.     EXT char nocd[] INIT("Can't chdir to directory %s\n");
  953. #else
  954.     EXT char nocd[] INIT("Can't find %s\n");
  955. #endif
  956.  
  957. /* #ifdef NOLINEBUF */
  958. #define FLUSH fflush(stdout)
  959. /* #else  */
  960. /* #define FLUSH */
  961. /* #endif  */
  962.  
  963. /* #ifdef lint
  964. #undef FLUSH
  965. #define FLUSH
  966. #undef putchar
  967. #define putchar(c)
  968. #endif   */
  969.