home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 554b.lha / WFile_v1.10 / source / template.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-09-10  |  4.8 KB  |  191 lines

  1. /*******************************************************************
  2. * template.c : processes user desired templates into command line  *
  3. *           parameters (argv) and gives them back to wfile to   *
  4. *           be further processed. (Actually it simulates user   *
  5. *           entered command line parameters)            *
  6. *                                   *
  7. * created: 1990 Mtwx                           *
  8. *******************************************************************/
  9.  
  10. /* --------------------- source code revisions, tracked by RCS ---------- */
  11.  
  12. /* $Header: Hard0:C-Compiler/src/wfile/rcs/template.c,v 1.1 91/08/14 14:18:23 Mtwx Exp Locker: Mtwx $ */
  13. /* $Log:    template.c,v $
  14.  * Revision 1.1  91/08/14  14:18:23  Mtwx
  15.  * - added EOF support in UNIX2MSDOS template
  16.  * 
  17.  * Revision 1.0  91/08/12  20:27:49  Mtwx
  18.  * Initial revision
  19.  *  */
  20.  
  21. /* ------------------------------- includes ----------------------------- */
  22.  
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25.  
  26. /* ----------------------- forward references ------------------- */
  27.  
  28. void check_malloc(),print_templ();
  29.  
  30. /* ----------------------- external references ------------------ */
  31.  
  32. extern char *templ_argv[];
  33.  
  34. /* -------------------------------------------------------------- */
  35.  
  36. int unix2msdos(command)
  37. char *command;
  38. {
  39.   register int i;
  40.  
  41.   for(i=0;i<9;i++)
  42.     templ_argv[i]=(char *)malloc(9);
  43.   check_malloc(9);
  44.   strcpy(templ_argv[0],"+CR");
  45.   strcpy(templ_argv[1],"-204=132"); /* ae */
  46.   strcpy(templ_argv[2],"-206=148"); /* oe */
  47.   strcpy(templ_argv[3],"-207=129"); /* ue */
  48.   strcpy(templ_argv[4],"-216=142"); /* AE */
  49.   strcpy(templ_argv[5],"-218=153"); /* OE */
  50.   strcpy(templ_argv[6],"-219=154"); /* UE */
  51.   strcpy(templ_argv[7],"-222=225"); /* sz */
  52.   strcpy(templ_argv[8],"+26"); /* EOF */
  53.   print_templ(command,9);
  54.   return 9;
  55. }
  56.  
  57. int msdos2unix(command)
  58. char *command;
  59. {
  60.   register int i;
  61.  
  62.   for(i=0;i<8;i++)
  63.     templ_argv[i]=(char *)malloc(9);
  64.   check_malloc(9);
  65.   strcpy(templ_argv[0],"-CR");
  66.   strcpy(templ_argv[1],"-132=204"); /* ae */
  67.   strcpy(templ_argv[2],"-148=206"); /* oe */
  68.   strcpy(templ_argv[3],"-129=207"); /* ue */
  69.   strcpy(templ_argv[4],"-142=216"); /* AE */
  70.   strcpy(templ_argv[5],"-153=218"); /* OE */
  71.   strcpy(templ_argv[6],"-154=219"); /* UE */
  72.   strcpy(templ_argv[7],"-225=222"); /* sz */
  73.   strcpy(templ_argv[8],"-26=0");    /* EOF */
  74.   print_templ(command,9);
  75.   return 9;
  76. }
  77.  
  78. int msdos2amiga(command)
  79. char *command;
  80. {
  81.   register int i;
  82.  
  83.   for(i=0;i<9;i++)
  84.     templ_argv[i]=(char *)malloc(9);
  85.   check_malloc(9);
  86.   strcpy(templ_argv[0],"-CR");
  87.   strcpy(templ_argv[1],"-132=228"); /* ae */
  88.   strcpy(templ_argv[2],"-148=246"); /* oe */
  89.   strcpy(templ_argv[3],"-129=252"); /* ue */
  90.   strcpy(templ_argv[4],"-142=196"); /* AE */
  91.   strcpy(templ_argv[5],"-153=214"); /* OE */
  92.   strcpy(templ_argv[6],"-154=220"); /* UE */
  93.   strcpy(templ_argv[7],"-225=223"); /* sz */
  94.   strcpy(templ_argv[8],"-26=0");    /* EOF */
  95.   print_templ(command,9);
  96.   return 9;
  97. }
  98.  
  99. int amiga2msdos(command)
  100. char *command;
  101. {
  102.   register int i;
  103.  
  104.   for(i=0;i<9;i++)
  105.     templ_argv[i]=(char *)malloc(9);
  106.   check_malloc(9);
  107.   strcpy(templ_argv[0],"+CR");
  108.   strcpy(templ_argv[1],"-228=132");
  109.   strcpy(templ_argv[2],"-246=148");
  110.   strcpy(templ_argv[3],"-252=129");
  111.   strcpy(templ_argv[4],"-196=142");
  112.   strcpy(templ_argv[5],"-214=153");
  113.   strcpy(templ_argv[6],"-220=154");
  114.   strcpy(templ_argv[7],"-223=225");
  115.   strcpy(templ_argv[8],"+26");
  116.   print_templ(command,9);
  117.   return 9;
  118. }
  119.  
  120. int unix2amiga(command)
  121. char *command;
  122. {
  123.   register int i;
  124.  
  125.   for(i=0;i<7;i++)
  126.     templ_argv[i]=(char *)malloc(9);
  127.   check_malloc(7);
  128.   strcpy(templ_argv[0],"-204=228"); /* ae */
  129.   strcpy(templ_argv[1],"-206=246"); /* oe */
  130.   strcpy(templ_argv[2],"-207=252"); /* ue */
  131.   strcpy(templ_argv[3],"-216=196"); /* AE */
  132.   strcpy(templ_argv[4],"-218=214"); /* OE */
  133.   strcpy(templ_argv[5],"-219=220"); /* UE */
  134.   strcpy(templ_argv[6],"-222=223"); /* sz */
  135.   print_templ(command,7);
  136.   return 7;
  137. }
  138.  
  139. int amiga2unix(command)
  140. char *command;
  141. {
  142.   register int i;
  143.  
  144.   for(i=0;i<7;i++)
  145.     templ_argv[i]=(char *)malloc(9);
  146.   check_malloc(7);
  147.   strcpy(templ_argv[0],"-132=204"); /* ae */
  148.   strcpy(templ_argv[1],"-148=206"); /* oe */
  149.   strcpy(templ_argv[2],"-129=207"); /* ue */
  150.   strcpy(templ_argv[3],"-142=216"); /* AE */
  151.   strcpy(templ_argv[4],"-153=218"); /* OE */
  152.   strcpy(templ_argv[5],"-154=219"); /* UE */
  153.   strcpy(templ_argv[6],"-225=222"); /* sz */
  154.   print_templ(command,7);
  155.   return 7;
  156. }
  157.  
  158. void check_malloc(number)
  159. int number;
  160. {
  161.   int i;
  162.  
  163.   for(i=0;i<number;i++)
  164.   {
  165.     if(templ_argv[i]==NULL)
  166.     {
  167.       puts("Couldn't get memory for building template!");
  168.       exit(1);
  169.     }
  170.   }
  171. }
  172.  
  173. void print_templ(char *command,int number)
  174. {
  175.   int i,length=0;
  176.  
  177.   printf("Option: %s\n",command);
  178.   for(i=0;i<number;i++)
  179.   {
  180.     if(length+strlen(templ_argv[i])+1>79)
  181.     {
  182.       printf("\n");
  183.       length=strlen(templ_argv[i])+1;
  184.     }
  185.     else
  186.       length+=strlen(templ_argv[i])+1;
  187.     printf("%s ",templ_argv[i]);
  188.   }
  189.   printf("\n");
  190. }
  191.