home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OS9000
/
APPS
/
rcs.lzh
/
rcs1
/
mani.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-04-20
|
4KB
|
135 lines
/*-----------------------------------------------------------------------
! !
! Name: mani !
! !
! Function: MANIFEST file processor !
! !
! Revision History: !
! # Reason for Change By Date !
! ---- ----------------------------------------------- ---- -------- !
! 1 Created hiro 3/24/93 !
-----------------------------------------------------------------------*/
#ifdef _UCC
_asm("_sysedit: equ 1");
#define environ _environ
#else
@_sysedit: equ 1
#endif
#ifdef _OS9000
#include <io.h>
#define environ _environ
#else
#include <sysio.h>
#endif
#include <stdio.h>
#include <ctype.h>
#include <strings.h>
#include <errno.h>
#ifndef _types
#include <types.h>
#endif
#define MAXARGC 256
FILE *namefile;
char *filename = "MANIFEST";
char *files[MAXARGC + 1];
extern char *_prgname(), **environ;
extern void *malloc();
extern int os9forkc();
int vopt;
main(argc, argv)
int argc;
char *argv[];
{
FILE *file;
register char *p, **fpp;
register int ch, waseq = 0;
char buf[256];
u_int status;
while (--argc > 0 && *(p = *++argv) == '-')
{
++p;
while (ch = *p++)
{
waseq = *p == '=';
if (waseq)
++p;
switch (ch)
{
case 'v':
vopt = 1; continue;
case 'z':
filename = p;
break;
default:
prtuse(_errmsg(1,"unknown option '%c'.\n\n",ch));
case '?':
prtuse(0);
}
break;
}
}
if (!argc)
prtuse(1);
for (ch = 0; argc > 0 && ch < MAXARGC; argc--)
files[ch++] = *argv++;
if ((namefile = fopen(filename,"r")) == NULL)
exit(_errmsg(errno,"can't open \"%s\" ",filename));
while (p = fgets(buf, sizeof(buf), namefile))
{
p[strlen(p) - 1] = '\0';
while (isspace(*p))
p++;
if (!*p || *p == '#' || *p == '*')
continue;
else if (ch >= MAXARGC - 1)
_errmsg(1, "too many lines; \"%s\" discarded.\n", p);
else if (!(files[ch] = malloc(strlen(p)+1)))
_errmsg(1, "memory allocation error; \"%s\" discarded.\n", p);
strcpy(files[ch++], p);
}
if (vopt)
for (fpp = files; *fpp; fpp++)
fprintf(stderr, "%s%c", *fpp, fpp[1] ? ' ' : '\n');
if ((ch = os9exec(os9forkc, *files, files, environ, 0, 0, 3)) == -1)
exit(_errmsg(errno, "can't fork \"%s\". ", *files));
while (wait(&status) != ch)
;
exit(status);
}
/**--------------------------------------------------------------
! cmds[] - array of pointers to strings of help text
!*/
static char *cmds[] = {
"Function: appliy manifest file contents to <command>\n",
"Options:\n",
" -v verbose mode\n",
" -z[=<file>] override default manifest file \"MANIFEST\"\n"
};
/**--------------------------------------------------------------
! printuse - print the help text to standard error.
!*/
static prtuse(stat)
int stat;
{
register char **p = cmds,
**e = cmds + sizeof cmds / sizeof (char *);
fprintf(stderr,"Syntax: %s {<opts>} <command> {<params>}\n", _prgname());
while (p < e)
fputs(*p++,stderr);
exit(stat);
}