home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume31 / mbox / part04 < prev    next >
Text File  |  1992-07-10  |  62KB  |  2,569 lines

  1. Newsgroups: comp.sources.misc
  2. From: Volker.Schuermann@unnet.w.open.de@unnet (Volker Schuermann)
  3. Subject:  v31i020:  mbox - A BBS for UNIX and MINIX v1.6 PL10, Part04/11
  4. Message-ID: <1992Jul10.050249.27414@sparky.imd.sterling.com>
  5. X-Md4-Signature: d40318db5e08fb50ed95fbe4751a54c7
  6. Date: Fri, 10 Jul 1992 05:02:49 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: Volker.Schuermann@unnet.w.open.de@unnet (Volker Schuermann)
  10. Posting-number: Volume 31, Issue 20
  11. Archive-name: mbox/part04
  12. Environment: MINIX, ISC, ESIX, SVR3
  13. Supersedes: mbox: Volume 29, Issue 63-72
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then feed it
  17. # into a shell via "sh file" or similar.  To overwrite existing files,
  18. # type "sh file -c".
  19. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  20. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  21. # Contents:  src/mb-daemon.c src/show.c src/tools.c
  22. # Wrapped by kent@sparky on Thu Jul  9 23:26:00 1992
  23. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  24. echo If this archive is complete, you will see the following message:
  25. echo '          "shar: End of archive 4 (of 11)."'
  26. if test -f 'src/mb-daemon.c' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'src/mb-daemon.c'\"
  28. else
  29.   echo shar: Extracting \"'src/mb-daemon.c'\" \(22450 characters\)
  30.   sed "s/^X//" >'src/mb-daemon.c' <<'END_OF_FILE'
  31. X/***************************************************************************/
  32. X/*        PROGRAMM  ix/Mbox                           */
  33. X/*             DATEI  mb-daemon.c                       */
  34. X/*        FUNKTIONEN  reflector(), scan(), mix(), main()           */
  35. X/*             AUTOR  vs (Volker Schuermann/MINIX-Version)           */
  36. X/*  LETZTE AENDERUNG  31.05.1992                       */
  37. X/***************************************************************************/
  38. X
  39. X#ifndef _ESTDIO
  40. X#include <stdio.h>
  41. X#else
  42. X#include <estdio.h>
  43. X#endif
  44. X#include <sys/types.h>
  45. X#include <sys/stat.h>
  46. X#include <time.h>
  47. X#include <dirent.h>
  48. X
  49. X#include "mbox.h"
  50. X
  51. X
  52. Xint FASTMODE;
  53. X
  54. X
  55. Xint mb_gruppen;
  56. Xint mb_new;
  57. Xlong mb_bytes;
  58. Xlong mb_new_bytes;
  59. Xlong mb_artikel;
  60. X
  61. X#ifdef ADDRMODE
  62. XFILE *ad;
  63. X#endif
  64. X
  65. X/***************************************************************************/
  66. X/*      FUNKTION  reflector()                           */
  67. X/*  BESCHREIBUNG  Sendet eine persoenliche Mail an den Autor eines Arti-   */
  68. X/*          kels in einer bestimmten NG.                               */
  69. X/*                                                               */
  70. X/*          VORSICHT: Wilde Reflectoren werden vom Netz getrennt !!! */
  71. X/*     PARAMETER  arg  =  DUMMY (?)                                        */
  72. X/*          msg  =  Artikel                                          */
  73. X/*     RUECKGABE  -1   =  Artikel nicht gefunden                           */
  74. X/*                0    =  Ok                            */
  75. X/***************************************************************************/
  76. X
  77. Xint FLAG;
  78. X
  79. Xint reflector(arg, msg)
  80. Xchar arg[];
  81. Xchar msg[];
  82. X{
  83. X  FILE *fp;
  84. X  FILE *ff;
  85. X
  86. X  char s[255];
  87. X  char tmp[STRING];
  88. X
  89. X  char receiver[STRING];
  90. X
  91. X  char path[255];
  92. X  char reply_to[255];
  93. X  char from[255];
  94. X  char sender[255];
  95. X  char subject[255];
  96. X  char summary[255];
  97. X  char keywords[255];
  98. X  char newsgroups[255];
  99. X  char followup_to[255];
  100. X  char distribution[255];
  101. X  char date[255];
  102. X  char lines[255];
  103. X  char message_id[255];
  104. X  char organization[255];
  105. X  char posted[255];
  106. X  char article_id[255];
  107. X  char nntp_post[255];
  108. X  char references[255];
  109. X
  110. X  int id_err = 0;
  111. X  int i;
  112. X  int inlines, ok;
  113. X
  114. X  int reply = 0;
  115. X  int noreply = 0;
  116. X  int dirlist = 0;
  117. X  int logfile = 0;
  118. X  int info = 0;
  119. X  int minimal = 0;
  120. X  long timer;
  121. X
  122. X
  123. X  fp = fopen(msg, "r");
  124. X  if (fp == NULL) return -1;
  125. X
  126. X  sprintf(tmp, "%s/%d", TMP, getpid());
  127. X  ff = fopen(tmp, "w");
  128. X  
  129. X  i = 1;
  130. X  inlines = -1;
  131. X
  132. X  while (fgets(s, 255, fp) != NULL) {
  133. X    ok = 0;
  134. X    if (strcomp("Path:", s) == 0) {
  135. X        sprintf(path, "%02d>> %s <<\n", i, (char *) stripped(s));
  136. X        ok++;
  137. X    }
  138. X    if (strcomp("Reply-To:", s) == 0) {
  139. X        sprintf(reply_to, "%02d>> %s <<\n", i, (char *) stripped(s));
  140. X        reply--;
  141. X        ok++;
  142. X    }
  143. X    if (strcomp("From:", s) == 0) {
  144. X        sprintf(from, "%02d>> %s <<\n", i, (char *) stripped(s));
  145. X        ok++;
  146. X    }
  147. X    if (strcomp("Sender:", s) == 0) {
  148. X        sprintf(sender, "%02d>> %s <<\n", i, (char *) stripped(s));
  149. X        ok++;
  150. X    }
  151. X    if (strcomp("Subject:", s) == 0) {
  152. X        sprintf(subject, "%02d>> %s <<\n", i, (char *) stripped(s));
  153. X        ok++;
  154. X    }
  155. X    if (strcomp("Summary:", s) == 0) {
  156. X        sprintf(summary, "%02d>> %s <<\n", i, (char *) stripped(s));
  157. X        ok++;
  158. X    }
  159. X    if (strcomp("Keywords:", s) == 0) {
  160. X        sprintf(keywords, "%02d>> %s <<\n", i, (char *) stripped(s));
  161. X        ok++;
  162. X    }
  163. X    if (strcomp("Newsgroups:", s) == 0) {
  164. X        sprintf(newsgroups, "%02d>> %s <<\n", i, (char *) stripped(s));
  165. X        ok++;
  166. X    }
  167. X    if (strcomp("Followup-To:", s) == 0) {
  168. X        sprintf(followup_to, "%02d>> %s <<\n", i, (char *) stripped(s));
  169. X        ok++;
  170. X    }
  171. X    if (strcomp("Distribution:", s) == 0) {
  172. X        sprintf(distribution, "%02d>> %s <<\n", i, (char *) stripped(s));
  173. X        ok++;
  174. X    }
  175. X    if (strcomp("Date:", s) == 0) {
  176. X        sprintf(date, "%02d>> %s <<\n", i, (char *) stripped(s));
  177. X        ok++;
  178. X    }
  179. X    if (strcomp("Lines:", s) == 0) {
  180. X        sprintf(lines, "%02d>> %s <<\n", i, (char *) stripped(s));
  181. X        ok++;
  182. X    }
  183. X    if (strcomp("Message-I", s) == 0) {
  184. X        sprintf(message_id, "%02d>> %s <<\n", i, (char *) stripped(s));
  185. X        /*
  186. X        if (s[9] == 'D') id_err++;
  187. X        */
  188. X        ok++;
  189. X    }
  190. X    if (strcomp("Organization:", s) == 0) {
  191. X        sprintf(organization, "%02d>> %s <<\n", i, (char *) stripped(s));
  192. X        ok++;
  193. X    }
  194. X    if (strcomp("Posted:", s) == 0) {
  195. X        sprintf(posted, "%02d>> %s <<\n", i, (char *) stripped(s));
  196. X        ok++;
  197. X    }
  198. X    if (strcomp("Article-I.D.:", s) == 0) {
  199. X        sprintf(article_id, "%02d>> %s <<\n", i, (char *) stripped(s));
  200. X        ok++;
  201. X    }
  202. X    if (strcomp("Nntp-Posting-Host:", s) == 0) {
  203. X        sprintf(nntp_post, "%02d>> %s <<\n", i, (char *) stripped(s));
  204. X        ok++;
  205. X    }
  206. X    if (strcomp("References:", s) == 0) {
  207. X        sprintf(references, "%02d>> %s <<\n", i, (char *) stripped(s));
  208. X        ok++;
  209. X    }
  210. X
  211. X
  212. X
  213. X    if (strcomp("NO REPLY", s)        == 0 ||
  214. X        strcomp("NOT REPLY", s)       == 0 ||
  215. X        strcomp("KEIN REPLY", s)      == 0 ||
  216. X        strcomp("NO REPLIES", s)      == 0 ||
  217. X        strcomp("KEINE REPLIES", s)   == 0 ||
  218. X        strcomp("NO REPLYS", s)       == 0 ||
  219. X        strcomp("KEINE REPLYS", s)    == 0 ||
  220. X        strcomp("KEINE ANTWORTEN", s) == 0 ||
  221. X        strcomp("NICHT ANTWORTEN", s) == 0 ||
  222. X        strcomp("NO REFLECT", s)      == 0 ||
  223. X        strcomp("NOT REFLECT", s)     == 0 ||
  224. X        strcomp("NO ANSWER", s)       == 0 ||
  225. X        strcomp("NOT ANSWER", s)      == 0 ||
  226. X        strcomp("IGNORE", s)          == 0)
  227. X        noreply++;
  228. X
  229. X    if (strcomp("PLEASE REPLY", s)    == 0 ||
  230. X        strcomp("BITTE REPLY", s)     == 0 ||
  231. X        strcomp("PLEASE REFLECT", s)  == 0 ||
  232. X        strcomp("BITTE REFLECT", s)   == 0 ||
  233. X        strcomp("BITTE ANTWORT", s)   == 0 ||
  234. X        strcomp("REPLY", s)           == 0 ||
  235. X        strcomp("REFLECT", s)         == 0 ||
  236. X        strcomp("ANTWORT", s)         == 0)
  237. X        reply++;
  238. X
  239. X    if (strcomp("DIRLIST", s) == 0) dirlist++;
  240. X
  241. X    if (strcomp("LOGFILE", s) == 0) logfile++;
  242. X
  243. X    if (strcomp("INFO", s) == 0 ||
  244. X        strcomp("HELP", s) == 0)
  245. X        info++;
  246. X
  247. X    if (strcomp("SHORT", s) == 0) minimal++;
  248. X
  249. X    if (ok == 0) {
  250. X        /* Sprintf(s, "%02d Body >> %s <<\n\n", i, (char *) stripped(s)); */
  251. X        inlines++;
  252. X    }
  253. X    i++;
  254. X  }
  255. X  fclose(fp);
  256. X
  257. X  strcpy(s, (char *) strcopy(organization, 19, 80));
  258. X  if ((FLAG == 1) && (strcomp(ORGANIZATION, s) != 0)) return -1;
  259. X
  260. X  if (reply_to[0] != '\0') {
  261. X    strcpy(receiver, (char *) strcopy(reply_to, 15, 80));
  262. X  } else {
  263. X    strcpy(receiver, (char *) strcopy(from, 11, 80));
  264. X  }
  265. X
  266. X  i = 0;
  267. X  while ((receiver[i] != '\0') && (receiver[i] != '(')) i++;
  268. X  receiver[(i - 1)] = '\0';
  269. X
  270. X
  271. X
  272. X  time(&timer);
  273. X
  274. X  fprintf(ff, "From: reflector@%s (Reflecting Device)\n", UUCPID2); 
  275. X  fprintf(ff, "Organization: %s\n", ORGANIZATION);
  276. X  if(message_id[0] != '\0'){
  277. X    fprintf(fp, "References: %s", message_id);
  278. X  }
  279. X  fprintf(ff, "To: %s\n", receiver);
  280. X  fprintf(ff, "Subject: *Reflexion*\n");
  281. X  fprintf(ff, "X-Mailer: %s %s %s\n", VERSION, PATCHLEVEL, AUTOR);    
  282. X  fprintf(ff, "Message-Id: <%x.reflector@%s>\n", timer, UUCPID2);
  283. X  fputs("\n", ff);
  284. X
  285. X
  286. X
  287. X  fp = fopen(REFLECT_LOG, "a");
  288. X  if (fp == NULL) {
  289. X    while (1) printf("%c", 7);
  290. X  }
  291. X  fprintf(fp, "%s - %s", (char *) mydate(1), from);
  292. X  fprintf(fp, "         - %s", message_id);
  293. X  fprintf(fp, "         - %s", subject);
  294. X  if (dirlist != 0) {
  295. X    fprintf(fp, "         - DIRLIST-Request\n");
  296. X  }
  297. X  if (logfile != 0) {
  298. X    fprintf(fp, "         - LOGFILE-Request\n");
  299. X  }
  300. X  if (info != 0) {
  301. X    fprintf(fp, "         - INFO-Request\n");
  302. X  }
  303. X  fprintf(fp, "         - Reflected to %s\n\n", receiver);
  304. X  fclose(fp);
  305. X
  306. X
  307. X  fprintf(ff, "%s\n\n", MVERSION);
  308. X
  309. X
  310. X  if ((dirlist == 0) && (logfile == 0) && (info == 0) && (minimal == 0)) {
  311. X    fprintf(ff, "That's what we received in NG \"%s\" ...\n\n", arg);
  312. X
  313. X    fputs(path, ff);
  314. X    fputs(from, ff);
  315. X    fputs(reply_to, ff);
  316. X    fputs(sender, ff);
  317. X    fputs(newsgroups, ff);
  318. X    fputs(subject, ff);
  319. X    fputs(article_id, ff);
  320. X    fputs(posted, ff);
  321. X    fputs(nntp_post, ff);
  322. X    fputs(summary, ff);
  323. X    fputs(keywords, ff);
  324. X    fputs(followup_to, ff);
  325. X    fputs(distribution, ff);
  326. X    fputs(references, ff);
  327. X    fputs(message_id, ff);
  328. X    fputs(organization, ff);
  329. X    fputs(date, ff);
  330. X    fputs(lines, ff);
  331. X
  332. X
  333. X    fputs("\n\nDiagnostics ...\n\n", ff);
  334. X
  335. X    if (id_err != 0) {
  336. X        fprintf(ff, "- \"Message-ID\" may cause trouble ... use \"Message-Id\".\n\n");
  337. X    }
  338. X    if (reply_to[0] == '\0') {
  339. X        fprintf(ff, "- No \"Reply-To\"-Path ... don't know how to deliever responses.\n\n");
  340. X    }
  341. X    i = atoi((char *) strcopy(lines, 12, 80));
  342. X    inlines--;
  343. X    if (inlines != i) {
  344. X        fprintf(ff, "- Your Header reports %d lines ... we counted %d.\n\n", i, inlines);
  345. X    }
  346. X    if ((reply != 0) || (noreply != 0)) {
  347. X        fprintf(ff, "- Found %d Reply-Requests and %d No-Replies.\n\n", reply, noreply);
  348. X    }
  349. X  }
  350. X  if (dirlist != 0) {
  351. X    fp = fopen(DIRLIST, "r");
  352. X    if (fp != NULL) {
  353. X        fputs("DIRLIST:\n\n", ff);
  354. X        while (fgets(s, 250, fp) != NULL) fputs(s, ff);
  355. X        fclose(fp);
  356. X    } else {
  357. X        fputs("Sorry, no DIRLIST-Entry found ...\n\n", ff);
  358. X    }
  359. X    printf("\n\n");
  360. X  }
  361. X  if (logfile != 0) {
  362. X    fp = fopen(REFLECT_LOG, "r");
  363. X    if (fp != NULL) {
  364. X        fputs("LOGFILE:\n\n", ff);
  365. X        while (fgets(s, 250, fp) != NULL) fputs(s, ff);
  366. X        fclose(fp);
  367. X    } else {
  368. X        fputs("Sorry, no LOGFILE-Entry found ...\n\n", ff);
  369. X    }
  370. X    printf("\n\n");
  371. X  }
  372. X  if (info != 0) {
  373. X    fputs("INFO (weitere Schluesselwoerter):\n\n", ff);
  374. X    fputs("LOGFILE - Wenn der Reflektor nicht reflektiert, kann man sich\n", ff);
  375. X    fputs("          das LOGFILE senden lassen, um zu ueberpruefen ob der\n", ff);
  376. X    fputs("                 Artikel jemals erfasst worden ist.\n\n", ff);
  377. X
  378. X    fputs("DIRLIST - Eine Liste des lokalen MINIX-Archivs. Da der Reflektor\n", ff);
  379. X    fputs("          (noch) kein PD-Server ist, kann man diese Liste nur zu\n", ff);
  380. X    fputs("          Testzwecken anfordern.\n\n", ff);
  381. X
  382. X    fputs("SHORT   - Quittiert nur den Empfang des Artikels.\n\n", ff);
  383. X  }
  384. X  if (minimal != 0) {
  385. X    fprintf(ff, "Received your article %s", message_id);
  386. X  }
  387. X  fclose(ff);
  388. X
  389. X  sprintf(s, "/bin/sh ./etc/rmail.sh %s %s", tmp, receiver);
  390. X  system(s);
  391. X
  392. X  unlink(tmp);
  393. X
  394. X  return 0;
  395. X}
  396. X
  397. X
  398. X
  399. X/***************************************************************************/
  400. X/*      FUNKTION  pdsize()                           */
  401. X/*  BESCHREIBUNG  Groesse eine PD-Datei ermitteln                */
  402. X/*     PARAMETER  arg - Name des NG-Eintrags                               */
  403. X/*     RUECKGABE  Groesse in kBytes                                        */
  404. X/***************************************************************************/
  405. X
  406. Xint pdsize( arg )
  407. Xchar arg[];
  408. X{
  409. X  FILE *fp;
  410. X  char s[STRING];
  411. X  int ok = 0, i;
  412. X  struct stat fstat;
  413. X
  414. X  fp = fopen( arg, "r" );
  415. X  if(fp == NULL){
  416. X    return (int) 0;
  417. X  }
  418. X  while((ok == 0) && (fgets(s, 80, fp) != NULL)){
  419. X    if(strcomp("BINFILE", s) == 0) ok++;
  420. X  }
  421. X  fgets(s, 80, fp);
  422. X  fclose(fp);
  423. X
  424. X  if(ok == 0) strcpy(s, (char *) arg);
  425. X
  426. X  if(stat((char *) stripped(s), &fstat) != NULL){
  427. X    fp = fopen( CPRN, "a" );
  428. X        if(fp != NULL){
  429. X        fprintf(fp, "\nMB-DAEMON  (%s)  \"%s\" ??\n", mydate(1), (char *) stripped(s));
  430. X        fclose(fp);
  431. X    }
  432. X    return (int) 0;
  433. X  }
  434. X  i = (int) (fstat.st_size / 1024);
  435. X  if(i < 1) i = 1;
  436. X  return (int) i;
  437. X}
  438. X
  439. X
  440. X
  441. X
  442. X
  443. X
  444. X
  445. X/***************************************************************************/
  446. X/*      FUNKTION  scan()                           */
  447. X/*  BESCHREIBUNG  Filtert einen NEWS-Artikel, und erstellt einen Eintrag   */
  448. X/*          fuer das entsprechenden INDEX-Files der ix/Mbox.       */
  449. X/*     PARAMETER  arg  =  NG                                               */
  450. X/*     RUECKGABE  Datum des aktuellsten Artikels                           */
  451. X/***************************************************************************/
  452. X
  453. Xchar *scan(arg)
  454. Xchar arg[];
  455. X{
  456. X  FILE *ff;
  457. X  FILE *fp;
  458. X  FILE *fl;
  459. X  FILE *ft;
  460. X
  461. X  char s[STRING];
  462. X  char t[STRING];
  463. X  char f[STRING];
  464. X  char v[STRING];
  465. X  char from[STRING];
  466. X  char subj[STRING];
  467. X  char date[STRING];
  468. X  char line[STRING];
  469. X  char orga[STRING];
  470. X  char Ndir[STRING];
  471. X  char Ldir[STRING];
  472. X  char Tdir[STRING];
  473. X  char ex[1024];
  474. X  char et[355];
  475. X
  476. X  int dirarray[MAX_PER_NG];
  477. X  int idp = 0, iii = 0;
  478. X
  479. X  DIR *dp;
  480. X  struct dirent *actdir;
  481. X
  482. X
  483. X  static char sdate[STRING];
  484. X
  485. X  char today[STRING];
  486. X  char thatday[STRING];
  487. X  char arti[STRING];
  488. X
  489. X  int i, j;
  490. X  int ok = 0;
  491. X  int a, b;
  492. X  int BINFILE = 0;
  493. X  int PDGROUP = 0;
  494. X  int fsi = 0;
  495. X  int seq = 0;
  496. X  int OLDENTRY = 0;
  497. X  int OLDn = 0;
  498. X  int OLDo = 0;
  499. X  int got_org = 0;
  500. X
  501. X  struct stat fstat;
  502. X  struct tm *tp;
  503. X
  504. X  i = 0;
  505. X  while (arg[i] != '\0') {
  506. X    t[i] = arg[i];
  507. X    if (t[i] == '.') t[i] = '/';
  508. X    i++;
  509. X  }
  510. X  t[i] = '\0';
  511. X
  512. X  sprintf(Ndir, "%s/%s", NEWS, t);
  513. X
  514. X  if(length(arg) > 14){
  515. X#ifndef _LONGNAMES
  516. X    strcpy(s, (char *) shortname(arg));
  517. X#else
  518. X    strcpy(s, (char *) arg);
  519. X#endif
  520. X    sprintf(Ldir, "%s/%s", LIB, s);
  521. X  } 
  522. X  else{
  523. X    sprintf(Ldir, "%s/%s", LIB, arg);
  524. X  }
  525. X  strcpy(Ldir, (char *) stripped(Ldir));
  526. X
  527. X  sprintf(Tdir, "%s/TD.%d", TMP, getpid());
  528. X
  529. X  if (FLAG == 0) printf("\n%s...\n", Ndir);
  530. X
  531. X  sprintf(f, "%s/%dA", TMP, getpid());
  532. X
  533. X
  534. X  dp = opendir( Ndir );
  535. X  if(dp == NULL){
  536. X    printf("::No such directory!\n\n");
  537. X    return "";
  538. X  }
  539. X  while((actdir = readdir(dp)) != NULL){
  540. X     dirarray[idp] = atoi(actdir->d_name);
  541. X     if(dirarray[idp] != 0) idp++;
  542. X     if(idp >= MAX_PER_NG){
  543. X        nerror("mb-daemon.c", 506, "scan", "Verzeichnis zu gross > ", Ndir );        
  544. X     }
  545. X  }
  546. X  closedir(dp);
  547. X
  548. X  for(i = 0; i < idp; i++){
  549. X    for(j = 0; j< idp; j++){
  550. X        if(dirarray[i] > dirarray[j]){
  551. X            a = dirarray[j];
  552. X            dirarray[j] = dirarray[i];
  553. X            dirarray[i] = a;
  554. X        }
  555. X        }
  556. X  } 
  557. X
  558. X  if(idp == 0){
  559. X    if (FLAG == 0) printf("::Directory is empty!\n\n");
  560. X    return "";
  561. X  }
  562. X
  563. X  sprintf(sdate, "%s", ":-)");
  564. X
  565. X  sprintf(today, "%s", (char *) mydate(1));
  566. X
  567. X
  568. X  ft = fopen(Ldir, "r");
  569. X  if(ft == NULL){
  570. X    ft = fopen(Ldir, "w");
  571. X    fputs("\n\n0\n", ft);
  572. X    fclose(ft);
  573. X    ft = fopen(Ldir, "r");
  574. X    OLDo = -2;
  575. X  }
  576. X  fgets(s, 81, ft);
  577. X  fgets(s, 81, ft);
  578. X  fgets(s, 81, ft);
  579. X  OLDENTRY = atoi(s); 
  580. X
  581. X  mblock(Ldir);
  582. X
  583. X  ff = fopen(Tdir, "w");
  584. X
  585. X  seq = 0;
  586. X
  587. X  mb_gruppen++;
  588. X
  589. X
  590. X  if(strcomp(PDNG, arg) == 0){
  591. X    PDGROUP++;    
  592. X    fprintf(ff, "%s\n", GBL08_MSG); 
  593. X  }
  594. X  else{
  595. X    fprintf(ff, "%s\n", GBL05_MSG);
  596. X  }
  597. X  fputs("===============================================================================\n", ff);
  598. X
  599. X  while (iii < idp) {
  600. X
  601. X    if((dirarray[iii] < OLDENTRY) && (FASTMODE == 1)) goto YET_SCANNED;
  602. X
  603. X    OLDn++;
  604. X
  605. X    seq++;
  606. X    BINFILE = 0;
  607. X    fsi++;
  608. X
  609. X    sprintf(arti, "%s/%d", Ndir, dirarray[iii]);  
  610. X    strcpy(t, (char *) arti); /* ??? */
  611. X
  612. X    if (FLAG == 0) printf("%s: ", t);
  613. X
  614. X    fp = fopen(t, "r");
  615. X    if (fp != NULL) {
  616. X
  617. X        stat(t, &fstat);
  618. X        tp = localtime(&fstat.st_mtime);
  619. X
  620. X        if(fstat.st_mode & S_IFDIR) goto OFF_HERE;
  621. X
  622. X        mb_bytes += (long) fstat.st_size;
  623. X        sprintf(thatday, "%02.2d.%02.2d.%02.2d", tp->tm_mday, tp->tm_mon + TZS, tp->tm_year);
  624. X        if(strcomp(thatday, today) == 0) mb_new_bytes += (long) fstat.st_size;
  625. X
  626. X        if (sdate[0] == ':') {
  627. X            sprintf(sdate, "%4.4d%02.2d%02.2d",
  628. X                1900 + tp->tm_year, tp->tm_mon + TZS, tp->tm_mday);
  629. X            sprintf(s, "%02.2d:%02.2d",
  630. X                tp->tm_hour, tp->tm_min);
  631. X            LASTTIME = timeconv(s);
  632. X            if (FLAG == 0) printf(" (%s) ", sdate);
  633. X            if(strcomp(thatday, today) == 0) mb_new++;
  634. X        }
  635. X        if (strcomp(arg, REFLECT_NG) == 0) {
  636. X            if (strcomp(thatday, today) == 0) {
  637. X                reflector(arg, t);
  638. X            }
  639. X        }
  640. X        from[0] = '\0';
  641. X        subj[0] = '\0';
  642. X        date[0] = '\0';
  643. X        line[0] = '\0';
  644. X        orga[0] = '\0';
  645. X
  646. X        got_org = 0;
  647. X        i = 0;
  648. X
  649. X        while((got_org == 0) && (i < 20)){
  650. X            fgets(ex, 350, fp);
  651. X#ifdef ADDRMODE
  652. X            if (strcomp("de.", arg) == 0) {
  653. X                if (strcomp("Path:", ex) == 0) {
  654. X                    fprintf(ad, "%s\n", (char *) stripped(ex));
  655. X                }
  656. X            }
  657. X#endif
  658. X            ex[80] = '\0'; strcpy(s, ex);
  659. X            if (strcomp("From:", s) == 0) {
  660. X                strcpy(from, s);
  661. X            }
  662. X            if (strcomp("Reply-To:", s) == 0) {
  663. X                strcpy(from, s);
  664. X            }
  665. X            if (strcomp("Subject:", s)      == 0) strcpy(subj, s);
  666. X            if (strcomp("Date:", s)         == 0) strcpy(date, s);
  667. X            if (strcomp("Lines:", s)        == 0) strcpy(line, s);
  668. X            if (strcomp("BINFILE", s)       == 0) BINFILE++;
  669. X            if (strcomp("Organization:", s) == 0) strcpy(orga, s);
  670. X            if (strlen(s) < 3) got_org++;
  671. X            i++;
  672. X        }
  673. X
  674. X#ifdef ADDRMODE        
  675. X        if (strcomp("de.", arg) == 0) {
  676. X            fprintf(ad, "%s\n", (char *) stripped(from));
  677. X            fprintf(ad, "%s\n", (char *) stripped(orga));
  678. X        }
  679. X#endif
  680. X
  681. X        if (FLAG == 0) printf("%s", subj);
  682. X
  683. X        if ((from[0] == 'F') || (from[0] == 'R')) {
  684. X
  685. X            sprintf(s, "%d        ", dirarray[iii]);
  686. X            s[6] = '\0';
  687. X            if (BINFILE != 0) s[5] = '*';
  688. X
  689. X            subj[79] = '\0';
  690. X            strcpy(ex, (char *) strcopy(subj, 8, 79));
  691. X            strcpy(et, (char *) stripped(ex));
  692. X            strcpy(ex, et);
  693. X            strcat(ex, "                           ");
  694. X            ex[25] = '\0';
  695. X            strcat(s, ex);
  696. X            strcat(s, "   ");
  697. X
  698. X
  699. X            i = 8;
  700. X            if (from[0] == 'R') i = 10;
  701. X
  702. X            from[79] = '\0';
  703. X            strcpy(ex, (char *) strcopy(from, i, 80));
  704. X            strcpy(et, (char *) stripped(ex));
  705. X            strcpy(ex, et);
  706. X
  707. X            a = 0;
  708. X            b = 0;
  709. X            i = 0;
  710. X            while (ex[i] != '\0') {
  711. X                if (ex[i] == '(') a = i + 1;
  712. X                if (ex[i] == ')') b = i - 1;
  713. X                i++;
  714. X            }
  715. X            if (a < b) {
  716. X                strcpy(et, (char *) strcopy(ex, a, b));
  717. X                strcpy(ex, et);
  718. X            }
  719. X            strcat(ex, "                           ");
  720. X            ex[19] = '\0';
  721. X            strcat(s, ex);
  722. X            strcat(s, "   ");
  723. X
  724. X
  725. X            i = 0;
  726. X            j = 0;
  727. X            while (date[i] != '\0') {
  728. X                if (j == 0) {
  729. X                    if ((date[i] >= '1') && (date[i] <= '9'))
  730. X                        j = i;
  731. X                }
  732. X                i++;
  733. X            }
  734. X
  735. X            sprintf(ex, "%02.2d.%02.2d.%02.2d  %02.2d:%02.2d",
  736. X             tp->tm_mday, tp->tm_mon + TZS, tp->tm_year,
  737. X                tp->tm_hour, tp->tm_min);
  738. X            strcat(ex, "                         ");
  739. X            ex[15] = '\0';
  740. X            strcat(s, ex);
  741. X            strcat(s, "  ");
  742. X
  743. X            strcpy(ex, (char *) strcopy(line, 7, 20));
  744. X            strcpy(t, (char *) stripped(ex));
  745. X            i = atoi(t);
  746. X            sprintf(ex, "%-6.d", i);
  747. X        
  748. X            if(PDGROUP != 0){
  749. X                sprintf(ex, "%-6.d", pdsize(arti));
  750. X            }
  751. X
  752. X            strcat(s, ex);
  753. X            fputs(s, ff);
  754. X            fputs("\n", ff);
  755. X
  756. X            mb_artikel++;
  757. X
  758. X            ok = 1;
  759. X        } else {
  760. X            if (FLAG == 0) printf("invalid header!\n");
  761. X        }
  762. X
  763. X        OFF_HERE:
  764. X
  765. X        if (fp != 0) fclose(fp);
  766. X    } else {
  767. X        if (FLAG == 0) printf("can't open!\n");
  768. X    }
  769. X    iii++;
  770. X  }
  771. X
  772. X  YET_SCANNED:
  773. X
  774. X  if(OLDn != 0) OLDn -= 1;
  775. X
  776. X  idp -= 2; /* ??? */
  777. X
  778. X  while(iii < idp){
  779. X    if((OLDn != 0) || (FASTMODE == 0)){
  780. X        fgets(s, 81, ft); 
  781. X        fputs(s, ff);
  782. X    }
  783. X    if(FLAG == 0){
  784. X        sprintf(t, "%s/%d", Ndir, dirarray[iii]);
  785. X        stat(t, &fstat);
  786. X        mb_bytes += (long) fstat.st_size;
  787. X    }
  788. X    mb_artikel++;
  789. X    OLDo++;
  790. X    iii++;
  791. X  }
  792. X
  793. X  if((OLDn != 0) || (FASTMODE == 0)){
  794. X    fgets(s, 81, ft);
  795. X    if((FASTMODE == 1) && (OLDo > 0)) fputs(s, ff);
  796. X    fclose(ff);
  797. X    fclose(ft);
  798. X    if(rename( Tdir, Ldir ) != 0){
  799. X        ff = fopen( Tdir, "r");
  800. X        ft = fopen( Ldir, "w");
  801. X        while(fgets(s, 81, ff) != NULL){
  802. X            fputs(s, ft);
  803. X        }
  804. X    }
  805. X  }
  806. X  if (ff != 0) fclose(ff);
  807. X  if (ft != 0) fclose(ft);
  808. X
  809. X  unlink(f);
  810. X  unlink(Tdir);
  811. X
  812. X
  813. X  if (sdate[0] == ':') {
  814. X    sprintf(sdate, "%s", "19700101");
  815. X    LASTTIME = 0;
  816. X  }
  817. X
  818. X#ifdef _SYS7
  819. X  if ((seq > MAX_PER_NG) && (FLAG == 0) && (strcomp("local", arg) != 0)) {
  820. X    sprintf(s, "%s -n %s -e %d", EXPIRE, arg, EXPIRED_DAYS);
  821. X    printf("%s\n", s);
  822. X    system(s);
  823. X    sprintf(s, "%s %s EXP", MB_DAEMON, arg);
  824. X    system(s);
  825. X  }
  826. X#endif
  827. X  
  828. X  mbunlock(Ldir);
  829. X
  830. X  if((FASTMODE == 1) && (FLAG == 0)){
  831. X    OLDo += 2;
  832. X    printf("\n==> %s %d. %s %d.\n\n", MBD01_MSG, OLDn, MBD02_MSG, OLDo);
  833. X  }
  834. X  
  835. X  return (char *) sdate;
  836. X}
  837. X
  838. X
  839. X
  840. X/***************************************************************************/
  841. X/*      FUNKTION  mix()                               */
  842. X/*  BESCHREIBUNG  Aktualisiert einzelnen Eintraege im AGROUPS-File.       */
  843. X/*     PARAMETER  s  =  NG                                                 */
  844. X/*          t  =  Neuer AGROUPS-Eintrag                              */
  845. X/*     RUECKGABE  keine                                                    */
  846. X/***************************************************************************/
  847. X
  848. Xvoid mix( s, t )
  849. Xchar s[], t[];
  850. X{
  851. X  FILE *ff, *fp;
  852. X  char tmp[STRING];
  853. X  char f[STRING];
  854. X
  855. X  sprintf(tmp, "%s/ff%d", TMP, getpid());
  856. X
  857. X
  858. X  maybe_locked( AGROUPS, "r" );
  859. X  fp = fopen( AGROUPS, "r" );
  860. X  if(fp == NULL){
  861. X    printf("%s ?", AGROUPS);
  862. X    exit(-1);
  863. X  }
  864. X
  865. X  ff = fopen( tmp, "w" );
  866. X  if(ff == NULL){
  867. X    printf("%s ?", tmp);
  868. X    exit(-1);
  869. X  }
  870. X
  871. X  while(fgets(f, 80, fp) != NULL){
  872. X    if(strcomp(s, f) == 0){
  873. X        fputs(t, ff);
  874. X    }
  875. X    else{
  876. X        fputs(f, ff);
  877. X    }
  878. X  }
  879. X  fclose(fp);
  880. X  fclose(ff);
  881. X
  882. X  sprintf(f, "mv %s %s", tmp, AGROUPS);
  883. X  system( f );
  884. X}
  885. X
  886. X
  887. X
  888. X
  889. X
  890. X/***************************************************************************/
  891. X/*      FUNKTION  main() (mb_daemon)                       */
  892. X/*  BESCHREIBUNG  Scannt einen bzw. alle NEWS-Artikel, um die INDEX-Files  */
  893. X/*          der ix/Mbox zu aktualisieren.                            */
  894. X/*     PARAMETER  argc  =  Anzahl der Parameter                            */
  895. X/*          argv  =  NG  = nur diese NG scannen                */
  896. X/*               ''  = alle NGs scannen                    */
  897. X/*     RUECKGABE  keine                                                    */
  898. X/***************************************************************************/
  899. X
  900. Xmain(argc, argv)
  901. Xint argc;
  902. Xchar *argv[];
  903. X{
  904. X  FILE *fp;
  905. X  FILE *fa;
  906. X  char s[STRING];
  907. X  char t[STRING];
  908. X  char d[STRING];
  909. X
  910. X
  911. X  int a, b, i;
  912. X
  913. X  chdir(HOME);
  914. X
  915. X  setuid(0);
  916. X  setgid(0);
  917. X  umask(0000);
  918. X
  919. X  FLAG = 0;
  920. X  FASTMODE = 1;
  921. X
  922. X  if(argc > 1){
  923. X    FLAG++;
  924. X  }
  925. X  if(argc > 2){            /* MB-Daemon ruft MB-Daemon !!! */
  926. X    FLAG++; 
  927. X    FASTMODE = 0; 
  928. X  }
  929. X
  930. X  if(strcomp("all", argv[1]) == 0) FLAG = 0;
  931. X
  932. X#if 0
  933. X  if(argv[2][0] == '-'){    /* Index KOMPLETT neu bilden !!! */
  934. X    FASTMODE = 0;
  935. X  }
  936. X#endif
  937. X
  938. X  if(FLAG == 0){
  939. X    if (fa = fopen(AGROUPS, "w"))
  940. X    fclose(fa);
  941. X  }
  942. X
  943. X#ifdef ADDRMODE
  944. X    ad = fopen( "/local/address/addresses", "a" );
  945. X    if(ad == NULL){
  946. X    printf("\n[local/address/addresses] ???\n");
  947. X    exit( 0 );    
  948. X    }
  949. X#endif
  950. X
  951. X  mb_gruppen = 0;
  952. X  mb_new = 0;
  953. X  mb_bytes = 0L;
  954. X  mb_new_bytes = 0L;
  955. X  mb_artikel = 0L;
  956. X
  957. X
  958. X  if (fp = fopen(NGROUPS, "r"))
  959. X  while (fscanf(fp, "%s %d %d %s", s, &a, &b, t) > 0) {
  960. X#ifdef _CNEWS
  961. X    if(t[0] == '=')
  962. X        continue;
  963. X#endif
  964. X    if(FLAG > 0){
  965. X        if(strcomp(argv[1], s) == 0){
  966. X            d[0] = '\0';
  967. X#ifdef _SYS7
  968. X            strcat(d, (char *) scan(s));
  969. X#else
  970. X            strcat(d, (char *) scan(&s));
  971. X#endif
  972. X            sprintf(t, "%s  %s  %ld\n", s, d, LASTTIME);
  973. X            if(FLAG < 2) mix( s, t );
  974. X        }
  975. X    }
  976. X    else{
  977. X        d[0] = '\0';
  978. X#ifdef _SYS7    
  979. X        strcat(d, (char *) scan(s));
  980. X#else    
  981. X        strcat(d, (char *) scan(&s));
  982. X#endif
  983. X        fa = fopen(AGROUPS, "a");
  984. X        fprintf(fa, "%s  %s  %ld\n", s, d, LASTTIME);
  985. X        fclose(fa);
  986. X    }
  987. X  }
  988. X  if(fp != 0) fclose(fp);
  989. X
  990. X  if(FLAG > 0){
  991. X  }
  992. X  else{
  993. X     mb_bytes = (long)(mb_bytes / 1024);
  994. X     mb_new_bytes = (long)(mb_new_bytes /1024);
  995. X   
  996. X     sprintf(d, "%s/%d.mbd", TMP, getpid());
  997. X     fp = fopen( d, "w" );
  998. X     fprintf(fp, "%s  %s    %6.d   %6.ld",
  999. X                  mydate(1), mytime(1), mb_new, mb_new_bytes);
  1000. X     fprintf(fp, "%16.16s", " ");
  1001. X     fprintf(fp, "%6.d   %6.ld   %6.ld\n", mb_gruppen, mb_artikel, mb_bytes);
  1002. X
  1003. X     b = PRO_ENTRIES / 2; a = 0;
  1004. X
  1005. X     fa = fopen( MB_DLOG, "r" );
  1006. X     if(fa != 0){
  1007. X    while((fgets(s, STRING, fa) != 0) && (a < b)){
  1008. X        fputs(s, fp);
  1009. X        a++;
  1010. X    }
  1011. X    fclose(fa);
  1012. X     }
  1013. X     if(fp != 0) fclose(fp);
  1014. X
  1015. X     sprintf(s, "mv %s %s > /dev/null", d, MB_DLOG);
  1016. X     system(s);
  1017. X  } 
  1018. X
  1019. X  if((FASTMODE == 1) && (FLAG == 0)){
  1020. X    printf("%s %d %s %ld %s.\n", MBD03_MSG, mb_new, MBD04_MSG, 
  1021. X        mb_new_bytes, MBD05_MSG);
  1022. X    printf("%s %d %s %ld %s %ld %s.\n\n", 
  1023. X        MBD06_MSG, mb_gruppen, MBD07_MSG, mb_artikel, MBD08_MSG, 
  1024. X        mb_bytes, MBD09_MSG);
  1025. X  }
  1026. X
  1027. X
  1028. X#ifdef ADDRMODE
  1029. X  if(ad != 0) fclose(ad);
  1030. X#endif
  1031. X
  1032. X  return;
  1033. X}
  1034. X
  1035. X
  1036. END_OF_FILE
  1037.   if test 22450 -ne `wc -c <'src/mb-daemon.c'`; then
  1038.     echo shar: \"'src/mb-daemon.c'\" unpacked with wrong size!
  1039.   fi
  1040.   # end of 'src/mb-daemon.c'
  1041. fi
  1042. if test -f 'src/show.c' -a "${1}" != "-c" ; then 
  1043.   echo shar: Will not clobber existing file \"'src/show.c'\"
  1044. else
  1045.   echo shar: Extracting \"'src/show.c'\" \(11749 characters\)
  1046.   sed "s/^X//" >'src/show.c' <<'END_OF_FILE'
  1047. X/***************************************************************************/
  1048. X/*        PROGRAMM  ix/Mbox                           */
  1049. X/*             DATEI  show.c                           */
  1050. X/*        FUNKTIONEN  show(), more(), richtext(), quoted_printable()       */
  1051. X/*             AUTOR  vs (Volker Schuermann/MINIX-Version)           */
  1052. X/*  LETZTE AENDERUNG  08.06.1992                       */
  1053. X/***************************************************************************/
  1054. X
  1055. X#include <stdio.h>
  1056. X#include <string.h>
  1057. X
  1058. X#include "mbox.h"
  1059. X
  1060. X
  1061. Xstatic int show_more;
  1062. Xstatic FILE *page;
  1063. Xstatic char show_tmp[STRING];
  1064. Xstatic int seite;
  1065. X
  1066. X
  1067. Xextern char headinfo[STRING];
  1068. X
  1069. Xstatic int morechen;
  1070. X
  1071. X
  1072. X/* Globals fuer RTF (Richtext Format): */
  1073. X
  1074. Xstatic int RTFcomment; 
  1075. Xstatic int RTFcenter;
  1076. Xstatic int RTFrightflush;
  1077. Xstatic int RTFheading;
  1078. X
  1079. Xstatic char ENCODING[STRING];
  1080. X
  1081. Xstatic int QPkeys;
  1082. X
  1083. Xchar *richtext();
  1084. Xchar *quoted_printable();
  1085. X
  1086. X
  1087. X/***************************************************************************/
  1088. X/*      FUNKTION  show()                               */
  1089. X/*  BESCHREIBUNG  Zeigt den Inhalt einer Datei an.                */
  1090. X/*     PARAMETER  fname    = Dateiname                                     */
  1091. X/*          maxlines = mehr Zeilen auf keinen Fall ausgeben          */
  1092. X/*          mode     = '> 99'  Ueberschrift einrechnen               */
  1093. X/*                   '= 99'  Reset (alle Parameter von "show")   */
  1094. X/*                   '=  0'  Kontinuierlich ausgeben             */
  1095. X/*     RUECKGABE  -1  =  Datei nicht gefunden                              */
  1096. X/***************************************************************************/
  1097. X
  1098. X#define LLL 80
  1099. X
  1100. Xint show(fname, maxlines, mode)
  1101. Xchar fname[];
  1102. Xint maxlines;
  1103. Xint mode;
  1104. X{
  1105. X  FILE *fp;
  1106. X
  1107. X  char s[LONGSTRING];
  1108. X  char o[LONGSTRING];
  1109. X  char t[STRING];
  1110. X  char CONTENT[STRING];
  1111. X  int c;
  1112. X  int ml;
  1113. X  int ret_status = 0;
  1114. X  int maxi = MAX_SCR_LINES;
  1115. X  int swing = 0;
  1116. X  int sl, ok;
  1117. X  int HEADER_lines = 0;
  1118. X  int HEADER_path = 0;
  1119. X  int HEADER_double = 0;
  1120. X
  1121. X  int FACE = 0;
  1122. X
  1123. X
  1124. X  if (mode > 99) {        /* HEADLINE */
  1125. X    mode -= 100;
  1126. X    maxi -= 2;
  1127. X    swing = 2;
  1128. X    morechen = 1;
  1129. X    seite = 1;
  1130. X  }
  1131. X  if (mode == 99) {        /* RESET */
  1132. X    show_more = 0;
  1133. X    seite = 1;
  1134. X    return 0;
  1135. X  }
  1136. X  fp = fopen(fname, "r");
  1137. X  if (fp == NULL) {
  1138. X    return -1;
  1139. X  }
  1140. X  ml = 0;
  1141. X  morechen = 0;
  1142. X
  1143. X  CONTENT[0] = '\0';
  1144. X  ENCODING[0] = '\0';
  1145. X  RTFcomment    = 0;
  1146. X  RTFcenter     = 0;
  1147. X  RTFrightflush = 0; 
  1148. X  RTFheading    = 0;
  1149. X
  1150. X  QPkeys     = 0;
  1151. X
  1152. X  sprintf(show_tmp, "%s/show%d", TMP, getpid());
  1153. X  page = fopen(show_tmp, "w");
  1154. X
  1155. X  if (mode != 2)
  1156. X    show_more = 0;
  1157. X  else
  1158. X    morechen = show_more;
  1159. X
  1160. X  if (show_more > maxi) show_more = 0;
  1161. X
  1162. X
  1163. X  while ((ml < maxlines) && (fgets(s, LONGSTRING, fp) != NULL)) {
  1164. X
  1165. X    if(SHORT_HEADER){
  1166. X        if((strcomp("Path: ", s) == 0) || (strcomp("Newsgroups: ", s) == 0)){
  1167. X            HEADER_path++;
  1168. X            continue;
  1169. X        }
  1170. X
  1171. X        if((HEADER_path != 0) && (HEADER_lines == 0)){
  1172. X
  1173. X            if(strcomp("From: ", s) == 0){
  1174. X                printf("%s %s", GBL01_MSG, strcopy(s, 6, strlen(s)));
  1175. X                fprintf(fp, "%s %s", GBL01_MSG, strcopy(s, 6, strlen(s)));
  1176. X                morechen++;
  1177. X            }
  1178. X            if(strcomp("Subject: ", s) == 0){
  1179. X                printf("%s %s", GBL03_MSG, strcopy(s, 9, strlen(s)));
  1180. X                fprintf(fp, "%s %s", GBL03_MSG, strcopy(s, 9, strlen(s)));
  1181. X                morechen++;
  1182. X            }        
  1183. X            if(strcomp("Date: ", s) == 0){
  1184. X                printf("%s %s\n", GBL02_MSG, strcopy(s, 6, strlen(s)));
  1185. X                fprintf(fp, "%s %s\n", GBL02_MSG, strcopy(s, 6, strlen(s)));
  1186. X                morechen++;
  1187. X            }
  1188. X            if(strlen(s) < 3){
  1189. X                HEADER_lines++;
  1190. X                morechen++;
  1191. X            }
  1192. X            continue;
  1193. X         }    
  1194. X    }
  1195. X    else{
  1196. X        if(HEADER_lines == 0){
  1197. X            sprintf(t, "%s %s", GBL01_MSG, X_MAIL_DEMON);
  1198. X            if(strcomp(t, s) == 0){
  1199. X                do{
  1200. X                    fgets(s, 250, fp);
  1201. X                }while(strcomp("From", s) != 0);
  1202. X                HEADER_double++;
  1203. X                ansi("md");
  1204. X            }
  1205. X            if((strcomp("Path:", s) == 0) || (strcomp("Newsgroups:", s) == 0) || (strcomp(GBL01_MSG, s) == 0)){
  1206. X                ansi("md");
  1207. X                HEADER_double++;
  1208. X            }    
  1209. X            if(strlen(s) < 3){
  1210. X                HEADER_lines++;
  1211. X                HEADER_double = 0;
  1212. X                ansi("me");
  1213. X            }            
  1214. X        }
  1215. X    }
  1216. X
  1217. X    if(strcomp("Content-Type:", s) == 0){
  1218. X        strcpy(CONTENT, (char *) strcopy(s, 14, 80));
  1219. X        if(strcomp("text/richtext", CONTENT) != 0) /* RTF etc. */
  1220. X             CONTENT[0] = '\0';
  1221. X    }
  1222. X    if(strcomp("Content-Transfer-Encoding:", s) == 0){
  1223. X        strcpy(ENCODING, (char *) strcopy(s, 27, 80));
  1224. X                
  1225. X    }
  1226. X    if(strcomp("Content-", s) == 0){
  1227. X        if((HEADER_lines != 0) || (ml < 2)) s[0] = '\0'; /* :-)) */
  1228. X    }
  1229. X        if(strcomp("X-Face:", s) == 0){
  1230. X        if(FACE == 0){
  1231. X            FACE++;
  1232. X        }
  1233. X    }
  1234. X    
  1235. X    sl = length(s);
  1236. X    while(sl > LLL){
  1237. X        strcpy(o, (char *) s);
  1238. X        sl = LLL; ok = 0;
  1239. X        while((sl > 0) && (ok == 0)){
  1240. X            if(s[sl] < 48){
  1241. X                ok = sl;
  1242. X            }
  1243. X            sl--;
  1244. X        }
  1245. X        s[ok] = '\0';
  1246. X        morechen++;
  1247. X#ifdef _MULTIMEDIA
  1248. X        if(strcomp("Quoted-Printable", ENCODING) == 0){
  1249. X            strcpy(s, (char *) quoted_printable(s));
  1250. X        }
  1251. X        if(CONTENT[0] == '\0'){
  1252. X            printf("%s\n", s);
  1253. X        }
  1254. X        else{
  1255. X            strcpy(s, (char *) richtext(s));
  1256. X            fprintf(page, "%s", s);
  1257. X        }
  1258. X#else
  1259. X        printf("%s\n", s);
  1260. X        fprintf(page, "%s\n", s);
  1261. X#endif
  1262. X        strcpy(s, (char *)bigcopy(o, ok, length(o)));
  1263. X        sl = length(s);
  1264. X        if(ok == 0){
  1265. X            sl = LLL;
  1266. X            printf("[SysBug \"show.c\"]");
  1267. X        }
  1268. X        if(s[0] == '\n') s[0] = '\0';
  1269. X    }
  1270. X    if(s[strlen(s)] == '\n') s[strlen(s)] == '\0'; 
  1271. X#ifdef _MULTIMEDIA
  1272. X    if(strcomp("Quoted-Printable", ENCODING) == 0){
  1273. X        strcpy(s, (char *) quoted_printable(s));
  1274. X    }
  1275. X    if(CONTENT[0] == '\0'){
  1276. X        printf("%s", s);
  1277. X    }
  1278. X    else{
  1279. X        strcpy(s, (char *) richtext(s));
  1280. X    }
  1281. X#else
  1282. X    printf("%s", s);
  1283. X#endif
  1284. X    fputs(s, page);
  1285. X    ml++;
  1286. X    morechen++;
  1287. X    if ((morechen >= maxi) && (mode > 0)) {
  1288. X        morechen = 0;
  1289. X        maxi += swing;
  1290. X        swing = 0;
  1291. X        fclose(page);
  1292. X        ret_status = more();
  1293. X        if (ret_status != 0) {
  1294. X            ml = maxlines + 9999;
  1295. X        }
  1296. X        else {
  1297. X            page = fopen(show_tmp, "w");
  1298. X            if(HEADER_double != 0){
  1299. X                ansi( "md" );
  1300. X            }
  1301. X        }
  1302. X    }
  1303. X  }
  1304. X  fclose(fp);
  1305. X
  1306. X  show_more = morechen;
  1307. X
  1308. X  if (page != NULL) fclose(page);
  1309. X  unlink(show_tmp);
  1310. X
  1311. X  /*            Experimental Use only !
  1312. X  if(FACE != 0){
  1313. X    faces( fname );
  1314. X  }
  1315. X  */
  1316. X
  1317. X  return (int) ret_status;
  1318. X}
  1319. X
  1320. X
  1321. X
  1322. X/***************************************************************************/
  1323. X/*      FUNKTION  more()                           */
  1324. X/*  BESCHREIBUNG  Erfragen ob weitergelesen werden soll, oder nicht.       */
  1325. X/*     PARAMETER  keine                                                 */
  1326. X/*     RUECKGABE  0  =  weiterlesen                                        */
  1327. X/*         -1  =  abbrechen                           */
  1328. X/***************************************************************************/
  1329. X
  1330. Xint more()
  1331. X{
  1332. X  char s[255];
  1333. X  char c;
  1334. X  int ok = 0;
  1335. X
  1336. XFIRST_TRY:
  1337. X
  1338. X  ansi("mr");
  1339. X  printf("                                                                               ");
  1340. X  printf("%c[%s] (?) > ", CR, SHO04_MSG);
  1341. X  ansi("me");
  1342. X
  1343. XSECOND_TRY:
  1344. X
  1345. X  c = getint();
  1346. X
  1347. X  if (c == '?') {
  1348. X    ansi("mr");
  1349. X    clearline();
  1350. X    printf("%c%s > ", CR, SHO05_MSG);
  1351. X    ansi("me");
  1352. X    goto SECOND_TRY;
  1353. X  }
  1354. X  if (c > 96) c -= 32;
  1355. X
  1356. X  if ((c == DEL) ||
  1357. X      (c == CTRL_D) ||
  1358. X      (c == CTRL_X) ||
  1359. X      (c == SHO06_MSG) ||
  1360. X      (c == SHO07_MSG))
  1361. X    ok = -1;
  1362. X
  1363. X  if ((c == SHO08_MSG) || (c == SHO09_MSG)) ok = 1;
  1364. X
  1365. X  if (c == SHO10_MSG) {
  1366. X    ansi("cl");
  1367. X    ansi("mr");
  1368. X    printf("                                                                               ");
  1369. X    printf("%c%s\n", CR, SHO11_MSG);
  1370. X    ansi("me");    
  1371. X    page = fopen(show_tmp, "r");
  1372. X    if (page != NULL) {
  1373. X        while (fgets(s, 250, page) != NULL) {
  1374. X            printf("%s", s);
  1375. X        }
  1376. X        fclose(page);
  1377. X    }
  1378. X    goto FIRST_TRY;
  1379. X  }
  1380. X  if(ok != 1){    
  1381. X      if (USER.more == 3) {
  1382. X        clearline();
  1383. X      }
  1384. X      else {
  1385. X        if(USER.more != 0){
  1386. X            ansi("cl");
  1387. X            seite++;
  1388. X            sprintf(s, "%s^-  [%s %d]", headinfo, SHO12_MSG, seite);
  1389. X            headline(s);
  1390. X        }
  1391. X        else printf("\n\n");
  1392. X      }
  1393. X  }
  1394. X  else{    
  1395. X    clearline();
  1396. X  }
  1397. X
  1398. X  return (int) ok;
  1399. X}
  1400. X
  1401. X
  1402. X
  1403. X/***************************************************************************/
  1404. X/*      FUNKTION  richtext()                           */
  1405. X/*  BESCHREIBUNG  RTF ... die Zukunft kommt bestimmt :-)))           */
  1406. X/*     PARAMETER  Zeile im RT-Format                                       */
  1407. X/*     RUECKGABE  Zeile im ANSI-Format                       */
  1408. X/***************************************************************************/
  1409. X
  1410. Xchar *richtext( s )
  1411. Xchar s[];
  1412. X{
  1413. X  char rt[STRING];
  1414. X  char line[LONGSTRING];
  1415. X  char space[LONGSTRING];
  1416. X  int i = 0, j;
  1417. X  int l = 0;
  1418. X  int not;
  1419. X  int keys = 0;
  1420. X
  1421. X  while(s[i] != '\0'){
  1422. X    if(s[i] != '<'){
  1423. X        if(RTFcomment == 0){
  1424. X            /* RTF-Konform:
  1425. X            if(s[i] == '\n')
  1426. X                line[l] = ' ';
  1427. X            else
  1428. X                line[l] = s[i];
  1429. X            NICHT RTF-Konform: */
  1430. X
  1431. X            line[l] = s[i];
  1432. X            l++;
  1433. X            keys++;
  1434. X        }
  1435. X    }
  1436. X    else{
  1437. X        line[l] = '\0';
  1438. X        not = 0;
  1439. X        i++;
  1440. X        j = i;
  1441. X        while((s[j] != '>') && (s[j] != '\0')){
  1442. X            if(s[j] == '/'){
  1443. X                i++;
  1444. X                not++;
  1445. X            }
  1446. X            j++;
  1447. X        }
  1448. X        strcpy(rt, (char *) strcopy(s, i, (j-1)));
  1449. X
  1450. X        if(not == 0){
  1451. X            if(strcomp("Bold",       rt) == 0) 
  1452. X                strcat( line, (char *) termansi( "md" ));
  1453. X            if(strcomp("Italic",     rt) == 0) 
  1454. X                strcat( line, (char *) termansi( "mr" ));
  1455. X            if(strcomp("Bigger",     rt) == 0) 
  1456. X                strcat( line, (char *) termansi( "md" ));
  1457. X            if(strcomp("Underline",  rt) == 0) 
  1458. X                strcat( line, (char *) termansi( "mr" ));
  1459. X            if(strcomp("Paragraph",  rt) == 0){
  1460. X                strcat( line, "\n\n");
  1461. X                morechen += 2;
  1462. X            }
  1463. X            if(strcomp("Comment",    rt) == 0)
  1464. X                RTFcomment++;
  1465. X            if(strcomp("Center",     rt) == 0)
  1466. X                RTFcenter++;
  1467. X            if(strcomp("FlushRight", rt) == 0)
  1468. X                RTFrightflush++;
  1469. X            if(strcomp("Heading",   rt) == 0){
  1470. X                RTFheading++;
  1471. X                strcat( line, (char *) termansi( "md" ));
  1472. X            }
  1473. X        }
  1474. X        else{
  1475. X            if(strcomp("Bold",       rt) == 0) 
  1476. X                strcat( line, (char *) termansi( "me" ));
  1477. X            if(strcomp("Italic",     rt) == 0) 
  1478. X                strcat( line, (char *) termansi( "me" ));
  1479. X            if(strcomp("Bigger",     rt) == 0) 
  1480. X                strcat( line, (char *) termansi( "me" ));
  1481. X            if(strcomp("Underline",  rt) == 0) 
  1482. X                strcat( line, (char *) termansi( "me" ));
  1483. X            if(strcomp("Paragraph",  rt) == 0){
  1484. X                strcat( line, "\n\n");
  1485. X                morechen += 2;
  1486. X            }
  1487. X            if(strcomp("Comment",    rt) == 0)
  1488. X                RTFcomment = 0;
  1489. X            if(strcomp("Center",     rt) == 0)
  1490. X                RTFcenter = 9999;
  1491. X            if(strcomp("FlushRight", rt) == 0)
  1492. X                RTFrightflush = 9999;
  1493. X            if(strcomp("Heading",   rt) == 0){
  1494. X                RTFheading = 9999;
  1495. X                strcat( line, (char *) termansi( "me" ));
  1496. X            }
  1497. X        }
  1498. X
  1499. X        if(strcomp("LT", rt) == 0) 
  1500. X            strcat( line, (char *) "<" );
  1501. X
  1502. X        /* NICHT RTF-Konform:
  1503. X        if(strcomp("NL", rt) == 0){ 
  1504. X            strcat( line, (char *)  "\n" );
  1505. X            morechen++;
  1506. X        }
  1507. X        */
  1508. X
  1509. X        if(strcomp("NP", rt) == 0) 
  1510. X            strcat( line, (char *) "\f" );
  1511. X        if(RTFcomment == 0){
  1512. X            l = strlen(line);
  1513. X        }
  1514. X        i = j;
  1515. X    }
  1516. X    i++;
  1517. X  }
  1518. X  line[l] = '\0';
  1519. X  strcpy(space, (char *) "                                                                              ");    
  1520. X
  1521. X  if((RTFcenter != 0) || (RTFheading != 0)){
  1522. X    i = (79 - keys) / 2; 
  1523. X    if(i <  0) i = 0;
  1524. X    if(i > 79) i = 0;
  1525. X    space[i] = '\0';
  1526. X    strcat(space, (char *) line);
  1527. X    strcpy(line, (char *) space);
  1528. X  }
  1529. X  if(RTFrightflush != 0){
  1530. X    i = 79 - keys;
  1531. X    space[i] = '\0';
  1532. X    strcat(space, (char *) line);
  1533. X    strcpy(line, (char *) space);
  1534. X  }
  1535. X  
  1536. X  printf("%s", line);
  1537. X
  1538. X  if(RTFcenter     == 9999) RTFcenter = 0;
  1539. X  if(RTFrightflush == 9999) RTFrightflush = 0;
  1540. X  if(RTFheading    == 9999) RTFheading = 0;
  1541. X
  1542. X  return (char *) line;
  1543. X}
  1544. X
  1545. X
  1546. X
  1547. X
  1548. X/***************************************************************************/
  1549. X/*      FUNKTION  quoted_printable()                       */
  1550. X/*  BESCHREIBUNG  Transfer-Encoding: Regel #1 bis #5               */
  1551. X/*     PARAMETER  Zeile im RT-Format                                       */
  1552. X/*     RUECKGABE  Decodierte Zeile                       */
  1553. X/***************************************************************************/
  1554. X
  1555. Xchar *quoted_printable( s )
  1556. Xchar s[];
  1557. X{
  1558. X  char line[LONGSTRING];
  1559. X  char t[STRING];
  1560. X  int i = 0, l = 0, p = 0;
  1561. X
  1562. X  while(s[i] != '\0'){
  1563. X    if(s[i] == '='){
  1564. X        if(s[(i+1)] == '\n'){
  1565. X            i++;
  1566. X        }
  1567. X        else{
  1568. X            /*
  1569. X            sprintf(t, "0x%s", strcopy(s, (i+1), (i+2)));
  1570. X            line[l] = atoi(t);
  1571. X            l++;
  1572. X            */
  1573. X            i += 2;
  1574. X        }
  1575. X    }
  1576. X    else{
  1577. X        line[l] = s[i];
  1578. X        l++;
  1579. X        QPkeys++;
  1580. X        if(s[i] == '\n') QPkeys = 0;
  1581. X    }
  1582. X
  1583. X    if(QPkeys >= 75){
  1584. X        p = l;
  1585. X        while((line[p] != ' ') && (p > 0)){
  1586. X            p--;
  1587. X        }
  1588. X        line[p] = '\n';
  1589. X        QPkeys = 0;
  1590. X    }
  1591. X    i++;
  1592. X  }
  1593. X  line[l] = '\0';
  1594. X
  1595. X  return (char *) line;
  1596. X}
  1597. END_OF_FILE
  1598.   if test 11749 -ne `wc -c <'src/show.c'`; then
  1599.     echo shar: \"'src/show.c'\" unpacked with wrong size!
  1600.   fi
  1601.   # end of 'src/show.c'
  1602. fi
  1603. if test -f 'src/tools.c' -a "${1}" != "-c" ; then 
  1604.   echo shar: Will not clobber existing file \"'src/tools.c'\"
  1605. else
  1606.   echo shar: Extracting \"'src/tools.c'\" \(22598 characters\)
  1607.   sed "s/^X//" >'src/tools.c' <<'END_OF_FILE'
  1608. X/***************************************************************************/
  1609. X/*        PROGRAMM  ix/Mbox                           */
  1610. X/*             DATEI  tools.c                           */
  1611. X/*        FUNKTIONEN  whoami(), tty(), stripped(), upcased(), length(),    */
  1612. X/*              strcopy(), strcomp(), ansi(), mydate(), mytime(),    */
  1613. X/*                  crypted(), dateconv(), datereconv(), timeconv(),     */
  1614. X/*              timereconv(), maybe_locked(), num_stripped(),        */
  1615. X/*              rename(), headline(), ttyna(), bigcopy(), mblock(),  */
  1616. X/*              mbunlock(), shortname(), clearline(), isin()       */
  1617. X/*              termansi()                       */
  1618. X/*             AUTOR  vs (Volker Schuermann/MINIX-Version)           */
  1619. X/*  LETZTE AENDERUNG  28.05.1992                       */
  1620. X/***************************************************************************/
  1621. X
  1622. X#include <sys/types.h>
  1623. X#include <sys/stat.h>
  1624. X#include <stdio.h>
  1625. X#include <unistd.h>
  1626. X#include <time.h>
  1627. X#include <pwd.h>
  1628. X
  1629. X#ifdef _SYS7
  1630. X#include <termcap.h>
  1631. X#endif
  1632. X
  1633. X
  1634. X#ifdef _MBOX
  1635. X#define EXTERN
  1636. X#include "mbox.h"
  1637. X#else
  1638. X#define VERSION "TOOLS.C"
  1639. X#define CR 13
  1640. X#define TOL01_MSG    "Sonntag"
  1641. X#define TOL02_MSG    "Montag"
  1642. X#define TOL03_MSG    "Dienstag"
  1643. X#define TOL04_MSG    "Mittwoch"
  1644. X#define TOL05_MSG    "Donnerstag"
  1645. X#define TOL06_MSG    "Freitag"
  1646. X#define TOL07_MSG    "Samstag"
  1647. X#define TOL08_MSG    "Momentchen"
  1648. X#endif
  1649. X#ifdef STRING
  1650. X#undef STRING
  1651. X#endif
  1652. X
  1653. X#ifdef LONGSTRING
  1654. X#undef LONGSTRING
  1655. X#endif
  1656. X
  1657. X#define STRING 81
  1658. X#define LONGSTRING 256
  1659. X
  1660. Xchar headinfo[STRING];
  1661. X
  1662. X
  1663. X/***************************************************************************/
  1664. X/*      FUNKTION  whoami()                           */
  1665. X/*  BESCHREIBUNG  Name des eigenen SH-Accounts.                    */
  1666. X/*     PARAMETER  keine                                                       */
  1667. X/*     RUECKGABE  siehe BESCHREIBUNG                                       */
  1668. X/***************************************************************************/
  1669. X
  1670. Xchar *whoami()
  1671. X{
  1672. X  struct passwd *pw_entry;
  1673. X
  1674. X  pw_entry = getpwuid(getuid());
  1675. X
  1676. X  if (pw_entry->pw_uid < 0) return (char *) "OOPS";
  1677. X
  1678. X  return (char *) (pw_entry->pw_name);
  1679. X}
  1680. X
  1681. X
  1682. X
  1683. X
  1684. X/***************************************************************************/
  1685. X/*      FUNKTION  stripped()                           */
  1686. X/*  BESCHREIBUNG  STRING von fuehrenden und folgenden Leerzeichen be-      */
  1687. X/*          freien.                                                  */
  1688. X/*     PARAMETER  st  =  STRING inclusive Leerzeichen                      */
  1689. X/*     RUECKGABE  STRING exclusive Leerzeichen                             */
  1690. X/***************************************************************************/
  1691. X
  1692. Xchar *stripped(st)
  1693. Xchar st[];
  1694. X{
  1695. X  static char s[STRING];
  1696. X
  1697. X  int i = 0, a = 0, b = 0, c = 0;
  1698. X
  1699. X  if (st[0] == '\0') return (char *) '\0';
  1700. X  if ((st[0] == 10) || (st[0] == 13)) return (char *) " ";
  1701. X
  1702. X  strcpy(s, st);
  1703. X
  1704. X  while ((s[i] < 33) && (s[i] != '\0')) i++;
  1705. X  a = i;
  1706. X  while (s[a] != '\0') a++;
  1707. X  a--;
  1708. X  while (s[a] < 33) a--;
  1709. X
  1710. X  for (c = i; c <= a; c++) {
  1711. X    s[b] = s[c];
  1712. X    b++;
  1713. X  }
  1714. X  s[b] = '\0';
  1715. X
  1716. X  return (char *) s;
  1717. X}
  1718. X
  1719. X
  1720. X
  1721. X
  1722. X
  1723. X/***************************************************************************/
  1724. X/*      FUNKTION  upcased()                           */
  1725. X/*  BESCHREIBUNG  Zeichen eines STRING auf Grossbuchstaben umstellen.       */
  1726. X/*     PARAMETER  st  =  STRING mit Gross-/Kleinbuchstaben           */
  1727. X/*     RUECKGABE  STRING in Grossbuchstaben                                */
  1728. X/***************************************************************************/
  1729. X
  1730. Xchar *upcased(st)
  1731. Xchar st[];
  1732. X{
  1733. X  static char s[STRING];
  1734. X
  1735. X  int i = 0;
  1736. X
  1737. X
  1738. X  strcpy(s, st);
  1739. X
  1740. X  while (s[i] != '\0') {
  1741. X    if (s[i] > 96) s[i] -= 32;
  1742. X    i++;
  1743. X  }
  1744. X
  1745. X  return (char *) s;
  1746. X}
  1747. X
  1748. X
  1749. X
  1750. X
  1751. X
  1752. X/***************************************************************************/
  1753. X/*      FUNKTION  length()                           */
  1754. X/*  BESCHREIBUNG  Laenge eines STRING ermitteln (ja, ja, "strlen" ...)       */
  1755. X/*     PARAMETER  st  =  STRING                                            */
  1756. X/*     RUECKGABE  Laenge des STRING                                        */
  1757. X/***************************************************************************/
  1758. X
  1759. Xint length(st)
  1760. Xchar st[];
  1761. X{
  1762. X  int i = 0;
  1763. X
  1764. X  while (st[i] != '\0') i++;
  1765. X
  1766. X  return i;
  1767. X}
  1768. X
  1769. X
  1770. X
  1771. X
  1772. X/***************************************************************************/
  1773. X/*      FUNKTION  strcopy()                           */
  1774. X/*  BESCHREIBUNG  Einen TeilSTRING aus einem STRING herausschneiden.       */
  1775. X/*     PARAMETER  st  =  STRING                                            */
  1776. X/*          v   =  von Zeichen (1. Zeichen = 0 !!!)           */
  1777. X/*          b   =  bis Zeichen                           */
  1778. X/*     RUECKGABE  TeilSTRING                                               */
  1779. X/***************************************************************************/
  1780. X
  1781. Xchar *strcopy(st, v, b)
  1782. Xchar st[];
  1783. Xint v, b;
  1784. X{
  1785. X  static char s[STRING];
  1786. X
  1787. X  int i = 0, j;
  1788. X
  1789. X
  1790. X  strcpy(s, st);
  1791. X
  1792. X  if (length(s) < b) b = length(s);
  1793. X
  1794. X  for (j = v; j <= b; j++) {
  1795. X    s[i] = s[j];
  1796. X    i++;
  1797. X  }
  1798. X  s[i] = '\0';
  1799. X
  1800. X  return (char *) s;
  1801. X}
  1802. X
  1803. X
  1804. X/***************************************************************************/
  1805. X/*      FUNKTION  bigcopy()                           */
  1806. X/*  BESCHREIBUNG  Einen TeilLONGSTRING aus LONGSTRING herausschneiden.     */
  1807. X/*     PARAMETER  st  =  LONGSTRING                                        */
  1808. X/*          v   =  von Zeichen (1. Zeichen = 0 !!!)           */
  1809. X/*          b   =  bis Zeichen                           */
  1810. X/*     RUECKGABE  TeilLONGSTRING                                           */
  1811. X/***************************************************************************/
  1812. X
  1813. Xchar *bigcopy(st, v, b)
  1814. Xchar st[];
  1815. Xint v, b;
  1816. X{
  1817. X  static char s[LONGSTRING];
  1818. X
  1819. X  int i = 0, j;
  1820. X
  1821. X
  1822. X  strcpy(s, st);
  1823. X
  1824. X  if (length(s) < b) b = length(s);
  1825. X
  1826. X  for (j = v; j <= b; j++) {
  1827. X    s[i] = s[j];
  1828. X    i++;
  1829. X  }
  1830. X  s[i] = '\0';
  1831. X
  1832. X  return (char *) s;
  1833. X}
  1834. X
  1835. X
  1836. X
  1837. X
  1838. X/***************************************************************************/
  1839. X/*      FUNKTION  strcomp()                           */
  1840. X/*  BESCHREIBUNG  Zwei STRINGs vergleichen. Und zwar genau solange, bis    */
  1841. X/*          bei STRING1 das Ende ('\0') erreicht ist !!!             */
  1842. X/*                Gross-/Kleinschreibung wird dabei IGNORIERT !!!          */
  1843. X/*     PARAMETER  st  =  STRING1                                           */
  1844. X/*              tt  =  STRING2                                           */
  1845. X/*     RUECKGABE  Anzahl der UNGLEICHEN Zeichen                            */
  1846. X/***************************************************************************/
  1847. X
  1848. Xint strcomp(s, t)
  1849. Xchar s[], t[];
  1850. X{
  1851. X  int i = 0, a = 0;
  1852. X  int s1, t1;
  1853. X
  1854. X  while (s[i] != '\0') {
  1855. X    s1 = s[i];
  1856. X    t1 = t[i];
  1857. X    if ((t1 > 96) && (t1 < 123)) t1 -= 32;
  1858. X    if ((s1 > 96) && (s1 < 123)) s1 -= 32;
  1859. X    if (t1 != s1) a++;
  1860. X    i++;
  1861. X  }
  1862. X  return a;
  1863. X}
  1864. X
  1865. X
  1866. X/***************************************************************************/
  1867. X/*      FUNKTION  ansi()                           */
  1868. X/*  BESCHREIBUNG  TERMCAP-Eintrag fuer ein Terminal in "buf" einlesen,     */
  1869. X/*          und angeforderte Sequenzen finden & ausgeben.            */
  1870. X/*     PARAMETER  code  =  'INIT'  =  Eintrag holen und speichern       */
  1871. X/*                         =  Sequenz finden & ausgeben            */
  1872. X/*     RUECKGABE  -1  =  Terminal nicht gefunden                           */
  1873. X/*           1  =  Sequenz nicht gefunden                   */
  1874. X/***************************************************************************/
  1875. X
  1876. Xstatic char buf[1024];
  1877. X
  1878. Xint ansi(code)
  1879. Xchar code[];
  1880. X{
  1881. X  char *getenv();
  1882. X  static char s[STRING];
  1883. X  char *p = s;
  1884. X  char *term;
  1885. X
  1886. X#ifdef _MBOX
  1887. X  term = TERMINAL;
  1888. X#else
  1889. X  term = getenv("TERM");
  1890. X#endif
  1891. X
  1892. X  if (strcomp("INIT", code) == 0) {
  1893. X    if (tgetent(buf, term) != 1) return -1;
  1894. X  }
  1895. X  if (tgetstr(code, &p) == 0) return 1;
  1896. X
  1897. X  printf("%s", s);
  1898. X
  1899. X  return 0;
  1900. X}
  1901. X
  1902. Xchar *termansi(code)
  1903. Xchar code[];
  1904. X{
  1905. X  char *getenv();
  1906. X  char s[STRING];
  1907. X  char *p = s;
  1908. X  char *term;
  1909. X
  1910. X#ifdef _MBOX
  1911. X  term = TERMINAL;
  1912. X#else
  1913. X  term = getenv("TERM");
  1914. X#endif
  1915. X
  1916. X  if (strcomp("INIT", code) == 0) {
  1917. X    if (tgetent(buf, term) != 1) return (char *) '\0';
  1918. X  }
  1919. X  if (tgetstr(code, &p) == 0) return (char *) '\0';
  1920. X
  1921. X  return (char *) s;
  1922. X}
  1923. X
  1924. X
  1925. X
  1926. X/***************************************************************************/
  1927. X/*      FUNKTION  mydate()                           */
  1928. X/*  BESCHREIBUNG  Tagesdatum liefern.                         */
  1929. X/*     PARAMETER  mode  =  0  =  tt.mm.yyyy                   */
  1930. X/*               1  =  tt.mm.yy                   */
  1931. X/*               2  =  ttt                       */    
  1932. X/*     RUECKGABE  Datum                                                    */
  1933. X/***************************************************************************/
  1934. X
  1935. X#define TZS      1
  1936. X
  1937. Xchar *mydate(mode)
  1938. Xint mode;
  1939. X{
  1940. X  struct tm *tp;
  1941. X  time_t tt;
  1942. X  char wt[8][11];
  1943. X
  1944. X  static char s[STRING];
  1945. X
  1946. X#ifndef _MBOX
  1947. X  strcpy(wt[0], "Sonntag");
  1948. X  strcpy(wt[1], "Montag");
  1949. X  strcpy(wt[2], "Dienstag");
  1950. X  strcpy(wt[3], "Mittwoch");
  1951. X  strcpy(wt[4], "Donnerstag");
  1952. X  strcpy(wt[5], "Freitag");
  1953. X  strcpy(wt[6], "Samstag");
  1954. X#else
  1955. X  strcpy(wt[0], TOL01_MSG);
  1956. X  strcpy(wt[1], TOL02_MSG);
  1957. X  strcpy(wt[2], TOL03_MSG);
  1958. X  strcpy(wt[3], TOL04_MSG);
  1959. X  strcpy(wt[4], TOL05_MSG);
  1960. X  strcpy(wt[5], TOL06_MSG);
  1961. X  strcpy(wt[6], TOL07_MSG);
  1962. X#endif
  1963. X
  1964. X  time(&tt);
  1965. X  tp = localtime(&tt);
  1966. X  if (mode == 0) {
  1967. X    sprintf(s, "%02.2d.%02.2d.%04.4d", tp->tm_mday, tp->tm_mon + TZS, 1900 + tp->tm_year);
  1968. X  }
  1969. X  if (mode == 1) {
  1970. X    sprintf(s, "%02.2d.%02.2d.%02.2d", tp->tm_mday, tp->tm_mon + TZS, tp->tm_year);
  1971. X  }
  1972. X  if (mode == 2) {
  1973. X    sprintf(s, "%s", wt[tp->tm_wday]);
  1974. X  }
  1975. X  return (char *) s;
  1976. X}
  1977. X
  1978. X
  1979. X
  1980. X
  1981. X/***************************************************************************/
  1982. X/*      FUNKTION  mytime()                           */
  1983. X/*  BESCHREIBUNG  Tageszeit liefern.                         */
  1984. X/*     PARAMETER  mode  =  0  =  hh:mm:ss                   */
  1985. X/*               1  =  hh:mm                        */
  1986. X/*     RUECKGABE  Zeit                                                     */
  1987. X/***************************************************************************/
  1988. X
  1989. Xchar *mytime(mode)
  1990. Xint mode;
  1991. X{
  1992. X  struct tm *tp;
  1993. X  time_t tt;
  1994. X
  1995. X  static char s[STRING];
  1996. X
  1997. X  time(&tt);
  1998. X  tp = localtime(&tt);
  1999. X  sprintf(s, "%02.2d:%02.2d:%02.2d", tp->tm_hour, tp->tm_min, tp->tm_sec);
  2000. X
  2001. X  if (mode == 1) s[5] = '\0';
  2002. X
  2003. X  return (char *) s;
  2004. X}
  2005. X
  2006. X
  2007. X
  2008. X
  2009. X/***************************************************************************/
  2010. X/*      FUNKTION  crypted()                           */
  2011. X/*  BESCHREIBUNG  STRING verschluesseln und zurueckgeben.           */
  2012. X/*     PARAMETER  s  =  STRING                                             */
  2013. X/*     RUECKGABE  Verschluesselter STRING                                  */
  2014. X/***************************************************************************/
  2015. X
  2016. Xchar *crypted(s)
  2017. Xchar s[];
  2018. X{
  2019. X  static char t[STRING];
  2020. X  int i, a;
  2021. X
  2022. X
  2023. X  strcpy(t, s);
  2024. X  i = 0;
  2025. X  a = 2;
  2026. X  while (t[i] != '\0') {
  2027. X    t[i] = (t[i] / a) + 32;
  2028. X    i++;
  2029. X    a++;
  2030. X    if (a > 5) a = 2;
  2031. X  }
  2032. X
  2033. X  return (char *) t;
  2034. X}
  2035. X
  2036. X
  2037. X
  2038. X
  2039. X/***************************************************************************/
  2040. X/*      FUNKTION  dateconv()                            */
  2041. X/*  BESCHREIBUNG  Datum (STRING) in Datum (LONG) wandeln.           */
  2042. X/*     PARAMETER  d  =  Datum (STRING)                                     */
  2043. X/*     RUECKGABE  Datum (LONG)                                             */
  2044. X/***************************************************************************/
  2045. X
  2046. Xlong dateconv(d)
  2047. Xchar d[];
  2048. X{
  2049. X  char s[STRING];
  2050. X  int a, b, i;
  2051. X
  2052. X
  2053. X  strcpy(s, (char *) strcopy(d, 0, 1));
  2054. X  a = atoi(s);
  2055. X  strcpy(s, (char *) strcopy(d, 3, 4));
  2056. X  b = atoi(s);
  2057. X  strcpy(s, (char *) strcopy(d, 6, 9));
  2058. X  i = atoi(s);
  2059. X  if (i < 1900) i += 1900;
  2060. X
  2061. X  sprintf(s, "%4.4d%02.2d%02.2d", i, b, a);
  2062. X
  2063. X  return atol(s);
  2064. X}
  2065. X
  2066. X
  2067. X
  2068. X/***************************************************************************/
  2069. X/*      FUNKTION  datereconv()                            */
  2070. X/*  BESCHREIBUNG  Datum (LONG) in Datum (STRING) wandeln.           */
  2071. X/*     PARAMETER  l  =  Datum (LONG)                                       */
  2072. X/*     RUECKGABE  Datum (STRING)                                           */
  2073. X/***************************************************************************/
  2074. X
  2075. Xchar *datereconv(l)
  2076. Xlong l;
  2077. X{
  2078. X  static char s[STRING];
  2079. X  static char t[STRING];
  2080. X
  2081. X
  2082. X  if (l < 19000000)
  2083. X    sprintf(s, "%ld", 1900000L + l);
  2084. X  else
  2085. X    sprintf(s, "%ld", l);
  2086. X
  2087. X  strcpy(t, (char *) strcopy(s, 6, 7));
  2088. X  strcat(t, ".");
  2089. X  strcat(t, (char *) strcopy(s, 4, 5));
  2090. X  strcat(t, ".");
  2091. X  strcat(t, (char *) strcopy(s, 0, 3));
  2092. X
  2093. X  return (char *) t;
  2094. X}
  2095. X
  2096. X
  2097. X
  2098. X/***************************************************************************/
  2099. X/*      FUNKTION  timeconv()                            */
  2100. X/*  BESCHREIBUNG  Zeit (STRING) in Zeit (LONG) wandeln.               */
  2101. X/*     PARAMETER  t  =  Zeit (STRING)                                      */
  2102. X/*     RUECKGABE  Zeit (LONG)                                              */
  2103. X/***************************************************************************/
  2104. X
  2105. Xint timeconv(t)
  2106. Xchar t[];
  2107. X{
  2108. X  char s[STRING];
  2109. X  int i = 0;
  2110. X
  2111. X
  2112. X  strcpy(s, (char *) strcopy(t, 0, 1));
  2113. X  i = 100 * atoi(s);
  2114. X  strcpy(s, (char *) strcopy(t, 3, 4));
  2115. X  i += atoi(s);
  2116. X
  2117. X  return i;
  2118. X}
  2119. X
  2120. X
  2121. X
  2122. X
  2123. X/***************************************************************************/
  2124. X/*      FUNKTION  timereconv()                            */
  2125. X/*  BESCHREIBUNG  Zeit (LONG) in Zeit (STRING) wandeln.               */
  2126. X/*     PARAMETER  i  =  Zeit (LONG)                                        */
  2127. X/*     RUECKGABE  Zeit (STRING)                                            */
  2128. X/***************************************************************************/
  2129. X
  2130. Xchar *timereconv(i)
  2131. Xint i;
  2132. X{
  2133. X  static char s[STRING];
  2134. X  static char t[STRING];
  2135. X
  2136. X
  2137. X  if (i < 10000)
  2138. X    sprintf(s, "%04.4d00", i);
  2139. X  else
  2140. X    sprintf(s, "%06.6d", i);
  2141. X
  2142. X  strcpy(t, (char *) strcopy(s, 0, 1));
  2143. X  strcat(t, ":");
  2144. X  strcat(t, (char *) strcopy(s, 2, 3));
  2145. X  strcat(t, ":");
  2146. X  strcat(t, (char *) strcopy(s, 4, 5));
  2147. X
  2148. X  return (char *) t;
  2149. X}
  2150. X
  2151. X
  2152. X
  2153. X/***************************************************************************/
  2154. X/*      FUNKTION  shortname()                            */
  2155. X/*  BESCHREIBUNG  Wandelt lange Namen (NGs) ins 14-Zeichenformat, um Ver-  */
  2156. X/*                Wechslungen zu vermeiden:                   */
  2157. X/*                                       */
  2158. X/*              comp.protocols.tcp-ip.sources.wanted           */
  2159. X/*                =>  com0ces.wanted                       */
  2160. X/*                                               */
  2161. X/*     PARAMETER  longname : langer Name                                   */
  2162. X/*                                       */
  2163. X/*                                          */
  2164. X/*     RUECKGABE  s : kurzer Name                                          */
  2165. X/***************************************************************************/
  2166. X
  2167. Xchar *shortname( longname )
  2168. Xchar longname[];
  2169. X{
  2170. X  char s[STRING];
  2171. X  char t[STRING];
  2172. X
  2173. X  int i = 0, j = 0;
  2174. X
  2175. X  strcpy(s, longname);
  2176. X
  2177. X  strcpy(t, longname);
  2178. X
  2179. X  while(s[i] != '\0'){
  2180. X    if(s[i] == '/') j = i + 1;
  2181. X    i++;
  2182. X  }
  2183. X
  2184. X  i = strlen(t);
  2185. X
  2186. X  if((i - j) < 15) return (char *) s;
  2187. X
  2188. X  s[j + 3] = '0'; s[j + 4] = '\0';
  2189. X  strcat(s, (char *) strcopy(t, (i-10), i));
  2190. X
  2191. X  return (char *) s;
  2192. X}
  2193. X
  2194. X
  2195. X
  2196. X
  2197. X
  2198. X/***************************************************************************/
  2199. X/*      FUNKTION  maybe_locked()                       */
  2200. X/*  BESCHREIBUNG  Um sicherzustellen das eine Datei, die eigentlich vor-   */
  2201. X/*          handen sein MUSS, wirklich nicht da ist (und nicht nur   */
  2202. X/*          gerade von einem anderen Task benutzt wird), verzoegert  */
  2203. X/*          diese Funktion die Fehlermeldung um eine festgelegte     */
  2204. X/*          Zeitspanne.                                              */
  2205. X/*     PARAMETER  name  =  Dateiname                           */
  2206. X/*          mode  =  Zugriffsmodus (sollte NICHT verwendet werden !) */
  2207. X/*     RUECKGABE   0    =  Datei erreichbar                   */
  2208. X/*          -1    =  Datei nicht verfuegbar               */
  2209. X/***************************************************************************/
  2210. X
  2211. Xint maybe_locked(name, mode)
  2212. Xchar name[], mode[];
  2213. X{
  2214. X  FILE *fp;
  2215. X  int i = 0, LCK = 0;
  2216. X  char s[STRING];
  2217. X
  2218. X  sprintf(s, "%s.LCK", name);
  2219. X
  2220. X#ifndef _LONGNAMES
  2221. X  strcpy(s, (char *) shortname(s));
  2222. X#endif
  2223. X
  2224. X  TRY_TWICE:
  2225. X
  2226. X  fp = NULL;
  2227. X
  2228. X  do {
  2229. X    if(fp != NULL) fclose(fp);
  2230. X    fp = fopen(s, "r");
  2231. X    i++;
  2232. X    if (fp != NULL) {
  2233. X        if(i == 1) printf("%c%s ", CR, TOL08_MSG);
  2234. X        printf(".");
  2235. X        sleep(3);
  2236. X    }
  2237. X  } while ((i < 8) && (fp != 0));
  2238. X
  2239. X  if(fp != 0){
  2240. X    fclose(fp);
  2241. X#ifdef _MBOX
  2242. X    mbunlock(name);  /* <--- DAS IST NATUERLICH NICHT KORREKT !!! */
  2243. X    goto TRY_TWICE;  /* <--- DAS AUCH NICHT !!! */
  2244. X    nerror("tools.c", 566, "maybe_locked", "Datei gesperrt", name);    
  2245. X#else
  2246. X    printf("\n\nDatei >>%s<< gesperrt !!!\n\n", name);
  2247. X#endif
  2248. X    exit( -1 );
  2249. X  }
  2250. X
  2251. X  i = 0;
  2252. X
  2253. X  do {
  2254. X    fp = fopen(name, "r");    /* "r" => "mode", aber VORSICHT ! */
  2255. X    i++;
  2256. X    if (fp == NULL) {
  2257. X        if(i == 1) printf("%c%s ", CR, TOL08_MSG);    
  2258. X        printf(".");
  2259. X        sync();
  2260. X        sleep(3);
  2261. X    }
  2262. X  } while ((i < 5) && (fp == NULL));
  2263. X
  2264. X  if (fp == NULL) return -1;
  2265. X
  2266. X  fclose(fp);
  2267. X  return 0;
  2268. X}
  2269. X
  2270. X
  2271. X
  2272. X
  2273. X
  2274. X/***************************************************************************/
  2275. X/*      FUNKTION  num_stripped()                       */
  2276. X/*  BESCHREIBUNG  Entfernt alle Ziffern aus STRING.               */
  2277. X/*     PARAMETER  s  =  STRING (incl. Ziffern)                   */
  2278. X/*     RUECKGABE  STRING (excl. Ziffern)                   */
  2279. X/***************************************************************************/
  2280. X
  2281. Xchar *numstripped(s)
  2282. Xchar s[];
  2283. X{
  2284. X  static char t[STRING];
  2285. X  int i = 0, a = 0;
  2286. X
  2287. X  while (s[i] != '\0') {
  2288. X    if (((s[i] > 64) && (s[i] < 127)) || (s[i] == ' ') || (s[i] == '-')) {
  2289. X        t[a] = s[i];
  2290. X        a++;
  2291. X    }
  2292. X    i++;
  2293. X  }
  2294. X  t[a] = '\0';
  2295. X
  2296. X  return (char *) t;
  2297. X}
  2298. X
  2299. X
  2300. X
  2301. X
  2302. X/***************************************************************************/
  2303. X/*      FUNKTION  rename()                           */
  2304. X/*  BESCHREIBUNG  Benennt Datei1 in Datei2 um (ok, gelogen ... Datei1 wird */
  2305. X/*          in Datei2 kopiert).                                      */
  2306. X/*     PARAMETER  alt  =  Datei1                                           */
  2307. X/*          neu  =  Datei2                                           */
  2308. X/*     RUECKGABE   0   =  ok                                               */
  2309. X/*          -1   =  Datei1 nicht gefunden                   */
  2310. X/***************************************************************************/
  2311. X
  2312. X#ifndef _ANSI
  2313. X
  2314. Xint rename(alt, neu)
  2315. Xchar *alt[], *neu[];
  2316. X{
  2317. X  FILE *fp;
  2318. X  FILE *ff;
  2319. X
  2320. X  char s[250];
  2321. X
  2322. X  fp = fopen(neu, "w");
  2323. X  if (fp == NULL) {
  2324. X    return -1;
  2325. X  }
  2326. X  ff = fopen(alt, "r");
  2327. X  if (ff == NULL) {
  2328. X    return -2;
  2329. X  }
  2330. X  while (fgets(s, 250, ff) != NULL) {
  2331. X    fputs(s, fp);
  2332. X  }
  2333. X
  2334. X  fclose(fp);
  2335. X  fclose(ff);
  2336. X
  2337. X  unlink(alt);
  2338. X
  2339. X  return 0;
  2340. X}
  2341. X
  2342. X#endif
  2343. X
  2344. X
  2345. X
  2346. X
  2347. X/***************************************************************************/
  2348. X/*      FUNKTION  headline()                           */
  2349. X/*  BESCHREIBUNG  Ueberschrift mit Ansage-Text ausgeben. Vorher wird der   */
  2350. X/*          der Bildschirm geloescht (falls moegliche) und auf       */
  2351. X/*          negative Darstellung umgeschaltet.                       */
  2352. X/*     PARAMETER  line  =  Ansage-Text                       */
  2353. X/*     RUECKGABE  keine                                                    */
  2354. X/***************************************************************************/
  2355. X
  2356. Xvoid headline(line)
  2357. Xchar line[];
  2358. X{
  2359. X  char ex[255];
  2360. X  int i;
  2361. X
  2362. X
  2363. X  strcpy(ex, line);
  2364. X  i = 0;
  2365. X  while(line[i] != '\0'){
  2366. X    if(line[i] == '^'){
  2367. X        strcpy(ex, (char *) strcopy(line, 0, (i-1)));
  2368. X        line[i] = ' ';
  2369. X    }
  2370. X    i++;
  2371. X  }
  2372. X  strcpy(headinfo, ex);
  2373. X  sprintf(ex, "%s                                                                          ", line);
  2374. X  ex[79] = '\0';
  2375. X  if (ansi("cl") != -1) {
  2376. X    if (ansi("mr") == 1) {
  2377. X        if (ansi("so") == 1) { 
  2378. X            printf("\n\n------  %s  ------\n\n", line);
  2379. X            return;
  2380. X        }
  2381. X    }
  2382. X    printf("%s\n", ex);
  2383. X    if (ansi("me") == 1) {
  2384. X        ansi("se");
  2385. X    }
  2386. X  }
  2387. X  else {
  2388. X    printf("\n\n\n\n\n------  %s  ------\n\n", line);
  2389. X  }
  2390. X}
  2391. X
  2392. X
  2393. X/***************************************************************************/
  2394. X/*      FUNKTION  mblock()                           */
  2395. X/*  BESCHREIBUNG  Schuetzt eine Datei vor ALLEN Zugriffen           */
  2396. X/*     PARAMETER  path  =  Datei                       */
  2397. X/*     RUECKGABE  keine                                                    */
  2398. X/***************************************************************************/
  2399. X
  2400. Xvoid mblock( path )
  2401. Xchar path[];
  2402. X{
  2403. X  FILE *fp;
  2404. X  char s[STRING];
  2405. X
  2406. X  sprintf(s, "%s.LCK", path); 
  2407. X
  2408. X#ifndef _LONGNAMES
  2409. X  strcpy(s, (char *) shortname(s));
  2410. X#endif
  2411. X
  2412. X  fp = fopen( s, "w" );
  2413. X  fputs(VERSION, fp);
  2414. X  fclose(fp);
  2415. X}
  2416. X
  2417. X
  2418. X/***************************************************************************/
  2419. X/*      FUNKTION  unmblock()                           */
  2420. X/*  BESCHREIBUNG  Erlaubt Zugriffe auf eine Datei               */
  2421. X/*     PARAMETER  path  =  Datei                       */
  2422. X/*     RUECKGABE  keine                                                    */
  2423. X/***************************************************************************/
  2424. X
  2425. Xvoid mbunlock( path )
  2426. Xchar path[];
  2427. X{
  2428. X  char s[STRING];
  2429. X  
  2430. X  sprintf(s, "%s.LCK", path); 
  2431. X
  2432. X#ifndef _LONGNAMES
  2433. X  strcpy(s, (char *) shortname(s));
  2434. X#endif
  2435. X
  2436. X  unlink(s);
  2437. X}
  2438. X
  2439. X
  2440. X/***************************************************************************/
  2441. X/*      FUNKTION  tty()                               */
  2442. X/*  BESCHREIBUNG  Name des eigenen Terminal-Anschlusses.            */
  2443. X/*     PARAMETER  keine                                                       */
  2444. X/*     RUECKGABE  siehe BESCHREIBUNG                                       */
  2445. X/***************************************************************************/
  2446. X
  2447. Xint tty()
  2448. X{
  2449. X  char s[STRING];
  2450. X  char t[STRING];
  2451. X  int i, l, a, b;
  2452. X
  2453. X
  2454. X  strcpy(s, (char *) ttyname(0));
  2455. X  l = length(s);
  2456. X  i = l;
  2457. X
  2458. X  while ((s[l] != 'y') && (l > 0)) l--;
  2459. X
  2460. X  l++;
  2461. X  a = 0;
  2462. X
  2463. X  for (b = l; b < i; b++) {
  2464. X    t[a] = s[b];
  2465. X    a++;
  2466. X  }
  2467. X  t[a] = '\0';
  2468. X
  2469. X  return atoi(t);
  2470. X}
  2471. X
  2472. X
  2473. X/***************************************************************************/
  2474. X/*      FUNKTION  ttyna()                           */
  2475. X/*  BESCHREIBUNG  Name des eigenen Terminal-Anschlusses.            */
  2476. X/*     PARAMETER  keine                                                       */
  2477. X/*     RUECKGABE  siehe BESCHREIBUNG                                       */
  2478. X/***************************************************************************/
  2479. X
  2480. Xchar *ttyna()
  2481. X{
  2482. X  static char s[STRING];
  2483. X  static char t[STRING];
  2484. X  int i, j, l;
  2485. X
  2486. X
  2487. X  strcpy(s, (char *) ttyname(0));
  2488. X
  2489. X  l = length(s) + 1;
  2490. X
  2491. X  i = 0; 
  2492. X  while(s[i] != '\0'){
  2493. X    if(s[i] == '/') j = i + 1;
  2494. X    i++;
  2495. X  }
  2496. X  (void) strcpy(t, (char *) strcopy(s, j, l));
  2497. X  
  2498. X  return (char *) t;
  2499. X}
  2500. X
  2501. X
  2502. X
  2503. X/***************************************************************************/
  2504. X/*      FUNKTION  clearline()                           */
  2505. X/*  BESCHREIBUNG  Bildschirmzeile loeschen.                    */
  2506. X/*     PARAMETER  keine                                                       */
  2507. X/*     RUECKGABE  keine                                               */
  2508. X/***************************************************************************/
  2509. X
  2510. Xvoid clearline()
  2511. X{
  2512. X  printf("%c", CR);
  2513. X  if (ansi("ce") == 1) {
  2514. X    printf("                                                               ");
  2515. X  }
  2516. X  printf("%c", CR);
  2517. X}
  2518. X
  2519. X
  2520. X/***************************************************************************/
  2521. X/*      FUNKTION  isin()                           */
  2522. X/*  BESCHREIBUNG  Prueft ob ein Zeichen in einer Zeichenkette vorkommt.       */
  2523. X/*     PARAMETER  pattern = Zeichenkette mit den moegl. Uebereinstimmungen */
  2524. X/*          c       = Zeichen                       */
  2525. X/*     RUECKGABE  0       = Zeichen ist NICHT in Zeichenkette enthalten       */
  2526. X/***************************************************************************/
  2527. X
  2528. Xint isin( pattern, c )
  2529. Xchar pattern[];
  2530. Xint c;
  2531. X{
  2532. X  int i = 0;
  2533. X  int ok = 0;
  2534. X
  2535. X  while((pattern[i] != '\0') && (ok == 0)){
  2536. X    if(pattern[i] == c) ok++;    
  2537. X    i++;
  2538. X  }
  2539. X  
  2540. X  return (int) ok;  
  2541. X}
  2542. X
  2543. END_OF_FILE
  2544.   if test 22598 -ne `wc -c <'src/tools.c'`; then
  2545.     echo shar: \"'src/tools.c'\" unpacked with wrong size!
  2546.   fi
  2547.   # end of 'src/tools.c'
  2548. fi
  2549. echo shar: End of archive 4 \(of 11\).
  2550. cp /dev/null ark4isdone
  2551. MISSING=""
  2552. for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
  2553.     if test ! -f ark${I}isdone ; then
  2554.     MISSING="${MISSING} ${I}"
  2555.     fi
  2556. done
  2557. if test "${MISSING}" = "" ; then
  2558.     echo You have unpacked all 11 archives.
  2559.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2560. else
  2561.     echo You still must unpack the following archives:
  2562.     echo "        " ${MISSING}
  2563. fi
  2564. exit 0
  2565. exit 0 # Just in case...
  2566.