Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ucbvax!CORNELLC.CCS.CORNELL.EDU.BITNET!ewilts%Ins.MRC.AdhocNet.CA%Stasis.MRC.AdhocNet.CA%UNCAEDU. From: ewilts%Ins.MRC.AdhocNet.CA%Stasis.MRC.AdhocNet.CA%UNCAEDU.@CORNELLC.CCS.CORNELL.EDU.BITNET (Ed Wilts) Newsgroups: comp.os.vms Subject: ARC_C.SHAR11_OF_19 Message-ID: <880624092639.02b@Ins.MRC.AdhocNet.CA> Date: 24 Jun 88 15:26:36 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 162 $Part11: $ File_is="ARCRUN.C" $ Check_Sum_is=6780394 $ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY Xstatic char *RCSid = "$Header: arcrun.c,v 1.2 86/07/15 07:53:55 turner Exp $"; X X/* X * $Log:`009arcrun.c,v $ X * Hack-attack 1.3 86/12/20 01:23:45 wilhite@usceast.uucp X * `009Bludgeoned into submission for VAX 11/780 BSD4.2 X *`009(ugly code, but fewer core dumps) X * X * Revision 1.2 86/07/15 07:53:55 turner X * X * X * Revision 1.1 86/06/26 15:00:40 turner X * initial version X * X * X */ X X/* ARC - Archive utility - ARCRUN X X$define(tag,$$segment(@1,$$index(@1,=)+1))# X$define(version,Version $tag( XTED_VERSION DB =1.17), created on $tag( XTED_DATE DB =02/03/86) at $tag( XTED_TIME DB =22:59:06))# X$undefine(tag)# X $version X X(C) COPYRIGHT 1985 by System Enhancement Associates; ALL RIGHTS RESERVED X X By: Thom Henderson X X Description: X This file contains the routines used to "run" a file X which is stored in an archive. At present, all we really do X is (a) extract a temporary file, (b) give its name as a system X command, and then (c) delete the file. X X Language: X Computer Innovations Optimizing C86 X*/ X#include X#include "arc.h" X XINT runarc(num,arg) /* run file from archive */ XINT num; /* number of arguments */ Xchar *arg[]; /* pointers to arguments */ X{ X struct heads hdr; /* file header */ X INT run; /* true to run current file */ X INT did[MAXARG]; /* true when argument was used */ X INT n; /* index */ X char *makefnam(); /* filename fixer */ X char buf[STRLEN]; /* filename buffer */ X FILE *fopen(); /* file opener */ X INT runfile(); X X for(n=0; nname,buf); */ X sprintf(buf,"%s.RUN",arctemp); X X/* if(!strcmp(buf,"$ARCTEMP.BAS")) X * strcpy(sys,"BASICA $ARCTEMP"); X * X * else if(!strcmp(buf,"$ARCTEMP.BAT") X * || !strcmp(buf,"$ARCTEMP.COM") X * || !strcmp(buf,"$ARCTEMP.EXE")) X * strcpy(sys,"$ARCTEMP"); X * X * else X * { if(warn) X * { printf("File %s is not a .BAS, .BAT, .COM, or .EXE\n", X * hdr->name); X * nerrs++; X * } X * fseek(arc,hdr->size,1); X * return; X * } X */ X X if(warn) X if(tmp=fopen(buf,"r")) X abort("Temporary file %s already exists",buf); X if(!(tmp=fopen(buf,"w"))) X abort("Unable to create temporary file %s",buf); X X if(note) X printf("Invoking file: %s\n",hdr->name); X X dir = gcdir(""); /* see where we are */ X unpack(arc,tmp,hdr); /* unpack the entry */ X fclose(tmp); /* release the file */ X chmod(buf,"700"); /* make it exec'able */ X#ifdef VAXC X/* X * If we want to get fancy we could check for .COM files etc... X */ X strcpy(sys,"$ RUN "); X strcat(sys, buf); X system(sys); X#else X system(buf); /* try to invoke it */ X#endif X chdir(dir); free(dir); /* return to whence we started */ X X if(unlink(buf) && warn) X { printf("Cannot unsave temporary file %s\n",buf); X nerrs++; X } X} X $ GoSub Convert_File $ Goto Part13