home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 28
/
amigaformatcd28.iso
/
-seriously_amiga-
/
archivers
/
arcppc
/
src
/
rcs
/
arcrun.c,v
< prev
next >
Wrap
Text File
|
1998-04-23
|
6KB
|
293 lines
head 1.4;
branch ;
access ;
symbols patch1:1.4;
locks ; strict;
comment @ * @;
1.4
date 88.07.31.18.52.50; author hyc; state Exp;
branches ;
next 1.3;
1.3
date 88.06.01.19.57.16; author hyc; state Exp;
branches ;
next 1.2;
1.2
date 88.06.01.16.24.17; author hyc; state Exp;
branches ;
next 1.1;
1.1
date 88.06.01.16.09.17; author hyc; state Exp;
branches ;
next ;
desc
@@
1.4
log
@fix declarations, fix args to fopen()
@
text
@/*
* $Header: arcrun.c,v 1.3 88/06/01 19:57:16 hyc Locked $
*/
/*
* ARC - Archive utility - ARCRUN
*
* Version 1.20, created on 03/24/86 at 19:34:31
*
* (C) COPYRIGHT 1985,85 by System Enhancement Associates; ALL RIGHTS RESERVED
*
* By: Thom Henderson
*
* Description: This file contains the routines used to "run" a file which is
* stored in an archive. At present, all we really do is (a) extract a
* temporary file, (b) give its name as a system command, and then (c) delete
* the file.
*
* Language: Computer Innovations Optimizing C86
*/
#include <stdio.h>
#include "arc.h"
void rempath(), openarc(), closearc(), abort();
int readhdr(), match(), unpack();
static void runfile();
char *strcat();
void
runarc(num, arg) /* run file from archive */
int num; /* number of arguments */
char *arg[]; /* pointers to arguments */
{
struct heads hdr; /* file header */
char *makefnam(); /* filename fixer */
char buf[STRLEN]; /* filename buffer */
FILE *fopen();/* file opener */
char *dummy[2];
dummy[0]="dummy";
dummy[1]=NULL;
rempath(num, arg); /* strip off paths */
openarc(0); /* open archive for reading */
if (num) { /* if files were named */
while (readhdr(&hdr, arc)) { /* while more files to check */
if (match(hdr.name, makefnam(arg[0], ".*", buf)))
runfile(&hdr, num, arg);
else
fseek(arc, hdr.size, 1);
}
} else
while (readhdr(&hdr, arc)) /* else run all files */
runfile(&hdr, 1, dummy);
closearc(0); /* close archive after changes */
}
static void
runfile(hdr, num, arg) /* run a file */
struct heads *hdr; /* pointer to header data */
int num; /* number of arguments */
char *arg[]; /* pointers to arguments */
{
FILE *tmp, *fopen(); /* temporary file */
char *dir, *gcdir(); /* directory stuff */
char buf[STRLEN], *makefnam(); /* temp file name, fixer */
#if DOS
char nbuf[64], *i, *rindex();
#endif
#if !GEMDOS
int n; /* index */
char sys[STRLEN]; /* invocation command buffer */
#endif
/* makefnam("$ARCTEMP",hdr->name,buf); */
#if UNIX
sprintf(buf, "%s.RUN", arctemp);
strcpy(sys, buf);
#else
strcpy(nbuf, arctemp);
makefnam(nbuf,hdr->name,buf);
i = rindex(buf,'.');
#endif
#if MSDOS
if (!strcmp(i, ".BAS")) {
strcpy(sys, "BASICA ");
strcat(sys, buf);
}
else if (!strcmp(i, ".BAT")
|| !strcmp(i, ".COM")
|| !strcmp(i, ".EXE"))
strcpy(sys, buf);
else {
if (warn) {
printf("File %s is not a .BAS, .BAT, .COM, or .EXE\n",
hdr->name);
nerrs++;
}
fseek(arc, hdr->size, 1); /* skip this file */
return;
}
#endif
#if GEMDOS
if (strcmp(i, ".PRG")
&& strcmp(i, ".TTP")
&& strcmp(i, ".TOS"))
{
if (warn) {
printf("File %s is not a .PRG, .TOS, or .TTP\n",
hdr->name);
nerrs++;
}
fseek(arc, hdr->size, 1); /* skip this file */
return;
}
#endif
if (warn)
if (tmp = fopen(buf, "r"))
abort("Temporary file %s already exists", buf);
if (!(tmp = fopen(buf, OPEN_W)))
abort("Unable to create temporary file %s", buf);
if (note)
printf("Invoking file: %s\n", hdr->name);
dir = gcdir(""); /* see where we are */
unpack(arc, tmp, hdr); /* unpack the entry */
fclose(tmp); /* release the file */
chmod(buf, "700"); /* make it executable */
#if GEMDOS
execve(buf, arg, NULL);
#else
for (n = 1; n < num; n++) { /* add command line arguments */
strcat(sys, " ");
strcat(sys, arg[n]);
}
system(buf); /* try to invoke it */
#endif
chdir(dir);
free(dir); /* return to whence we started */
if (unlink(buf) && warn) {
printf("Cannot unsave temporary file %s\n", buf);
nerrs++;
}
}
@
1.3
log
@Changed compilation conditionals
@
text
@d2 1
a2 1
* $Header: arcrun.c,v 1.2 88/06/01 16:24:17 hyc Locked $
d25 2
a37 1
int runfile();
d60 1
a60 1
static int
d124 1
a124 1
if (!(tmp = fopen(buf, "wb")))
@
1.2
log
@Merge Atari ST code
@
text
@d2 1
a2 1
* $Header: arcrun.c,v 1.1 88/06/01 16:09:17 hyc Locked $
d37 1
a37 1
char *dummy[2]={"dummy",NULL};
d39 2
d68 1
a68 1
#ifdef DOS
d71 1
a71 1
#ifndef GEMDOS
d77 1
a77 1
#ifdef BSD
d85 1
a85 1
#ifdef MSDOS
d105 1
a105 1
#ifdef GEMDOS
d133 1
a133 1
#ifdef GEMDOS
@
1.1
log
@Initial revision
@
text
@d2 1
a2 1
* $Header: arcrun.c,v 1.4 88/04/19 01:40:14 hyc Exp $
d37 1
d46 1
a46 1
runfile(&hdr, num, &arg[1]);
d52 1
a52 1
runfile(&hdr, 0, NULL);
d64 1
d66 5
a70 1
#ifdef MSDOS
a72 2
char *dir, *gcdir(); /* directory stuff */
int n; /* index */
d75 1
d77 6
a82 1
d84 8
a91 2
if (!strcmp(buf, "$ARCTEMP.BAS"))
strcpy(sys, "BASICA $ARCTEMP");
a92 5
else if (!strcmp(buf, "$ARCTEMP.BAT")
|| !strcmp(buf, "$ARCTEMP.COM")
|| !strcmp(buf, "$ARCTEMP.EXE"))
strcpy(sys, "$ARCTEMP");
d103 14
d121 1
a121 1
if (!(tmp = fopen(buf, "w")))
a126 5
for (n = 0; n < num; n++) { /* add command line arguments */
strcat(buf, " ");
strcat(buf, arg[n]);
}
d131 7
d139 1
@