From: CSBVAX::MRGATE!RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP 12-AUG-1988 02:10 To: ARISIA::EVERHART Subj: Re: VMS versions of rm, mv etc? Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Thu, 11 AUG 88 22:53:51 PDT Received: from CitHex.Caltech.Edu by KL.SRI.COM with TCP; Thu, 11 Aug 88 22:43:39 PDT Date: Thu, 11 Aug 88 22:42:29 PDT From: carl@CitHex.Caltech.Edu (Carl J Lydick) Message-Id: <880811224010.e77@CitHex.Caltech.Edu> Subject: Re: VMS versions of rm, mv etc? In-Reply-To: Your message <1322@ucsfcca.ucsf.edu> dated 10-Aug-1988 To: cca.ucsf.edu!ccb.ucsf.edu!dick@cgl.ucsf.edu, info-vax@CitHex.Caltech.Edu > We are using the Gnu gcc compiler to support printing from a VMS > MicroVAX II thru the Excelan TCP/IP board to an IBM machine with > a big fast printer. Several parts of the VMS program are rather > slow and complicated because we don't know the right way to: Even though you're using the GNU C compiler, that shouldn't stop you from using the VAX C Run-Time Library. Using said library probably won't make your program any faster, but it could make it less complicated. The appropriate calls are listed below. ******************************************************************************** - remove a file (rm) from within a C program int delete(char *file_specification); - rename a file (mv) int rename (const char *old_file_spec, const char *new_file_spec); - start a process & pass a command line int system (const char *string); - make a directory (mkdir) int mkdir(char *dir_spec, unsigned mode [,unsigned uic, unsigned max_versions, unsigned r_v_num]); The argument, dir_spec, is a valid VAX/VMS or DEC/Shell directory specification which can include a device name. The argument, mode, sets the file protection (see chmod in The Guide to VAX C); the argument, uic, sets the User Identification Code; the argument, r_v_num sets the relative volume number. This function returns zero on success and -1 on failure. - remove a directory (rmdir) int chmod(char *name, unsigned mode); int delete(char *file_specification); First chmod the directory to give yourself delete permission on it, then use delete to delete it. You can't delete the directory if there are any files still in it. - change ownership of a file (chown) In Unix compatibility library?? int chown(char *name, unsigned owner, unsigned group); - change permissions of a file (chmod) In same library?? int chmod(char *name, unsigned mode); ******************************************************************************** - link a new filename to also refer to an existing file (ln) This one's a little tougher, since DEC discourages users creating multiple directory entries for files. There is, therefore, no corresponding VAX C Run-Time function. However, the following program does the job. You'll have to come up with your own versions of FAB.H and NAM.H. ******************************************************************************** #include fab.h #include nam.h ln(oldname, newname) char *oldname, *newname; { struct FAB fab; struct NAM nam; char esabuf[64]; short did[3], fid[3]; int i, stat; fab = cc$rms_fab; nam = cc$rms_nam; fab.fab$l_fna = oldname; fab.fab$b_fns = strlen(oldname); fab.fab$b_fac = FAB$M_GET; fab.fab$w_ifi = 0; fab.fab$b_shr = FAB$M_SHRGET; fab.fab$l_nam = &nam; stat = SYS$OPEN(&fab); if ((stat & 7) != 1) exit(stat); SYS$CLOSE(&fab); for (i = 0; i < 3; ++i) { did[i] = nam.nam$w_did[i]; fid[i] = nam.nam$w_fid[i]; } fab = cc$rms_fab; nam = cc$rms_nam; fab.fab$l_fna = newname; fab.fab$b_fns = strlen(newname); fab.fab$w_ifi = 0; fab.fab$l_nam = &nam; nam.nam$l_esa = esabuf; nam.nam$b_ess = 64; stat = SYS$PARSE(&fab); if ((stat & 7) != 1) exit(stat); for (i = 0; i < 3; ++i) { nam.nam$w_did[i] = did[i]; nam.nam$w_fid[i] = fid[i]; } stat = SYS$ENTER(&fab); exit(stat); }