home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_C / EUROSET.ZIP / DEMO.C < prev    next >
C/C++ Source or Header  |  1994-01-27  |  10KB  |  267 lines

  1. /* demo.c  1994 jan 03  [gh]
  2. +-----------------------------------------------------------------------------
  3. | Abstract:
  4. |    Test fold library
  5. |
  6. | Authorship:
  7. |    Copyright (c) 1994 Gisle Hannemyr.
  8. |    Permission is granted to hack, make and distribute copies of this program
  9. |    as long as this copyright notice is not removed.
  10. |    Flames, bug reports, comments and improvements to:
  11. |       snail: Gisle Hannemyr, Brageveien 3A, 0452 Oslo, Norway
  12. |       email: X400:  gisle.hannemyr@nr.no
  13. |              Inet: gisle@ifi.uio.no, gisle@oslonett.no
  14. |              UUCP: ...!mcsun!ifi!gisle
  15. |
  16. |
  17. | History:
  18. |    1.0 94 jan 03 [gh] Wrote it.
  19. +---------------------------------------------------------------------------*/
  20.  
  21. #include <stdio.h>
  22. #include <string.h>
  23. #include "fold.h"
  24.  
  25. /*---( samples )------------------------------------------------------------*/
  26.  
  27. unsigned char Jumbo[10000];
  28.  
  29.  
  30. unsigned char *plain = (unsigned char *)"\
  31. Path: ifi.uio.no!nntp.uio.no!trane.uninett.no!sunic!EU.net!howland.reston.an\
  32. s.net!xlink.net!rz.uni-karlsruhe.de!subnet.sub.net!syris.de!noris.de!not-for\
  33. -mail\n\
  34. From: erlichs@syris.de (Matthias Erlichs)\n\
  35. Newsgroups: news.software.nntp\n\
  36. Subject: Re: Using = in the active file...\n\
  37. Date: 17 Jan 1994 15:10:48 +0100\n\
  38. Organization: Smurf-O-Box, Nuernberg, FRG\n\
  39. Lines: 14\n\
  40. Message-ID: <2he698$3t7@syris.de>\n\
  41. References: <2g1emi$gl1@ns1.arlut.utexas.edu> <Pnews.bruce.75833709.6178@bl\
  42. illy.uucp> <2h3pm1$ro@syris.de> <Pnews.bruce.758596240.17719@blilly.uu\
  43. cp>\n\
  44. NNTP-Posting-Host: localhost\n\
  45. \n\
  46. In news.software.nntp, article <Pnews.bruce.758596240.17719@blilly.uucp>,\n\
  47.   lillyb@ccmail.nhq.sony.com (Bruce Lilly) writes:\n\
  48. > \n\
  49. > Subscription is not necessarily appropriate; one use at C news\n\
  50. > sites is to file in one place all articles in groups that are\n\
  51. > passed on to other systems, but which are not desired locally--\n\
  52. > \"=junk\" works well for this, along with expiration of the junk\n\
  53. \n\
  54. INN uses \"j\" instead of \"=junk\" for exactly this reason.\n\
  55. Posting to such groups is allowed.\n\
  56. -- \n\
  57. Matthias Erlichs        \ XLink-POP N\374rnberg | EMail: erlichs@syris.de\n\
  58. Schleiermacherstra\337e 21  \  Unix+Linux+Mac   | Phone: please use email.\n\
  59. 90491 N\374rnberg (Germany)  \   Consulting+Networking+Programming+etc'ing\n";
  60.  
  61.  
  62. unsigned char *usacii = (unsigned char *)"\
  63. Path: ifi.uio.no!nac.no!trane.uninett.no!sunic!EU.net!uunet!nntp.club.cc.cmu\
  64. .edu!tres.ust.gov!ptbma.usbm.gov!klevemmc\n\
  65. From: klevemmc@ptbma.ust.gov (Klevemann)\n\
  66. Newsgroups: news.software.nntp\n\
  67. Subject: Logging NNRP\n\
  68. Date: 11 Jan 1994 16:11:07 GMT\n\
  69. Organization: U. S. Tres\n\
  70. Lines: 13\n\
  71. Distribution: inet\n\
  72. Message-ID: <2guj2r$6v4@miner.usbm.gov>\n\
  73. NNTP-Posting-Host: ptbma.usbm.gov\n\
  74. X-Newsreader: TIN [version 1.2 PL2]\n\
  75. \n\
  76. I think I might have asked this question before, but is there a way to \n\
  77. log nnrp requests with inn 1.4 ?\n\
  78. --\n\
  79. Bill Klevemann, Network Support Group, U.S. Tres.\n";
  80.  
  81.  
  82. unsigned char *isol1 = (unsigned char *)"\
  83. Path: ifi.uio.no!nntp.uio.no!trane.uninett.no!sunic!EU.net!howland.reston.an\
  84. s.net!xlink.net!rz.uni-karlsruhe.de!subnet.sub.net!syris.de!noris.de!not-for\
  85. -mail\n\
  86. From: erlichs@syris.de (Matthias Erlichs)\n\
  87. Newsgroups: news.software.nntp\n\
  88. Subject: Re: Using = in the active file...\n\
  89. Date: 17 Jan 1994 15:10:48 +0100\n\
  90. Organization: Smurf-O-Box, Nuernberg, FRG\n\
  91. Lines: 14\n\
  92. Message-ID: <2he698$3t7@syris.de>\n\
  93. References: <2g1emi$gl1@ns1.arlut.utexas.edu> <Pnews.bruce.75833709.6178@bl\
  94. illy.uucp> <2h3pm1$ro@syris.de> <Pnews.bruce.758596240.17719@blilly.uu\
  95. cp>\n\
  96. NNTP-Posting-Host: localhost\n\
  97. Mime-Version: 1.0\n\
  98. Content-Type: text/plain; charset=iso-8859-1\n\
  99. Content-Transfer-Encoding: 8bit\n\
  100. \n\
  101. In news.software.nntp, article <Pnews.bruce.758596240.17719@blilly.uucp>,\n\
  102.   lillyb@ccmail.nhq.sony.com (Bruce Lilly) writes:\n\
  103. > \n\
  104. > Subscription is not necessarily appropriate; one use at C news\n\
  105. > sites is to file in one place all articles in groups that are\n\
  106. > passed on to other systems, but which are not desired locally--\n\
  107. > \"=junk\" works well for this, along with expiration of the junk\n\
  108. \n\
  109. INN uses \"j\" instead of \"=junk\" for exactly this reason.\n\
  110. Posting to such groups is allowed.\n\
  111. -- \n\
  112. Matthias Erlichs        \ XLink-POP N\374rnberg | EMail: erlichs@syris.de\n\
  113. Schleiermacherstra\337e 21  \  Unix+Linux+Mac   | Phone: please use email.\n\
  114. 90491 N\374rnberg (Germany)  \   Consulting+Networking+Programming+etc'ing\n";
  115.  
  116.  
  117. unsigned char *isol1qp = (unsigned char *)"\
  118. From \"Georg Gearlos <georg@cpanix.no>\" Fri Jun 11 13:19:58 1993\n\
  119. Flags: 000000000001\n\
  120. Return-Path: <georg>\n\
  121. Received: from gyda.cpanix.no by cpanix.no with SMTP \n\
  122.     id <AAcpanix.no26176> for <georg@cpanix.no>; Fri, 11 Jun 1993 13:1\
  123. 9:57 +0200\n\
  124. Received: by gyda.cpanix.no ; Fri, 11 Jun 1993 13:19:56 +0200\n\
  125. Date: Fri, 11 Jun 1993 13:19:55 +0200\n\
  126. Mime-Version: 1.0\n\
  127. From: Georg Gearlos <georg@cpanix.no>\n\
  128. To: peons@cybernet.no\n\
  129. Subject: Fin reklame for Cybernet!\n\
  130. Message-Id: <CMM.0.90.4.739797595.georg@gyda.cpanix.no>\n\
  131. Content-Type: text/plain; charset=\"iso-8859-1\"\n\
  132. Content-Transfer-Encoding: quoted-printable\n\
  133. \n\
  134. QTIP, som er et program for bruk av IT til kvalitet i produksjon,\n\
  135. har n=E5 avsluttet sitt forprosjekt og anbefaler bl.a. at medlems-\n\
  136. bedrifter uten E-mail tegner avtale med Cybernet for =E5 f=E5 tilgang\n\
  137. til elektronisk post.\n\
  138. \n\
  139. Jeg synes dette var fint =E5 f=E5 h=F8re, og minner samtidig om et viktig\n\
  140. prinsipp i \"gerilja-markedsf=F8ring\":  Det er sv=E6rt viktig =E5\n\
  141. f=E5 fatt i \"the movers and shakers\" som kunder.  Det er disse som\n\
  142. etablerer trender og sprer praksis rundt seg.  Vi burde kanskje g=E5\n\
  143. gjennom kundelista og identifisere M&S -- og gi disse VIP-behandling.\n\
  144. \n\
  145. Meta-disclaimer: A society that needs disclaimers has too many lawyers.\n\
  146. =20\n\
  147. - Georg Gearlos  (Cybernet Inc.)\n\
  148.   OSI:   C=3Dno;PRMD=3Duninett;O=3Dnr;S=3DGearlos;G=3DGeorg (X.400 SA =\n\
  149. format)\n\
  150.          georg.gearlos@nfraad.no                  (RFC-822  format)\n\
  151.   Inet:  georg@cpanix.no\n\
  152.   UUCP:  ...!mcsun!ifi!georg\n\
  153. ------------------------------------------------\n";
  154.  
  155. unsigned char *iso646n = (unsigned char *)"\
  156. Newsgroups: no.general,no.mail\n\
  157. Path: oslonett.no!telepost.no!news.eunet.no!nuug!falch!falch!steinarb\n\
  158. From: steinarb@falch.no (Steinar Bang)\n\
  159. Subject: X.400 til Internet gateway?\n\
  160. Content-Type: text/plain; charset=x-iso-ir-60\n\
  161. Message-ID: <STEINARB.94Jan20155501@falch.falch.no>\n\
  162. Followup-To: no.general\n\
  163. Sender: Falch Newsfeed <usenet@falch.no>\n\
  164. Content-Transfer-Encoding: 7bit\n\
  165. Organization: Falch Hurtigtrykk, Oslo, Norway\n\
  166. Mime-Version: 1.0\n\
  167. Date: Thu, 20 Jan 1994 14:55:01 GMT\n\
  168. Lines: 10\n\
  169. \n\
  170. Finnes det noen MIME-sak ala X.400 til SMTP gateway, som kj|rer p}\n\
  171. Sparc/PC/Novell/Mac, } f} kj|pt (eller som finnes fritt tilgjengelig)\n\
  172. idag? Hvem tar man is}fall kontakt med?\n\
  173. \n\
  174. Jeg har lest FAQ-lista til comp.mail.mime, s} det er ikke n|dvendig }\n\
  175. sende meg den.  Men hvis det er noen som vet noe konkret om\n\
  176. l|sningene rundt PP eller Z-mail, som st}r nevnt i denne FAQ-lista, s}\n\
  177. er jeg meget interessert i } h|re om det.\n\
  178. \n\
  179. - Steinar\n";
  180.  
  181.  
  182. /*---( demo )---------------------------------------------------------------*/
  183.  
  184. void dodemo(cset, which)
  185. int cset;
  186. int which;
  187. {
  188.     unsigned char *buf, *head, *body;
  189.  
  190.     switch (which) {
  191.       case 0:  buf = plain;   break;
  192.       case 1:  buf = usacii;  break;
  193.       case 2:  buf = isol1;   break;
  194.       case 3:  buf = isol1qp; break;
  195.       case 4:  buf = iso646n; break;
  196.       default: fputs("*** Unknown demo.\n", stderr);
  197.     } /* dodemo */
  198.  
  199.     strcpy(Jumbo, buf);
  200.     head = Jumbo;
  201.     body = splitbody(Jumbo);
  202.     if (!body) fputs("*** no body?\n", stderr);
  203.  
  204.     initout(cset);        /* Or set this up permanently to be right   */
  205.     inithead(head);        /* Parse headers                */
  206.     unmimebuffer(body);        /* Unmime it.                    */
  207.     foldbuffer(body);        /* Fold the buffer.                */
  208.  
  209.     fputs("========================================================================\n",  stdout);
  210.     if (head) fputs(head, stdout);
  211.     fputs("------------------------------------------------------------------------\n",  stdout);
  212.     if (body) fputs(body, stdout);
  213.     fputs("========================================================================\n",  stdout);
  214.  
  215. } /* dodemo */
  216.  
  217.  
  218. /*---( main )---------------------------------------------------------------*/
  219.  
  220. int main(argc, argv)
  221. int  argc; char *argv[];
  222. {
  223.     char buff[80];
  224.     int ii, jj;
  225.  
  226.     fputs("\
  227. First we need to know your character set, please select one off:\n\
  228.     1) ISO-646-IRV\n\
  229.     2) ISO-IR-60\n\
  230.     3) ISO-8859/1\n\
  231.     4) IBM CP 850\n\
  232.     5) Macintosh\n\
  233.     6) (Exit)\n\
  234. Select one (1-6) : ", stdout);
  235.     fflush(stdout);
  236.     fgets(buff, 10, stdin);
  237.     sscanf(buff, "%d", &ii);
  238.     if ((ii < 1) || (ii >= 6)) return(0);
  239.  
  240.     for (;;) {
  241.     fputs("\
  242. Please select one off:\n\
  243.     0) Plain, no headers\n\
  244.     1) US ASCII,   7 bit\n\
  245.     2) ISO-8859/1, 8 bit\n\
  246.     3) ISO-8859/1, quoted-printable\n\
  247.     4) ISO-IR60 (Norwegian) 7 bit)\n\
  248.     5) (Exit)\n\
  249. Select one (0-5) : ", stdout);
  250.     fflush(stdout);
  251.     fgets(buff, 10, stdin);
  252.     sscanf(buff, "%d", &jj);
  253.     printf(">>> %d\n", jj);
  254.     if ((jj < 0) || (jj >= 5)) break;
  255.  
  256.     dodemo(ii, jj);
  257.     } /* forever */
  258.  
  259.  
  260.     return(0);
  261.  
  262. } /* main */
  263.  
  264. /* EOF */
  265.  
  266.  
  267.