From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f7344,32c594a83e2d8db X-Google-Attributes: gidf7344,public X-Google-Thread: 114b0c,32c594a83e2d8db X-Google-Attributes: gid114b0c,public X-Google-Thread: 1164f8,32c594a83e2d8db X-Google-Attributes: gid1164f8,public X-Google-Thread: 111308,32c594a83e2d8db X-Google-Attributes: gid111308,public X-Google-ArrivalTime: 1993-10-14 13:45:31 PST Xref: gmd.de comp.client-server:1573 comp.os.vms:32698 comp.sys.dec:10912 comp.sys.hp:26259 Path: gmd.de!xlink.net!howland.reston.ans.net!usc!elroy.jpl.nasa.gov!nntp-server.caltech.edu!SOL1.GPS.CALTECH.EDU!CARL From: carl@SOL1.GPS.CALTECH.EDU (Carl J Lydick) Newsgroups: comp.client-server,comp.os.vms,comp.sys.dec,comp.sys.hp Subject: Re: Move from VMS to Open VMS or to HP-UX? Advice sought! Date: 14 Oct 1993 19:50:16 GMT Organization: HST Wide Field/Planetary Camera Distribution: world Message-ID: <29kahoINNc6b@gap.caltech.edu> References: <1993Oct8.132923.2213@ivax> <294mn6$hn6@hpfcbig.sde.hp.com> <1993Oct9.110807.20739@infodev.cam.ac.uk>,<29enij$ivr@hpfcbig.sde.hp.com> Reply-To: carl@SOL1.GPS.CALTECH.EDU NNTP-Posting-Host: sol1.gps.caltech.edu In article <29enij$ivr@hpfcbig.sde.hp.com>, marc@sde.hp.com (Marc Sabatella) writes: ="Parsing" was the wrong for me to have used; the original post mentioned ="specification of file arguments". That is, for a given command that operates =on a set of files, how is that set of files specified? The Unix model is to =allow a list to be presented on stdin, so you can generate the list however you =want - including by listing them in a text file. The original implication was =that VMS programs included code to handle various methods of specification. I =have since been informed that the poster was incorrect - VMS programs do not =include such code, but rather, the "shell" handles it all. This then =eliminates the inconsistency problem, but it does nothing to eliminate the =customization problem ("but I *want* to specify my files this way that the =shell doesn't support"). Your above paragraph is incomprehensible. First of all, the unix model for specifying files is to have the shell deal with any wild-cards and hand the program the resulting list of files as arguments. VMS does NOT have a "shell," and even if you insist on calling DCL a shell, it STILL doesn't "handle it all" in the sense you seem to be claiming. Any image that wants to handle wild-carded filespecs is responsible for generating its own list of filespecs from the wild-carded versions. However, the library routine LIB$FIND_FILE will take care of figuring out what the syntax of the filespec means. It's not at all difficult to write a subroutine to call LIB$FIND_FILE and generate a list of filenames in the standard UNIX style. If you want to muck around with non-standard syntax for filespecs, you need only have the subroutine do its own preparsing on the filespec it's supplied before handing it to LIB$FIND_FILE. Here's a simple subroutine that handles standard VMS filespecs (including, if you wish, remote node specifications and access control strings): /******************************************************************************\ * get_files: Expand a wild-carded filespec, placing the results into an * * array of character pointers; * * Arguments: * * char *spec : input filespec; * * int *nfiles: pointer to integer to receive count of matching filespecs * * char ***filelist : pointer to character pointer pointer to receive address* * of array of character pointers to resulting files * \******************************************************************************/ #include descrip #define $DESCRIPTOR_D(name) struct dsc$descriptor_d name = \ { 0, DSC$K_DTYPE_T, DSC$K_CLASS_D, 0 } get_files(char *spec, int *nfiles, char ***filelist) { $DESCRIPTOR(filespec, spec); $DESCRIPTOR_D(result); int context, i; struct NODE { struct NODE *NODE_nxtnode; char *NODE_value; } *root_node, *node; root_node = (struct NODE *) malloc(sizeof(struct NODE)); node = root_node; context = *nfiles = 0; filespec.dsc$w_length = strlen(spec); while((LIB$FIND_FILE(&filespec, &result, &context, 0, 0, 0, 0) & 7) == 1) { node->NODE_nxtnode = (struct NODE *) malloc(sizeof(struct NODE)); node->NODE_value = (char *) malloc(result.dsc$w_length + 1); strncpy(node->NODE_value, result.dsc$a_pointer, result.dsc$w_length); node->NODE_value[result.dsc$w_length] = '\0'; ++*nfiles; node = node->NODE_nxtnode; } LIB$FIND_FILE_END(&context); *filelist = (char **) malloc((*nfiles + 1) * sizeof(char *)); for(i = 0, node = root_node; i < * nfiles; ++i) { (*filelist)[i] = node->NODE_value; node = node->NODE_nxtnode; free(root_node); root_node = node; } (*filelist)[i] = 0; } /******************************************************************************/ Here's an example of using it to print out a list of all filespecs matching each f the arguments passed to a program: main(int nargs, char **args) { char **files; int nfiles, i, j; for(j = 1; j < nargs; ++j) { get_files(args[j], &nfiles, &files); for(i = 0; i < nfiles; ++i) puts(files[i]); } } -------------------------------------------------------------------------------- Carl J Lydick | INTERnet: CARL@SOL1.GPS.CALTECH.EDU | NSI/HEPnet: SOL1::CARL Disclaimer: Hey, I understand VAXen and VMS. That's what I get paid for. My understanding of astronomy is purely at the amateur level (or below). So unless what I'm saying is directly related to VAX/VMS, don't hold me or my organization responsible for it. If it IS related to VAX/VMS, you can try to hold me responsible for it, but my organization had nothing to do with it.