diff options
Diffstat (limited to 'vms')
-rw-r--r-- | vms/ChangeLog | 5 | ||||
-rw-r--r-- | vms/vms.h | 73 | ||||
-rw-r--r-- | vms/vms_args.c | 20 | ||||
-rw-r--r-- | vms/vms_cli.c | 44 | ||||
-rw-r--r-- | vms/vms_fwrite.c | 10 | ||||
-rw-r--r-- | vms/vms_misc.c | 6 | ||||
-rw-r--r-- | vms/vms_popen.c | 43 |
7 files changed, 135 insertions, 66 deletions
diff --git a/vms/ChangeLog b/vms/ChangeLog index cdcdcf04..3a16319a 100644 --- a/vms/ChangeLog +++ b/vms/ChangeLog @@ -7,7 +7,7 @@ update. (vms_debug) New command to switch to debug_gawk New/fixed tests: - (basic) badassign1,dfamb1,exit2,nfloop,badbuild, + (basic) badassign1,dfamb1,exit2,nfloop,badbuild, callparam,exitval2,exitval3,inpref,paramasfunc1, paramasfunc2,regexpbrack,sortglos,rebrackloc aryprm9,nulinsrc,rstest4,rstest5 @@ -18,6 +18,9 @@ (locale) backbigs1,backsmalls1,backsmalls2,mbprintf4 (shlib) inplace2,testext,lc_num1,mbprintf1, mbprintf2,mbprintf3,mbprintf4,mbfw1,ordchr2 + * vms.h, vms_args.c, vms_cli.c, vms_fwrite.c, + vms_misc.c, vms_popen.c: + Use VMS provided descriptor definitions. 2016-01-27 John E. Malmberg <wb8tyw@qsl.net> @@ -3,7 +3,7 @@ * Pat Rankin, Nov'89 */ -#if 0 +#if 1 #include <iodef.h> #else #define IO$_WRITEVBLK 48 /* write virtual block */ @@ -11,7 +11,7 @@ #define IO$M_CANCTRLO (1 << IO$V_CANCTRLO) #endif -#if 0 +#if 1 #include <clidef.h> #include <cliverbdef.h> #include <fscndef.h> @@ -22,19 +22,26 @@ #define FSCN$_FILESPEC 1 #endif -#if 0 +#if 1 #include <climsgdef.h> #else -#define CLI$_RUNUSED 0x00030000 /* value returned by $CLI for "RUN" */ -#define CLI$_SYNTAX 0x000310FC /* error signalled by CLI$DCL_PARSE */ #define CLI$_INSFPRM 0x00038048 /* insufficient parameters */ #define CLI$_VALREQ 0x00038150 /* missing required value */ #define CLI$_NEGATED 0x000381F8 /* explicitly negated */ #define CLI$_CONFLICT 0x00038258 /* conflicting qualifiers */ #define CLI$_NOOPTPRS 0x00038840 /* no option present */ #endif +/* Missing in VAX/VMS 7.3 */ +#ifndef CLI$_RUNUSED +#define CLI$_RUNUSED 0x00030000 /* value returned by $CLI for "RUN" */ +#endif +/* Missing as of VMS 8.4 */ +#ifndef CLI$_SYNTAX +#define CLI$_SYNTAX 0x000310FC /* error signalled by CLI$DCL_PARSE */ +#endif + -#if 0 +#if 1 #include <psldef.h> #else #define PSL$C_USER 3 /* user mode */ @@ -44,36 +51,60 @@ typedef unsigned long U_Long; typedef unsigned short U_Short; -typedef struct _dsc { int len; char *adr; } Dsc; /* limited string descriptor */ - /* standard VMS itemlist-3 structure */ +#include <descrip.h> +#include <stsdef.h> + +#pragma member_alignment save +#pragma nomember_alignment longword +#pragma message save +#pragma message disable misalgndmem typedef struct _itm { U_Short len, code; void *buffer; U_Short *retlen; } Itm; +#pragma message restore +#pragma member_alignment restore + -#define vmswork(sts) ((sts)&1) -#define vmsfail(sts) (!vmswork(sts)) +#define vmswork(sts) $VMS_STATUS_SUCCESS(sts) +#define vmsfail(sts) (!$VMS_STATUS_SUCCESS(sts)) #define CondVal(sts) ((sts)&0x0FFFFFF8) /* strip severity & msg inhibit */ -#define Descrip(strdsc,strbuf) Dsc strdsc = {sizeof strbuf - 1, (char *)strbuf} +#define Descrip(strdsc,strbuf) struct dsc$descriptor_s \ + strdsc = {sizeof strbuf - 1, DSC$K_DTYPE_T, DSC$K_CLASS_S, (char *)strbuf} extern int shell$is_shell(void); -extern U_Long LIB$FIND_FILE(const Dsc *, Dsc *, void *, ...); +extern U_Long LIB$FIND_FILE(const struct dsc$descriptor_s *, + struct dsc$descriptor_s *, void *, ...); extern U_Long LIB$FIND_FILE_END(void *); #ifndef NO_TTY_FWRITE extern U_Long LIB$GET_EF(long *); -extern U_Long SYS$ASSIGN(const Dsc *, short *, long, const Dsc *); +extern U_Long SYS$ASSIGN(const struct dsc$descriptor_s *, short *, long, + const struct dsc$descriptor_s *); extern U_Long SYS$DASSGN(short); extern U_Long SYS$QIO(U_Long, U_Long, U_Long, void *, void (*)(U_Long), U_Long, const char *, int, int, U_Long, int, int); extern U_Long SYS$SYNCH(long, void *); #endif /*!NO_TTY_FWRITE*/ -extern U_Long LIB$SPAWN(const Dsc *,const Dsc *,const Dsc *, - const U_Long *,const Dsc *,U_Long *,U_Long *,...); +extern U_Long LIB$SPAWN(const struct dsc$descriptor_s *, + const struct dsc$descriptor_s *, + const struct dsc$descriptor_s *, + const U_Long *, + const struct dsc$descriptor_s *, + U_Long *, U_Long * ,...); /* system services for logical name manipulation */ -extern U_Long SYS$TRNLNM(const U_Long *,const Dsc *,const Dsc *, - const unsigned char *,Itm *); -extern U_Long SYS$CRELNM(const U_Long *,const Dsc *,const Dsc *, - const unsigned char *,const Itm *); -extern U_Long SYS$CRELOG(int,const Dsc *,const Dsc *,unsigned char); -extern U_Long SYS$DELLNM(const Dsc *,const Dsc *,const unsigned char *); +extern U_Long SYS$TRNLNM(const U_Long *, + const struct dsc$descriptor_s *, + const struct dsc$descriptor_s *, + const unsigned char *, Itm *); +extern U_Long SYS$CRELNM(const U_Long *, + const struct dsc$descriptor_s *, + const struct dsc$descriptor_s *, + const unsigned char *, const Itm *); +extern U_Long SYS$CRELOG(int, + const struct dsc$descriptor_s *, + const struct dsc$descriptor_s *, + unsigned char); +extern U_Long SYS$DELLNM(const struct dsc$descriptor_s *, + const struct dsc$descriptor_s *, + const unsigned char *); extern void v_add_arg(int, const char *); extern void vms_exit(int); diff --git a/vms/vms_args.c b/vms/vms_args.c index 12165131..de94b641 100644 --- a/vms/vms_args.c +++ b/vms/vms_args.c @@ -319,7 +319,7 @@ static void vms_expand_wildcards( const char *prospective_filespec ) { char *p, spec_buf[255+1], res_buf[255+1]; - Dsc spec, result; + struct dsc$descriptor_s spec, result; void *context; register int len = strlen(prospective_filespec); @@ -333,8 +333,14 @@ vms_expand_wildcards( const char *prospective_filespec ) else if (strchr(spec_buf, '*') == strchr(spec_buf, '%') /* => both NULL */ && strstr(spec_buf, "...") == NULL) return; /* no wildcards present; don't attempt file lookup */ - spec.len = len, spec.adr = spec_buf; - result.len = sizeof res_buf - 1, result.adr = res_buf; + spec.dsc$w_length = len; + spec.dsc$a_pointer = spec_buf; + spec.dsc$b_dtype = DSC$K_DTYPE_T; + spec.dsc$b_class = DSC$K_CLASS_S; + result.dsc$w_length = sizeof res_buf - 1; + result.dsc$a_pointer = res_buf; + result.dsc$b_dtype = DSC$K_DTYPE_T; + result.dsc$b_class = DSC$K_CLASS_S; /* The filespec is already in v_argv[v_argc]; if we fail to match anything, we'll just leave it there (unlike most shells, where it would evaporate). @@ -395,7 +401,7 @@ skipblanks( const char *ptr ) static U_Long vms_define( const char *log_name, const char *trans_val ) { - Dsc log_dsc; + struct dsc$descriptor_s log_dsc; static Descrip(lnmtable,"LNM$PROCESS_TABLE"); static U_Long attr = LNM$M_CONFINE; static Itm itemlist[] = { {0,LNM$_STRING,0,0}, {0,0} }; @@ -407,8 +413,10 @@ vms_define( const char *log_name, const char *trans_val ) && (trans_val[len] == '\0' || trans_val[len] == ':')) return 0; - log_dsc.adr = (char *)log_name; - log_dsc.len = len; + log_dsc.dsc$a_pointer = (char *)log_name; + log_dsc.dsc$w_length = len; + log_dsc.dsc$b_dtype = DSC$K_DTYPE_T; + log_dsc.dsc$b_class = DSC$K_CLASS_S; itemlist[0].buffer = (char *)trans_val; itemlist[0].len = strlen(trans_val); return SYS$CRELNM(&attr, &lnmtable, &log_dsc, &acmode, itemlist); diff --git a/vms/vms_cli.c b/vms/vms_cli.c index 08e2d142..13c7979d 100644 --- a/vms/vms_cli.c +++ b/vms/vms_cli.c @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - + /* * vms_cli.c - command line interface routines. @@ -29,11 +29,12 @@ #include <string.h> #endif -extern U_Long CLI$PRESENT(const Dsc *); -extern U_Long CLI$GET_VALUE(const Dsc *, Dsc *, short *); -extern U_Long CLI$DCL_PARSE(const Dsc *, const void *, ...); +extern U_Long CLI$PRESENT(const struct dsc$descriptor_s *); +extern U_Long CLI$GET_VALUE(const struct dsc$descriptor_s *, + struct dsc$descriptor_s *, short *); +extern U_Long CLI$DCL_PARSE(const struct dsc$descriptor_s *, const void *, ...); extern U_Long SYS$CLI(void *, ...); -extern U_Long SYS$FILESCAN(const Dsc *, void *, long *); +extern U_Long SYS$FILESCAN(const struct dsc$descriptor_s *, void *, long *); extern void *LIB$ESTABLISH(U_Long (*handler)(void *, void *)); extern U_Long LIB$SIG_TO_RET(void *, void *); /* condition handler */ @@ -42,10 +43,12 @@ extern U_Long LIB$SIG_TO_RET(void *, void *); /* condition handler */ U_Long Cli_Present( const char *item ) { - Dsc item_dsc; + struct dsc$descriptor_s item_dsc; (void)LIB$ESTABLISH(LIB$SIG_TO_RET); - item_dsc.len = strlen(item_dsc.adr = (char *)item); + item_dsc.dsc$w_length = strlen(item_dsc.dsc$a_pointer = (char *)item); + item_dsc.dsc$b_dtype = DSC$K_DTYPE_T; + item_dsc.dsc$b_class = DSC$K_CLASS_S; return CLI$PRESENT(&item_dsc); } @@ -54,13 +57,18 @@ Cli_Present( const char *item ) U_Long Cli_Get_Value( const char *item, char *result, int size ) { - Dsc item_dsc, res_dsc; + struct dsc$descriptor_s item_dsc, res_dsc; U_Long sts; short len = 0; (void)LIB$ESTABLISH(LIB$SIG_TO_RET); - item_dsc.len = strlen(item_dsc.adr = (char *)item); - res_dsc.len = size, res_dsc.adr = result; + item_dsc.dsc$w_length = strlen(item_dsc.dsc$a_pointer = (char *)item); + item_dsc.dsc$b_dtype = DSC$K_DTYPE_T; + item_dsc.dsc$b_class = DSC$K_CLASS_S; + res_dsc.dsc$w_length = size; + res_dsc.dsc$a_pointer = result; + res_dsc.dsc$b_dtype = DSC$K_DTYPE_T; + res_dsc.dsc$b_class = DSC$K_CLASS_S; sts = CLI$GET_VALUE(&item_dsc, &res_dsc, &len); result[len] = '\0'; return sts; @@ -75,7 +83,8 @@ Cli_Parse_Command( const void *cmd_tables, const char *cmd_verb ) { struct { short len, code; void *adr; } fscn[2]; struct { char rqtype, rqindx, rqflags, rqstat; unsigned :32; - Dsc rdesc; unsigned :32; unsigned :32; unsigned :32; } cmd; + struct dsc$descriptor_s rdesc; + unsigned :32; unsigned :32; unsigned :32; } cmd; U_Long sts; int ltmp; char longbuf[8200]; @@ -93,15 +102,16 @@ Cli_Parse_Command( const void *cmd_tables, const char *cmd_verb ) memset(fscn, 0, sizeof fscn); fscn[0].code = FSCN$_FILESPEC; /* full file specification */ (void)SYS$FILESCAN(&cmd.rdesc, fscn, (long *)0); - cmd.rdesc.len -= fscn[0].len; /* shrink size */ - cmd.rdesc.adr += fscn[0].len; /* advance ptr */ + cmd.rdesc.dsc$w_length -= fscn[0].len; /* shrink size */ + cmd.rdesc.dsc$a_pointer += fscn[0].len; /* advance ptr */ } /* prepend verb and then parse the command line */ strcat(strcpy(longbuf, cmd_verb), " "), ltmp = strlen(longbuf); - if (cmd.rdesc.len + ltmp > sizeof longbuf) - cmd.rdesc.len = sizeof longbuf - ltmp; - strncpy(&longbuf[ltmp], cmd.rdesc.adr, cmd.rdesc.len); - cmd.rdesc.len += ltmp, cmd.rdesc.adr = longbuf; + if (cmd.rdesc.dsc$w_length + ltmp > sizeof longbuf) + cmd.rdesc.dsc$w_length = sizeof longbuf - ltmp; + strncpy(&longbuf[ltmp], + cmd.rdesc.dsc$a_pointer, cmd.rdesc.dsc$w_length); + cmd.rdesc.dsc$w_length += ltmp, cmd.rdesc.dsc$a_pointer = longbuf; sts = CLI$DCL_PARSE(&cmd.rdesc, cmd_tables); } diff --git a/vms/vms_fwrite.c b/vms/vms_fwrite.c index f29ec832..76eec6bd 100644 --- a/vms/vms_fwrite.c +++ b/vms/vms_fwrite.c @@ -78,12 +78,16 @@ tty_fwrite( const void *buf, size_t size, size_t number, FILE *file ) if (chan == 0) { /* if not initialized, need to assign a channel */ if (isatty(file_num) > 0 /* isatty: 1=yes, 0=no, -1=problem */ && ! do_debug) { - Dsc device; + struct dsc$descriptor_s device; char devnam[255+1]; fgetname(file, devnam); /* get 'file's name */ - device.len = strlen(device.adr = devnam); /* create descriptor */ - if (vmswork(SYS$ASSIGN(&device, &chan, 0, (Dsc *)0))) { + /* create descriptor */ + device.dsc$w_length = strlen(device.dsc$a_pointer = devnam); + device.dsc$b_dtype = DSC$K_DTYPE_T; + device.dsc$b_class = DSC$K_CLASS_S; + if (vmswork(SYS$ASSIGN(&device, &chan, 0, + (struct dsc$descriptor_s *)0))) { /* get an event flag; use #0 if problem */ if (evfn == -1 && vmsfail(LIB$GET_EF(&evfn))) evfn = 0; } else chan = 0; /* $ASSIGN failed */ diff --git a/vms/vms_misc.c b/vms/vms_misc.c index 82c2f8a8..e561af59 100644 --- a/vms/vms_misc.c +++ b/vms/vms_misc.c @@ -120,7 +120,7 @@ vms_open( const char *name, int mode, ... ) struct stat stb; int stat_result; const char *mbc, *shr = "shr=get", *ctx = "ctx=stm"; - + stat_result = stat((char *)name, &stb); if ( stat_result < 0) { /* assume DECnet */ mbc = "mbc=8"; @@ -187,7 +187,9 @@ vms_gettimeofday(struct timeval *tv, void *timezone__not_used) /* Emulate unix's gettimeofday call; timezone argument is ignored. */ - static const Dsc epoch_dsc = { sizeof UNIX_EPOCH - sizeof "", UNIX_EPOCH }; + static const struct dsc$descriptor_s epoch_dsc = + { sizeof UNIX_EPOCH - sizeof "", + DSC$K_DTYPE_T, DSC$K_CLASS_S, UNIX_EPOCH }; static long epoch[2] = {0L,0L}; /* needs one time initialization */ const long thunk = VMS_UNITS_PER_SECOND; long now[2], quad[2]; diff --git a/vms/vms_popen.c b/vms/vms_popen.c index 23482df1..e6238bfa 100644 --- a/vms/vms_popen.c +++ b/vms/vms_popen.c @@ -71,8 +71,8 @@ extern char *mktemp(char *); static void push_logicals(void); static void pop_logicals(void); -static Itm *save_translation(const Dsc *); -static void restore_translation(const Dsc *, const Itm *); +static Itm *save_translation(const struct dsc$descriptor_s *); +static void restore_translation(const struct dsc$descriptor_s *, const Itm *); typedef enum { unopened = 0, reading, writing } pipemode; typedef struct pipe_info { @@ -159,22 +159,30 @@ pclose( FILE *current ) int vms_execute( const char *command, const char *input, const char *output ) { - Dsc cmd, in, out, *in_p, *out_p; + struct dsc$descriptor_s cmd, in, out, *in_p, *out_p; U_Long sts, cmpltn_sts; - cmd.len = strlen(cmd.adr = (char *)command); - if (input) - in.len = strlen(in.adr = (char *)input), in_p = ∈ - else + cmd.dsc$w_length = strlen(cmd.dsc$a_pointer = (char *)command); + cmd.dsc$b_dtype = DSC$K_DTYPE_T; + cmd.dsc$b_class = DSC$K_CLASS_S; + if (input) { + in.dsc$w_length = strlen(in.dsc$a_pointer = (char *)input); + in_p = ∈ + in.dsc$b_dtype = DSC$K_DTYPE_T; + in.dsc$b_class = DSC$K_CLASS_S; + } else in_p = 0; - if (output) - out.len = strlen(out.adr = (char *)output), out_p = &out; - else + if (output) { + out.dsc$w_length = strlen(out.dsc$a_pointer = (char *)output); + out_p = &out; + out.dsc$b_dtype = DSC$K_DTYPE_T; + out.dsc$b_class = DSC$K_CLASS_S; + } else out_p = 0; push_logicals(); /* guard against user-mode definitions of sys$Xput */ sts = LIB$SPAWN(&cmd, in_p, out_p, (U_Long *)0, - (Dsc *)0, (U_Long *)0, &cmpltn_sts); + (struct dsc$descriptor_s *)0, (U_Long *)0, &cmpltn_sts); pop_logicals(); /* restore environment */ if (vmswork(sts) && vmsfail(cmpltn_sts)) sts = cmpltn_sts; @@ -255,7 +263,7 @@ pop_logicals( void ) /* redefine sys$input and/or sys$output */ } static Itm * -save_translation( const Dsc *logname ) +save_translation( const struct dsc$descriptor_s *logname ) { Itm trans[4], *itmlst; long trans_attr, max_trans_indx; /* 0-based translation index count */ @@ -318,9 +326,10 @@ save_translation( const Dsc *logname ) } static void -restore_translation( const Dsc *logname, const Itm *itemlist ) +restore_translation( const struct dsc$descriptor_s *logname, + const Itm *itemlist ) { - Dsc trans_val; + struct dsc$descriptor_s trans_val; U_Long *attr_p; # define LOG_PROCESS_TABLE 2 /* <obsolete> */ # define LOG_USERMODE PSL$C_USER @@ -332,8 +341,10 @@ restore_translation( const Dsc *logname, const Itm *itemlist ) so it'll be the first string entry in the itemlist. */ /* assert( itemlist[2].code == LNM$_STRING ); */ - trans_val.adr = itemlist[2].buffer; - trans_val.len = itemlist[2].len; + trans_val.dsc$a_pointer = itemlist[2].buffer; + trans_val.dsc$w_length = itemlist[2].len; + trans_val.dsc$b_dtype = DSC$K_DTYPE_T; + trans_val.dsc$b_class = DSC$K_CLASS_S; (void) SYS$CRELOG(LOG_PROCESS_TABLE, logname, &trans_val, LOG_USERMODE); } else { /* $crelnm definition; itemlist could specify multiple translations, |