home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sources / misc / 3913 < prev    next >
Encoding:
Text File  |  1992-09-08  |  63.4 KB  |  2,457 lines

  1. Newsgroups: comp.sources.misc
  2. Path: sparky!kent
  3. From: sandy@godzilla.Quotron.COM (Sanford Zelkovitz)
  4. Subject:  v32i022:  xbbs - A Bulletin Board System for System V, Part07/11
  5. Message-ID: <1992Sep9.045326.26501@sparky.imd.sterling.com>
  6. Followup-To: comp.sources.d
  7. X-Md4-Signature: b1d325a30fe5930ea48fb8c4b280fbd0
  8. Sender: kent@sparky.imd.sterling.com (Kent Landfield)
  9. Organization: Sterling Software
  10. References: <csm-v32i016=xbbs.234515@sparky.IMD.Sterling.COM>
  11. Date: Wed, 9 Sep 1992 04:53:26 GMT
  12. Approved: kent@sparky.imd.sterling.com
  13. Lines: 2442
  14.  
  15. Submitted-by: sandy@godzilla.Quotron.COM (Sanford Zelkovitz)
  16. Posting-number: Volume 32, Issue 22
  17. Archive-name: xbbs/part07
  18. Environment: SYSV, Xenix
  19.  
  20. #! /bin/sh
  21. # This is a shell archive.  Remove anything before this line, then feed it
  22. # into a shell via "sh file" or similar.  To overwrite existing files,
  23. # type "sh file -c".
  24. # Contents:  bbscarc.c bbscconf.c bbscmsga.c bbscport.c bulletin.mod
  25. #   crc.c msgpack/packfile.c
  26. # Wrapped by kent@sparky on Fri Sep  4 12:48:53 1992
  27. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  28. echo If this archive is complete, you will see the following message:
  29. echo '          "shar: End of archive 7 (of 11)."'
  30. if test -f 'bbscarc.c' -a "${1}" != "-c" ; then 
  31.   echo shar: Will not clobber existing file \"'bbscarc.c'\"
  32. else
  33.   echo shar: Extracting \"'bbscarc.c'\" \(4767 characters\)
  34.   sed "s/^X//" >'bbscarc.c' <<'END_OF_FILE'
  35. X#include "bbscdef.h"
  36. X
  37. Xstruct heads {                /* archive entry header format */
  38. X    char        name[13];    /* file name */
  39. X    int        size;        /* size of file, in bytes */
  40. X    unsigned short    date;        /* creation date */
  41. X    unsigned short    time;        /* creation time */
  42. X    unsigned short        crc;        /* cyclic redundancy check */
  43. X    int        length;        /* true file length */
  44. X};
  45. X
  46. X#define ARCMARK        26    /* special archive marker */
  47. X#define ARCVER        9    /* archive header version code */
  48. X#define ARCFNLEN    13    /* file name length */
  49. X
  50. Xchar    hdrver;            /* header version */
  51. XFILE    *arc;            /* the old archive */
  52. XFILE    *inps;
  53. X
  54. Xlistarc(filename, port_id)
  55. Xchar    *filename, *port_id;
  56. X{
  57. X    struct heads    hdr;            /* header data */
  58. X    long        tnum, tlen, tsize;    /* totals */
  59. X    strcpy(buf128, "/tmp/arclst.");
  60. X    strcat(buf128, port_id);
  61. X    inps = fopen(buf128, "w");
  62. X
  63. X    strcpy(buf128, filename);
  64. X
  65. X    fprintf(inps, "\nArchive:  %s\n\n", buf128);
  66. X
  67. X    tnum = tlen = tsize = 0;    /* reset totals */
  68. X
  69. X    fprintf(inps, "Name          Length    Stowage    SF   Size now  ");
  70. X    fprintf(inps, "Date       Time    CRC\n");
  71. X    fprintf(inps, "============  ========  ========  ====  ========  ");
  72. X    fprintf(inps, "=========  ======  ====\n");
  73. X    
  74. X    if (!(arc = fopen(buf128, "rb"))) {    /* open archive for reading */
  75. X        fprintf(inps, "Cannot read archive: %s\n", buf128);
  76. X        return;
  77. X    }
  78. X
  79. X    while (readhdr(&hdr, arc)) {    /* else report on all files */
  80. X        lstfile(&hdr);
  81. X        tnum++;         /* update totals */
  82. X        tlen += hdr.length;
  83. X        tsize += hdr.size;
  84. X        fseek(arc, hdr.size, 1);/* skip to next header */
  85. X    }
  86. X
  87. X    fclose(arc);            /* close archive after reading */
  88. X
  89. X    fprintf(inps, "        ====  ========            ====  ========\n");
  90. X    fprintf(inps, "Total %6ld  %8ld            %3ld%%  %8ld  \n\n",
  91. X       tnum, tlen, tlen ? 100L - (100L * tsize) / tlen : 0, tsize);
  92. X    fclose(inps);
  93. X}
  94. X
  95. Xstatic lstfile(hdr)               /* tell about a file */
  96. Xstruct heads *hdr;               /* pointer to header data */
  97. X{
  98. X    int    yr, mo, dy;               /* parts of a date */
  99. X    int    hh, mm, ss;               /* parts of a time */
  100. X
  101. X    static char    *mon[] = {           /* month abbreviations */
  102. X        "Jan", "Feb", "Mar", "Apr",
  103. X        "May", "Jun", "Jul", "Aug",
  104. X        "Sep", "Oct", "Nov", "Dec"
  105. X    };
  106. X
  107. X    yr = (hdr -> date >> 9) & 0x7f;        /* dissect the date */
  108. X    mo = (hdr -> date >> 5) & 0x0f;
  109. X    dy = hdr -> date & 0x1f;
  110. X
  111. X    hh = (hdr -> time >> 11) & 0x1f;    /* dissect the time */
  112. X    mm = (hdr -> time >> 5) & 0x3f;
  113. X    ss = (hdr -> time & 0x1f) * 2;
  114. X
  115. X    fprintf(inps, "%-12s  %8ld  ", hdr -> name, hdr -> length);
  116. X
  117. X    switch (hdrver) {
  118. X    case 1:
  119. X    case 2:
  120. X        fprintf(inps, "   --   ");
  121. X        break;
  122. X    case 3:
  123. X        fprintf(inps, " Packed ");
  124. X        break;
  125. X    case 4:
  126. X        fprintf(inps, "Squeezed");
  127. X        break;
  128. X    case 5:
  129. X    case 6:
  130. X    case 7:
  131. X        fprintf(inps, "crunched");
  132. X        break;
  133. X    case 8:
  134. X        fprintf(inps, "Crunched");
  135. X        break;
  136. X    case 9: fprintf(inps, "Squashed");
  137. X        break;
  138. X    default:
  139. X        fprintf(inps, "Unknown!");
  140. X    }
  141. X
  142. X    fprintf(inps, "  %3ld%%  %8ld  %2d %3s %02d  %2d:%02d%c  %04X\n",
  143. X        100L - (100L * hdr -> size) / hdr -> length,
  144. X        hdr -> size,
  145. X        dy, mon[mo-1], (yr + 80) % 100,
  146. X        (hh > 12 ? hh - 12 : hh), mm, (hh > 12 ? 'p' : 'a'), hdr -> crc);
  147. X}
  148. X
  149. Xint readhdr(hdr, f)            /* read a header from an archive */
  150. Xstruct heads    *hdr;            /* storage for header */
  151. XFILE        *f;            /* archive to read header from */
  152. X{
  153. X    char        name[ARCFNLEN];    /* filename buffer */
  154. X    int        try = 0;    /* retry counter */
  155. X    static int    first = 1;    /* true only on first read */
  156. X
  157. X    if (!f)                /* if archive didn't open */
  158. X        return 0;        /* then pretend it's the end */
  159. X    if (feof(f))            /* if no more data */
  160. X        return 0;        /* then signal end of archive */
  161. X
  162. X    if (fgetc(f) != ARCMARK) {    /* check archive validity */
  163. X        fprintf(inps, "An entry in %s has a bad header.\n", buf128);
  164. X
  165. X        while(!feof(f)) {
  166. X            try++;
  167. X            if (fgetc(f) == ARCMARK) {
  168. X                ungetc(hdrver = fgetc(f), f);
  169. X                if (hdrver >= 0 && hdrver <= ARCVER)
  170. X                    break;
  171. X            }
  172. X        }
  173. X
  174. X        if (feof(f) && first) {
  175. X            fprintf(inps,"%s is not an archive.\n", buf128);
  176. X            return 0;
  177. X        }
  178. X
  179. X        fprintf(inps, "  %d bytes skipped.\n", try);
  180. X
  181. X        if (feof(f))
  182. X            return 0;
  183. X    }
  184. X
  185. X    hdrver = fgetc(f);        /* get header version */
  186. X    if (hdrver < 0) {
  187. X        fprintf(inps, "Invalid header in archive %s\n", buf128);
  188. X        return 0;
  189. X    }
  190. X    if (hdrver == 0)
  191. X        return 0;        /* note our end of archive marker */
  192. X    if (hdrver > ARCVER) {
  193. X        fread(name, sizeof(char), ARCFNLEN, f);
  194. X        fprintf(inps, "I don't know how to handle file %s in archive %s\n",
  195. X           name, buf128);
  196. X        fprintf(inps, "I think you need a newer version of ARC.\n");
  197. X            return 0;
  198. X    }
  199. X
  200. X    /* amount to read depends on header type */
  201. X
  202. X    if (hdrver == 1) {            /* old style is shorter */
  203. X        fread(hdr, sizeof (struct heads) - sizeof (long int), 1, f);
  204. X        hdrver = 2;                   /* convert header to new format */
  205. X        hdr -> length = hdr -> size;    /* size is same when not packed */
  206. X    } else
  207. X        fread(hdr, sizeof (struct heads), 1, f);
  208. X    first = 0;
  209. X    return 1;                /* we read something */
  210. X}
  211. END_OF_FILE
  212.   if test 4767 -ne `wc -c <'bbscarc.c'`; then
  213.     echo shar: \"'bbscarc.c'\" unpacked with wrong size!
  214.   fi
  215.   # end of 'bbscarc.c'
  216. fi
  217. if test -f 'bbscconf.c' -a "${1}" != "-c" ; then 
  218.   echo shar: Will not clobber existing file \"'bbscconf.c'\"
  219. else
  220.   echo shar: Extracting \"'bbscconf.c'\" \(7847 characters\)
  221.   sed "s/^X//" >'bbscconf.c' <<'END_OF_FILE'
  222. X/* Conference Section     05/01/90      */
  223. X#include <sys/types.h>
  224. X#include <sys/stat.h>
  225. X#include <utmp.h>
  226. X#include <string.h>
  227. X#include <fcntl.h>
  228. X#include <pwd.h>
  229. X#include <signal.h>
  230. X#include "bbscdef.h"
  231. X
  232. X#ifdef SYSV
  233. X#include <dirent.h>
  234. X#include <sys/dir.h>
  235. X#else
  236. X#include <sys/ndir.h>
  237. X#endif
  238. X
  239. Xextern int      no_cntrl_k;
  240. Xstruct stat     thisstat;
  241. Xchar           *getlogin();
  242. X
  243. X#ifdef SYSV
  244. X#ifndef ESIX54
  245. X#define    opendir(path) fopen (path, "r")
  246. X#define closedir(dirp) fclose (dirp)
  247. Xstruct dirent  *
  248. Xreaddir(dirp)
  249. X    DIR            *dirp;
  250. X{
  251. X    static struct dirent entry;
  252. X    if (dirp == NULL)
  253. X    return (NULL);
  254. X    for (;;) {
  255. X    if (fread(&entry, sizeof(struct dirent), 1, dirp) == 0)
  256. X        return (NULL);
  257. X    if (entry.d_ino)
  258. X        return (&entry);
  259. X    }
  260. X}
  261. X#endif
  262. X#endif
  263. X
  264. Xconf()
  265. X{
  266. X    int             mypid, loginpid, uid;
  267. X    register struct utmp *u;
  268. X    extern struct utmp *getutent();
  269. X    struct passwd  *getpwuid();
  270. X    struct passwd  *pwd;
  271. X    char            mybyte;
  272. X    char            byten, byter, bytes, bytet;
  273. X    char           *bufptr, *myname, *cmf;
  274. X    char            buffer[20], my_ext[10];
  275. X    char            buffs[99];
  276. X    int             length, handle, handlex;
  277. X    int             match, sigrets, pidrets, cmpflag;
  278. X    FILE           *infile;
  279. X    match = 1;
  280. X    byten = (char) '\n';
  281. X    byter = (char) '\r';
  282. X    bytes = (char) ' ';
  283. X    mypid = getpid();
  284. X    myname = getlogin();
  285. X    uid = getuid();
  286. X    loginpid = getppid();
  287. X    pwd = getpwuid(uid);
  288. X/*
  289. X     *Check to see if the login name is the same as the present users pw
  290. X     * name. If it isn't, let's play around a little and make it work for us!
  291. X*/
  292. X    strcpy(who_am_i, myname);
  293. X    strcpy(who_am_I, pwd->pw_name);
  294. X    handle = strcmp(who_am_i, who_am_I);
  295. X    if (handle != 0)
  296. X    match = 0;
  297. X/*
  298. X     *Flag that we are in conference!
  299. X*/
  300. X    while ((u = getutent()) != NULL) {
  301. X    handle = strcmp(u->ut_user, myname);
  302. X    if (match) {
  303. X        if (handle == 0 && u->ut_pid == mypid) {
  304. X        strcpy(my_ext, u->ut_id);
  305. X        strcpy(who_am_I, u->ut_line);
  306. X        }
  307. X    } else {
  308. X        if (handle == 0 && u->ut_pid == loginpid) {
  309. X        strcpy(my_ext, u->ut_id);
  310. X        strcpy(who_am_I, u->ut_line);
  311. X        }
  312. X    }
  313. X    }
  314. X    endutent();
  315. X    strcpy(who_am_i, "/tmp/conf");
  316. X    strcat(who_am_i, my_ext);
  317. X    if ((inbuf = fopen(who_am_i, "w")) == NULL) {
  318. X    portsout("\n\rError opening flag file!\n\r");
  319. X    exit(1);
  320. X    }
  321. X    fprintf(inbuf, "%s %s %s\n", w_fname, w_lname, who_am_I);
  322. X    fclose(inbuf);
  323. X/*
  324. X     *Flag all users that I just went into conference
  325. X*/
  326. X    strcpy(buf128, "ls /tmp/pid* > /tmp/on.sys.");
  327. X    strcat(buf128, my_ext);
  328. X    (void) system(buf128);
  329. X    strcpy(buf128, "/tmp/on.sys.");
  330. X    strcat(buf128, my_ext);
  331. X    if ((otbuf = fopen(buf128, "r")) == NULL) {
  332. X    portsout("\n\rError opening list file!\n\r");
  333. X    exit(1);
  334. X    }
  335. X    while (fscanf(otbuf, "%s", buffs) != EOF) {
  336. X    infile = fopen(buffs, "r");
  337. X    cmpflag = strlen(buffs);
  338. X    cmf = buffs + cmpflag - 2;
  339. X    strcpy(buffer, cmf);
  340. X    fgets(buffs, 6, infile);
  341. X    fclose(infile);
  342. X    pidrets = atoi(buffs);
  343. X    if ((sigrets = kill(pidrets, 0)) != 0)
  344. X        continue;        /* not valid  */
  345. X    setutent();
  346. X    cmpflag = 0;
  347. X    while ((u = getutent()) != NULL) {
  348. X        if (u->ut_pid == pidrets) {
  349. X        cmpflag = 1;
  350. X        strcpy(buf128, "/dev/");
  351. X        strcat(buf128, u->ut_line);
  352. X        handle = open(buf128, O_WRONLY);
  353. X        sprintf(buf128, "\n\r**** %s %s went into conference ****\n\r", w_fname, w_lname);
  354. X        write(handle, buf128, strlen(buf128));
  355. X        close(handle);
  356. X        }
  357. X    }
  358. X    endutent();
  359. X    if (!cmpflag) {
  360. X        setutent();
  361. X        while ((u = getutent()) != NULL) {
  362. X        cmpflag = strlen(u->ut_line);
  363. X        cmf = u->ut_line + cmpflag - 2;
  364. X        if ((strcmp(cmf, buffer)) == 0) {
  365. X            strcpy(buf128, "/dev/");
  366. X            strcat(buf128, u->ut_line);
  367. X            handle = open(buf128, O_WRONLY);
  368. X            sprintf(buf128, "\n\r**** %s %s went into conference ****\n\r", w_fname, w_lname);
  369. X            write(handle, buf128, strlen(buf128));
  370. X            close(handle);
  371. X        }
  372. X        }
  373. X        endutent();
  374. X    }
  375. X    cmpflag = 0;
  376. X    }
  377. X    fclose(otbuf);
  378. X
  379. X
  380. X/*   
  381. X     *List the users that are presently in conference
  382. X*/
  383. X    portsout("\n\r\n\rThe following users are presently in conference\n\r");
  384. X    no_cntrl_k = 1;
  385. X    strcpy(buf128, "ls /tmp/conf* > /tmp/inconf.");
  386. X    strcat(buf128, my_ext);
  387. X    (void) system(buf128);
  388. X    strcpy(buf128, "/tmp/inconf.");
  389. X    strcat(buf128, my_ext);
  390. X    if ((otbuf = fopen(buf128, "r")) == NULL) {
  391. X    portsout("\n\rError opening list file!\n\r");
  392. X    exit(1);
  393. X    }
  394. X    while (fscanf(otbuf, "%s", who_am_i) != EOF) {
  395. X    cmd_p(who_am_i);
  396. X    }
  397. X    fclose(otbuf);
  398. X    no_cntrl_k = 0;
  399. X/*
  400. X     *Start the loop for input
  401. X*/
  402. X
  403. X    portsout("\n\rDepressing the escape key will exit the conference!\n\r");
  404. X    strcpy(who_am_I, "<");
  405. X    strcat(who_am_I, w_fname);
  406. X    strcat(who_am_I, " ");
  407. X    strcat(who_am_I, w_lname);
  408. X    strcat(who_am_I, "> ");
  409. X    buf128[0] = '\0';
  410. X    while (1) {
  411. X    bufptr = buf128;
  412. X    *bufptr = '\0';
  413. X      conf_loop:
  414. X    mybyte = portin_chat();
  415. X    if (mybyte == '\033')
  416. X        break;
  417. X    if (mybyte == 127)
  418. X        mybyte = '\b';
  419. X    if (mybyte == '\b') {
  420. X        length = strlen(buf128);
  421. X        if (!length)
  422. X        goto conf_loop;
  423. X        length--;
  424. X        portout_chat(mybyte);
  425. X        portout_chat(bytes);
  426. X        portout_chat(mybyte);
  427. X        bufptr = length + buf128;
  428. X        *bufptr = '\0';
  429. X        goto conf_loop;
  430. X    }
  431. X    portout_chat(mybyte);
  432. X    length = strlen(buf128);
  433. X    bufptr = length + buf128;
  434. X    *bufptr++ = mybyte;
  435. X    *bufptr = '\0';
  436. X    if (mybyte == '\n' || mybyte == '\r')
  437. X        goto saver;
  438. X    goto conf_loop;
  439. X      saver:
  440. X    if (mybyte == '\n')
  441. X        bytet = byter;
  442. X    else
  443. X        bytet = byten;
  444. X    portout_chat(bytet);
  445. X    length = strlen(buf128);
  446. X    bufptr = length + buf128;
  447. X    *bufptr++ = bytet;
  448. X    *bufptr = '\0';
  449. X    strcpy(who_am_i, "ls /tmp/conf* > /tmp/inconf.");
  450. X    strcat(who_am_i, my_ext);
  451. X    (void) system(who_am_i);
  452. X    strcpy(who_am_i, "/tmp/inconf.");
  453. X    strcat(who_am_i, my_ext);
  454. X    if ((inbuf = fopen(who_am_i, "r")) == NULL) {
  455. X        portsout("\n\rError opening list file!\n\r");
  456. X        exit(1);
  457. X    }
  458. X    while (fscanf(inbuf, "%s", who_am_i) != EOF) {
  459. X        handle = strlen(who_am_i);
  460. X        handlex = strlen(my_ext);
  461. X        length = handle - handlex + 1;
  462. X        substr(who_am_i, x_pathandfile, length, handlex);
  463. X        length = strcmp(x_pathandfile, my_ext);
  464. X        if (length != 0) {
  465. X        otbuf = fopen(who_am_i, "r");
  466. X        fscanf(otbuf, "%s%s%s", who_am_i, x_filename, x_pathandfile);
  467. X        fclose(otbuf);
  468. X        strcpy(who_am_i, "/dev/");
  469. X        strcat(who_am_i, x_pathandfile);
  470. X        handle = open(who_am_i, O_WRONLY);
  471. X        length = strlen(who_am_I);
  472. X        write(handle, who_am_I, length);
  473. X        length = strlen(buf128);
  474. X        write(handle, buf128, length);
  475. X        close(handle);
  476. X        }
  477. X    }
  478. X    fclose(inbuf);
  479. X    }
  480. X    strcpy(who_am_i, "/tmp/conf");
  481. X    strcat(who_am_i, my_ext);
  482. X    unlink(who_am_i);
  483. X}
  484. Xwho_is_there()
  485. X{
  486. X    DIR            *dirp;
  487. X    FILE           *infile;
  488. X
  489. X#ifdef SYSV
  490. X    struct dirent  *readdir();
  491. X    struct dirent  *dp;
  492. X#else
  493. X    struct direct  *readdir();
  494. X    struct direct  *dp;
  495. X#endif
  496. X
  497. X    char           *ptr1, *ptr2;
  498. X    int             i, j;
  499. X    portsout("\n\r\n\r");
  500. X    dirp = opendir("/tmp");
  501. X    while ((dp = readdir(dirp)) != NULL) {
  502. X    strcpy(who_am_i, dp->d_name);
  503. X    ptr1 = who_am_i;
  504. X    ptr2 = who_am_I;
  505. X    for (i = 0; i < 3; i++)
  506. X        *ptr2++ = *ptr1++;
  507. X    *ptr2 = '\0';
  508. X    j = strcmp(who_am_I, "pid");
  509. X    if (!j) {
  510. X        strcpy(who_am_I, "/tmp/");
  511. X        strcat(who_am_I, dp->d_name);
  512. X        infile = fopen(who_am_I, "r");
  513. X        fgets(who_am_I, 6, infile);
  514. X        i = atoi(who_am_I);
  515. X        fclose(infile);
  516. X        j = kill(i, 0);    /* see if it is a good pid */
  517. X        if (!j) {
  518. X        strcpy(buf128, ORGPATH);
  519. X        strcat(buf128, "lastcall.bbs");
  520. X        ptr1 = who_am_i + 3;
  521. X        ptr2 = who_am_I;
  522. X        for (i = 3; i < 5; i++)
  523. X            *ptr2++ = *ptr1++;
  524. X        *ptr2 = '\0';
  525. X        strcat(buf128, who_am_I);
  526. X        infile = fopen(buf128, "r");
  527. X        fgets(buf128, 99, infile);
  528. X        strip(buf128);
  529. X        portsout("On port ");
  530. X        portsout(who_am_I);
  531. X        portsout(" -- ");
  532. X        portsout(buf128);
  533. X        portsout(CRLF);
  534. X        fclose(infile);
  535. X        }
  536. X    }
  537. X    }
  538. X    closedir(dirp);
  539. X    portsout("\n\r\n\r");
  540. X}
  541. END_OF_FILE
  542.   if test 7847 -ne `wc -c <'bbscconf.c'`; then
  543.     echo shar: \"'bbscconf.c'\" unpacked with wrong size!
  544.   fi
  545.   # end of 'bbscconf.c'
  546. fi
  547. if test -f 'bbscmsga.c' -a "${1}" != "-c" ; then 
  548.   echo shar: Will not clobber existing file \"'bbscmsga.c'\"
  549. else
  550.   echo shar: Extracting \"'bbscmsga.c'\" \(9408 characters\)
  551.   sed "s/^X//" >'bbscmsga.c' <<'END_OF_FILE'
  552. X/*------------------------------------------------------------------------
  553. X       Name: bbscarea.c
  554. X   Comments: Display file areas and select one
  555. X  ------------------------------------------------------------------------*/
  556. X
  557. X#include <stdio.h>
  558. X#include <string.h>
  559. X#include <ctype.h>
  560. X#include "bbscdef.h"
  561. X
  562. X
  563. Xint             set_yet_m = FALSE;
  564. Xextern int      user_priv;
  565. X
  566. X
  567. Xchange_msga( type ) int type;
  568. X{
  569. X    FILE           *fpt, *fopen();
  570. X    char           *fgets(), *getenv();
  571. X    char            choice[4];
  572. X#ifndef SYSV
  573. X    char            dir_priv_ascii[7];
  574. X#endif
  575. X#ifdef SYSV
  576. X    char            dir_priv_ascii[20];
  577. X#endif
  578. X
  579. X    char           *buf_ptr;
  580. X    int             line_cnt, ret, i;
  581. X    int             index_value, ptr;
  582. X    int             length;
  583. X
  584. X    if( type == -1)
  585. X        return;
  586. X
  587. Xdo_again:
  588. X    strcpy(buf128, MSGS);
  589. X
  590. X    if ((fpt = fopen(buf128, "r")) == NULL) {
  591. X        portsout("\n\rError Opening File Area List: Notify Sysop!\n\r");
  592. X        return (-1);
  593. X    }
  594. X    if(!type) {
  595. X    portsout("\n\r    Directory     Description                                      \n\r");
  596. X    portsout("    ============= ========================================== \n\r");
  597. X    }
  598. X
  599. X    line_cnt = 0;
  600. X    while (fpt) {
  601. X        zfl(f_lines[line_cnt], 81);
  602. X        if ((fgets(f_lines[line_cnt], 80, fpt)) == NULL) {
  603. X            if (line_cnt == 0) {
  604. X                portsout("\n\rEOF Unexpected in Message Area List: Notify Sysop!\n\r");
  605. X                return (-1);
  606. X            }
  607. X            break;    /* if not 1st line */
  608. X        }        /* end of if ((fgets)) */
  609. X        if (line_cnt > 0) {
  610. X            length = strlen(f_lines[line_cnt]);
  611. X            length -= 57;
  612. X            if(length > 6)
  613. X                length = 6;
  614. X            substr(f_lines[line_cnt], dir_priv_ascii, 57, length);
  615. X            dir_priv[line_cnt] = atoi(dir_priv_ascii);
  616. X            if (dir_priv[line_cnt] > user_priv)
  617. X                goto next_read;
  618. X            strcpy(who_am_i, f_lines[line_cnt]);
  619. X            buf_ptr = who_am_i;
  620. X            buf_ptr += 56;
  621. X            for (ptr = 0; ptr < 6; ptr++)
  622. X                *buf_ptr++ = ' ';
  623. X            *buf_ptr = '\0';
  624. X            sprintf(buf128, "%2d) %s", line_cnt, who_am_i);
  625. X            if(!type) {
  626. X            strip(buf128);
  627. X            term_space(buf128);
  628. X            portsout(buf128);
  629. X            portsout("\n\r");
  630. X            }
  631. X        }
  632. Xnext_read:
  633. X        ++line_cnt;
  634. X    }            /* end of while (fpt) */
  635. X    if (line_cnt <= 1)
  636. X        return;
  637. X    if (set_yet_m && !type) {
  638. X        portsout(CRLF);
  639. X        portsout(" Q) Quit to Previous Menu");
  640. X    }
  641. X    if(!type)portsout(CRLF);
  642. X    fclose(fpt);
  643. X    if(!type)portsout(CRLF);
  644. X
  645. X    while (1) {
  646. X        if(!type) {
  647. X        portsout("Enter Selection ===> ");
  648. X        portsin_cmp(choice, 2, "Qq");
  649. X        portsout(CRLF);
  650. X        *choice = toupper(*choice);
  651. X
  652. X        if (*choice == 'Q' && set_yet_m)
  653. X            return (-1);
  654. X
  655. X
  656. X        index_value = atoi(choice);
  657. X        }
  658. X        else index_value = type;
  659. X        if (index_value > 0 && index_value < line_cnt) {
  660. X            if (dir_priv[index_value] <= user_priv) {
  661. X                parse_arg(f_lines[index_value]);
  662. X                set_yet_m = TRUE;
  663. X                hdrread();
  664. X                itoa(buf128,index_value);
  665. X                if(index_value > 9)
  666. X                    {
  667. X                    strcpy(l_m_base, buf128);
  668. X                    }
  669. X                else
  670. X                    {
  671. X                    strcpy(l_m_base, "0");
  672. X                    strcat(l_m_base,buf128);
  673. X                    }
  674. X                
  675. X                rewritx();
  676. X                return (0);
  677. X            }
  678. X        }
  679. X        if( type != 0 ) {
  680. X            type = 0;
  681. X            portsout("\n\rInvalid directory request!\n\r");
  682. X            goto do_again;
  683. X        }
  684. X    }
  685. X}
  686. X
  687. X
  688. X
  689. X
  690. X
  691. Xparse_arg(string)
  692. X    char           *string;
  693. X{
  694. X
  695. X    register char  *file_ptr, *xptr;
  696. X    register int    i;
  697. X
  698. X    strcpy(m_pathname, ORGPATH);
  699. X    file_ptr = (m_pathname + strlen(m_pathname));
  700. X    xptr = who_am_I;
  701. X
  702. X    i = 0;
  703. X    while (string[i] != ' ') {
  704. X        *file_ptr = string[i];
  705. X        *xptr = string[i];
  706. X        ++xptr;
  707. X        ++file_ptr;
  708. X        ++i;
  709. X    }
  710. X    *file_ptr = '/';
  711. X    ++file_ptr;
  712. X    *file_ptr = '\0';
  713. X    *xptr = '\0';
  714. X
  715. X}
  716. Xcheck_msga()
  717. X{
  718. X    FILE           *fpt, *fopen();
  719. X    char           *fgets(), *getenv();
  720. X    char            choice[4];
  721. X#ifndef SYSV
  722. X    char            dir_priv_ascii[7];
  723. X#endif
  724. X#ifdef SYSV
  725. X    char            dir_priv_ascii[20];
  726. X#endif
  727. X    char           *buf_ptr, *file_ptr, *char_ptr;
  728. X    int             line_cnt, ret, i;
  729. X    int             index_value, ptr;
  730. X    int             length, strl, ii;
  731. X
  732. X
  733. X    strcpy(buf128, MSGS);
  734. X
  735. X    if ((fpt = fopen(buf128, "r")) == NULL) {
  736. X        portsout("\n\rError Opening File Area List: Notify Sysop!\n\r");
  737. X        return (-1);
  738. X    }
  739. X    line_cnt = 0;
  740. X    while (fpt) {
  741. X        zfl(f_lines[line_cnt], 81);
  742. X        if ((fgets(f_lines[line_cnt], 80, fpt)) == NULL) {
  743. X            if (line_cnt == 0) {
  744. X                portsout("\n\rEOF Unexpected in Message Area List: Notify Sysop!\n\r");
  745. X                return (-1);
  746. X            }
  747. X            break;    /* if not 1st line */
  748. X        }        /* end of if ((fgets)) */
  749. X        if (line_cnt > 0) {
  750. X            length = strlen(f_lines[line_cnt]);
  751. X            length -= 57;
  752. X            if(length > 6)
  753. X                length = 6;
  754. X            substr(f_lines[line_cnt], dir_priv_ascii, 57, length);
  755. X            strl = strlen(dir_priv_ascii);
  756. X            if (strl == 0) {
  757. X                portsout("\n\rError reading privilege level\n\r");
  758. X                exit(1);
  759. X            }
  760. X            char_ptr = strchr(dir_priv_ascii, '*');
  761. X            if (char_ptr != NULL) {
  762. X                strcpy(c_pathname, ORGPATH);
  763. X                file_ptr = (c_pathname + strlen(c_pathname));
  764. X                ii = 0;
  765. X                while (f_lines[line_cnt][ii] != ' ') {
  766. X                    *file_ptr = f_lines[line_cnt][ii];
  767. X                    ++file_ptr;
  768. X                    ++ii;
  769. X                }
  770. X                *file_ptr = '/';
  771. X                ++file_ptr;
  772. X                *file_ptr = '\0';
  773. X                *char_ptr = '\0';
  774. X            }
  775. X            dir_priv[line_cnt] = atoi(dir_priv_ascii);
  776. X            if (dir_priv[line_cnt] > user_priv)
  777. X                goto next_read;
  778. X            strcpy(who_am_i, f_lines[line_cnt]);
  779. X            buf_ptr = who_am_i;
  780. X            buf_ptr += 56;
  781. X            for (ptr = 0; ptr < 5; ptr++)
  782. X                *buf_ptr++ = ' ';
  783. X            sprintf(buf128, "%2d) %s", line_cnt, who_am_i);
  784. X        }
  785. Xnext_read:
  786. X        ++line_cnt;
  787. X    }            /* end of while (fpt) */
  788. X    fclose(fpt);
  789. X
  790. X    if (line_cnt <= 1)
  791. X        return;
  792. X
  793. X
  794. X    for (index_value = 1; index_value < line_cnt; index_value++) {
  795. X        if (dir_priv[index_value] <= user_priv) {
  796. X            parse_arg(f_lines[index_value]);
  797. X            hdrread();
  798. X            portsout("\n\rMail check for area '");
  799. X            portsout(who_am_I);
  800. X            portsout("'\n\r");
  801. X            mail_to_you();
  802. X            portsout("\n\r*************************************************\n\r");
  803. X        }
  804. X    }
  805. X/*                      SIG checking                         */
  806. X    strcpy(buf128, SIGS);
  807. X
  808. X    if ((fpt = fopen(buf128, "r")) == NULL) {
  809. X        fclose(fpt);
  810. X        return;      /* No sigs */
  811. X    }
  812. X    line_cnt = 0;
  813. X    while (fpt) {
  814. X        zfl(f_lines[line_cnt], 83);
  815. X        if ((fgets(f_lines[line_cnt], 82, fpt)) == NULL) {
  816. X            if (line_cnt == 0) {
  817. X                portsout("\n\rEOF Unexpected in SIG Area List: Notify Sysop!\n\r");
  818. X                return (-1);
  819. X            }
  820. X            break;    /* if not 1st line */
  821. X        }        /* end of if ((fgets)) */
  822. X        if (line_cnt > 0) {
  823. X            length = strlen(f_lines[line_cnt]);
  824. X            length -= 74;
  825. X            if(length > 6)
  826. X                length = 6;
  827. X            substr(f_lines[line_cnt], dir_priv_ascii, 74, length);
  828. X            strl = strlen(dir_priv_ascii);
  829. X            if (strl == 0) {
  830. X                portsout("\n\rError reading privilege level\n\r");
  831. X                exit(1);
  832. X            }
  833. X            char_ptr = strchr(dir_priv_ascii, '*');
  834. X            if (char_ptr != NULL) {
  835. X                *char_ptr = '\0';
  836. X            }
  837. X            dir_priv[line_cnt] = atoi(dir_priv_ascii);
  838. X            if (dir_priv[line_cnt] > user_priv)
  839. X                goto next_read_sig;
  840. X            strcpy(who_am_i, f_lines[line_cnt]);
  841. X            buf_ptr = who_am_i;
  842. X            buf_ptr += 73;
  843. X            for (ptr = 0; ptr < 5; ptr++)
  844. X                *buf_ptr++ = ' ';
  845. X            sprintf(buf128, "%2d) %s", line_cnt, who_am_i);
  846. X        }
  847. Xnext_read_sig:
  848. X        ++line_cnt;
  849. X    }            /* end of while (fpt) */
  850. X    fclose(fpt);
  851. X
  852. X    if (line_cnt <= 1)
  853. X        return;
  854. X
  855. X
  856. X    for (index_value = 1; index_value < line_cnt; index_value++) {
  857. X        if (dir_priv[index_value] <= user_priv) {
  858. X            parse_arg(f_lines[index_value]);
  859. X            strcat(m_pathname, "msgs/");
  860. X            hdrread();
  861. X            portsout("\n\rMail check for SIG area '");
  862. X            portsout(who_am_I);
  863. X            portsout("'\n\r");
  864. X            mail_to_you();
  865. X            portsout("\n\r*************************************************\n\r");
  866. X        }
  867. X    }
  868. X/*                   End of SIG checking                     */
  869. X}
  870. Xcheck_msga_n()
  871. X{
  872. X    FILE           *fpt, *fopen();
  873. X    char           *fgets(), *getenv();
  874. X    char            choice[4];
  875. X#ifndef SYSV
  876. X    char            dir_priv_ascii[7];
  877. X#endif
  878. X#ifdef SYSV
  879. X    char            dir_priv_ascii[20];
  880. X#endif
  881. X    char           *buf_ptr, *file_ptr, *char_ptr;
  882. X    int             line_cnt, ret, i;
  883. X    int             index_value, ptr;
  884. X    int             length, strl, ii;
  885. X
  886. X
  887. X    strcpy(buf128, MSGS);
  888. X
  889. X    if ((fpt = fopen(buf128, "r")) == NULL) {
  890. X        portsout("\n\rError Opening File Area List: Notify Sysop!\n\r");
  891. X        return (-1);
  892. X    }
  893. X    line_cnt = 0;
  894. X    while (fpt) {
  895. X        zfl(f_lines[line_cnt], 81);
  896. X        if ((fgets(f_lines[line_cnt], 80, fpt)) == NULL) {
  897. X            if (line_cnt == 0) {
  898. X                portsout("\n\rEOF Unexpected in Message Area List: Notify Sysop!\n\r");
  899. X                return (-1);
  900. X            }
  901. X            break;    /* if not 1st line */
  902. X        }        /* end of if ((fgets)) */
  903. X        if (line_cnt > 0) {
  904. X            length = strlen(f_lines[line_cnt]);
  905. X            length -= 57;
  906. X            if(length > 6)
  907. X                length = 6;
  908. X            substr(f_lines[line_cnt], dir_priv_ascii, 57, length);
  909. X            strl = strlen(dir_priv_ascii);
  910. X            if (strl == 0) {
  911. X                portsout("\n\rError reading privilege level\n\r");
  912. X                exit(1);
  913. X            }
  914. X            char_ptr = strchr(dir_priv_ascii, '*');
  915. X            if (char_ptr != NULL) {
  916. X                strcpy(c_pathname, ORGPATH);
  917. X                file_ptr = (c_pathname + strlen(c_pathname));
  918. X                ii = 0;
  919. X                while (f_lines[line_cnt][ii] != ' ') {
  920. X                    *file_ptr = f_lines[line_cnt][ii];
  921. X                    ++file_ptr;
  922. X                    ++ii;
  923. X                }
  924. X                *file_ptr = '/';
  925. X                ++file_ptr;
  926. X                *file_ptr = '\0';
  927. X                *char_ptr = '\0';
  928. X            }
  929. X            dir_priv[line_cnt] = atoi(dir_priv_ascii);
  930. X            if (dir_priv[line_cnt] > user_priv)
  931. X                goto next_read_n;
  932. X            strcpy(who_am_i, f_lines[line_cnt]);
  933. X            buf_ptr = who_am_i;
  934. X            buf_ptr += 56;
  935. X            for (ptr = 0; ptr < 5; ptr++)
  936. X                *buf_ptr++ = ' ';
  937. X            sprintf(buf128, "%2d) %s", line_cnt, who_am_i);
  938. X        }
  939. Xnext_read_n:
  940. X        ++line_cnt;
  941. X    }            /* end of while (fpt) */
  942. X    fclose(fpt);
  943. X
  944. X    if (line_cnt <= 1)
  945. X        return;
  946. X
  947. X
  948. X    for (index_value = 1; index_value < line_cnt; index_value++) {
  949. X        if (dir_priv[index_value] <= user_priv) {
  950. X            parse_arg(f_lines[index_value]);
  951. X            hdrread();
  952. X        }
  953. X    }
  954. X}
  955. END_OF_FILE
  956.   if test 9408 -ne `wc -c <'bbscmsga.c'`; then
  957.     echo shar: \"'bbscmsga.c'\" unpacked with wrong size!
  958.   fi
  959.   # end of 'bbscmsga.c'
  960. fi
  961. if test -f 'bbscport.c' -a "${1}" != "-c" ; then 
  962.   echo shar: Will not clobber existing file \"'bbscport.c'\"
  963. else
  964.   echo shar: Extracting \"'bbscport.c'\" \(7862 characters\)
  965.   sed "s/^X//" >'bbscport.c' <<'END_OF_FILE'
  966. X/*
  967. X    bbscport.c
  968. X
  969. X*/
  970. X
  971. X#include "bbscdef.h"
  972. X#include <string.h>
  973. X#include <ctype.h>
  974. X#include <sys/types.h>
  975. X#include <sys/locking.h>
  976. Xextern int no_cntrl_k;
  977. Xextern int hold_off;
  978. Xextern int toggle_hold;
  979. Xextern unsigned int Zsec;
  980. X
  981. X#define LASTDATE  " 05/05/89 "
  982. X
  983. X#define PGMNAME "BBSCPORT "
  984. X
  985. Xchar portin()        /* get one byte from the port */
  986. X{
  987. X    char byte;
  988. X    int byte0;
  989. X    unsigned int ssec, tsec, usec, vsec;
  990. X    int this_timer, wsec;
  991. X    if(toggle_hold) (void) sys_toggle();
  992. X    hold_off = TRUE;
  993. X    this_timer = which_timer;
  994. X    which_timer = 3;
  995. X    ssec = alarm(0);
  996. X    tsec = waittime;
  997. X    if(tsec > ssec)
  998. X        {
  999. X        tsec = ssec;
  1000. X        which_timer = this_timer;
  1001. X        }
  1002. X    Zsec = ssec - tsec;
  1003. X    alarm(tsec);
  1004. X    byte0=cget();
  1005. X    byte = (char)byte0;
  1006. X    switch ( byte0 ) {
  1007. X    
  1008. X    case -1:
  1009. X        fprintf(stderr,"cget() returns -1 -- ABORTING");
  1010. X        exit(1);
  1011. X    default:
  1012. X        usec = alarm(0);
  1013. X        which_timer = this_timer;
  1014. X        wsec = ssec - (tsec - usec);
  1015. X        if(wsec < 2 ) wsec = 2;
  1016. X        vsec = wsec;
  1017. X        alarm( vsec );
  1018. X        hold_off = FALSE;
  1019. X        if(toggle_hold) (void)sys_toggle();
  1020. X        return(byte);
  1021. X    }
  1022. X}
  1023. X
  1024. Xchar portin_chat()        /* get one byte from the port */
  1025. X{
  1026. X    char byte;
  1027. X    int byte0;
  1028. X    byte0=cget_chat();
  1029. X    byte = (char)byte0;
  1030. X    switch ( byte0 ) {
  1031. X    
  1032. X    case -1:
  1033. X        fprintf(stderr,"cget() returns -1 -- ABORTING");
  1034. X        exit(1);
  1035. X    default:
  1036. X        return(byte);
  1037. X    }
  1038. X}
  1039. Xportsin(buf,max)    /* get a line of input max. chars long */
  1040. Xint max ; char *buf ;
  1041. X    {
  1042. X    int cnt, byte ; char bytex ;
  1043. X    cnt = 0;
  1044. X    byte = FALSE;
  1045. X    while (++cnt <= max && byte != '\r')
  1046. X        {
  1047. X        while((byte = (int)portin()) < ' ' || byte > '}')
  1048. X            {
  1049. X            if( byte == 127) byte = '\b';
  1050. X            if (byte == '\r') { break ; } /* carriage return */
  1051. X            if (byte == '\b' && cnt > 1)    /* backspace */
  1052. X                {
  1053. X                portout(byte);
  1054. X                portout(' ');
  1055. X                portout(byte);
  1056. X                *buf--;    /* backout last char */
  1057. X                cnt--;    /* decrement count too */
  1058. X                }
  1059. X            }
  1060. X        if (byte != '\r')
  1061. X            {
  1062. X            *buf++ = byte;
  1063. X            }
  1064. X        portout(byte);    /* echo good chars only */
  1065. X        }
  1066. X    *buf++    = '\0';            /* tag \0 on end */
  1067. X    }
  1068. Xportsinz(buf,max)    /* get a line of input max. chars long */
  1069. Xint max ; char *buf ;
  1070. X    {
  1071. X    int cnt, byte ; char bytex ;
  1072. X    cnt = 0;
  1073. X    byte = FALSE;
  1074. X    while (++cnt <= max && byte != '\r')
  1075. X        {
  1076. X        while((byte = (int)portin()) < ' ' || byte > '}')
  1077. X            {
  1078. X            if (byte == 127) byte = '\b';
  1079. X            if (byte == '\r') { break ; } /* carriage return */
  1080. X            if (byte == '\b' && cnt > 1)    /* backspace */
  1081. X                {
  1082. X                portout(byte);
  1083. X                portout(' ');
  1084. X                portout(byte);
  1085. X                *buf--;    /* backout last char */
  1086. X                cnt--;    /* decrement count too */
  1087. X                }
  1088. X            }
  1089. X        if (byte != '\r')
  1090. X            {
  1091. X            *buf++ = byte;
  1092. X            }
  1093. X        portout('_');    /* echo an underscore  */
  1094. X        }
  1095. X    *buf++    = '\0';            /* tag \0 on end */
  1096. X    }
  1097. Xportsinm(buf,max,buf1)    /* get a line of input max. chars long */
  1098. Xint max;
  1099. Xchar *buf, *buf1;
  1100. X    {
  1101. X    int cnt, byte ; char bytex ;
  1102. X    int  new_max;
  1103. X    cnt = 0;
  1104. X    new_max = max;
  1105. X    byte = FALSE;
  1106. X    while (++cnt <= new_max && byte != '\r')
  1107. X        {
  1108. X        while((byte = (int)portin()) < ' ' || byte > '}')
  1109. X            {
  1110. X            if (byte == 127) byte = '\b';
  1111. X            if (byte == '\r') { break ; } /* carriage return */
  1112. X            if (byte == '\b' && cnt > 1)    /* backspace */
  1113. X                {
  1114. X                portout(byte);
  1115. X                portout(' ');
  1116. X                portout(byte);
  1117. X                *buf--;    /* backout last char */
  1118. X                cnt--;    /* decrement count too */
  1119. X                }
  1120. X            if (byte == '\b' && cnt == 1 && in_the_buffer > 0)
  1121. X                {
  1122. X                portout(byte);
  1123. X                portout(' ');
  1124. X                portout(byte);
  1125. X                in_the_buffer--;
  1126. X                new_max++;
  1127. X                buf1[in_the_buffer] = '\0';
  1128. X                }
  1129. X
  1130. X            }
  1131. X        if (byte != '\r')
  1132. X            {
  1133. X            *buf++ = byte;
  1134. X            }
  1135. X        portout(byte);    /* echo good chars only */
  1136. X        }
  1137. X    *buf++    = '\0';            /* tag \0 on end */
  1138. X    }
  1139. X
  1140. X
  1141. Xportsin_cmp(buf,max,cmp_str)    /* get a line of input max. chars long */
  1142. Xint max ; char *buf , *cmp_str;
  1143. X    {
  1144. X    int cnt, byte ; char bytex ;
  1145. X    char *result;
  1146. X    cnt = 0;
  1147. X    byte = FALSE;
  1148. X    while (++cnt <= max && byte != '\r')
  1149. X        {
  1150. X        while((byte = (int)portin()) < ' ' || byte > '}')
  1151. X            {
  1152. X            if (byte == 127) byte = '\b';
  1153. X            if (byte == '\r') { break ; } /* carriage return */
  1154. X            if (byte == '\b' && cnt > 1)    /* backspace */
  1155. X                {
  1156. X                portout(byte);
  1157. X                portout(' ');
  1158. X                portout(byte);
  1159. X                *buf--;    /* backout last char */
  1160. X                cnt--;    /* decrement count too */
  1161. X                }
  1162. X            }
  1163. X        if (byte != '\r')
  1164. X            {
  1165. X            if(cnt == 1)
  1166. X                {
  1167. X                result = strchr(cmp_str,byte);
  1168. X                if(result != NULL)        
  1169. X                    {
  1170. X                    *buf++ = byte;
  1171. X                    portout(byte);
  1172. X                    *buf++ = '\0';
  1173. X                    return;
  1174. X                    }
  1175. X                }
  1176. X            *buf++ = byte;
  1177. X            }
  1178. X        portout(byte);    /* echo good chars only */
  1179. X        }
  1180. X    *buf++    = '\0';            /* tag \0 on end */
  1181. X    }
  1182. X
  1183. Xportout(byte)        /* send one byte to the port */
  1184. Xchar byte;        /* return CTL_K for those times want to check */
  1185. X    {        /* if the person wants to stop sending        */
  1186. X    char byte0 ;
  1187. X    byte0 = byte ; write(STDOUT,&byte0,1) ; /* send the byte */
  1188. X    if(if_monitor)
  1189. X        {
  1190. X        write(mon_handle,&byte0,1);
  1191. X        }
  1192. X    return(OK) ;
  1193. X    }
  1194. X  
  1195. Xportout_chat(byte)        /* send one byte to the port */
  1196. Xchar byte;        /* return CTL_K for those times want to check */
  1197. X    {        /* if the person wants to stop sending        */
  1198. X    char byte0 ;
  1199. X    byte0 = byte ; write(STDOUT,&byte0,1) ; /* send the byte */
  1200. X    if(if_monitor)
  1201. X        {
  1202. X        write(mon_handle,&byte0,1);
  1203. X        }
  1204. X    return(OK) ;
  1205. X    }
  1206. X  
  1207. Xportsout(string)    /* send a string to the port */
  1208. Xchar *string ;
  1209. X    {
  1210. X    char byte ;
  1211. X
  1212. X    while (byte = (*string++))
  1213. X        {
  1214. X          portout(byte) ;        /* send one byte at a time */
  1215. X        }
  1216. X    }
  1217. X
  1218. Xportsout_chat(string)    /* send a string to the port */
  1219. Xchar *string ;
  1220. X    {
  1221. X    char byte ;
  1222. X
  1223. X    while (byte = (*string++))
  1224. X        {
  1225. X          portout_chat(byte) ;        /* send one byte at a time */
  1226. X        }
  1227. X    }
  1228. Xportlsout(string,len)  /* send a string to the port, pad to length */
  1229. Xchar *string ; int len ;
  1230. X    {
  1231. X    char byte ;
  1232. X
  1233. X    while (byte = (*string++))
  1234. X        {
  1235. X          portout(byte) ;        /* send one byte at a time */
  1236. X        len-- ;
  1237. X        }
  1238. X    while (len > 0) { portout(' ') ; len-- ; } /* pad with spaces */
  1239. X    }
  1240. X
  1241. Xporttype(tbuf)        /* type a file to the port */
  1242. XFILE    *tbuf ;
  1243. X    {
  1244. X    int byte ;
  1245. X    int xp;
  1246. X    if(xpert)xp = 10; else xp = 5;
  1247. X    stop_that = FALSE;    /* reset switch */
  1248. X    if(!no_cntrl_k) portsout("\r\nType CTL-K to skip this\r\n\n");
  1249. X    lnctx=1;
  1250. X    byte = 0;
  1251. X    while (((byte = getc (tbuf)) != EOF) && (byte != CPMEOF))
  1252. X        {
  1253. X        if(byte == '\n')
  1254. X            {
  1255. X            portout('\r');
  1256. X            if(toggle)
  1257. X            {
  1258. X                lnctx++;
  1259. X                if ( lnctx == 23 )
  1260. X                    {
  1261. X                    portsout(CRLF);
  1262. X                    if(!no_cntrl_k)
  1263. X                        portsout("*** Depress a key to continue ( control-k to quit ) ........ ");
  1264. X                    else
  1265. X                        portsout("*** Depress a key to continue  ........ ");
  1266. X                    jnk[0] = portin();
  1267. X                    if (jnk[0] == CTL_K )
  1268. X                    {              
  1269. X                        stop_that = TRUE;
  1270. X                    }
  1271. X                    portsout(CRLF);
  1272. X                    lnctx=1;
  1273. X                    }
  1274. X            }
  1275. X            }
  1276. X        if ( isprint(byte) == 0  && isspace(byte) == 0 )
  1277. X        {
  1278. X            portsout(CRLF);
  1279. X            portsout(CRLF);
  1280. X            portsout(CRLF);
  1281. X            portsout("A non-printable character has been detected!");
  1282. X            portsout(CRLF);
  1283. X            portsout("This is probably NOT an ASCII file!");
  1284. X            portsout(CRLF);
  1285. X            portsout(CRLF);
  1286. X            portsout(CRLF);
  1287. X            stop_that = FALSE;
  1288. X            return;
  1289. X        }
  1290. X        portout(byte);
  1291. X        if (stop_that)         /* received ctl-K or K */
  1292. X            {
  1293. X            portsout(CRLF);
  1294. X            stop_that = FALSE;    /* reset switch */
  1295. X            return;            /* nuf's enough */
  1296. X            }
  1297. X        }
  1298. X    if(toggle && !no_cntrl_k && ( lnctx > xp ))
  1299. X        {
  1300. X        portsout(CRLF);
  1301. X        portsout("*** Depress a key to continue ........ ");
  1302. X        jnk[0] = portin();
  1303. X        portsout(CRLF);
  1304. X        }
  1305. X    }
  1306. X
  1307. Xportinit()
  1308. X    {
  1309. X        setraw();
  1310. X    }
  1311. X    /* set raw mode for this terminal 
  1312. X    struct sgttyb arg;
  1313. X    ioctl (STDIN, TIOCGETP, &arg);
  1314. X    arg.sg_flags |= RAW ;
  1315. X    arg.sg_flags &= ~ECHO;
  1316. X    ioctl (STDIN, TIOCSETP, &arg);
  1317. X    }
  1318. X*/
  1319. X
  1320. Xportrst()
  1321. X    {
  1322. X        restore();
  1323. X    }
  1324. X    /* set raw mode for this terminal 
  1325. X    struct sgttyb arg;
  1326. X    ioctl (STDIN, TIOCGETP, &arg);
  1327. X    arg.sg_flags &= ~RAW;
  1328. X    arg.sg_flags |= ECHO ;
  1329. X    ioctl (STDIN, TIOCSETP, &arg);
  1330. X    }
  1331. X*/
  1332. X
  1333. Xchar gobble()                /* gobble up any answer */
  1334. X    {
  1335. X    int cnt = 0 ;
  1336. X    while (cnt++ < 20) (void)portin() ;
  1337. X    }
  1338. Xrewritx()
  1339. X{
  1340. X    FILE *scope;
  1341. X    int fds, result;
  1342. X    if((scope=fopen(USERS,"r+"))==NULL)
  1343. X        {
  1344. X        portsout("\n\rError opening USERS file!\n\r");
  1345. X        exit(1);
  1346. X        }
  1347. X    fds = fileno(scope);
  1348. X    rewind(scope);
  1349. X    locking(fds, LK_LOCK, 0L);
  1350. X    result=fseek(scope, save_d_pos, 0);
  1351. X    rewrtuser(scope);
  1352. X    rewind(scope);
  1353. X    locking(fds, LK_UNLCK, 0L);
  1354. X    fclose(scope);
  1355. X}
  1356. END_OF_FILE
  1357.   if test 7862 -ne `wc -c <'bbscport.c'`; then
  1358.     echo shar: \"'bbscport.c'\" unpacked with wrong size!
  1359.   fi
  1360.   # end of 'bbscport.c'
  1361. fi
  1362. if test -f 'bulletin.mod' -a "${1}" != "-c" ; then 
  1363.   echo shar: Will not clobber existing file \"'bulletin.mod'\"
  1364. else
  1365.   echo shar: Extracting \"'bulletin.mod'\" \(9228 characters\)
  1366.   sed "s/^X//" >'bulletin.mod' <<'END_OF_FILE'
  1367. X
  1368. X
  1369. X
  1370. X                                   Version 7.00
  1371. X
  1372. X        The message base has been expanded to allow upto 99 lines per message
  1373. X        instead of the older maximum of 20. Multiple questionnaires are now
  1374. X        supported instead of only one.
  1375. X
  1376. X        Version 7.10 Improved file listings and other minor modifications.
  1377. X
  1378. X        Version 7.20 Fixed BUG in zmodem and ymodem-batch uploads.
  1379. X
  1380. X        Version 7.21 Unreleased version --- added USENET ACCESS
  1381. X
  1382. X        Version 7.22 Allow ^K to exit zip mail
  1383. X
  1384. X        Version 7.23 is exactly the same as 7.22 but has a compile option
  1385. X                     in bbsc1.c to define logname as getlogin for SYSV.
  1386. X
  1387. X        Version 7.24 Cleaned up main memu
  1388. X
  1389. X        Version 7.25 Added Batch read command in message section. Also, the
  1390. X                     code now notified the user when he/she was last on the
  1391. X                     system. 
  1392. X
  1393. X        Version 7.30 Fixed a NASTY bug in the message base which happened
  1394. X                     when messages got to be around 80 lines and more.
  1395. X
  1396. X        Version 7.31 Trapped SIGHUP and added MUCH MORE information into
  1397. X                     the callers log!!! Enhanced the questionnaire routine.
  1398. X
  1399. X
  1400. X        Version 7.40 Enhanced message system. Now, the user can block and
  1401. X                     center text.
  1402. X
  1403. X        Version 7.41 Made a new message section entry called "e(N)ter blocked
  1404. X                     message". Also, deleted the "not used" U(nix mail) entry.
  1405. X
  1406. X        Version 7.42 IMPROVED text blocking algorithm
  1407. X
  1408. X        Version 7.43 BUG FIX in blocking/rt justify algorithm. An if statement
  1409. X                     was previously " > 72" and should have been " >= 72"
  1410. X                     Files changed were bbsc12.h and bbsc2.c
  1411. X
  1412. X        Version 7.44 Now the code will list the contents of .zip files
  1413. X                     unzipunx.tar.Z is needed for this new option.
  1414. X
  1415. X        Version 7.45 Added Control-k reminders
  1416. X
  1417. X        Version 7.50 NEW SIG option..... Read MAKEsig for installation
  1418. X
  1419. X        Version 7.51 Modified msg checking code to include sigs.
  1420. X                     Added a new optional file called sigentry.bbs which
  1421. X                     is displayed to the user when he opts to log into a
  1422. X                     private sig and he is not registered.
  1423. X
  1424. X        Version 7.60 The menus are NOW variable according to the user's
  1425. X                     privilege level. If the user DOES NOT have the privilege
  1426. X                     to use the option, the option will NOT be displayed.
  1427. X
  1428. X        Version 7.70 New option in the files menu "Z(ip new list)". This
  1429. X                     new option allows you to scan all allowable directories
  1430. X                     for new files.
  1431. X
  1432. X        Version 7.80 The Zip new list) option is now Z(ip file menu). Now,
  1433. X                     you can ZIP for NEW, locate, raw and regual file list.
  1434. X
  1435. X        Version 7.81 Fixed "usenet" option so that if the user enters usenet
  1436. X                     more than once, the path will be correct. Added logging
  1437. X                     of chats into the callers file.
  1438. X
  1439. X         Version 7.82 Enhanced the questionnaire by adding two new commands:
  1440. X                      ^ and *. The '^' is nearly the same as the '!' except
  1441. X                      that the input MUST NOT be NULL ( strlen > 0 ). The
  1442. X                      '*' is nearly the same as the '$' except for the same
  1443. X                      reason.
  1444. X
  1445. X
  1446. X         Version 7.83 You can now DISALLOW bbs users from certain sio lines.
  1447. X                      A new file, inval_port.bbs, can contain a list of the
  1448. X                      sio lines which you do not wish bbs users to use. An
  1449. X                      example of this file is included in the distribution.
  1450. X                      A log of the disallowed called is stored in a file
  1451. X                      called restricted.bbs.
  1452. X
  1453. X         Version 7.84 Added Additional features option to each SIG; therefore,
  1454. X                      each SIG can have its own external programs and/or
  1455. X                      shell scripts which is independent of the main menu
  1456. X                      A(dditional) features option. The format of the 
  1457. X                      features.bbs file is exactly the same as the one for
  1458. X                      the main menu; however, this file is stored in the SIG
  1459. X                      directory ( same as where sigentry.bbs and sigwelcome.bbs
  1460. X                      are stored )
  1461. X
  1462. X        Version 7.85  When a message is sent to a user, the name is now 
  1463. X                      verified. In addition to name verification, the follow-
  1464. X                      two aliases are permitted: Sysop and ALL. If Sysop is
  1465. X                      used as the first name, the Sysop's real name will be
  1466. X                      substituted into the message; if All is used as the
  1467. X                      first name, All Users will be substituted.
  1468. X                      If the upload directory is nolonger in the same file-
  1469. X                      system as the upload path, a Unix style mv will be
  1470. X                      performed; however, the user will get a message telling
  1471. X                      him to notify the sysop that the upload path is not
  1472. X                      in the same filesystem as the bbs users' home directory.
  1473. X                      
  1474. X        Version 7.86  Improved time accounting ( more accurate and reliable )
  1475. X
  1476. X        Version 7.87  IMPORTANT --- Repaired possible security problem
  1477. X                      has been repaired. I won't make this known what it was
  1478. X                      yet until other sites upgrade to this version. 
  1479. X                      Added a V(ersion) option to the main menu.
  1480. X                      Made new file upload/download menu for wildcard transfer.
  1481. X
  1482. X        Version 7.88  Minor compatibilty mod for some *nixs
  1483. X
  1484. X    Version 7.89  Now, the readnews and postnews programs are variable
  1485. X                      determined within your configuration file. See my
  1486. X                      .config.bbs example if you are just editing an 
  1487. X                      existing file. Xbbsgen has been modified to add the
  1488. X                      new terms.
  1489. X
  1490. X        Version 7.90  Check to see if a file is printable ASCII before
  1491. X                      attempting to do an ASCII download or TYPE. Check to
  1492. X                      see if an asterisk was typed while using a file locate
  1493. X                      command. Bbscconf.c now no longer needs any external
  1494. X                      files to compile under SYSV.
  1495. X
  1496. X        Version 7.91  Allow multiple files to be downloaded from the d/l
  1497. X                      command line.
  1498. X
  1499. X        Version 7.92  Display the files that will be downloaded if a multiple
  1500. X                      request is made either by using an asterisk of by more
  1501. X                      than one request per comamnd line. Insure that the 
  1502. X                      cross-reference table does not get garbage stored in
  1503. X                      it.
  1504. X
  1505. X        Version 7.93  Minor modification to help with multiple file trasnfers.
  1506. X
  1507. X        Version 7.94  All users are notified when a user enters into
  1508. X                      conference. ( As per request )
  1509. X
  1510. X        Version 7.95  Added a new option in the main menu which displays the
  1511. X                      present users which are in conference.
  1512. X
  1513. X        Version 7.96  Fixed difftime() problem with SCO UNIX also modified
  1514. X                      multi-file transfer option line.
  1515. X
  1516. X        Version 7.97  Added more info about downloaded files in "callers"
  1517. X                      file. Fixed minor "bug" in file description when the
  1518. X                      user uses the full 5 lines. Changed the "State"
  1519. X                      request for new callers to State/Provence/Country.
  1520. X
  1521. X        Version 7.98  Allow blocked ( right justified ) for message replays and
  1522. X                      departure messages.
  1523. X
  1524. X        Version 7.99  Guarantee that names are ONLY alpha characters. This will
  1525. X                      filter out line noise. Cosmetic changes too.
  1526. X
  1527. X    Version 7.100 Fixed minor bug which would allow less than 4 character
  1528. X                      passwords when changed.
  1529. X
  1530. X        Version 7.101 Now will compile and run under SysV.4. This has been
  1531. X                      tested under Esix5.4.4.
  1532. X
  1533. X        Version 7.200  Nolonger needs an external arc or unzip program. Tested
  1534. X                       under Xenix2.3.2 and SVR4 release 4.
  1535. X
  1536. X
  1537. X                     ************** OPTIONAL FILE *************
  1538. X
  1539. X        An  optional file, locking.h, is now available to allow the XBBS  code
  1540. X        to  compile  on AT&T 3Bs or other truly SysV systems.  Remember,  this
  1541. X        file MUST NOT be used for Xenix systems.
  1542. X
  1543. X
  1544. X                              ************************
  1545. X                              AVAILABLE FILE PROTOCOLS
  1546. X
  1547. X        For  Uploading:  Ascii, Xmodem-checksum, Xmodem-crc, Ymodem, SEAlink*,
  1548. X        Zmodem, and Kermit.
  1549. X
  1550. X        For  Downloading:  Ascii, Xmodem-checksum, Xmodem-crc, Ymodem, Kermit,
  1551. X        SEAlink*, Zmodem, and type. CREDITS: SEAlink is a copyrighted protocol 
  1552. X        by System Enhancements Associates.
  1553. X
  1554. X        Note:   The  kermit that is used on this system NOW  supports  sliding
  1555. X        windows!   There are TWO different Ymodem protocols available, BATCH &
  1556. X        NON-BATCH.
  1557. X
  1558. X        What    is    MOST   important..................    E   N   J   O    Y
  1559. X        ........................  Sanford ( Sandy ) Zelkovitz
  1560. END_OF_FILE
  1561.   if test 9228 -ne `wc -c <'bulletin.mod'`; then
  1562.     echo shar: \"'bulletin.mod'\" unpacked with wrong size!
  1563.   fi
  1564.   # end of 'bulletin.mod'
  1565. fi
  1566. if test -f 'crc.c' -a "${1}" != "-c" ; then 
  1567.   echo shar: Will not clobber existing file \"'crc.c'\"
  1568. else
  1569.   echo shar: Extracting \"'crc.c'\" \(9683 characters\)
  1570.   sed "s/^X//" >'crc.c' <<'END_OF_FILE'
  1571. X/*
  1572. X * A version of Ward Christensen's file transfer protocol for
  1573. X * Unix System V or 4.2 bsd.
  1574. X *
  1575. X *        Emmet P. Gray, ..!ihnp4!uiucuxc!fthood!egray, 16 Aug 85
  1576. X *
  1577. X * Modified by Sanford Zelkovitz   08/18/86
  1578. X * Last modification date = 05/20/87
  1579. X */
  1580. X
  1581. X#define SV
  1582. X#undef  BSD
  1583. X
  1584. X#include <stdio.h>
  1585. X#include <signal.h>
  1586. X#include <sys/types.h>
  1587. X#include <sys/stat.h>
  1588. X#ifdef SV
  1589. X#include <termio.h>
  1590. X#endif
  1591. X#ifdef BSD
  1592. X#include <sgtty.h>
  1593. X#endif
  1594. X
  1595. X#define MAXERRORS 10            /* max number of times to retry */
  1596. X#define SECSIZE    128            /* CP/M sector, transmission block */
  1597. X#define CPMEOF    26            /* End Of File (for CP/M) */
  1598. X#define SOH    1            /* Start Of Header */
  1599. X#define EOT    4            /* End Of Transmission */
  1600. X#define ACK    6            /* ACKnowledge */
  1601. X#define NAK    21            /* Negative AcKnowledge */
  1602. X#define CAN    24            /* CANcel */
  1603. X
  1604. Xint synchron;
  1605. Xint exit_return;
  1606. Xunsigned char crc1, crc2;
  1607. X#ifdef SV
  1608. Xstruct termio ttyhold;
  1609. X#endif
  1610. X#ifdef BSD
  1611. Xstruct sgttyb ttyhold;
  1612. X#endif
  1613. X
  1614. Xmain(argc, argv)
  1615. Xint argc;
  1616. Xchar *argv[];
  1617. X{
  1618. X    int msgstat;
  1619. X    char *tty, *ttyname();
  1620. X    struct stat stbuf;
  1621. X    exit_return=0;
  1622. X    if (argc != 3) {
  1623. X        usage();
  1624. X        exit(1);
  1625. X    }
  1626. X    tty = ttyname(1);
  1627. X    stat(tty, &stbuf); 
  1628. X    msgstat = (stbuf.st_mode & 0777);
  1629. X    chmod(tty, 0600);            /* mesg n */
  1630. X#ifdef SV
  1631. X    ioctl(0, TCGETA, &ttyhold);        /* get current settings */
  1632. X#endif
  1633. X#ifdef BSD
  1634. X    ioctl(0, TIOCGETP, &ttyhold);
  1635. X#endif
  1636. X    switch (*argv[1]) {
  1637. X        case 'r':
  1638. X            recvfile(argv[2]);
  1639. X            break;
  1640. X        case 's':
  1641. X            sendfile(argv[2]);
  1642. X            break;
  1643. X        default:
  1644. X            usage();
  1645. X    }
  1646. X#ifdef SV
  1647. X    ioctl(0, TCSETAF, &ttyhold);        /* restore settings */
  1648. X#endif
  1649. X#ifdef BSD
  1650. X    ioctl(0, TIOCSETP, &ttyhold);
  1651. X#endif
  1652. X    chmod(tty, msgstat);            /* restore mesg status */
  1653. X    exit(exit_return);
  1654. X}
  1655. X
  1656. X/* send a file to the remote */
  1657. Xsendfile(tfile)
  1658. Xchar *tfile;
  1659. X{
  1660. X    FILE *fp;
  1661. X    unsigned char chr, checksum, block, sector[SECSIZE];
  1662. X    int i, mode, nbytes, errcount, size, speed;
  1663. X    long min, sec;
  1664. X    static int baud[15] = {0, 50, 75, 110, 134, 150, 200,
  1665. X    300, 600, 1200, 1800, 2400, 4800, 9600, 19200};
  1666. X    struct stat sbuf;
  1667. X
  1668. X    if (!(fp = fopen(tfile, "r"))) {
  1669. X        fprintf(stderr, "xmodem: Can't open '%s' for read\r\n", tfile);
  1670. X        exit_return=1;
  1671. X        return;
  1672. X    }
  1673. X    stat(tfile, &sbuf);
  1674. X    size = (sbuf.st_size / 128) + 1;
  1675. X#ifdef SV
  1676. X    speed = baud[ttyhold.c_cflag & 017];
  1677. X#endif
  1678. X#ifdef BSD
  1679. X    speed = baud[ttyhold.sg_ispeed];
  1680. X#endif
  1681. X    sec = size;
  1682. X    sec = sec * 128L * 11L / speed;
  1683. X    min = sec / 60L;
  1684. X    sec = sec - min * 60L;
  1685. X    printf("File open: %d records\r\n", size);
  1686. X    printf("Send time: %ld min, %ld sec at %d baud\r\n", min, sec, speed);
  1687. X    printf("To cancel: use CTRL-X numerous times\r\n");
  1688. X    printf("Waiting ready signal\r\n");
  1689. X
  1690. X    rawmode();
  1691. X    errcount = 0;
  1692. X    mode = 0;
  1693. X    block = 1;
  1694. X    while (errcount < MAXERRORS) {
  1695. X        chr = getchar_t();
  1696. X        if (chr == NAK)            /* checksum mode */
  1697. X            break;
  1698. X        if (chr == 'C') {        /* CRC mode */
  1699. X            mode = 1;
  1700. X            break;
  1701. X        }
  1702. X        errcount++;
  1703. X    }
  1704. X    if (errcount == MAXERRORS) {
  1705. X        sleep(3);
  1706. X        fprintf(stderr, "xmodem: Timed out on acknowledge\r\n");
  1707. X        exit_return=1;
  1708. X        return;
  1709. X    }
  1710. X    while (nbytes = fread(sector, sizeof(sector[0]), SECSIZE, fp)) {
  1711. X        if (nbytes < SECSIZE) {        /* fill short sector */
  1712. X            for (i=nbytes; i < SECSIZE; i++)
  1713. X                sector[i] = CPMEOF;
  1714. X        }
  1715. X        errcount = 0;
  1716. X        while (errcount < MAXERRORS) {
  1717. X            putchar(SOH);        /* the header */
  1718. X            putchar(block);        /* the block number */
  1719. X            chr = ~block;
  1720. X            putchar(chr);        /* it's complement */
  1721. X            checksum = 0;
  1722. X            crc1 = 0;
  1723. X            crc2 = 0;
  1724. X            for (i=0; i < SECSIZE; i++) {
  1725. X                putchar(sector[i]);
  1726. X                if (mode)
  1727. X                    update_crc(sector[i]);
  1728. X                else
  1729. X                    checksum += sector[i];
  1730. X            }
  1731. X            if (mode) {
  1732. X                update_crc(0);
  1733. X                update_crc(0);
  1734. X                putchar(crc1);
  1735. X                putchar(crc2);
  1736. X            }
  1737. X            else
  1738. X                putchar(checksum);
  1739. Xrec_loop:
  1740. X            chr = getchar_t();
  1741. X            if (chr == CAN) {
  1742. X                sleep(3);
  1743. X                fprintf(stderr,"\r\nxmodem: Abort request received\r\n");
  1744. X                exit_return=1;
  1745. X                return;
  1746. X            }
  1747. X            if (chr == ACK)
  1748. X                break;        /* got it! */
  1749. X            if (chr != NAK ) goto rec_loop;   /* noise on line? */
  1750. X            errcount++;
  1751. X        }
  1752. X        if (errcount == MAXERRORS) {
  1753. X            error();
  1754. X            exit_return=1;
  1755. X            return;
  1756. X        }
  1757. X        block++;
  1758. X    }
  1759. X    errcount = 0;
  1760. X    exit_return=1;
  1761. X    while (errcount < MAXERRORS) {
  1762. X        putchar(EOT);
  1763. X        if (getchar_t() == ACK)
  1764. X            {
  1765. X            exit_return=0;
  1766. X            break;
  1767. X            }
  1768. X        errcount++;
  1769. X    }
  1770. X    return;
  1771. X}
  1772. X
  1773. X/* receive a file from the remote */
  1774. Xrecvfile(tfile)
  1775. Xchar *tfile;
  1776. X{
  1777. X    FILE *fp;
  1778. X    unsigned char hdr, blk, cblk, tmp, cksum;
  1779. X    unsigned char c1, c2, sum, block, sector[SECSIZE];
  1780. X    int i, stop = 0, mode, errcount, resync();
  1781. X    long true_end;
  1782. X    char ans[40];
  1783. X
  1784. X    if (!access(tfile, 00)) {
  1785. X        while (1) {
  1786. X            printf("File already exists \r\n");
  1787. X                return;
  1788. X        }
  1789. X    }
  1790. X
  1791. X    if (!(fp = fopen(tfile, "w"))) {
  1792. X        fprintf(stderr, "xmodem: Can't open '%s' for write\r\n", tfile);
  1793. X        return;
  1794. X    }
  1795. X    printf("File open - ready to receive\r\n");
  1796. X    rawmode();
  1797. X    errcount = 0;
  1798. X    block = 1;
  1799. X    
  1800. X    sleep(10);
  1801. X    while (errcount < MAXERRORS) {
  1802. X        if (errcount < (MAXERRORS / 2)) {
  1803. X            putchar('C');        /* try CRC mode first */
  1804. X            mode = 1;
  1805. X        }
  1806. X        else {
  1807. X            putchar(NAK);        /* then checksum */
  1808. X            mode = 0;
  1809. X        }
  1810. X        if ((hdr = getchar_t()) == SOH) {
  1811. X            ungetc(SOH, stdin);
  1812. X            break;
  1813. X        }
  1814. X        errcount++;
  1815. X    }
  1816. X    if (errcount == MAXERRORS) {
  1817. X        sleep(3);
  1818. X        fprintf(stderr, "\r\nxmodem: Timed out on acknowledge\r\n");
  1819. X        return;
  1820. X    }
  1821. X    errcount = 0;
  1822. X
  1823. X    while (errcount < MAXERRORS) {
  1824. X        hdr = getchar_t();
  1825. X        if (hdr == CAN) {
  1826. X            sleep(3);
  1827. X            fprintf(stderr, "\r\nxmodem: Abort request received\r\n");
  1828. X            return;
  1829. X        }
  1830. X        if (hdr == EOT)            /* done! */
  1831. X            break;
  1832. X        if (hdr != SOH) {        /* read in junk for 6 seconds */
  1833. X            synchron = 0;        /*  to re-synchronized block */
  1834. X            signal(SIGALRM, resync);
  1835. X            alarm(6);
  1836. X            while(synchron == 0)
  1837. X                hdr = getchar();
  1838. X            goto nak;
  1839. X        }
  1840. X        blk = getchar_t();
  1841. X        cblk = getchar_t();
  1842. X        crc1 = 0;
  1843. X        crc2 = 0;
  1844. X        sum = 0;
  1845. X        for (i=0; i < SECSIZE; i++) {
  1846. X            sector[i] = getchar_t();
  1847. X            if (mode)
  1848. X                update_crc(sector[i]);
  1849. X            else
  1850. X                sum += sector[i];
  1851. X        }
  1852. X        if (mode) {
  1853. X            c1 = getchar_t();
  1854. X            c2 = getchar_t();
  1855. X        }
  1856. X        else
  1857. X            cksum = getchar_t();
  1858. X        if (blk != block && blk != (block - 1))
  1859. X            goto nak;
  1860. X        tmp = ~blk;
  1861. X        if (cblk != tmp)
  1862. X            goto nak;
  1863. X        if (mode) {
  1864. X            update_crc(0);
  1865. X            update_crc(0);
  1866. X            if (c1 != crc1 || c2 != crc2)
  1867. X                goto nak;
  1868. X        }
  1869. X        else {
  1870. X            if (cksum != sum)
  1871. X                goto nak;
  1872. X        }
  1873. X        if (block == blk) {
  1874. X            fflush(fp);
  1875. X            fwrite(sector, sizeof(sector[0]), SECSIZE, fp);
  1876. X        }
  1877. X        block = blk + 1;
  1878. X        putchar(ACK);            /* got it! */
  1879. X        errcount = 0;
  1880. X        continue;
  1881. X
  1882. X    nak:    putchar(NAK);            /* do it over */
  1883. X        errcount++;
  1884. X    }
  1885. X    if (errcount == MAXERRORS) {
  1886. X        error();
  1887. X        return;
  1888. X    }
  1889. X    putchar(ACK);
  1890. X    for (i = SECSIZE -1; i >= 0; i--) {    /* find true EOF */
  1891. X        if (sector[i] != CPMEOF) {
  1892. X            stop = i;
  1893. X            break;
  1894. X        }
  1895. X    }
  1896. X/*
  1897. X * Some CPM systems don't pad the end of the file with ^Z's so the file may
  1898. X * have junk at the end.  A conservative approach had to be taken in order
  1899. X * for Unix object code (where ^Z's may be valid data) to transfer properly.
  1900. X */
  1901. X    true_end = ftell(fp) - SECSIZE + stop +1;
  1902. X    fclose(fp);
  1903. X    truncate(tfile, true_end);
  1904. X    return;
  1905. X}
  1906. X
  1907. X/* give minimal usage message */
  1908. Xusage()
  1909. X{
  1910. X    fprintf(stderr, "Usage: xmodem [ s | r ] filename\r\n");
  1911. X    fprintf(stderr, "       options are 's' for send or 'r' for receive\r\n");
  1912. X    return;
  1913. X}
  1914. X
  1915. X/* exceeded the maximum number of retry's */
  1916. Xerror()
  1917. X{
  1918. X    putchar(CAN);
  1919. X    putchar(CAN);
  1920. X    putchar(CAN);
  1921. X    putchar(CAN);
  1922. X    sleep(3);
  1923. X    fprintf(stderr, "\r\nxmodem: Exceeded error limit...aborting\r\n");
  1924. X    return;
  1925. X}
  1926. X
  1927. X/* update the CRC bytes */
  1928. Xupdate_crc(c)
  1929. Xunsigned char c;
  1930. X{
  1931. X    int i, temp;
  1932. X    unsigned char carry, c_crc1, c_crc2;
  1933. X    for (i=0; i < 8; i++) {
  1934. X        temp = c * 2;
  1935. X        c = temp;            /* rotate left */
  1936. X        carry = ((temp > 255) ? 1 : 0);
  1937. X        temp = crc2 * 2;
  1938. X        crc2 = temp;
  1939. X        crc2 |= carry;            /* rotate with carry */
  1940. X        c_crc2 = ((temp > 255) ? 1 : 0);
  1941. X        temp = crc1 * 2;
  1942. X        crc1 = temp;
  1943. X        crc1 |= c_crc2;
  1944. X        c_crc1 = ((temp > 255) ? 1 : 0);
  1945. X        if (c_crc1) {
  1946. X            crc2 ^= 0x21;
  1947. X            crc1 ^= 0x10;
  1948. X        }
  1949. X    }
  1950. X    return;
  1951. X}
  1952. X
  1953. X/* getchar with a 10 sec time out */
  1954. Xgetchar_t()
  1955. X{
  1956. X    int force_it();
  1957. X    unsigned char c;
  1958. X    signal(SIGALRM, force_it);
  1959. X    alarm(10);                /* only have 10 sec... */
  1960. X    c = getchar();
  1961. X    alarm(0);
  1962. X    return(c);
  1963. X}
  1964. X
  1965. X/*
  1966. X * This code (and the resync() below) is the most machine dependent part
  1967. X * of the program.  The action of the signal SIGALRM during a read system
  1968. X * call is not well defined.  Some systems return the stack to the point
  1969. X * outside the system call, others inside the call itself.  Have fun...
  1970. X */
  1971. Xforce_it()
  1972. X{
  1973. X    unsigned char c;
  1974. X    c = CPMEOF;                /* arbitrary default char */
  1975. X#ifdef SV
  1976. X    ungetc(c, stdin);
  1977. X#endif
  1978. X#ifdef BSD
  1979. X    ioctl(0, TIOCSTI, &c);
  1980. X#endif
  1981. X    return;
  1982. X}
  1983. X
  1984. X/* truncate file to given length */
  1985. Xtruncate(path, length)
  1986. Xchar *path;
  1987. Xlong length;
  1988. X{
  1989. X    FILE *fp, *tempfp;
  1990. X    long i;
  1991. X    char c, string[80], *tempfile, *mktemp();
  1992. X    if (!(fp = fopen(path, "r"))) {
  1993. X        fprintf(stderr, "xmodem: Can't open '%s' for read\r\n", path);
  1994. X        return;
  1995. X    }
  1996. X    tempfile = mktemp("/tmp/trunXXXXXX");
  1997. X    if (!(tempfp = fopen(tempfile, "w"))) {
  1998. X        fprintf(stderr, "xmodem: Can't open temporary file\r\n");
  1999. X        return;
  2000. X    }
  2001. X    for (i=0; i < length; i++) {
  2002. X        c = fgetc(fp);
  2003. X        fputc(c, tempfp);
  2004. X    }
  2005. X    fclose(fp);
  2006. X    fclose(tempfp);
  2007. X    sprintf(string, "mv %s %s", tempfile, path);
  2008. X    system(string);
  2009. X    return;
  2010. X}
  2011. X
  2012. X/* put the stdin/stdout in the "raw" mode */
  2013. Xrawmode()
  2014. X{
  2015. X#ifdef SV
  2016. X    struct termio tbuf;
  2017. X    ioctl(0, TCGETA, &tbuf);
  2018. X    tbuf.c_cc[4] = 1;            /* VMIN */
  2019. X    tbuf.c_cc[5] = 0;            /* VTIME */
  2020. X    tbuf.c_iflag = 0;
  2021. X    tbuf.c_oflag = 0;
  2022. X    tbuf.c_lflag = 0;
  2023. X    tbuf.c_cflag &= ~CSIZE;
  2024. X    tbuf.c_cflag |= CS8;
  2025. X    tbuf.c_cflag &= ~PARENB;
  2026. X    ioctl(0, TCSETAF, &tbuf);
  2027. X    return;
  2028. X#endif
  2029. X#ifdef BSD
  2030. X    struct sgttyb sgbuf;
  2031. X    ioctl(0, TIOCGETP, &sgbuf);
  2032. X    sgbuf.sg_flags |= RAW;
  2033. X    sgbuf.sg_flags &= ~ECHO;
  2034. X    ioctl(0, TIOCSETP, &sgbuf);
  2035. X    return;
  2036. X#endif
  2037. X}
  2038. X
  2039. X/*  after 6 seconds of reading junk data... */
  2040. Xresync()
  2041. X{
  2042. X    char c;
  2043. X    synchron = 1;                /* set the flag */
  2044. X    c = SOH;
  2045. X#ifdef SV
  2046. X    ungetc(c, stdin);
  2047. X#endif
  2048. X#ifdef BSD
  2049. X    ioctl(0, TIOCSTI, &c);
  2050. X#endif
  2051. X    return;
  2052. X}
  2053. END_OF_FILE
  2054.   if test 9683 -ne `wc -c <'crc.c'`; then
  2055.     echo shar: \"'crc.c'\" unpacked with wrong size!
  2056.   fi
  2057.   # end of 'crc.c'
  2058. fi
  2059. if test -f 'msgpack/packfile.c' -a "${1}" != "-c" ; then 
  2060.   echo shar: Will not clobber existing file \"'msgpack/packfile.c'\"
  2061. else
  2062.   echo shar: Extracting \"'msgpack/packfile.c'\" \(9557 characters\)
  2063.   sed "s/^X//" >'msgpack/packfile.c' <<'END_OF_FILE'
  2064. X/*
  2065. X * bbscfile.c 
  2066. X *
  2067. X */
  2068. X
  2069. X/* #define DEBUG 1 */
  2070. X
  2071. X#include "packdef.h"
  2072. X#include <string.h>
  2073. Xchar            bufs[99];
  2074. X
  2075. X
  2076. Xhdrwrt()
  2077. X{                /* write the header from memory variables *//* h
  2078. X                 * eader is a 1 record file */
  2079. X    int             fd;
  2080. X    int             fd1;
  2081. X    char            buf128[MSGSECT];
  2082. X
  2083. X    strcpy(bufs, m_pathname);
  2084. X    strcat(bufs, NEWHEADER);
  2085. X    if ((fd = open(bufs, WRITE, 0666)) < 0) {    /* open i/o */
  2086. X        printf("Can't open header-file, will create it!");
  2087. X        printf(CRLF);
  2088. X        if ((fd = creat(bufs, 0666)) < 0) {
  2089. X            printf("Can't create header-file, aborting!");
  2090. X            printf(CRLF);
  2091. X            return (ERROR);
  2092. X        }
  2093. X    }
  2094. X    strcpy(bufs, m_pathname);
  2095. X    strcat(bufs, NEWXREF);
  2096. X    if ((fd1 = open(bufs, WRITE, 0666)) < 0) {
  2097. X        printf("Can't open xref file, will create it!");
  2098. X        printf(CRLF);
  2099. X        if ((fd1 = creat(bufs, 0666)) < 0) {
  2100. X            printf(" XREF creation error! -- abort!");
  2101. X            printf(CRLF);
  2102. X            return (ERROR);
  2103. X        }
  2104. X    }
  2105. X    itoa(h_next_msg, h_next);    /* convert int to char */
  2106. X    itoa(h_act_msg, h_act);
  2107. X    strfill(buf128, 26, MSGSECT);    /* init buf128 to all hex 1a */
  2108. X    sprintf(buf128, "%s~%s~%s~",    /* build record */
  2109. X        h_next_msg,
  2110. X        h_act_msg,
  2111. X        h_date);
  2112. X    write(fd, buf128, MSGSECT);    /* write it */
  2113. X    close(fd);        /* no need to leave it open */
  2114. X    write(fd1, ytable, 4000);
  2115. X    close(fd1);
  2116. X    return (OK);
  2117. X}
  2118. X
  2119. Xhdrreadr()
  2120. X{                /* read the header file into memory */
  2121. X    int             fd, i, cnt1, cnt;
  2122. X    char            buf128[MSGSECT];
  2123. X    strcpy(bufs, m_pathname);
  2124. X    strcat(bufs, HEADER);
  2125. X    if ((fd = open(bufs, READ, 0666)) < 0) {
  2126. X        printf("Can't open header-file, using inital values!");
  2127. X        printf(CRLF);
  2128. X        h_next = 1;
  2129. X        h_next_msg[0] = '1';
  2130. X        h_next_msg[1] = 0;
  2131. X        h_act = 1;
  2132. X        h_act_msg[0] = '1';
  2133. X        h_act_msg[1] = 0;
  2134. X        h_date[0] = '0';
  2135. X        h_date[1] = 0;
  2136. X        goto next;
  2137. X    }
  2138. X    if ((cnt = read(fd, buf128, MSGSECT)) != MSGSECT) {
  2139. X        printf(CRLF);
  2140. X        printf("<<< header read error >>>");
  2141. X        printf(CRLF);
  2142. X        return (ERROR);
  2143. X    }
  2144. X    cnt = sscanf(buf128, "%[^~]~%[^~]~%[^~]~",
  2145. X             h_next_msg,
  2146. X             h_act_msg,
  2147. X             h_date);
  2148. Xnext:
  2149. X    close(fd);
  2150. X    strcpy(bufs, m_pathname);
  2151. X    strcat(bufs, CROSSREF);
  2152. X    if ((fd = open(bufs, READ, 0666)) < 0) {
  2153. X        printf("Can't open xref file --- setting values!");
  2154. X        printf(CRLF);
  2155. X        xtable[0] = 1L;
  2156. X        for (i = 1; i <= 999; i++)
  2157. X            xtable[i] = 0L;
  2158. X        return;
  2159. X    }
  2160. X    if ((cnt1 = read(fd, xtable, 4000)) != 4000) {
  2161. X        printf(CRLF);
  2162. X        printf("<<< xref read error >>>");
  2163. X        printf(CRLF);
  2164. X        return (ERROR);
  2165. X    }
  2166. X    close(fd);
  2167. X    /* 
  2168. X     * if (cnt != 2) { return(ERROR) ; } */
  2169. X    h_next = atoi(h_next_msg);
  2170. X    h_act = atoi(h_act_msg);
  2171. X    return (OK);
  2172. X}
  2173. X
  2174. Xhdrreadw()
  2175. X{                /* read the header file into memory */
  2176. X    int             fd, i, cnt1, cnt;
  2177. X    char            buf128[MSGSECT];
  2178. X
  2179. X    strcpy(bufs, m_pathname);
  2180. X    strcat(bufs, NEWHEADER);
  2181. X    if ((fd = open(bufs, READ, 0666)) < 0) {    /* open input */
  2182. X        printf("Can't open header-file, using inital values!");
  2183. X        printf(CRLF);
  2184. X        h_next = 1;
  2185. X        h_next_msg[0] = '1';
  2186. X        h_next_msg[1] = 0;
  2187. X        h_act = 1;
  2188. X        h_act_msg[0] = '1';
  2189. X        h_act_msg[1] = 0;
  2190. X        h_date[0] = '0';
  2191. X        h_date[1] = 0;
  2192. X        hdrwrt();
  2193. X        goto next;
  2194. X    }
  2195. X    if ((cnt = read(fd, buf128, MSGSECT)) != MSGSECT) {
  2196. X        printf(CRLF);
  2197. X        printf("<<< header read error >>>");
  2198. X        printf(CRLF);
  2199. X        return (ERROR);
  2200. X    }
  2201. X    cnt = sscanf(buf128, "%[^~]~%[^~]~%[^~]~",
  2202. X             h_next_msg,
  2203. X             h_act_msg,
  2204. X             h_date);
  2205. Xnext:
  2206. X    close(fd);        /* no need to leave it open */
  2207. X    strcpy(bufs, m_pathname);
  2208. X    strcat(bufs, NEWXREF);
  2209. X    if ((fd = open(bufs, READ, 0666)) < 0) {
  2210. X        printf("Can't open xref file --- setting values!");
  2211. X        printf(CRLF);
  2212. X        ytable[0] = 1L;
  2213. X        for (i = 1; i <= 999; i++)
  2214. X            ytable[i] = 0L;
  2215. X        return;
  2216. X    }
  2217. X    if ((cnt1 = read(fd, ytable, 4000)) != 4000) {
  2218. X        printf(CRLF);
  2219. X        printf("<<< xref read error >>>");
  2220. X        printf(CRLF);
  2221. X        return (ERROR);
  2222. X    }
  2223. X    close(fd);
  2224. X    /* 
  2225. X     * if (cnt != 2) { return(ERROR) ; } */
  2226. X    h_next = atoi(h_next_msg);
  2227. X    h_act = atoi(h_act_msg);
  2228. X    return (OK);
  2229. X}
  2230. X
  2231. Xmsgopenr(how)
  2232. X    int             how;    /* how to open 0=input, 1=output, 2=i/o */
  2233. X{
  2234. X    int             fd;
  2235. X
  2236. X    strcpy(bufs, m_pathname);
  2237. X    strcat(bufs, MESSAGES);
  2238. X    if ((fd = open(bufs, how, 0666)) < 0) {    /* open i/o */
  2239. X        printf("can't open message-file, will create it!");
  2240. X        printf(CRLF);
  2241. X        if ((fd = creat(bufs, 0666)) < 0) {
  2242. X            printf("can't create message-file, aborting!");
  2243. X            printf(CRLF);
  2244. X            return (ERROR);
  2245. X        }
  2246. X    }
  2247. X    return (fd);
  2248. X}
  2249. X
  2250. Xmsgopenw(how)
  2251. X    int             how;    /* how to open 0=input, 1=output, 2=i/o */
  2252. X{
  2253. X    int             fd;
  2254. X    strcpy(bufs, m_pathname);
  2255. X    strcat(bufs, NEWMSG);
  2256. X
  2257. X    if ((fd = open(bufs, how, 0666)) < 0) {    /* open i/o */
  2258. X        printf("can't open message-file, will create it!");
  2259. X        printf(CRLF);
  2260. X        if ((fd = creat(bufs, 0666)) < 0) {
  2261. X            printf("can't create message-file, aborting!");
  2262. X            printf(CRLF);
  2263. X            return (ERROR);
  2264. X        }
  2265. X    }
  2266. X    return (fd);
  2267. X}
  2268. X
  2269. Xmsgclose(fd)
  2270. X    int             fd;
  2271. X{
  2272. X    return (close(fd));
  2273. X}
  2274. X
  2275. Xmsgwrt(fd)            /* write the message file from memory
  2276. X                 * variables */
  2277. X    int             fd;    /* writes a message starting with the h_next
  2278. X                 * msg # */
  2279. X{
  2280. X    int             rc,    /* return code */
  2281. X                    cnt1, cnt2, len;
  2282. X    char            bufmsg0[MSG1MAX + 1], buf128[MSGSECT + 1], this1[10], next1[10];
  2283. X
  2284. X    rc = cnt1 = len = cnt2 = 0;
  2285. X    itoa(this1, h_next);    /* convert int to char */
  2286. X    ytable[h_act - 1] = h_next;
  2287. X    h_act++;
  2288. X    rc = seek(fd, h_next - 1, 0);    /* seek next available sector */
  2289. X    h_next++;
  2290. X    itoa(next1, h_next);
  2291. X    strfill(buf128, 0, MSGSECT);    /* init buf128 to all hex 00 */
  2292. X    /*
  2293. X     * build first piece of msg record 
  2294. X     */
  2295. X    sprintf(buf128, "%-10s~%-10s~%-2s~%-9s~%-15s~%-21s~%-21s~%-11s~%-21s~",
  2296. X        this1,        /* this rcd # */
  2297. X        next1,        /* points next rcd # */
  2298. X        msg_delete,    /* delete byte */
  2299. X        msg_date,
  2300. X        msg_time,
  2301. X        msg_to,
  2302. X        msg_from,
  2303. X        msg_pass,
  2304. X        msg_subject);
  2305. X    rc = write(fd, buf128, MSGSECT);    /* write the first 128 byte
  2306. X                         * record */
  2307. X    /* for a message record */
  2308. X    /*
  2309. X     * build the n+1 piece of msg record 
  2310. X     */
  2311. X
  2312. X    len = (strlen(msg_text) / MSG1MAX) + 1;    /* calc how many more 128 */
  2313. X    /* byte records to write */
  2314. X    cnt2 = 1;        /* init for substr */
  2315. X    while (len--) {
  2316. X        itoa(this1, h_next);    /* calc/convert record #'s */
  2317. X        h_next++;
  2318. X        if (len == 0) {
  2319. X            strcpy(next1, "0");    /* marks last 128 byte piece */
  2320. X        }
  2321. X         /* of a msg */ 
  2322. X        else {
  2323. X            itoa(next1, h_next);
  2324. X        }
  2325. X        strfill(bufmsg0, 0, MSG1MAX);
  2326. X        substr(msg_text, bufmsg0, cnt2, MSG1MAX);    /* mv MSG1MAX to buff */
  2327. X        cnt2 += MSG1MAX;/* up cnt2 by MSG1MAX */
  2328. X        strfill(buf128, 0, MSGSECT);    /* init buf128 to all hex 00 */
  2329. X        sprintf(buf128, "%-10s~%-10s~%-2s~%-102s~",
  2330. X            this1,    /* this rcd # */
  2331. X            next1,    /* point to next rcd # */
  2332. X            msg_delete,    /* delete byte */
  2333. X            bufmsg0);    /* piece of msg */
  2334. X        rc = write(fd, buf128, MSGSECT);    /* write n+1 128 byte
  2335. X                             * record */
  2336. X    }
  2337. X
  2338. X    strfill(buf128, 26, MSGSECT);    /* fill with all hex 1a */
  2339. X    rc = write(fd, buf128, MSGSECT);    /* write all hex 1a 128 byte
  2340. X                         * record */
  2341. X    return (OK);
  2342. X}
  2343. X
  2344. X
  2345. Xmsgread(fd, msgno)        /* read message number requested */
  2346. X    int             fd,    /* returns ERROR if msg past eof */
  2347. X                    msgno;    /* returns 0 if msg is not 1st piece */
  2348. X/* of a message */
  2349. X/* returns 0 if msg is deleted */
  2350. X/* returns msg # if successful */
  2351. X{
  2352. X    int             rc,    /* return code */
  2353. X                    msgac, cnt1, cnt2, len, next, ret_this, file_size;
  2354. X    char            bufmsg0[MSG1MAX + 1], buf128[MSGSECT + 256], buftmp[MSGSECT + 256], this1[10], act[10], next1[10];
  2355. X
  2356. X    msgac = xtable[msgno - 1];
  2357. X    if (msgac > h_next) {    /* don't try to seek past end of file */
  2358. X        return (ERROR);
  2359. X    }
  2360. X    if (msgac == 0) {
  2361. X        return (ERROR);
  2362. X    }
  2363. X    if ((rc = seek(fd, msgac - 1, 0)) == ERROR) {
  2364. X        printf(CRLF);
  2365. X        printf("Can't seek on message-file!");
  2366. X        printf(CRLF);
  2367. X        return (ERROR);    /* when cant find it */
  2368. X    }
  2369. X    if (read(fd, buf128, MSGSECT) != MSGSECT) {    /* read 128 byte sector */
  2370. X        printf(CRLF);
  2371. X        printf("Can't read in message-file!");
  2372. X        printf(CRLF);
  2373. X        return (ERROR);
  2374. X    }
  2375. X    /*
  2376. X     * get first piece of msg record 
  2377. X     */
  2378. X    /* do trial read, since if not first record, fields might overflow */
  2379. X    rc = sscanf(buf128, "%[^~]~%[^~]~%[^~]~%[^~]~%[^~]~%[^~]~%[^~]~%[^~]~%[^~]~",
  2380. X            buftmp, buftmp, buftmp, buftmp, buftmp, buftmp, buftmp, buftmp, buftmp);
  2381. X    if (rc != 9) {        /* makes sure we read the 1st piece *//* of a
  2382. X                 * message and not in the middle */
  2383. X        return (0);    /* 0 when is not the msg header */
  2384. X    }
  2385. X    /* now do the real read since looks like is a good record */
  2386. X    rc = sscanf(buf128, "%[^~]~%[^~]~%[^~]~%[^~]~%[^~]~%[^~]~%[^~]~%[^~]~%[^~]~",
  2387. X            this1,    /* this rcd # */
  2388. X            next1,    /* points to next rcd # */
  2389. X            msg_delete,    /* delete byte */
  2390. X            msg_date,
  2391. X            msg_time,
  2392. X            msg_to,
  2393. X            msg_from,
  2394. X            msg_pass,
  2395. X            msg_subject);
  2396. X    if (rc != 9) {        /* makes sure we read the 1st piece *//* of a
  2397. X                 * message and not in the middle */
  2398. X        return (0);    /* 0 when is not the msg header */
  2399. X    }
  2400. X    if (msg_delete[0] == '9') {    /* check for deleted messages *//* if
  2401. X                     * so, return as if not found */
  2402. X        return (0);
  2403. X    }
  2404. X    ret_this = atoi(this1);    /* return this msg no. */
  2405. X    next = atoi(next1);
  2406. X    itoa(act, msgno);
  2407. X    strcpy(msg_no, act);
  2408. X    msg_text[0] = '\0';
  2409. X    while (next) {        /* read until no more pieces for *//* this
  2410. X                 * message */
  2411. X        if (read(fd, buf128, MSGSECT) != MSGSECT) {    /* read next sector */
  2412. X            printf(CRLF);
  2413. X            printf("Can't read in message-file(2)!");
  2414. X            printf(CRLF);
  2415. X            return (ERROR);
  2416. X        }
  2417. X        strfill(bufmsg0, 0, MSG1MAX);    /* init bufmsg0 to all hex 00 */
  2418. X        rc = sscanf(buf128, "%[^~]~%[^~]~%[^~]~%[^~]~",
  2419. X                this1,    /* this rcd # */
  2420. X                next1,    /* point to next rcd # */
  2421. X                msg_delete,    /* delete byte */
  2422. X                bufmsg0);    /* piece of msg */
  2423. X        next = atoi(next1);
  2424. X        strcat(msg_text, bufmsg0);    /* tag piece of msg to */
  2425. X        /* whole msg array */
  2426. X    }
  2427. X    return (ret_this);    /* if all ok, return the msg no. found */
  2428. X}
  2429. X
  2430. X/* end of program       */
  2431. END_OF_FILE
  2432.   if test 9557 -ne `wc -c <'msgpack/packfile.c'`; then
  2433.     echo shar: \"'msgpack/packfile.c'\" unpacked with wrong size!
  2434.   fi
  2435.   # end of 'msgpack/packfile.c'
  2436. fi
  2437. echo shar: End of archive 7 \(of 11\).
  2438. cp /dev/null ark7isdone
  2439. MISSING=""
  2440. for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
  2441.     if test ! -f ark${I}isdone ; then
  2442.     MISSING="${MISSING} ${I}"
  2443.     fi
  2444. done
  2445. if test "${MISSING}" = "" ; then
  2446.     echo You have unpacked all 11 archives.
  2447.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2448. else
  2449.     echo You still must unpack the following archives:
  2450.     echo "        " ${MISSING}
  2451. fi
  2452. exit 0
  2453. exit 0 # Just in case...
  2454.