[comp.sys.dec] Shell functions in VAX C

molik@acsu.buffalo.edu (gregory b molik) (06/08/90)

Could someone please describe the syntax for the SHELL$TO_VMS function?


Greg
molik@acsu.buffalo.edu
ACSCGBM@UBVMS

leonard@telcom.arizona.edu (Aaron Leonard) (06/08/90)

>Could someone please describe the syntax for the SHELL$TO_VMS function?

Yeah, I actually tried using this beast once and it's a weird 'un.  It's
pretty complex, because it allows successive calls to explode wildcarded
filespecs into a series of VMS-ized specific filenames.  And you have to
pass it the address of a routine to deal with the filename returned.

I wrote up a little jacket routine to handle the simple (only one filename
returned) case; you can link it into your program.

Have fun,

Aaron

/* unix-filespec-to-vms.c
 */

static char ux_emul_vms_filespec[255];  /* a place to stash the VMS-y filespec
                                         * that SHELL$TO_VMS returns
                                         */

/* unix_filespec_to_vms
 *   Use SHELL$TO_VMS to translate a U*x-y filespec to a VMS-y one.
 *   
 * Returns: 0 if no filenames matched the input filespec, else 1.
 * Returns the first matching VMS-y filespec in first arg.
 *
 */

int unix_filespec_to_vms(vmsspec, unixspec)
char *vmsspec;
char *unixspec;                         /* possibly wild */
{
    int ux_emul_act_routine(), SHELL$TO_VMS();
    int num_files_found;

    num_files_found = SHELL$TO_VMS(unixspec, ux_emul_act_routine, 1);
    if (num_files_found != 1)
       return (0);
    strcpy(vmsspec, ux_emul_vms_filespec);
    return (1);
        
}   /* unix_filespec_to_vms */

int ux_emul_act_routine(fspec)
char *fspec;
{
    /* this routine is fired off by SHELL$TO_VMS if it finds any files. */

    strcpy(ux_emul_vms_filespec, fspec);        /* stash the filename */
    return (0);                                 /* don't get called again */
}

terence@hkov04.dec.com (Terence Lee @HKO, Digital Equipment Corporation) (06/08/90)

In article <27786@eerie.acsu.Buffalo.EDU>, molik@acsu.buffalo.edu (gregory b molik) writes...
#
#
#Could someone please describe the syntax for the SHELL$TO_VMS function?
#
#
#Greg
#molik@acsu.buffalo.edu
#ACSCGBM@UBVMS

/*
 *  shell$to_vms(shell_file_spec,user_written_action_routine,wildcard_flag)
 *  char    *shell_file_spec;
 *  int	    user_written_action_routine();
 *  int	    wildcard_flag;
 *
 *  return number_of_files_translated
 *
 *  int user_written_action_routine(vms_file_spec)
 *  char    *vms_file_spec;
 *
 *  return 1 for wildcard search to continue
 */

#include <stdio.h>

#define shell_1		"/dua1/deilhk/mis/terence/login.com"
#define shell_2		"/dua1/deilhk/mis/terence/*.*"

char	result[255];
char	*shell_to_vms_action();

main()
{
	printf("SHELL$TO_VMS %s\n",shell_1);
	shell$to_vms(shell_1,shell_to_vms_action,0);
	printf("SHELL$TO_VMS %s\n",shell_2);
	shell$to_vms(shell_2,shell_to_vms_action,1);
}

char *shell_to_vms_action(str)
char	*str;
{
	strcpy(result,str);
	printf("\t%s\n",result);
	return(1);
}

================================================================================
Terence Lee     terence%hkov04.dec@decwrl.dec.com
                root%hkvs04.dec@decwrl.dec.com
From Middlesex, UWO
================================================================================