home *** CD-ROM | disk | FTP | other *** search
- head 1.4;
- access;
- symbols;
- locks
- simons:1.4; strict;
- comment @ * @;
-
-
- 1.4
- date 93.10.06.12.19.18; author simons; state Exp;
- branches;
- next 1.3;
-
- 1.3
- date 93.09.14.17.20.14; author simons; state Stab;
- branches;
- next 1.2;
-
- 1.2
- date 93.09.14.17.10.14; author simons; state Exp;
- branches;
- next 1.1;
-
- 1.1
- date 93.09.14.17.04.08; author simons; state Exp;
- branches;
- next ;
-
-
- desc
- @__main() is a replacement for the standard startup-code, usually
- linked to C programs. This one provides the unparsed commandline
- to the main program and does not support the Workbench message.
- @
-
-
- 1.4
- log
- @Changed format of RCS-Header.
- @
- text
- @/*
- * $Filename: main.c $
- * $Revision: 1.3 $
- * $Date: 1993/09/14 17:20:14 $
- *
- * __main() is a replacement for the standard startup-code, usually
- * linked to C programs. This one provides the unparsed commandline
- * to the main program and does not support the Workbench message.
- *
- *
- * © Copyright 1993 Peter Simons, Germany
- * All Rights Reserved
- *
- * $Id: main.c,v 1.3 1993/09/14 17:20:14 simons Stab simons $
- *
- * ------------------------------ log history ----------------------------
- * $Log: main.c,v $
- * Revision 1.3 1993/09/14 17:20:14 simons
- * Removed any Workbench-startup and commandline parsing stuff.
- * The `real' main() now gets the unparsed commandline.
- *
- * Revision 1.2 1993/09/14 17:10:14 simons
- * Added RCSId string and removed the TINY-stuff.
- *
- * Revision 1.1 1993/09/14 17:04:08 simons
- * Initial revision
- */
-
- #include <stdio.h>
- #include <fcntl.h>
- #include <ios1.h>
- #include <string.h>
- #include <stdlib.h>
- #include <time.h>
- #include <workbench/startup.h>
- #include <libraries/dos.h>
- #include <libraries/dosextens.h>
- #include <proto/dos.h>
- #include <proto/exec.h>
- #include <exec/execbase.h>
-
- extern int __fmode;
-
- int main(char *);
-
- static const char __RCSId[] = "$Id: main.c,v 1.3 1993/09/14 17:20:14 simons Stab simons $";
-
- void __stdargs __main(char *line)
- {
- int ret, x;
- struct UFB ufbs[3];
-
-
- /* Open standard files. */
-
- ufbs[0].ufbnxt = &ufbs[1];
- ufbs[1].ufbnxt = &ufbs[2];
- ufbs[2].ufbnxt = NULL;
- __ufbs = &ufbs[0];
- ufbs[0].ufbfn = NULL;
- ufbs[1].ufbfn = NULL;
- ufbs[2].ufbfn = NULL;
- ufbs[0].ufbflg = UFB_RA | O_RAW | UFB_NC;
- ufbs[1].ufbflg = UFB_WA | O_RAW | UFB_NC;
- ufbs[2].ufbflg = UFB_WA | O_RAW | UFB_NC | UFB_CLO;
-
- ufbs[0].ufbfh = Input();
- ufbs[1].ufbfh = Output();
- if ((ufbs[2].ufbfh = Open("*", MODE_OLDFILE)) == NULL)
- ufbs[2].ufbfh = Open("NIL:", MODE_OLDFILE);
-
- __nufbs += 3;
-
- x = (__fmode) ? 0 : _IOXLAT;
- stdin->_file = 0;
- stdin->_flag = _IOREAD | x;
- stdout->_file = 1;
- stdout->_flag = _IOWRT | _IOLBF | x;
- stderr->_file = 2;
- stderr->_flag = _IOWRT | _IOLBF | x;
-
-
- /* Call user's main program! */
-
- ret = main(line); /* call main function */
- exit(ret);
- }
- @
-
-
- 1.3
- log
- @Removed any Workbench-startup and commandline parsing stuff.
- The `real' main() now gets the unparsed commandline.
- @
- text
- @d1 27
- a27 23
- /**
- ** $Filename: main.c $
- ** $Revision: 1.2 $
- ** $Date: 1993/09/14 17:10:14 $
- **
- ** __main() is a replacement for the standard startup-code, usually
- ** linked to C programs. This one provides the unparsed commandline
- ** to the main program and does not support the Workbench message.
- **
- **
- ** © Copyright 1993 Peter Simons, Germany
- ** All Rights Reserved
- **
- ** $Id: main.c,v 1.2 1993/09/14 17:10:14 simons Exp simons $
- **
- ** ------------------------------ log history ----------------------------
- ** $Log: main.c,v $
- ** Revision 1.2 1993/09/14 17:10:14 simons
- ** Added RCSId string and removed the TINY-stuff.
- **
- ** Revision 1.1 1993/09/14 17:04:08 simons
- ** Initial revision
- **/
- d46 1
- a46 1
- static const char __RCSId[] = "$Id: main.c,v 1.2 1993/09/14 17:10:14 simons Exp simons $";
- @
-
-
- 1.2
- log
- @Added RCSId string and removed the TINY-stuff.
- @
- text
- @d3 2
- a4 2
- ** $Revision: 1.1 $
- ** $Date: 1993/09/14 17:04:08 $
- d14 1
- a14 1
- ** $Id$
- d18 3
- d38 1
- a38 1
- extern struct ExecBase *SysBase;
- d40 1
- a40 6
- #define MAXARG 32
- #define QUOTE '"'
- #define MAXWINDOW 40
- #define ESCAPE '*'
- #define ESC '\027'
- #define NL '\n'
- d42 1
- a42 1
- #define isspace(c) ((c == ' ')||(c == '\t') || (c == '\n'))
- d44 4
- a47 5
-
- extern int __fmode;
-
- extern char __stdiowin[];
- extern char __stdiov37[];
- a48 2
- extern struct WBStartup *_WBenchMsg;
- int main(int, void *);
- d50 1
- a50 2
- static int argc; /* arg count */
- static char **targv, *argv[MAXARG+1]; /* arg pointers */
- d52 10
- a62 111
- static const char __RCSId[] = "$Id$";
-
- void __stdargs __main(line)
- char *line;
- {
- char **pargv;
- char *argbuf;
- int ret;
-
-
- int x;
- struct Process *process;
- struct FileHandle *handle;
- struct UFB ufbs[3];
- static char window[MAXWINDOW+18];
-
-
- /***
- * Build argument pointer list
- ***/
- while (argc < MAXARG)
- {
- while (isspace(*line)) line++;
- if (*line == '\0') break;
- pargv = &argv[argc++];
- if (*line == QUOTE)
- {
- argbuf = *pargv = ++line; /* ptr inside quoted string */
- while (*line != QUOTE && *line != 0)
- {
- if (*line == ESCAPE)
- {
- line++;
- switch (*line)
- {
- case '\0':
- *argbuf = 0;
- goto linedone;
- case 'E':
- *argbuf++ = ESC;
- break;
- case 'N':
- *argbuf++ = NL;
- break;
- default:
- *argbuf++ = *line;
- }
- line++;
- }
- else
- {
- *argbuf++ = *line++;
- }
- }
- line++;
- *argbuf++ = '\0'; /* terminate arg */
- }
- else /* non-quoted arg */
- {
- *pargv = line;
- while ((*line != '\0') && (!isspace(*line))) line++;
- if (*line == '\0') break;
- else *line++ = '\0'; /* terminate arg */
- }
- } /* while */
-
- linedone:
-
- targv = (argc == 0) ? (char **) _WBenchMsg : (char **) &argv[0];
-
-
- /***
- * Open standard files
- ***/
-
- ufbs[0].ufbnxt = &ufbs[1];
- ufbs[1].ufbnxt = &ufbs[2];
- ufbs[2].ufbnxt = NULL;
- __ufbs = &ufbs[0];
- ufbs[0].ufbfn = NULL;
- ufbs[1].ufbfn = NULL;
- ufbs[2].ufbfn = NULL;
- ufbs[0].ufbflg = UFB_RA | O_RAW | UFB_NC;
- ufbs[1].ufbflg = UFB_WA | O_RAW | UFB_NC;
- ufbs[2].ufbflg = UFB_WA | O_RAW | UFB_NC | UFB_CLO;
-
- if (argc == 0)
- { /* running under workbench */
- if (_WBenchMsg->sm_ToolWindow)
- ufbs[0].ufbfh = Open(_WBenchMsg->sm_ToolWindow, MODE_NEWFILE);
- else
- {
- strcpy(window, __stdiowin);
- strncat(window, _WBenchMsg->sm_ArgList->wa_Name, MAXWINDOW);
-
- if (SysBase->LibNode.lib_Version >= 36)
- strncat(window, __stdiov37, MAXWINDOW+18-strlen(window)-1);
-
- ufbs[0].ufbfh = Open(window, MODE_NEWFILE);
- }
-
- ufbs[0].ufbflg |= UFB_CLO;
- handle = (struct FileHandle *) (ufbs[0].ufbfh << 2);
- process = (struct Process *) FindTask(0);
- process->pr_ConsoleTask = (APTR) handle->fh_Type;
- if ((ufbs[1].ufbfh = Open("*", MODE_OLDFILE)) == NULL)
- ufbs[1].ufbfh = Open("NIL:", MODE_OLDFILE);
- ufbs[2].ufbfh = ufbs[1].ufbfh;
- }
- else
- { /* running under CLI */
- d66 1
- a66 14
- ufbs[2].ufbfh = Open("NIL:", MODE_OLDFILE);
- }
-
-
- __nufbs += 3;
-
-
- x = (__fmode) ? 0 : _IOXLAT;
- stdin->_file = 0;
- stdin->_flag = _IOREAD | x;
- stdout->_file = 1;
- stdout->_flag = _IOWRT | _IOLBF | x;
- stderr->_file = 2;
- stderr->_flag = _IOWRT | _IOLBF | x;
- d68 1
- d70 7
- a77 3
- /***
- * Call user's main program
- ***/
- d79 1
- a79 1
- ret = main(argc, targv); /* call main function */
- d81 2
- a82 1
- exit(ret);
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d3 2
- a4 2
- ** $Revision$
- ** $Date$
- d14 1
- a14 1
- ** $Id§
- d17 3
- a19 1
- ** $Log$
- a46 1
- #ifndef TINY
- a47 1
- #endif
- d59 1
- a60 1
-
- a68 1
- #ifndef TINY
- a73 1
- #endif
- a133 1
- #ifndef TINY
- a187 1
- #endif
- a195 1
- #ifndef TINY
- a196 3
- #else
- __exit(ret);
- #endif
- @
-