void file_archscan( char *archive, scanback func, void *closure ) { static struct dsc$descriptor_s library = {0, DSC$K_DTYPE_T, DSC$K_CLASS_S, NULL}; unsigned long lfunc = LBR$C_READ; unsigned long typ = LBR$C_TYP_UNK; unsigned long index = 1; register int status; VMS_archive = archive; VMS_func = func; VMS_closure = closure; status = lbr$ini_control( &context, &lfunc, &typ, NULL ); if ( !( status & 1 ) ) return; library.dsc$a_pointer = archive; library.dsc$w_length = strlen( archive ); status = lbr$open( &context, &library, NULL, NULL, NULL, NULL, NULL ); if ( !( status & 1 ) ) return; (void) lbr$get_index( &context, &index, file_archmember, NULL ); (void) lbr$close( &context ); }
long int ar_scan (const char *archive, ar_member_func_t function, const void *varg) { char *p; const char *arg = varg; static struct dsc$descriptor_s libdesc = { 0, DSC$K_DTYPE_T, DSC$K_CLASS_S, NULL }; unsigned long func = LBR$C_READ; unsigned long type = LBR$C_TYP_UNK; unsigned long index = 1; int status; status = lbr$ini_control (&VMS_lib_idx, &func, &type, 0); if (! (status & 1)) { ON (error, NILF, _("lbr$ini_control() failed with status = %d"), status); return -2; } /* there is no such descriptor with "const char *dsc$a_pointer" */ libdesc.dsc$a_pointer = (char *)archive; libdesc.dsc$w_length = strlen (archive); status = lbr$open (&VMS_lib_idx, &libdesc, 0, 0, 0, 0, 0); if (! (status & 1)) { OSS (error, NILF, _("unable to open library '%s' to lookup member '%s'"), archive, arg); return -1; } VMS_saved_memname = arg; /* For comparison, delete .obj from arg name. */ p = strrchr (VMS_saved_memname, '.'); if (p) *p = '\0'; VMS_function = function; VMS_member_date = (time_t) -1; lbr$get_index (&VMS_lib_idx, &index, VMS_get_member_info, 0); /* Undo the damage. */ if (p) *p = '.'; lbr$close (&VMS_lib_idx); return VMS_member_date > 0 ? VMS_member_date : 0; }
long int ar_scan (const char *archive, ar_member_func_t function, const void *varg) { char *vms_archive; static struct dsc$descriptor_s libdesc = { 0, DSC$K_DTYPE_T, DSC$K_CLASS_S, NULL }; const unsigned long func = LBR$C_READ; const unsigned long type = LBR$C_TYP_UNK; const unsigned long index = 1; unsigned long lib_idx; int status; VMS_saved_arg = varg; /* Null archive string can show up in test and cause an access violation */ if (archive == NULL) { /* Null filenames do not exist */ return -1; } /* archive path name must be in VMS format */ vms_archive = (char *) vmsify(archive, 0); status = lbr$ini_control(&VMS_lib_idx, &func, &type, 0); if (!$VMS_STATUS_SUCCESS(status)) { ON(error, NILF, _("lbr$ini_control() failed with status = %d"), status); return -2; } libdesc.dsc$a_pointer = vms_archive; libdesc.dsc$w_length = strlen(vms_archive); status = lbr$open(&VMS_lib_idx, &libdesc, 0, NULL, 0, NULL, 0); if (!$VMS_STATUS_SUCCESS(status)) { /* TODO: A library format failure could mean that this is a file generated by the GNU AR utility and in that case, we need to take the UNIX codepath. This will also take a change to the GNV AR wrapper program. */ switch (status) { case RMS$_FNF: /* Archive does not exist */ return -1; default: #ifndef TEST OSN(error, NILF, _("unable to open library '%s' to lookup member status %d"), archive, status); #endif /* For library format errors, specification says to return -2 */ return -2; } } VMS_function = function; /* Clear the return status, as we are supposed to stop calling the callback function if it becomes non-zero, and this is a static variable. */ VMS_function_ret = 0; status = lbr$get_index(&VMS_lib_idx, &index, VMS_get_member_info, NULL, 0); lbr$close(&VMS_lib_idx); /* Unless a failure occurred in the lbr$ routines, return the the status from the 'function' routine. */ if ($VMS_STATUS_SUCCESS(status)) { return VMS_function_ret; } /* This must be something wrong with the library and an error message should already have been printed. */ return -2; }
/* **++ ** ROUTINE: lbr_get_rdt ** ** FUNCTIONAL DESCRIPTION: ** ** Gets the RDT of a library module. ** ** RETURNS: cond_value, longword (unsigned), write only, by value ** ** PROTOTYPE: ** ** lbr_get_rdt(char *libfile, char *module, TIME *rdt); ** ** libfile: ASCIZ_string, read only, by reference ** module: ASCIZ_string, read only, by reference ** rdt: date_time, quadword (signed), write only, by reference ** ** IMPLICIT INPUTS: None. ** ** IMPLICIT OUTPUTS: None. ** ** COMPLETION CODES: Any from the LBR$ routines. ** ** SIDE EFFECTS: lbrque modified. ** **-- */ unsigned int lbr_get_rdt (char *lib, char *mod, TIME *rdt) { unsigned int lbrfunc=LBR$C_READ, lbr$c_knf = 0x08680F2, libidx = 1; char real_name[256]; unsigned char fid[28]; struct dsc$descriptor libdsc, moddsc; struct LBR *lbr; unsigned int status, len; unsigned short rfa[3]; struct mhddef mhd; /* ** First look up the library file */ status = file_find(lib, 0, real_name, fid); if (!OK(status)) return status; /* ** Already open? */ for (lbr = (struct LBR *)lbrque.head; lbr != (struct LBR *)&lbrque; lbr = lbr->flink) { if (memcmp(fid, &lbr->nam.nam$t_dvi, 28) == 0) break; } /* ** If not open yet, construct a context block and open it. */ if (lbr == (struct LBR *) &lbrque) { /* ** Already have max number of libraries open? If so, close one. */ if (lbrcount >= LBR$C_MAXCTL) { queue_remove(lbrque.head, &lbr); lbr$close(&lbr->lbrctx); lbrcount -= 1; } else { lbr = malloc(sizeof(struct LBR)); } queue_insert(lbr, lbrque.tail); lbr->lbrctx = 0; lbr->nam = cc$rms_nam; lbr->nam.nam$b_rss = sizeof(lbr->rspec)-1; lbr->nam.nam$b_ess = sizeof(lbr->espec)-1; lbr->nam.nam$l_esa = lbr->espec; lbr->nam.nam$l_rsa = lbr->rspec; status = lbr$ini_control(&lbr->lbrctx, &lbrfunc, 0, &lbr->nam); if (!OK(status)) lib$signal(status); INIT_SDESC(libdsc, strlen(real_name), real_name); status = lbr$open(&lbr->lbrctx, &libdsc); if (!OK(status)) return status; lbrcount += 1; } /* ** Look up the module in question... */ INIT_SDESC(moddsc, strlen(mod), mod); /* status = lbr$lookup_key(&lbr->lbrctx, &moddsc, rfa); */ mod2search4 = &moddsc; return_rfa_here = rfa; status = lbr$get_index(&lbr->lbrctx, &libidx, &caseblindsearch); if (status != 2) return lbr$c_knf; /* caseblindsearch returns 2 on success, 1 on failure */ /* ** ... and get the RDT from the module header */ INIT_SDESC(moddsc, sizeof(mhd), &mhd); status = lbr$set_module(&lbr->lbrctx, rfa, &moddsc, &len); if (!OK(status) && (status != LBR$_HDRTRUNC)) lib$signal(status); memcpy(rdt, &mhd.mhd$l_datim, 8); return SS$_NORMAL; }
long int ar_scan (char *archive, long int (*function) PARAMS ((void)), long int arg) { char *p; static struct dsc$descriptor_s libdesc = { 0, DSC$K_DTYPE_T, DSC$K_CLASS_S, NULL }; unsigned long func = LBR$C_READ; unsigned long type = LBR$C_TYP_UNK; unsigned long index = 1; int status; status = lbr$ini_control (&VMS_lib_idx, &func, &type, 0); if (! (status & 1)) { error (NILF, _("lbr$ini_control failed with status = %d"),status); return -2; } libdesc.dsc$a_pointer = archive; libdesc.dsc$w_length = strlen (archive); status = lbr$open (&VMS_lib_idx, &libdesc, 0, 0, 0, 0, 0); if (! (status & 1)) { error (NILF, _("unable to open library `%s' to lookup member `%s'"),