1 /* VMS::DCLsym - manipulate DCL symbols
4 * Author: Charles Bailey bailey@newman.upenn.edu
10 * 1.0 17-Aug-1995 Charles Bailey bailey@newman.upenn.edu
11 * original production version
15 #include <lib$routines.h>
16 #include <libclidef.h>
23 MODULE = VMS::DCLsym PACKAGE = VMS::DCLsym
30 struct dsc$descriptor_s namdsc = {0,DSC$K_DTYPE_T,DSC$K_CLASS_S,0},
31 valdsc = {0,DSC$K_DTYPE_T,DSC$K_CLASS_D,0};
34 unsigned long int retsts;
35 SETERRNO(0,SS$_NORMAL);
37 PUSHs(sv_newmortal());
38 SETERRNO(EINVAL,LIB$_INVARG);
41 namdsc.dsc$a_pointer = SvPV(name,namlen);
42 namdsc.dsc$w_length = (unsigned short int) namlen;
43 retsts = lib$get_symbol(&namdsc,&valdsc,0,&tbltype);
45 PUSHs(sv_2mortal(newSVpv(valdsc.dsc$w_length ?
46 valdsc.dsc$a_pointer : "",valdsc.dsc$w_length)));
47 EXTEND(sp,2); /* just in case we're at the end of the stack */
48 if (tbltype == LIB$K_CLI_LOCAL_SYM)
49 PUSHs(sv_2mortal(newSVpv("LOCAL",5)));
51 PUSHs(sv_2mortal(newSVpv("GLOBAL",6)));
52 _ckvmssts(lib$sfree1_dd(&valdsc));
55 /* error - we'll return an empty list */
58 break; /* nobody home */;
59 case LIB$_INVSYMNAM: /* user errors; set errno return undef */
63 set_vaxc_errno(retsts);
65 default: /* bail out */
66 { _ckvmssts(retsts); }
73 _setsym(name,val,typestr="LOCAL")
79 struct dsc$descriptor_s namdsc = {0,DSC$K_DTYPE_T,DSC$K_CLASS_S,0},
80 valdsc = {0,DSC$K_DTYPE_T,DSC$K_CLASS_S,0};
83 unsigned long int retsts;
84 SETERRNO(0,SS$_NORMAL);
86 SETERRNO(EINVAL,LIB$_INVARG);
89 namdsc.dsc$a_pointer = SvPV(name,slen);
90 namdsc.dsc$w_length = (unsigned short int) slen;
91 valdsc.dsc$a_pointer = SvPV(val,slen);
92 valdsc.dsc$w_length = (unsigned short int) slen;
93 type = strNE(typestr,"GLOBAL") ?
94 LIB$K_CLI_LOCAL_SYM : LIB$K_CLI_GLOBAL_SYM;
95 retsts = lib$set_symbol(&namdsc,&valdsc,&type);
96 if (retsts & 1) { XSRETURN_YES; }
99 case LIB$_AMBSYMDEF: /* user errors; set errno and return */
104 set_vaxc_errno(retsts);
106 break; /* NOTREACHED */
107 default: /* bail out */
108 { _ckvmssts(retsts); }
115 _delsym(name,typestr="LOCAL")
120 struct dsc$descriptor_s namdsc = {0,DSC$K_DTYPE_T,DSC$K_CLASS_S,0};
123 unsigned long int retsts;
124 SETERRNO(0,SS$_NORMAL);
125 if (!name || !typestr) {
126 SETERRNO(EINVAL,LIB$_INVARG);
129 namdsc.dsc$a_pointer = SvPV(name,slen);
130 namdsc.dsc$w_length = (unsigned short int) slen;
131 type = strNE(typestr,"GLOBAL") ?
132 LIB$K_CLI_LOCAL_SYM : LIB$K_CLI_GLOBAL_SYM;
133 retsts = lib$delete_symbol(&namdsc,&type);
134 if (retsts & 1) { XSRETURN_YES; }
137 case LIB$_INVSYMNAM: /* user errors; set errno and return */
141 set_vaxc_errno(retsts);
143 break; /* NOTREACHED */
144 default: /* bail out */
145 { _ckvmssts(retsts); }