home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************
- * template.c : processes user desired templates into command line *
- * parameters (argv) and gives them back to wfile to *
- * be further processed. (Actually it simulates user *
- * entered command line parameters) *
- * *
- * created: 1990 Mtwx *
- *******************************************************************/
-
- /* --------------------- source code revisions, tracked by RCS ---------- */
-
- /* $Header: Hard0:C-Compiler/src/wfile/rcs/template.c,v 1.1 91/08/14 14:18:23 Mtwx Exp Locker: Mtwx $ */
- /* $Log: template.c,v $
- * Revision 1.1 91/08/14 14:18:23 Mtwx
- * - added EOF support in UNIX2MSDOS template
- *
- * Revision 1.0 91/08/12 20:27:49 Mtwx
- * Initial revision
- * */
-
- /* ------------------------------- includes ----------------------------- */
-
- #include <stdio.h>
- #include <stdlib.h>
-
- /* ----------------------- forward references ------------------- */
-
- void check_malloc(),print_templ();
-
- /* ----------------------- external references ------------------ */
-
- extern char *templ_argv[];
-
- /* -------------------------------------------------------------- */
-
- int unix2msdos(command)
- char *command;
- {
- register int i;
-
- for(i=0;i<9;i++)
- templ_argv[i]=(char *)malloc(9);
- check_malloc(9);
- strcpy(templ_argv[0],"+CR");
- strcpy(templ_argv[1],"-204=132"); /* ae */
- strcpy(templ_argv[2],"-206=148"); /* oe */
- strcpy(templ_argv[3],"-207=129"); /* ue */
- strcpy(templ_argv[4],"-216=142"); /* AE */
- strcpy(templ_argv[5],"-218=153"); /* OE */
- strcpy(templ_argv[6],"-219=154"); /* UE */
- strcpy(templ_argv[7],"-222=225"); /* sz */
- strcpy(templ_argv[8],"+26"); /* EOF */
- print_templ(command,9);
- return 9;
- }
-
- int msdos2unix(command)
- char *command;
- {
- register int i;
-
- for(i=0;i<8;i++)
- templ_argv[i]=(char *)malloc(9);
- check_malloc(9);
- strcpy(templ_argv[0],"-CR");
- strcpy(templ_argv[1],"-132=204"); /* ae */
- strcpy(templ_argv[2],"-148=206"); /* oe */
- strcpy(templ_argv[3],"-129=207"); /* ue */
- strcpy(templ_argv[4],"-142=216"); /* AE */
- strcpy(templ_argv[5],"-153=218"); /* OE */
- strcpy(templ_argv[6],"-154=219"); /* UE */
- strcpy(templ_argv[7],"-225=222"); /* sz */
- strcpy(templ_argv[8],"-26=0"); /* EOF */
- print_templ(command,9);
- return 9;
- }
-
- int msdos2amiga(command)
- char *command;
- {
- register int i;
-
- for(i=0;i<9;i++)
- templ_argv[i]=(char *)malloc(9);
- check_malloc(9);
- strcpy(templ_argv[0],"-CR");
- strcpy(templ_argv[1],"-132=228"); /* ae */
- strcpy(templ_argv[2],"-148=246"); /* oe */
- strcpy(templ_argv[3],"-129=252"); /* ue */
- strcpy(templ_argv[4],"-142=196"); /* AE */
- strcpy(templ_argv[5],"-153=214"); /* OE */
- strcpy(templ_argv[6],"-154=220"); /* UE */
- strcpy(templ_argv[7],"-225=223"); /* sz */
- strcpy(templ_argv[8],"-26=0"); /* EOF */
- print_templ(command,9);
- return 9;
- }
-
- int amiga2msdos(command)
- char *command;
- {
- register int i;
-
- for(i=0;i<9;i++)
- templ_argv[i]=(char *)malloc(9);
- check_malloc(9);
- strcpy(templ_argv[0],"+CR");
- strcpy(templ_argv[1],"-228=132");
- strcpy(templ_argv[2],"-246=148");
- strcpy(templ_argv[3],"-252=129");
- strcpy(templ_argv[4],"-196=142");
- strcpy(templ_argv[5],"-214=153");
- strcpy(templ_argv[6],"-220=154");
- strcpy(templ_argv[7],"-223=225");
- strcpy(templ_argv[8],"+26");
- print_templ(command,9);
- return 9;
- }
-
- int unix2amiga(command)
- char *command;
- {
- register int i;
-
- for(i=0;i<7;i++)
- templ_argv[i]=(char *)malloc(9);
- check_malloc(7);
- strcpy(templ_argv[0],"-204=228"); /* ae */
- strcpy(templ_argv[1],"-206=246"); /* oe */
- strcpy(templ_argv[2],"-207=252"); /* ue */
- strcpy(templ_argv[3],"-216=196"); /* AE */
- strcpy(templ_argv[4],"-218=214"); /* OE */
- strcpy(templ_argv[5],"-219=220"); /* UE */
- strcpy(templ_argv[6],"-222=223"); /* sz */
- print_templ(command,7);
- return 7;
- }
-
- int amiga2unix(command)
- char *command;
- {
- register int i;
-
- for(i=0;i<7;i++)
- templ_argv[i]=(char *)malloc(9);
- check_malloc(7);
- strcpy(templ_argv[0],"-132=204"); /* ae */
- strcpy(templ_argv[1],"-148=206"); /* oe */
- strcpy(templ_argv[2],"-129=207"); /* ue */
- strcpy(templ_argv[3],"-142=216"); /* AE */
- strcpy(templ_argv[4],"-153=218"); /* OE */
- strcpy(templ_argv[5],"-154=219"); /* UE */
- strcpy(templ_argv[6],"-225=222"); /* sz */
- print_templ(command,7);
- return 7;
- }
-
- void check_malloc(number)
- int number;
- {
- int i;
-
- for(i=0;i<number;i++)
- {
- if(templ_argv[i]==NULL)
- {
- puts("Couldn't get memory for building template!");
- exit(1);
- }
- }
- }
-
- void print_templ(char *command,int number)
- {
- int i,length=0;
-
- printf("Option: %s\n",command);
- for(i=0;i<number;i++)
- {
- if(length+strlen(templ_argv[i])+1>79)
- {
- printf("\n");
- length=strlen(templ_argv[i])+1;
- }
- else
- length+=strlen(templ_argv[i])+1;
- printf("%s ",templ_argv[i]);
- }
- printf("\n");
- }
-