int main(int ac, char *av[]) { strcpy(arg1,av[1]); strcpy(arg2,av[2]); compare_name(av[1],av[2]); return 0; }
static AnjutaProjectNodeType get_target_type (IAnjutaProject *project, const char *id) { AnjutaProjectNodeType type; const GList *list; const GList *item; gint best = G_MAXINT; list = ianjuta_project_get_node_info (project, NULL); type = 0; for (item = list; item != NULL; item = g_list_next (item)) { AnjutaProjectNodeInfo *info = (AnjutaProjectNodeInfo *)item->data; if ((info->type & ANJUTA_PROJECT_TYPE_MASK) == ANJUTA_PROJECT_TARGET) { gint miss; miss = compare_name (id, info->name); if ((miss >= 0) && (miss < best)) { best = miss; type = info->type; } } } return type; }
static AnjutaProjectPropertyInfo * get_project_property (IAnjutaProject *project, AnjutaProjectNode *parent, const gchar *id) { GList *item; AnjutaProjectPropertyInfo *info = NULL; gint best = G_MAXINT; for (item = anjuta_project_node_get_properties_info (parent); item != NULL; item = g_list_next (item)) { gint miss; /* Find property based on their id */ if (strcmp (id, ((AnjutaProjectPropertyInfo *)item->data)->id) == 0) { info = ((AnjutaProjectPropertyInfo *)item->data); break; } /* Else use the best name */ miss = compare_name (id, ((AnjutaProjectPropertyInfo *)item->data)->name); if ((miss >= 0) && (miss < best)) { best = miss; info = ((AnjutaProjectPropertyInfo *)item->data); } } return info; }
static gint compare(gint sort_method, gboolean reverse, PurpleBlistNode *node1, PurpleBlistNode *node2) { gint ret = 0; switch(sort_method) { case SORT_METHOD_NOTHING: ret = compare_nothing(node1, node2); break; case SORT_METHOD_NAME: ret = compare_name(node1, node2); break; case SORT_METHOD_LAST_NAME: ret = compare_last_name(node1, node2); break; case SORT_METHOD_STATUS: ret = compare_status(node1, node2); break; case SORT_METHOD_ONOFFLINE: ret = compare_onoffline(node1, node2); break; case SORT_METHOD_PROTOCOL: ret = compare_protocol(node1, node2); break; case SORT_METHOD_PRIORITY: ret = compare_priority(node1, node2); break; case SORT_METHOD_ONOFFLINETIME: ret = compare_onofflinetime(node1, node2); break; case SORT_METHOD_LOGSIZE: ret = compare_logsize(node1, node2); break; case SORT_METHOD_ACCOUNT: ret = compare_account(node1, node2); break; } if(reverse) { ret *= (-1); } return ret; }
/* * Search through the keyring(s), starting at the current position, * for a keyblock which contains one of the keys described in the DESC array. */ int keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc, size_t ndesc, size_t *descindex) { int rc; PACKET pkt; int save_mode; off_t offset, main_offset; size_t n; int need_uid, need_words, need_keyid, need_fpr, any_skip; int pk_no, uid_no; int initial_skip; int use_offtbl; PKT_user_id *uid = NULL; PKT_public_key *pk = NULL; PKT_secret_key *sk = NULL; u32 aki[2]; /* figure out what information we need */ need_uid = need_words = need_keyid = need_fpr = any_skip = 0; for (n=0; n < ndesc; n++) { switch (desc[n].mode) { case KEYDB_SEARCH_MODE_EXACT: case KEYDB_SEARCH_MODE_SUBSTR: case KEYDB_SEARCH_MODE_MAIL: case KEYDB_SEARCH_MODE_MAILSUB: case KEYDB_SEARCH_MODE_MAILEND: need_uid = 1; break; case KEYDB_SEARCH_MODE_WORDS: need_uid = 1; need_words = 1; break; case KEYDB_SEARCH_MODE_SHORT_KID: case KEYDB_SEARCH_MODE_LONG_KID: need_keyid = 1; break; case KEYDB_SEARCH_MODE_FPR16: case KEYDB_SEARCH_MODE_FPR20: case KEYDB_SEARCH_MODE_FPR: need_fpr = 1; break; case KEYDB_SEARCH_MODE_FIRST: /* always restart the search in this mode */ keyring_search_reset (hd); break; default: break; } if (desc[n].skipfnc) { any_skip = 1; need_keyid = 1; } } rc = prepare_search (hd); if (rc) return rc; use_offtbl = !hd->secret && kr_offtbl; if (!use_offtbl) ; else if (!kr_offtbl_ready) need_keyid = 1; else if (ndesc == 1 && desc[0].mode == KEYDB_SEARCH_MODE_LONG_KID) { struct off_item *oi; oi = lookup_offset_hash_table (kr_offtbl, desc[0].u.kid); if (!oi) { /* We know that we don't have this key */ hd->found.kr = NULL; hd->current.eof = 1; return -1; } /* We could now create a positive search status and return. * However the problem is that another instance of gpg may * have changed the keyring so that the offsets are not valid * anymore - therefore we don't do it */ } if (need_words) { const char *name = NULL; log_debug ("word search mode does not yet work\n"); /* FIXME: here is a long standing bug in our function and in addition we just use the first search description */ for (n=0; n < ndesc && !name; n++) { if (desc[n].mode == KEYDB_SEARCH_MODE_WORDS) name = desc[n].u.name; } assert (name); if ( !hd->word_match.name || strcmp (hd->word_match.name, name) ) { /* name changed */ xfree (hd->word_match.name); xfree (hd->word_match.pattern); hd->word_match.name = xstrdup (name); hd->word_match.pattern = prepare_word_match (name); } name = hd->word_match.pattern; } init_packet(&pkt); save_mode = set_packet_list_mode(0); hd->found.kr = NULL; main_offset = 0; pk_no = uid_no = 0; initial_skip = 1; /* skip until we see the start of a keyblock */ while (!(rc=search_packet (hd->current.iobuf, &pkt, &offset, need_uid))) { byte afp[MAX_FINGERPRINT_LEN]; size_t an; if (pkt.pkttype == PKT_PUBLIC_KEY || pkt.pkttype == PKT_SECRET_KEY) { main_offset = offset; pk_no = uid_no = 0; initial_skip = 0; } if (initial_skip) { free_packet (&pkt); continue; } pk = NULL; sk = NULL; uid = NULL; if ( pkt.pkttype == PKT_PUBLIC_KEY || pkt.pkttype == PKT_PUBLIC_SUBKEY) { pk = pkt.pkt.public_key; ++pk_no; if (need_fpr) { fingerprint_from_pk (pk, afp, &an); while (an < 20) /* fill up to 20 bytes */ afp[an++] = 0; } if (need_keyid) keyid_from_pk (pk, aki); if (use_offtbl && !kr_offtbl_ready) update_offset_hash_table (kr_offtbl, aki, main_offset); } else if (pkt.pkttype == PKT_USER_ID) { uid = pkt.pkt.user_id; ++uid_no; } else if ( pkt.pkttype == PKT_SECRET_KEY || pkt.pkttype == PKT_SECRET_SUBKEY) { sk = pkt.pkt.secret_key; ++pk_no; if (need_fpr) { fingerprint_from_sk (sk, afp, &an); while (an < 20) /* fill up to 20 bytes */ afp[an++] = 0; } if (need_keyid) keyid_from_sk (sk, aki); } for (n=0; n < ndesc; n++) { switch (desc[n].mode) { case KEYDB_SEARCH_MODE_NONE: BUG (); break; case KEYDB_SEARCH_MODE_EXACT: case KEYDB_SEARCH_MODE_SUBSTR: case KEYDB_SEARCH_MODE_MAIL: case KEYDB_SEARCH_MODE_MAILSUB: case KEYDB_SEARCH_MODE_MAILEND: case KEYDB_SEARCH_MODE_WORDS: if ( uid && !compare_name (desc[n].mode, desc[n].u.name, uid->name, uid->len)) goto found; break; case KEYDB_SEARCH_MODE_SHORT_KID: if ((pk||sk) && desc[n].u.kid[1] == aki[1]) goto found; break; case KEYDB_SEARCH_MODE_LONG_KID: if ((pk||sk) && desc[n].u.kid[0] == aki[0] && desc[n].u.kid[1] == aki[1]) goto found; break; case KEYDB_SEARCH_MODE_FPR16: if ((pk||sk) && !memcmp (desc[n].u.fpr, afp, 16)) goto found; break; case KEYDB_SEARCH_MODE_FPR20: case KEYDB_SEARCH_MODE_FPR: if ((pk||sk) && !memcmp (desc[n].u.fpr, afp, 20)) goto found; break; case KEYDB_SEARCH_MODE_FIRST: if (pk||sk) goto found; break; case KEYDB_SEARCH_MODE_NEXT: if (pk||sk) goto found; break; default: rc = G10ERR_INV_ARG; goto found; } } free_packet (&pkt); continue; found: /* Record which desc we matched on. Note this value is only meaningful if this function returns with no errors. */ if(descindex) *descindex=n; for (n=any_skip?0:ndesc; n < ndesc; n++) { if (desc[n].skipfnc && desc[n].skipfnc (desc[n].skipfncvalue, aki, uid)) break; } if (n == ndesc) goto real_found; free_packet (&pkt); } real_found: if (!rc) { hd->found.offset = main_offset; hd->found.kr = hd->current.kr; hd->found.pk_no = (pk||sk)? pk_no : 0; hd->found.uid_no = uid? uid_no : 0; } else if (rc == -1) { hd->current.eof = 1; /* if we scanned all keyrings, we are sure that * all known key IDs are in our offtbl, mark that. */ if (use_offtbl && !kr_offtbl_ready) { KR_NAME kr; /* First set the did_full_scan flag for this keyring (ignore secret keyrings) */ for (kr=kr_names; kr; kr = kr->next) { if (!kr->secret && hd->resource == kr) { kr->did_full_scan = 1; break; } } /* Then check whether all flags are set and if so, mark the offtbl ready */ for (kr=kr_names; kr; kr = kr->next) { if (!kr->secret && !kr->did_full_scan) break; } if (!kr) kr_offtbl_ready = 1; } } else hd->current.error = rc; free_packet(&pkt); set_packet_list_mode(save_mode); return rc; }
/* Read the system's package database and extract information about * 'pkgname'. Return 0 in case of success, or -1 in case of error. * * If the package is unknown, return -1 and set errno to ENOENT * If the package database is corrupted, return -1 and set errno to EINVAL */ int get_package_info(const char* pkgName, PackageInfo *info) { char* buffer; size_t buffer_len; const char* p; const char* buffer_end; int result = -1; info->uid = 0; info->isDebuggable = 0; info->dataDir[0] = '\0'; info->seinfo[0] = '\0'; buffer = map_file(PACKAGES_LIST_FILE, &buffer_len); if (buffer == NULL) return -1; p = buffer; buffer_end = buffer + buffer_len; /* expect the following format on each line of the control file: * * <pkgName> <uid> <debugFlag> <dataDir> * * where: * <pkgName> is the package's name * <uid> is the application-specific user Id (decimal) * <debugFlag> is 1 if the package is debuggable, or 0 otherwise * <dataDir> is the path to the package's data directory (e.g. /data/data/com.example.foo) * <seinfo> is the seinfo label associated with the package * * The file is generated in com.android.server.PackageManagerService.Settings.writeLP() */ while (p < buffer_end) { /* find end of current line and start of next one */ const char* end = find_first(p, buffer_end, '\n'); const char* next = (end < buffer_end) ? end + 1 : buffer_end; const char* q; int uid, debugFlag; /* first field is the package name */ p = compare_name(p, end, pkgName); if (p == NULL) goto NEXT_LINE; /* skip spaces */ if (parse_spaces(&p, end) < 0) goto BAD_FORMAT; /* second field is the pid */ uid = parse_positive_decimal(&p, end); if (uid < 0) return -1; info->uid = (uid_t) uid; /* skip spaces */ if (parse_spaces(&p, end) < 0) goto BAD_FORMAT; /* third field is debug flag (0 or 1) */ debugFlag = parse_positive_decimal(&p, end); switch (debugFlag) { case 0: info->isDebuggable = 0; break; case 1: info->isDebuggable = 1; break; default: goto BAD_FORMAT; } /* skip spaces */ if (parse_spaces(&p, end) < 0) goto BAD_FORMAT; /* fourth field is data directory path and must not contain * spaces. */ q = skip_non_spaces(p, end); if (q == p) goto BAD_FORMAT; p = string_copy(info->dataDir, sizeof info->dataDir, p, q - p); /* skip spaces */ if (parse_spaces(&p, end) < 0) goto BAD_FORMAT; /* grab the seinfo string */ q = skip_non_spaces(p, end); if (q == p) goto BAD_FORMAT; string_copy(info->seinfo, sizeof info->seinfo, p, q - p); /* Ignore the rest */ result = 0; goto EXIT; NEXT_LINE: p = next; } /* the package is unknown */ errno = ENOENT; result = -1; goto EXIT; BAD_FORMAT: errno = EINVAL; result = -1; EXIT: unmap_file(buffer, buffer_len); return result; }
void Visit(const Waypoint &wp) { if (compare_type(wp, type_index) && (filter_data.distance_index == 0 || compare_name(wp, name)) && compare_direction(wp, direction_index, location, heading)) vector.push_back(wp, location); }
void compare_name(char* name1, char* name2) { DIR *dirA; // to open two directories struct stat infoA,infoB; struct dirent *dr; char temp[1000], temp2[1000]; char onlyIn[1000]; if ((dirA = opendir(name1)) != NULL) { while ((dr = readdir(dirA))!=NULL) { //get the detail and add "/" to form a path for futher calls strcpy(temp, name1); strcat(temp, "/"); strcat(temp, dr->d_name); if ((strcmp(dr->d_name, "..")!=0) && (strcmp(dr->d_name,".")!=0)) { strcpy(onlyIn,"/"); strcat(onlyIn,dr->d_name); char result[100]; strcpy(result,temp); strcpy(result,replace_str(result,onlyIn,"")); int existA=0,existB=0,isFolderA=0,isFolderB=0; // for name's properties existA = stat(temp,&infoA);//get the struct stat from the name isFolderA= S_ISDIR(infoA.st_mode);//check if it is a folder or a file strcpy(temp2,temp); strcpy(temp2,replace_str(temp2,arg1,arg2)); // A/abcd/ef -> B/abcd/ef existB= stat(temp2,&infoB); if (existB!=-1) // if that name exists in B { /* A IS A FILE */ if (isFolderA==0)//if this is a file, check if it exists in B { isFolderB= S_ISDIR(infoB.st_mode); //////// FILE ---- FOLDER ///////////////// if (isFolderB==1)//if this is a folder instead, print it out { //check if its empty char empty[10]; int size=0; size = infoA.st_size; if (size==0) { strcpy(empty," empty"); } else { strcpy(empty,""); } printf("File %s is a regular%s file while file is a directory\n", temp,empty); } //////// FILE ----- FILE ///////////// else if (isFolderB==0) { FILE *fileA,*fileB; int sizeA=0,sizeB=0; sizeA = infoA.st_size; sizeB = infoB.st_size; fileA = fopen(temp, "rb"); fileB = fopen(temp2, "rb"); if( (fileA == NULL) || (fileB == NULL) ) { printf("Cannot open file"); } else { char lineA[sizeA],lineB[sizeB]; fread(lineA, 1, sizeof(lineA), fileA); fread(lineB, 1, sizeof(lineB), fileB); if(sizeA != sizeB || memcmp(lineA,lineB,sizeA)!=0) { printf("Files %s and %s differ\n",temp,temp2); } } } // if not exist print out } /* A IS A FOLDER */ else //if this is a folder, check in B { isFolderB= S_ISDIR(infoB.st_mode); ///////// FOLDER ----- FILE ////////////////// if (isFolderB==0) { //check if its empty char empty[10]; int size=0; size = infoB.st_size; if (size==0) { strcpy(empty," empty"); } else { strcpy(empty,""); } printf("File %s is a directory while file %s is a regular%s file\n", temp,temp2,empty); } ///////// FOLDER ----- FOLDER else if (isFolderB==1) { compare_name(temp,temp2); } } } else // if that does not exist in B { printf("Only in %s: %s\n",result,dr->d_name); } } } } closedir(dirA); if ((dirA = opendir(name2)) != NULL) { while ((dr = readdir(dirA))!=NULL) { strcpy(temp, name2); strcat(temp, "/"); strcat(temp, dr->d_name); if ((strcmp(dr->d_name, "..")!=0) && (strcmp(dr->d_name,".")!=0)) { strcpy(onlyIn,"/"); strcat(onlyIn,dr->d_name); char result[100]; strcpy(result,temp); strcpy(result,replace_str(result,onlyIn,"")); strcpy(temp2,temp); strcpy(temp2,replace_str(temp2,arg2,arg1)); // A/abcd/ef -> B/abcd/ef int existB; existB= stat(temp2,&infoB); if (existB==-1) { printf("Only in %s: %s\n",result,dr->d_name); } } } } closedir(dirA); }
/* * Search through the keyring(s), starting at the current position, * for a keyblock which contains one of the keys described in the DESC array. */ int keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc, size_t ndesc, size_t *descindex, int ignore_legacy) { int rc; PACKET pkt; struct parse_packet_ctx_s parsectx; int save_mode; off_t offset, main_offset; size_t n; int need_uid, need_words, need_keyid, need_fpr, any_skip; int pk_no, uid_no; int initial_skip; int scanned_from_start; int use_key_present_hash; PKT_user_id *uid = NULL; PKT_public_key *pk = NULL; u32 aki[2]; /* figure out what information we need */ need_uid = need_words = need_keyid = need_fpr = any_skip = 0; for (n=0; n < ndesc; n++) { switch (desc[n].mode) { case KEYDB_SEARCH_MODE_EXACT: case KEYDB_SEARCH_MODE_SUBSTR: case KEYDB_SEARCH_MODE_MAIL: case KEYDB_SEARCH_MODE_MAILSUB: case KEYDB_SEARCH_MODE_MAILEND: need_uid = 1; break; case KEYDB_SEARCH_MODE_WORDS: need_uid = 1; need_words = 1; break; case KEYDB_SEARCH_MODE_SHORT_KID: case KEYDB_SEARCH_MODE_LONG_KID: need_keyid = 1; break; case KEYDB_SEARCH_MODE_FPR16: case KEYDB_SEARCH_MODE_FPR20: case KEYDB_SEARCH_MODE_FPR: need_fpr = 1; break; case KEYDB_SEARCH_MODE_FIRST: /* always restart the search in this mode */ keyring_search_reset (hd); break; default: break; } if (desc[n].skipfnc) { any_skip = 1; need_keyid = 1; } } if (DBG_LOOKUP) log_debug ("%s: need_uid = %d; need_words = %d; need_keyid = %d; need_fpr = %d; any_skip = %d\n", __func__, need_uid, need_words, need_keyid, need_fpr, any_skip); rc = prepare_search (hd); if (rc) { if (DBG_LOOKUP) log_debug ("%s: prepare_search failed: %s (%d)\n", __func__, gpg_strerror (rc), gpg_err_code (rc)); return rc; } use_key_present_hash = !!key_present_hash; if (!use_key_present_hash) { if (DBG_LOOKUP) log_debug ("%s: no offset table.\n", __func__); } else if (!key_present_hash_ready) { if (DBG_LOOKUP) log_debug ("%s: initializing offset table. (need_keyid: %d => 1)\n", __func__, need_keyid); need_keyid = 1; } else if (ndesc == 1 && desc[0].mode == KEYDB_SEARCH_MODE_LONG_KID) { struct key_present *oi; if (DBG_LOOKUP) log_debug ("%s: look up by long key id, checking cache\n", __func__); oi = key_present_hash_lookup (key_present_hash, desc[0].u.kid); if (!oi) { /* We know that we don't have this key */ if (DBG_LOOKUP) log_debug ("%s: cache says not present\n", __func__); hd->found.kr = NULL; hd->current.eof = 1; return -1; } /* We could now create a positive search status and return. * However the problem is that another instance of gpg may * have changed the keyring so that the offsets are not valid * anymore - therefore we don't do it */ } if (need_words) { const char *name = NULL; log_debug ("word search mode does not yet work\n"); /* FIXME: here is a long standing bug in our function and in addition we just use the first search description */ for (n=0; n < ndesc && !name; n++) { if (desc[n].mode == KEYDB_SEARCH_MODE_WORDS) name = desc[n].u.name; } log_assert (name); if ( !hd->word_match.name || strcmp (hd->word_match.name, name) ) { /* name changed */ xfree (hd->word_match.name); xfree (hd->word_match.pattern); hd->word_match.name = xstrdup (name); hd->word_match.pattern = prepare_word_match (name); } /* name = hd->word_match.pattern; */ } init_packet(&pkt); save_mode = set_packet_list_mode(0); hd->found.kr = NULL; main_offset = 0; pk_no = uid_no = 0; initial_skip = 1; /* skip until we see the start of a keyblock */ scanned_from_start = iobuf_tell (hd->current.iobuf) == 0; if (DBG_LOOKUP) log_debug ("%s: %ssearching from start of resource.\n", __func__, scanned_from_start ? "" : "not "); init_parse_packet (&parsectx, hd->current.iobuf); while (1) { byte afp[MAX_FINGERPRINT_LEN]; size_t an; rc = search_packet (&parsectx, &pkt, &offset, need_uid); if (ignore_legacy && gpg_err_code (rc) == GPG_ERR_LEGACY_KEY) { free_packet (&pkt, &parsectx); continue; } if (rc) break; if (pkt.pkttype == PKT_PUBLIC_KEY || pkt.pkttype == PKT_SECRET_KEY) { main_offset = offset; pk_no = uid_no = 0; initial_skip = 0; } if (initial_skip) { free_packet (&pkt, &parsectx); continue; } pk = NULL; uid = NULL; if ( pkt.pkttype == PKT_PUBLIC_KEY || pkt.pkttype == PKT_PUBLIC_SUBKEY || pkt.pkttype == PKT_SECRET_KEY || pkt.pkttype == PKT_SECRET_SUBKEY) { pk = pkt.pkt.public_key; ++pk_no; if (need_fpr) { fingerprint_from_pk (pk, afp, &an); while (an < 20) /* fill up to 20 bytes */ afp[an++] = 0; } if (need_keyid) keyid_from_pk (pk, aki); if (use_key_present_hash && !key_present_hash_ready && scanned_from_start) key_present_hash_update (key_present_hash, aki); } else if (pkt.pkttype == PKT_USER_ID) { uid = pkt.pkt.user_id; ++uid_no; } for (n=0; n < ndesc; n++) { switch (desc[n].mode) { case KEYDB_SEARCH_MODE_NONE: BUG (); break; case KEYDB_SEARCH_MODE_EXACT: case KEYDB_SEARCH_MODE_SUBSTR: case KEYDB_SEARCH_MODE_MAIL: case KEYDB_SEARCH_MODE_MAILSUB: case KEYDB_SEARCH_MODE_MAILEND: case KEYDB_SEARCH_MODE_WORDS: if ( uid && !compare_name (desc[n].mode, desc[n].u.name, uid->name, uid->len)) goto found; break; case KEYDB_SEARCH_MODE_SHORT_KID: if (pk && desc[n].u.kid[1] == aki[1]) goto found; break; case KEYDB_SEARCH_MODE_LONG_KID: if (pk && desc[n].u.kid[0] == aki[0] && desc[n].u.kid[1] == aki[1]) goto found; break; case KEYDB_SEARCH_MODE_FPR16: if (pk && !memcmp (desc[n].u.fpr, afp, 16)) goto found; break; case KEYDB_SEARCH_MODE_FPR20: case KEYDB_SEARCH_MODE_FPR: if (pk && !memcmp (desc[n].u.fpr, afp, 20)) goto found; break; case KEYDB_SEARCH_MODE_FIRST: if (pk) goto found; break; case KEYDB_SEARCH_MODE_NEXT: if (pk) goto found; break; default: rc = GPG_ERR_INV_ARG; goto found; } } free_packet (&pkt, &parsectx); continue; found: if (rc) goto real_found; if (DBG_LOOKUP) log_debug ("%s: packet starting at offset %lld matched descriptor %zu\n" , __func__, (long long)offset, n); /* Record which desc we matched on. Note this value is only meaningful if this function returns with no errors. */ if(descindex) *descindex=n; for (n=any_skip?0:ndesc; n < ndesc; n++) { if (desc[n].skipfnc && desc[n].skipfnc (desc[n].skipfncvalue, aki, uid_no)) { if (DBG_LOOKUP) log_debug ("%s: skipping match: desc %zd's skip function returned TRUE\n", __func__, n); break; } } if (n == ndesc) goto real_found; free_packet (&pkt, &parsectx); } real_found: if (!rc) { if (DBG_LOOKUP) log_debug ("%s: returning success\n", __func__); hd->found.offset = main_offset; hd->found.kr = hd->current.kr; hd->found.pk_no = pk? pk_no : 0; hd->found.uid_no = uid? uid_no : 0; } else if (rc == -1) { if (DBG_LOOKUP) log_debug ("%s: no matches (EOF)\n", __func__); hd->current.eof = 1; /* if we scanned all keyrings, we are sure that * all known key IDs are in our offtbl, mark that. */ if (use_key_present_hash && !key_present_hash_ready && scanned_from_start) { KR_RESOURCE kr; /* First set the did_full_scan flag for this keyring. */ for (kr=kr_resources; kr; kr = kr->next) { if (hd->resource == kr) { kr->did_full_scan = 1; break; } } /* Then check whether all flags are set and if so, mark the offtbl ready */ for (kr=kr_resources; kr; kr = kr->next) { if (!kr->did_full_scan) break; } if (!kr) key_present_hash_ready = 1; } } else { if (DBG_LOOKUP) log_debug ("%s: error encountered during search: %s (%d)\n", __func__, gpg_strerror (rc), rc); hd->current.error = rc; } free_packet (&pkt, &parsectx); deinit_parse_packet (&parsectx); set_packet_list_mode(save_mode); return rc; }