home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / text / manipulation / bbsadd10.lha / bbsadd / bbsadd.c next >
Encoding:
C/C++ Source or Header  |  1980-01-01  |  4.5 KB  |  127 lines

  1. /***********************************************************************\
  2. *               BBSADD By S.K.Lindsay aka Linds - Terradome             *
  3. *************************************************************************
  4. * Sorry The codes a bit messy, I have only been doing C for 4 days, be  *
  5. * prepared to see a lot of code from me, I am determined to make a name *
  6. * for my self in the Amiga world. This file should compile no problems  *
  7. * on any C package on any computer (The escape codes may cockup a bit   *
  8. * on the PC etc.) as I have only used standard input and output         *
  9. * functions. If you have any questions, problems or anything  please    *
  10. * contact me, I want connections worldwide, I want code-swappers, demo  *
  11. * writers, tracker writers, grapix artists, C programmers etc. to all   *
  12. * contact me, I * WILL * reply to ANYONE who writes, As it stands at    *
  13. * the moment I am only O.K at C, I can't do a lot of things so I would  *
  14. * like help of anyone or everyone who can help me get good. Also I may  *
  15. * not be too hot myself yet, but I know a lot of people so if you have  *
  16. * a problem on any computer or a piece of hardware, software etc. write *
  17. * to me and tell me what it is and the chances are I will know someone  *
  18. * that can help you.                                                    *
  19. *                                                                       *
  20. *   Contact address : 146 High St West, Coatham, Redcar, Cleveland,     *
  21. *                     TS10 1SD. England.                                *
  22. *                                                                       *
  23. *  If you prefer to phone then contact me on +44 (0642) 475394 and ask  *
  24. *  for Steven (Don't ask for linds or you will be hung up on!!)         *
  25. \***********************************************************************/
  26.  
  27. #include <stdio.h>
  28.  
  29. void syntax();
  30. void info();
  31.  
  32. main(int argc, char *argv[])
  33. {
  34.   FILE *in, *in2, *out;
  35.   int c, working=0, loop=0;
  36.  
  37.     printf("\nBBSADD by LINDS TERRADOME\n\n");
  38.  
  39.     if (argc <2)
  40.     {
  41.         info();
  42.         exit();
  43.     }
  44.     
  45.     if (argc >4)
  46.     {
  47.         printf("Error : Too many arguments.\n");
  48.         syntax();
  49.         exit();
  50.     }
  51.     
  52.     if (argc != 4)
  53.     {
  54.         printf("Error : Not enough arguments.\n");
  55.         syntax();
  56.         exit();
  57.     }
  58.  
  59.     if ((in = fopen(argv[1],"r")) == NULL) {
  60.         printf ("Error : Can't load source1 textfile %s\n\n",argv[1]);
  61.         exit();
  62.     }
  63.     
  64.     if ((in2 = fopen(argv[2],"r")) == NULL) {
  65.         printf ("Error : Can't load source2 textfile %s\n\n",argv[2]);
  66.         fclose(in); exit();
  67.     }
  68.  
  69.   if ((out = fopen(argv[3],"w")) == NULL) {
  70.     printf ("Error : Can't save destination %s\n\n",argv[3]);
  71.     fclose(in); fclose(in2); exit();
  72.   }
  73.  
  74.   while ( working == NULL ) {
  75.   if((c=getc(in)) == EOF) {
  76.     printf("Source1 Textfile Read Ok.\n"); working=1; }
  77.  
  78.   if ( working == NULL ) {
  79.   if((putc(c,out)) == EOF) {
  80.       printf("Error : Disk Write Error.\n\n"); working=2; } }
  81.   }
  82.  
  83.   fclose (in);
  84.  
  85.   if (working == 1) {
  86.   for (loop=0; loop<2; loop++) {
  87.   if((putc(10,out)) == EOF) {
  88.     printf("Error : Disk Write Error.\n\n"); working=2; }
  89.   } }
  90.  
  91.   while (working == 1 ) {
  92.   if((c=getc(in2)) == EOF) {
  93.     printf("Source2 Textfile Read OK.\n"); working=3; }
  94.  
  95.   if ( working == 1 ) {
  96.   if((putc(c,out)) == EOF) {
  97.     printf("Error : Disk Write Error.\n\n"); working=2; } }
  98.   }
  99.  
  100.   fclose(in2);
  101.  
  102.   if (working == 3)
  103.     printf("File Written Correctly, Bye, Bye!\n\n");
  104.   
  105.   exit();
  106. }
  107.  
  108. void syntax()
  109. {
  110.     printf ("\n  Syntax : BBSADD <source1> <source2> <destination>\n\n");
  111. }
  112.  
  113. void info()
  114. {
  115.     printf ("BBSADD will merge a textfile to the top of another textfile\n");
  116.     printf ("and place a one line gap inbetween them. This was originally\n");
  117.     printf ("intended for Sysops who wish to put the logo and info of there\n");
  118.   printf ("BBS at the top of textfiles to be downloaded from there systems\n");
  119.   printf ("(thus the name), But it can be used to merge any textfiles together.\n");
  120.   printf ("example : differant manuals for the safe product, BBS lists, jokes etc.\n");
  121.   printf ("If it is useful to you send me some good C source code and I will send\n");
  122.   printf ("you some back!\n");
  123.   printf ("\nAddress : 146 High St West, Coatham, Redcar, Cleveland, TS10 1SD, England.\n");
  124.     syntax();
  125.     printf ("Hope it's useful, Greets to PeteFudgeSteve and Pazza\n\n");
  126. }
  127.