home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume32 / xbbs / part07 < prev    next >
Encoding:
Text File  |  1992-09-08  |  63.2 KB  |  2,451 lines

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