123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434 |
- #if 0
- # define module_name VMSMUNCH
- # define module_version "V1.3-4"
- #endif
- #if 0
- # if defined(__DECC) || defined(__GNUC__)
- # pragma module module_name module_version
- # else
- # module module_name module_version
- # endif
- #endif
- #define sys$asctim SYS$ASCTIM
- #define sys$assign SYS$ASSIGN
- #define sys$bintim SYS$BINTIM
- #define sys$dassgn SYS$DASSGN
- #define sys$parse SYS$PARSE
- #define sys$qiow SYS$QIOW
- #define sys$search SYS$SEARCH
- #include "zip.h"
- #include <stdio.h>
- #include <string.h>
- #include <iodef.h>
- #include <starlet.h>
- #include <fibdef.h> /* this gets created with the c3.0 compiler */
- #if defined(fib$w_did) || (defined(__union) && (__union == variant_union))
- # define FIB$W_DID fib$w_did
- # define FIB$W_FID fib$w_fid
- # define FIB$L_ACCTL fib$l_acctl
- #else
- # define FIB$W_DID fib$r_did_overlay.fib$w_did
- # define FIB$W_FID fib$r_fid_overlay.fib$w_fid
- # define FIB$L_ACCTL fib$r_acctl_overlay.fib$l_acctl
- #endif
- #include "vms.h"
- #include "vmsmunch.h"
- #include "vmsdefs.h"
- static void asctim(char *time, long int binval[2]);
- static void bintim(char *time, long int binval[2]);
- #ifndef SS$_NORMAL
- # define SS$_NORMAL 1
- # define SS$_BADPARAM 20
- #endif
- #ifdef vax
- # define __VAX 1
- #endif
- #ifdef __VAX
- # define GVTC (unsigned int)
- #else
- # define GVTC
- #endif
- int VMSmunch(
- char *filename,
- int action,
- char *ptr )
- {
-
- static struct FAB Fab;
- static struct NAM_STRUCT Nam;
- static struct fibdef Fib;
- static struct dsc$descriptor FibDesc =
- {sizeof(Fib),DSC$K_DTYPE_Z,DSC$K_CLASS_S,(char *)&Fib};
- static struct dsc$descriptor_s DevDesc =
- {0,DSC$K_DTYPE_T,DSC$K_CLASS_S,&Nam.NAM_DVI[1]};
- static struct fatdef Fat;
- static union {
- struct fchdef fch;
- long int dummy;
- } uchar;
- static struct fjndef jnl;
- static long int Cdate[2],Rdate[2],Edate[2],Bdate[2];
- static short int revisions;
- static unsigned long uic;
- #if defined(__DECC) || defined(__DECCXX)
- #pragma __member_alignment __save
- #pragma __nomember_alignment
- #endif
- static union {
- unsigned short int value;
- struct {
- unsigned system : 4;
- unsigned owner : 4;
- unsigned group : 4;
- unsigned world : 4;
- } bits;
- } prot;
- #if defined(__DECC) || defined(__DECCXX)
- #pragma __member_alignment __restore
- #endif
- static struct atrdef Atr[] = {
- {sizeof(Fat),ATR$C_RECATTR, GVTC &Fat},
- {sizeof(uchar),ATR$C_UCHAR, GVTC &uchar},
- {sizeof(Cdate),ATR$C_CREDATE, GVTC &Cdate[0]},
- {sizeof(Rdate),ATR$C_REVDATE, GVTC &Rdate[0]},
- {sizeof(Edate),ATR$C_EXPDATE, GVTC &Edate[0]},
- {sizeof(Bdate),ATR$C_BAKDATE, GVTC &Bdate[0]},
- {sizeof(revisions),ATR$C_ASCDATES, GVTC &revisions},
- {sizeof(prot),ATR$C_FPRO, GVTC &prot},
- {sizeof(uic),ATR$C_UIC, GVTC &uic},
- {sizeof(jnl),ATR$C_JOURNAL, GVTC &jnl},
- {0,0,0}
- } ;
- static char EName[NAM_MAXRSS];
- static char RName[NAM_MAXRSS];
- static struct dsc$descriptor_s FileName =
- {0,DSC$K_DTYPE_T,DSC$K_CLASS_S,0};
- static struct dsc$descriptor_s string = {0,DSC$K_DTYPE_T,DSC$K_CLASS_S,0};
- static short int DevChan;
- static short int iosb[4];
- static long int i,status;
-
- static int old_rtype=FAT$C_FIXED;
-
- Fab = cc$rms_fab;
- Fab.fab$l_fna = filename;
- Fab.fab$b_fns = strlen(filename);
- Fab.FAB_NAM = &Nam;
- Nam = CC_RMS_NAM;
- Nam.NAM_ESA = EName;
- Nam.NAM_ESS = sizeof(EName);
- Nam.NAM_RSA = RName;
- Nam.NAM_RSS = sizeof(RName);
-
- status = sys$parse(&Fab);
- if (!(status & 1)) return(status);
-
- status = sys$search(&Fab);
- if (!(status & 1)) return(status);
- while (status & 1) {
-
- DevDesc.dsc$w_length = Nam.NAM_DVI[0];
- status = sys$assign(&DevDesc,&DevChan,0,0);
- if (!(status & 1)) return(status);
- FileName.dsc$a_pointer = Nam.NAM_L_NAME;
- FileName.dsc$w_length = Nam.NAM_B_NAME+Nam.NAM_B_TYPE+Nam.NAM_B_VER;
-
- for (i=0;i<3;i++) {
- Fib.FIB$W_FID[i]=Nam.NAM_FID[i];
- Fib.FIB$W_DID[i]=Nam.NAM_DID[i];
- }
-
-
-
- status = sys$qiow(0,DevChan,IO$_ACCESS,&iosb,0,0,
- &FibDesc,&FileName,0,0,&Atr,0);
- if (!(status & 1) || !((status = iosb[0]) & 1)) {
- sys$dassgn(DevChan);
- return(status);
- }
-
- switch (action) {
- case GET_TIMES:
- asctim(((struct VMStimbuf *)ptr)->modtime, Cdate);
- asctim(((struct VMStimbuf *)ptr)->actime, Rdate);
- sys$dassgn(DevChan);
- return RMS$_NORMAL;
- break;
- case SET_TIMES:
- if (((struct VMStimbuf *)ptr)->modtime != (char *)NULL)
- bintim(((struct VMStimbuf *)ptr)->modtime, Cdate);
- if (((struct VMStimbuf *)ptr)->actime != (char *)NULL)
- bintim(((struct VMStimbuf *)ptr)->actime, Rdate);
- break;
- case GET_RTYPE:
- *(int *)ptr = Fat.fat$v_rtype;
- sys$dassgn(DevChan);
- return RMS$_NORMAL;
- break;
- case CHANGE_RTYPE:
- old_rtype = Fat.fat$v_rtype;
- if ((*(int *)ptr < FAT$C_UNDEFINED) ||
- (*(int *)ptr > FAT$C_STREAMCR))
- Fat.fat$v_rtype = FAT$C_STREAMLF;
- else
- Fat.fat$v_rtype = *(int *)ptr;
- break;
- case RESTORE_RTYPE:
- Fat.fat$v_rtype = old_rtype;
- break;
- default:
- sys$dassgn(DevChan);
- return SS$_BADPARAM;
- }
-
-
- Fib.FIB$L_ACCTL = FIB$M_NORECORD;
- for (i=0;i<3;i++) {
- Fib.FIB$W_FID[i]=Nam.NAM_FID[i];
- Fib.FIB$W_DID[i]=Nam.NAM_DID[i];
- }
-
-
-
-
- status = sys$qiow(0,DevChan,IO$_MODIFY,&iosb,0,0,
- &FibDesc,&FileName,0,0,&Atr,0);
- if (!(status & 1) || !((status = iosb[0]) & 1)) {
- sys$dassgn(DevChan);
- return(status);
- }
- status = sys$dassgn(DevChan);
- if (!(status & 1)) return(status);
-
- status = sys$search(&Fab);
- }
- return(status);
- }
- static void asctim(
- char *time,
- long int binval[2] )
- {
- static struct dsc$descriptor date_str={23,DSC$K_DTYPE_T,DSC$K_CLASS_S,0};
-
- date_str.dsc$a_pointer = time;
- sys$asctim(0, &date_str, binval, 0);
- time[23] = '\0';
- }
- static void bintim(
- char *time,
- long int binval[2] )
- {
- static struct dsc$descriptor date_str={0,DSC$K_DTYPE_T,DSC$K_CLASS_S,0};
- date_str.dsc$w_length = strlen(time);
- date_str.dsc$a_pointer = time;
- sys$bintim(&date_str, binval);
- }
|