HaschT* hasch_sequence ( char *seq1, int ktup) { char c; int key, offset=0, ls; HaschT *H; Hasch_entry *e; H=hcreate ( strlen (seq1), declare_ktup_hasch_data, free_ktup_hasch_data); ls=strlen (seq1); while (ls>=(ktup)) { c=seq1[ktup];seq1[ktup]='\0'; key=string2key (seq1, NULL); e=hsearch (H,key,FIND, declare_ktup_hasch_data, free_ktup_hasch_data); if (e==NULL) { e=hsearch (H,key,ADD,declare_ktup_hasch_data,free_ktup_hasch_data); (e->data)->list[++(e->data)->list[1]+1]=offset; } else { if ((e->data)->list[0]==((e->data)->list[1]+2)){(e->data)->list[0]+=10;(e->data)->list=(int*)vrealloc ((e->data)->list,(e->data)->list[0]*sizeof (int));} (e->data)->list[++(e->data)->list[1]+1]=offset; } seq1[ktup]=c;seq1++;ls--; offset++; } return H; }
int main(void) { ENTRY e, *ep; int i; hcreate(30); for (i = 0; i < 24; i++) { e.key = data[i]; /* data is just an integer, instead of a pointer to something */ e.data = (void *) i; ep = hsearch(e, ENTER); /* there should be no failures */ if (ep == NULL) { fprintf(stderr, "entry failed\n"); exit(EXIT_FAILURE); } } for (i = 22; i < 26; i++) { /* print two entries from the table, and show that two are not in the table */ e.key = data[i]; ep = hsearch(e, FIND); printf("%9.9s -> %9.9s:%d\n", e.key, ep ? ep->key : "NULL", ep ? (int)(ep->data) : 0); } hdestroy(); exit(EXIT_SUCCESS); }
int main(int argc, char *argv[]) { FILE *fp; char *mode, *file; char *w; char buf[MAXLEN]; struct wordcnt wordcnt[2048]; int wcount = 0; int i; if (argc < 3) { printf("Usage: %s [123] inputfile\n", argv[0]); return 1; } mode = argv[1]; file = argv[2]; if ((fp = fopen(file, "r")) == NULL) { printf("file open error: file=%s\n", file); return 1; } hcreate(4096); while (getword(fp, buf, MAXLEN) != NULL) { ENTRY item, *ip; struct wordcnt *wc = &wordcnt[wcount]; item.key = buf; item.data = &wc->cnt; if ((ip = hsearch(item, FIND)) == NULL) { int len = strnlen(buf, MAXLEN); char *key = (char *) malloc(sizeof (char) * len); strncpy(key, buf, MAXLEN); item.key = key; wc->word = key; wc->cnt = 1; hsearch(item, ENTER); wcount++; } else { *((int *) ip->data) += 1; } } qsort(wordcnt, wcount, sizeof (struct wordcnt), wccmp); for (i = 0; i < wcount; i++) { struct wordcnt *wc = &wordcnt[i]; printf("% 4d: %s\n", wc->cnt, wc->word); } hdestroy(); fclose(fp); return 0; }
static int do_test (void) { if (hcreate (1) == 0) { puts ("hcreate failed"); return 1; } ENTRY e; e.key = (char *) "a"; e.data = (char *) "b"; if (hsearch (e, ENTER) == NULL) { puts ("ENTER failed"); return 1; } ENTRY s; s.key = (char *) "c"; if (hsearch (s, FIND) != NULL) { puts ("FIND succeeded"); return 1; } return 0; }
/** * Takes an accuser and victim, looks up their data in the hash * (or adds the veteran if needed), and sets their group based * on the rules in file header. * * The data pointer in the hash will be 1 if the entry is a liar * * Returns 1 if a key was hashed, 0 otherwise. */ int set_groups(char *accuser, char *victim) { ENTRY ae, *aep; /* Accuser entry (pointer) */ ENTRY ve, *vep; /* Victim entry (pointer) */ ae.key = accuser; ve.key = victim; aep = hsearch(ae, FIND); vep = hsearch(ve, FIND); if (aep == NULL && vep == NULL) { /* Can't make assumption, just return */ return 0; } else if (aep != NULL && vep == NULL) { if (aep->data == HONEST) { ve.data = LIAR; num_liars++; } else { ve.data = HONEST; } vep = hsearch(ve, ENTER); return 1; } else if (vep != NULL && aep == NULL) { if (vep->data == HONEST) { ae.data = LIAR; num_liars++; } else { ae.data = HONEST; } aep = hsearch(ae, ENTER); return 1; } return 0; }
static char *get_ipinfo( struct mtr_ctl *ctl, ip_t * addr) { char key[NAMELEN]; char lookup_key[NAMELEN]; char *val = NULL; ENTRY item; if (!addr) return NULL; if (ctl->af == AF_INET6) { #ifdef ENABLE_IPV6 reverse_host6(addr, key, NAMELEN); if (snprintf(lookup_key, NAMELEN, "%s.origin6.asn.cymru.com", key) >= NAMELEN) return NULL; #else return NULL; #endif } else { unsigned char buff[4]; memcpy(buff, addr, 4); if (snprintf (key, NAMELEN, "%d.%d.%d.%d", buff[3], buff[2], buff[1], buff[0]) >= NAMELEN) return NULL; if (snprintf(lookup_key, NAMELEN, "%s.origin.asn.cymru.com", key) >= NAMELEN) return NULL; } if (iihash) { ENTRY *found_item; DEB_syslog(LOG_INFO, ">> Search: %s", key); item.key = key;; if ((found_item = hsearch(item, FIND))) { if (!(val = (*((items_t *) found_item->data))[ctl->ipinfo_no])) val = (*((items_t *) found_item->data))[0]; DEB_syslog(LOG_INFO, "Found (hashed): %s", val); } } if (!val) { DEB_syslog(LOG_INFO, "Lookup: %s", key); if ((val = split_txtrec(ctl, ipinfo_lookup(lookup_key)))) { DEB_syslog(LOG_INFO, "Looked up: %s", key); if (iihash) if ((item.key = xstrdup(key))) { item.data = (void *) items; hsearch(item, ENTER); DEB_syslog(LOG_INFO, "Insert into hash: %s", key); } } } return val; }
static utree_t * find_outgroup_mrca(utree_t ** node_list, utree_t * root, char * outgroup_list, int tip_count) { int i; utree_t * outgroup; char * taxon; size_t taxon_len; ENTRY * found = NULL; /* create a hashtable of tip labels */ hcreate(2 * tip_count); for (i = 0; i < tip_count; ++i) { ENTRY entry; entry.key = node_list[i]->label; entry.data = node_list[i]; hsearch(entry,ENTER); } while (*outgroup_list) { taxon_len = strcspn(outgroup_list, ","); if (!taxon_len) fatal("Erroneous outgroup format (double comma)/taxon missing"); taxon = strndup(outgroup_list, taxon_len); /* find the taxon in the hash table */ ENTRY query; query.key = taxon; found = NULL; found = hsearch(query,FIND); if (!found) fatal("Taxon %s in --outgroup does not appear in the tree", taxon); ((utree_t *)(found->data))->mark = 1; printf("\t%s\n", taxon); free(taxon); outgroup_list += taxon_len; if (*outgroup_list == ',') outgroup_list += 1; } printf("Label: %s\n", ((utree_t *)(found->data))->label); outgroup = outgroup_node(((utree_t *)(found->data))->back); hdestroy(); return outgroup; }
/* * Load a timezone from file or from cache. * Does not verify that the timezone is acceptable! */ struct pg_tz* pg_tzset(const char *name) { pg_tz_cache *tzp; struct state tzstate; char uppername[TZ_STRLEN_MAX + 1]; char canonname[TZ_STRLEN_MAX + 1]; char* p; if (strlen(name) > TZ_STRLEN_MAX) return NULL; /* not going to fit */ if (!timezone_cache) if (!init_timezone_hashtable()) return NULL; /* * Upcase the given name to perform a case-insensitive hashtable search. * (We could alternatively downcase it, but we prefer upcase so that we * can get consistently upcased results from tzparse() in case the name is * a POSIX-style timezone spec.) */ p = uppername; while (*name) *p++ = pg_toupper((unsigned char) *name++); *p = '\0'; tzp = (pg_tz_cache *) hsearch(timezone_cache, uppername, H_FIND, NULL); if (tzp) { /* Timezone found in cache, nothing more to do */ return &tzp->tz; } if (tzload(uppername, canonname, &tzstate, TRUE) != 0) { if (uppername[0] == ':' || tzparse(uppername, &tzstate, FALSE) != 0) { /* Unknown timezone. Fail our call instead of loading GMT! */ return NULL; } /* For POSIX timezone specs, use uppercase name as canonical */ strcpy(canonname, uppername); } /* Save timezone in the cache */ tzp = (pg_tz_cache*) hsearch(timezone_cache, uppername, H_ENTER, NULL); /* hsearch already copied uppername into the hash key */ strcpy(tzp->tz.TZname, canonname); memcpy(&tzp->tz.state, &tzstate, sizeof(tzstate)); return &tzp->tz; }
id* enter(int flag, char* str, int length){ /************************************************ Copy detected identifier or keyword (str) in heap ************************************************/ char* name = (char*)malloc(sizeof(char)); strcpy(name, str); /************************************************ Use hash table of standard library <search.h> For searching, set name as a key of ENTRY item ************************************************/ ENTRY item; ENTRY* result; item.key = name; result = hsearch(item, FIND); id* data; /**************************************************************************** 1) result is not null : detected str already exists in hash table - increases count - return result's data to print in main function 2) result is null : new identifier - make id entity - save the id entity in heap - save the id entity in hash table - return that id entity ****************************************************************************/ if(result) { data = result->data; (data->count)++; } else { data = (id*)malloc(sizeof(id)); data->tokentype = flag; data->name = name; data->count = flag==KEYWORD? 0 : 1; item.data = data; result = hsearch(item, ENTER); } return data; };
int AssignNodesToModulesFromFile(FILE *inF, Partition *part, char **labels) { char label[MAX_LABEL_LENGTH]; char sep[2]; int j = 0, nfields = 0, nnode = part->N; hcreate(part->N); int i; ENTRY e, *ep; for (i=0; i<nnode; i++) { e.key = labels[i]; e.data = (void *) i; ep = hsearch(e, ENTER); } while (!feof(inF)) { nfields=fscanf(inF,"%[^\t\n]%[\t\n]",&label,&sep); if (nfields) { e.key = label; ep = hsearch(e, FIND); i = (int) ep->data; nnode--; if (!part->modules[j]->size) { part->nempty --; part->nodes[i]->module = j; part->modules[j]->size = 1; part->modules[j]->strength = part->nodes[i]->strength; part->modules[j]->first = part->nodes[i]; part->modules[j]->last = part->nodes[i]; } else { part->nodes[i]->module = j; part->modules[j]->size++; part->modules[j]->strength += part->nodes[i]->strength; part->modules[j]->last->next = part->nodes[i]; part->nodes[i]->prev = part->modules[j]->last; part->modules[j]->last = part->nodes[i]; } if(sep[0]=='\n') j++; } } CompressPartition(part); hdestroy(); return nnode; }
static void symtab_enter(const char *key, void *data) { ENTRY symtab_entry; symtab_entry.key = (char *)key; symtab_entry.data = data; if (hsearch(symtab_entry, FIND) != NULL) generror("rd %s", symtab_entry.key); if (hsearch(symtab_entry, ENTER) == NULL) generror(">s"); }
/* * Read all sets from the libdscfg configuration file, and store everything in * the hashfile. * * We assume that the config file has been opened & rewound for us. We store * the volume name as the key, and the setnumber where we found it as the data. * * The caller can pass in a pointer to the maximum number of volumes, or * a pointer to NULL, specifying we want 'all' the volumes. The table is * searched using find_in_hash. */ static void create_cfg_hash() { char key[CFG_MAX_KEY], buf[CFG_MAX_BUF]; char vol[CFG_MAX_BUF], cnode[CFG_MAX_BUF]; int setnumber; ENTRY item; if (hcreate((size_t)sv_max_devices) == 0) error(NULL, gettext("unable to create hash table")); for (setnumber = 1; /* CSTYLED */; setnumber++) { (void) snprintf(key, sizeof (key), "sv.set%d", setnumber); if (cfg_get_cstring(cfg, key, buf, sizeof (buf)) < 0) break; if (sscanf(buf, "%s - %s", vol, cnode) != 2) { continue; } item.key = strdup(vol); item.data = (void *)setnumber; if (hsearch(item, ENTER) == NULL) { error(NULL, gettext("unable to add entry to hash table")); } } }
/* Forget any invalid pages >= minblkno, because they've been dropped */ static void forget_invalid_pages(struct fnode node, enum fork forkno, block_t minblkno) { struct hseq_status status; xl_invalid_page *hentry; if (invalid_page_tab == NULL) return; /* nothing to do */ hseq_init(&status, invalid_page_tab); while ((hentry = (xl_invalid_page *) hseq_search(&status)) != NULL) { if (FNODE_EQ(hentry->key.node, node) && hentry->key.forkno == forkno && hentry->key.blkno >= minblkno) { if (log_min_messages <= DEBUG2 || client_min_messages <= DEBUG2) { char *path = relpathperm(hentry->key.node, forkno); elog(DEBUG2, "page %u of relation %s has been" " dropped", hentry->key.blkno, path); pfree(path); } if (hsearch(invalid_page_tab, (void*) &hentry->key, H_REMOVE, NULL) == NULL) elog(ERROR, "hash table corrupted"); } } }
/** Creates the hash table for speeding up file finding. * * @size the size we want to make this hash table * @head the first gd_fs_entry_t in the list of files * * @returns 0 on success, 1 on failure */ int create_hash_table(size_t size, const struct gd_fs_entry_t* head) { int ret = hcreate(size); if(!ret) { fprintf(stderr, "hcreate failed\n"); return 1; } ENTRY entry; struct gd_fs_entry_t *iter = head; while(iter != NULL) { entry.key = iter->filename.str; entry.data = iter; ENTRY* entered = hsearch(entry, ENTER); if(0 && !entered) { fprintf(stderr, "hsearch: %s\n", strerror(errno)); destroy_hash_table(); return 1; } iter = iter->next; } return 0; }
/* Forget any invalid pages in a whole database */ static void forget_invalid_pages_db(oid_t dbid) { struct hseq_status status; xl_invalid_page *hentry; if (invalid_page_tab == NULL) return; /* nothing to do */ hseq_init(&status, invalid_page_tab); while ((hentry = (xl_invalid_page *)hseq_search(&status)) != NULL) { if (hentry->key.node.dbs == dbid) { if (log_min_messages <= DEBUG2 || client_min_messages <= DEBUG2) { char *path; path = relpathperm(hentry->key.node, hentry->key.forkno); elog(DEBUG2, "page %u of relation %s has been dropped", hentry->key.blkno, path); pfree(path); } if (hsearch(invalid_page_tab, (void*) &hentry->key, H_REMOVE, NULL) == NULL) elog(ERROR, "hash table corrupted"); } } }
/** * Insert <key, val> into the global hash table * * return int: * 0 - success * 1 - failed to insert */ int ht_insert(const char *key, const char *val) { e.key = (char *)key; e.data = (void *)val; ep = hsearch(e, ENTER); if (NULL == ep) { fprintf(stderr, "entry failed in hash table \n"); exit(EXIT_FAILURE); } /* DFZ: debug info */ log_msg("\n =====DFZ debug: ep->key = %s, ep->data = %s \n", ep->key, ep->data); /* * DFZ: test ht_search */ ep = ht_search("/tmpfile"); if ((ENTRY*)0 != ep) log_msg("\n =====DFZ debug: ep->key = %s, ep->data = %s (after 'ht_search')\n", ep->key, ep->data); else log_msg("\n =====DFZ debug: not found '/tmpfile' \n "); return 0; }
// enters color struct into hashtable, with a key based on the functional type, // and the owner. (the owner changes when a player touches an object, etc.) void savecs(struct colorset *colors, int colortype, int ownedby) { ENTRY entry, *res; char *keystr; struct entrylist *currentry; keystr = makekey(colortype, ownedby); entry.key = keystr; entry.data = (void *) colors; if ((res = hsearch(entry, ENTER)) == NULL) { fprintf(stderr, "*** error: failed to insert hash table element.\n"); exit(6); } // keep a list of entries to free later on. currentry = malloc(sizeof(struct entrylist)); entrylast->next = currentry; currentry->prev = entrylast; currentry->next = NULL; currentry->entry = res; entrylast = currentry; }
/* * Read an u-record (emitted by lint1 if a symbol was used). */ static void usedsym(pos_t *posp, const char *cp) { usym_t *usym; hte_t *hte; const char *name; usym = xalloc(sizeof (usym_t)); STRUCT_ASSIGN(usym->u_pos, *posp); /* needed as delimiter between two numbers */ if (*cp++ != 'x') inperr(); name = inpname(cp, &cp); hte = _hsearch(renametab, name, 0); if (hte != NULL) hte = hte->h_hte; else hte = hsearch(name, 1); hte->h_used = 1; *hte->h_lusym = usym; hte->h_lusym = &usym->u_nxt; }
Hasch_entry* hsearch (HaschT *T, int k, int action, struct Hasch_data * declare_data(struct Hasch_entry *), struct Hasch_data *free_data(struct Hasch_data *) ) { /*action: FIND,ADD, REMOVE*/ Hasch_entry *p, *pi; int h; /* find the key: k->h*/ h=k%T->ne; if ( action==ADD || action==FIND) { p=pi=T->p[h]; while (p && p->k!=k){p=p->n;} if (action==ADD && !p) { p=insert_hasch_entry_in_list (pi, NULL, NULL, declare_data, free_data); p->k=k; } else if (action==FIND && !p)p=NULL; return p; } else if ( action==REMOVE) { allocate_hasch_entry(hsearch ( T, k, FIND, declare_data, free_data), FREE, declare_data, free_data); return NULL; } return NULL; }
static ENTRY *find(char *word) { ENTRY e; e.key = word; return hsearch(e, FIND); }
/* * find_opr_cache_ent * * Look for a cache entry matching the given key. If found, return the * contained operator OID, else return INVALID_OID. */ static oid_t find_opr_cache_ent(struct opr_cache_key *key) { struct opr_cache_ent *oprentry; if (OprCacheHash == NULL) { /* First time through: initialize the hash table */ struct hash_ctl ctl; pg_memset(&ctl, 0, sizeof(ctl)); ctl.keysize = sizeof(struct opr_cache_key); ctl.entrysize = sizeof(struct opr_cache_ent); ctl.hash = tag_hash; OprCacheHash = hcreate("Operator lookup cache", 256, &ctl, H_ELEM | H_FUNC); /* Arrange to flush cache on pg_operator and pg_cast changes */ register_syscache_cb(OPER_NS, inval_opr_cache_cb, (datum_t) 0); register_syscache_cb(CASTSOURCETARGET, inval_opr_cache_cb, (datum_t) 0); } /* Look for an existing entry */ oprentry = (struct opr_cache_ent *) hsearch(OprCacheHash, (void *) key, H_FIND, NULL); if (oprentry == NULL) return INVALID_OID; return oprentry->opr_oid; }
/* * If there is a symbol named "main", mark it as used. */ void mainused(void) { hte_t *hte; if ((hte = hsearch("main", 0)) != NULL) hte->h_used = 1; }
struct id *enter(int lextype, char *str, int length) { /* implementaion is almost same with Project1 Code */ /**************************************************** Use hash table of STL <search.h> FOr searching, set name as a key of ENTRY item ****************************************************/ ENTRY item; ENTRY* result; item.key = str; result = hsearch(item, FIND); struct id* data; /*************************************************************** 1) result isn't null : detected str already exists in hash table - return result's data to lexer 2) result is null : new identifier - make id entity - save the id entity in heap - save the id entity in hash table - return that id entity ***************************************************************/ if(result) { data = result->data; } else { data = (struct id*)malloc(sizeof(struct id)); data->lextype = lextype; data->name = (char*)malloc(sizeof(char)*length); strncpy(data->name, str, length); item.data = data; item.key = data->name; result = hsearch(item, ENTER); } return data; }
int main(int argc, char* argv[]) { int i = 0; ENTRY e, *ep, *ep2; FILE *fp; char buf[MAXBUF]; char num[15]; hcreate(1); fp = Fopen("/home/jervis/csapp/tinyweb/data/kj20100602.txt", "r"); memset(buf, 0, MAXBUF); while (Fgets(buf, 50, fp)) { i++; if (i >100) break; memset(num, 0, sizeof(num)); strncpy(num, buf, 3); e.key = num; printf("[%s][%d]\n", e.key, strlen(e.key)); e.data = (void *)i; if ((ep = hsearch(e, FIND)) != NULL) { printf("第%d个[%s]与%d个[%s]重复\n", i, e.key, (int)(ep->data), ep->key); } else { printf("------------------------\n"); printf("[%s][%d]\n\n", e.key, strlen(e.key)); if ((ep2 = hsearch(e, ENTER)) != NULL) { /* printf("插入%s=>%d\n", ep2->key, (int)(ep2->data)); */ } else { perror("table full"); exit(EXIT_FAILURE); } } } printf("===================\n"); e.key = "677"; printf("[%s][%d]\n", e.key, strlen(e.key)); if ((ep = hsearch(e, FIND)) != NULL) { printf("find %d => %s\n", (int)(ep->data), ep->key); } hdestroy(); Fclose(fp); return 0; }
int ktup_comparison_hasch ( char *i_seq1, char *i_seq2, const int ktup) { /*Ktup comparison adapted from Rob Edgar, NAR, vol32, No1, 381, 2004*/ /*1: hasch sequence 1 2: Count the number of seq2 ktup found in seq1 */ char c; int key; static HaschT*H1; static char *pseq; Hasch_entry *e; char *s; int l, ls; int p, a, max_dist=-1; double score=0; if (!strm (i_seq1, pseq)) { if (H1) { hdestroy (H1, declare_ktup_hasch_data, free_ktup_hasch_data); string2key (NULL, NULL); } H1=hasch_sequence ( i_seq1, ktup); vfree (pseq);pseq=(char*)vcalloc ( strlen (i_seq1)+1, sizeof (char)); sprintf ( pseq, "%s", i_seq1); } ls=l=strlen (i_seq2); s=i_seq2; p=0; while (ls>ktup) { c=s[ktup];s[ktup]='\0'; key=string2key (s, NULL); e=hsearch (H1,key,FIND, declare_ktup_hasch_data, free_ktup_hasch_data); if ( e==NULL); else if ( max_dist==-1)score++; else { for ( a=1; a<=(e->data)->list[1]; a++) if (FABS((p-(e->data)->list[a]))<=max_dist) {score++; break;} } s[ktup]=c;s++;p++;ls--; } score/=(l-ktup); score=(log(0.1+score)-log(0.1))/(log(1.1)-log(0.1)); if ( score>100) score=100; return (int)(score*100); }
/* * make_opr_cache_ent * * Insert a cache entry for the given key. */ static void make_opr_cache_ent(struct opr_cache_key* key, oid_t opr_oid) { struct opr_cache_ent *oprentry; ASSERT(OprCacheHash != NULL); oprentry = (struct opr_cache_ent*) hsearch(OprCacheHash, (void*) key, H_ENTER, NULL); oprentry->opr_oid = opr_oid; }
static void add_cond (const char *c) { ENTRY e; e.key = strdup (c); e.data = HASHVAL_ITEM; if (!hsearch (e, ENTER)){ perror ("hsearch(3) failed"); exit (2); } }
struct rule * findrule(char *name) { char *lowername; char *p, *q; ENTRY *e; ENTRY search; struct rule *r; lowername = malloc(strlen(name) + 1); for (p = name, q = lowername; *p; p++, q++) if (isupper(*p)) *q = tolower(*p); else *q = *p; *q = '\0'; search.key = lowername; search.data = NULL; e = hsearch(search, FIND); if (e == NULL) { r = calloc(1, sizeof(struct rule)); r->name = name; r->lowername = lowername; search.data = r; e = hsearch(search, ENTER); if (e == NULL) { fprintf(stderr, "hash table full -- increase MAXRULE\n"); exit(1); } if (rules) { r->next = rules; r->prev = rules->prev; rules->prev->next = r; rules->prev = r; } else { rules = r->next = r->prev = r; } return r; } else { free(lowername); return (struct rule *)e->data; } }
/** Searches hash table for a filename. * * @key the name of the file to find * * @returns the gd_fs_entry_t representing that file */ struct gd_fs_entry_t* gd_fs_entry_find(const char* key) { ENTRY keyentry; keyentry.key = key; keyentry.data = NULL; ENTRY* entry = hsearch(keyentry, FIND); if(entry == NULL) return NULL; return (struct gd_fs_entry_t*) entry->data; }
static void add_field (const char *f) { ENTRY e; e.key = strdup (f); e.data = HASHVAL_FIELD; if (!hsearch (e, ENTER)){ perror ("hsearch(3) failed"); exit (2); } }