From: dpm@access2.digex.net (David P. Murphy) Subject: Re: FILE * -> FAB or RAB? Date: 1996/07/31 Message-ID: #1/1 references: <4tmig3$fko@newsbf02.news.aol.com> organization: Phase of the Moon Software Inc. Alexandria, VA newsgroups: comp.os.vms mschill513@aol.com (MSchill513) writes: >Is there any way using DEC C and given a FILE structure represneting an >open file to find the underlying RMS structures? yes, there is. it is not supported and it is probably quite version-dependent, but here it is. you can see from looking in that a FILE * is really a handle to a struct _iobuf, which is defined as a sixteen-byte structure. what you _don't_ know is that that structure is in fact much larger, and --- ta da --- contains pointers to no fewer than five RMS structures. six, if you count the NAM block pointed to by the FAB. the problem is finding where they are: they definitely changed at least once between version V6.1's DECC$SHR and version V7.0's DECC$SHR. and of course the arrangement is different for the VAXCRTL. the following code was compiled, linked and run under ALPHA V6.1 against version T02.0-018 of DECC$SHR dated april 1994. it is based upon the V7.0 source listings [V70.CRTL.LIS]VAXCIO.SRC module, and i make no claims for any other versions than those mentioned. in fact, i'd bet US$10 that it would not be correct. mike, could you tell us _why_ you need this? $ type findrms.c #include #include #include #include /* the first seven members of this structure are cut&pasted * from the _iobuf definition in the official STDIO.H header */ struct DECCRTL_IOBUF { int _cnt; char *_ptr; char *_base; unsigned char _flag; unsigned char _file; unsigned char _pad1; unsigned char _pad2; int stuff[14]; int morestuff[5]; /* should be 6 in V7.0? */ char *vms_name; int evenmorestuff[7]; /* should be 5 in V7.0? */ struct RAB *rabptr; /* RAB and FAB are reversed in V7.0? */ struct FAB *fabptr; struct XABDAT *xabdatptr; struct XABFHC *xabfhcptr; struct XABPRO *xabproptr; }; #define SHOWBLOCK(label, ptr, id, code) \ printf("\n%s=%08X", label, xyzzy->ptr); \ if (xyzzy->ptr != NULL) { \ printf(" CODE=%2d (%2d)", xyzzy->ptr->id, code); \ } int main( int argc, char *argv[] ) { FILE *fp; struct DECCRTL_IOBUF *xyzzy; if ((fp = fopen("SYS$LOGIN:LOGIN.COM", "r")) != NULL) { xyzzy = *((struct DECCRTL_IOBUF **) fp); printf("fp=%08X true=%08X name=%08X", fp, xyzzy, xyzzy->vms_name); if (xyzzy->vms_name != NULL) { printf(" %s", xyzzy->vms_name); } SHOWBLOCK("FAB ", fabptr, fab$b_bid, FAB$C_BID); SHOWBLOCK("RAB ", rabptr, rab$b_bid, RAB$C_BID); SHOWBLOCK("XABDAT", xabdatptr, xab$b_cod, XAB$C_DAT); SHOWBLOCK("XABFHC", xabfhcptr, xab$b_cod, XAB$C_FHC); SHOWBLOCK("XABPRO", xabproptr, xab$b_cod, XAB$C_PRO); printf("\n"); if (xyzzy->fabptr->fab$l_nam != NULL) { if (xyzzy->fabptr->fab$l_nam->nam$l_rsa != NULL) { printf("resfs=%-*s\n", (int) xyzzy->fabptr->fab$l_nam->nam$b_rsl, xyzzy->fabptr->fab$l_nam->nam$l_rsa); } } } exit(1); } $ cc findrms $ link findrms $ run findrms fp=7FE70D2C true=00065528 name=00065808 SYS$LOGIN:LOGIN.COM FAB =00065608 CODE= 3 ( 3) RAB =000657F8 CODE= 1 ( 1) XABDAT=000656C8 CODE=18 (18) XABFHC=00065710 CODE=29 (29) XABPRO=00065748 CODE=19 (19) resfs=USR:[MURPHY]LOGIN.COM;109 $ ok dpm -- David P. Murphy mailto:murphy@connor.datametrics.com (work) systems programmer mailto:dpm@access.digex.net (personal) http://www.access.digex.net/~dpm COGITO ERGO DISCLAIMUM ftp://ftp.access.digex.net/pub/access/dpm