long parself( struct hive *h, char *t, unsigned long off ) { nk_hdr *n; lf_hdr *l; hashrecord *hr; long res; int i; hr = (hashrecord*) malloc(sizeof(hashrecord)); n = (nk_hdr*) malloc(sizeof(nk_hdr)); l = (lf_hdr*) malloc(sizeof(lf_hdr)); l = read_lf(l, h, off ); #ifdef DEBUG printf("off = %x, key_num = %d ", off, l->key_num); #endif for( i = 0; i < l->key_num; i++ ){ hr = read_hr(hr, l->hr, i); n = read_nk(n, h, hr->nk_offset + 0x1000 ); #ifdef DEBUG printf("/ i=%d/%d, keyname = %x, nk_offset = %x\n", i, l->key_num, hr->keyname, hr->nk_offset); printf("//t = %s, keyname = %s, len = %d\n", t, strndup(n->key_name, n->name_len), n->name_len); #endif if( !memcmp( t, n->key_name, n->name_len ) && (strlen(t) == n->name_len)) { res = hr->nk_offset; free(n); free(l); return res; } } free(n); free(l); return -1; }
int _RegEnumKey( struct hive *h, nk_hdr *nr, int index, char *name, int *namelen ) { lf_hdr *lf; nk_hdr *nk; hashrecord *hr; lf = (lf_hdr*) malloc(sizeof(lf_hdr)); nk = (nk_hdr*) malloc(sizeof(nk_hdr)); hr = (hashrecord*) malloc(sizeof(hashrecord)); #ifdef DEBUG printf("subkey_num = %d\n", nr->subkey_num); #endif if( index < nr->subkey_num ) { lf = read_lf(lf, h, nr->lf_off + 0x1000 ); hr = read_hr(hr, lf->hr, index); nk = read_nk(nk, h, hr->nk_offset + 0x1000 ); memcpy( name, nk->key_name, min( *namelen, nk->name_len ) ); name[ min( *namelen, nk->name_len ) ] = 0; *namelen = nk->name_len; free(lf); return ( (index + 1) < nr->subkey_num ) ? (index + 1) : -1; } free(lf); return -1; }
void read_climate_and_pc () { char fn [77], fnp [77], lfs [7]; int i, j, jj = 0, lf; if (global_monitor) monitor_leaf(1, "read_climate_and_pc"); read_esd(); open_files(1); printf(" Reading: Climate and Plant Community description. \n\n"); for (i = 0; i < n_lats; i++) { for (j = 0; j < n_lons; j++) { if (earth[i][j] == '1') { read_climate(); read_pc(); set_constants(jj); int2str(eco[jj].iflpn, (jj + 1), 6, 0); ++jj; } else skip_data(1); } skip_data(0); } close_files(0); printf(" Reading: LF FCs. \n"); strcpy(fnp, global_directory); strcat(fnp, "/lf_"); for (lf = 1; lf <= num_lf; lf++) { printf(" LF = %3d \n", lf); strcpy(fn, fnp); if (lf < 10) strcat(fn, "00"); else if (lf < 100) strcat(fn, "0"); int_to_ascii(lf, lfs); strcat(fn, lfs); read_lf(lf, fn); } printf("\n"); if (global_monitor) monitor_leaf(0, "read_climate_and_pc"); }