static struct submodule *lookup_or_create_by_name(struct submodule_cache *cache, const unsigned char *gitmodules_sha1, const char *name) { struct submodule *submodule; struct strbuf name_buf = STRBUF_INIT; submodule = cache_lookup_name(cache, gitmodules_sha1, name); if (submodule) return submodule; submodule = xmalloc(sizeof(*submodule)); strbuf_addstr(&name_buf, name); submodule->name = strbuf_detach(&name_buf, NULL); submodule->path = NULL; submodule->url = NULL; submodule->update_strategy.type = SM_UPDATE_UNSPECIFIED; submodule->update_strategy.command = NULL; submodule->fetch_recurse = RECURSE_SUBMODULES_NONE; submodule->ignore = NULL; submodule->branch = NULL; submodule->recommend_shallow = -1; hashcpy(submodule->gitmodules_sha1, gitmodules_sha1); cache_add(cache, submodule); return submodule; }
void dns_handle_new_query(dns_request_t *m) { //struct in_addr in; int retval = 0; /* modified by CMC from retval=-1 2002/12/6 */ if( m->message.question[0].type == A || m->message.question[0].type == AAA){ /* added by CMC to deny name 2002/11/19 */ if ( deny_lookup_name( m->cname ) ) { debug("%s --> blocked.\n", m->cname); openlog("URL Filter", 0, 0); syslog(0, "URL access to %s is blocked\n", m->cname); closelog(); dns_construct_error_reply(m); dns_write_packet( dns_sock, m->src_addr, m->src_port, m ); return; } /* standard query */ retval = cache_lookup_name( m->cname, m->ip ); }else if( m->message.question[0].type == PTR ){ /* reverse lookup */ retval = cache_lookup_ip( m->ip, m->cname ); } debug(".......... %s ---- %s\n", m->cname, m->ip ); switch( retval ) { case 0: if( is_connected() ){ debug("Adding to list-> id: %d\n", m->message.header.id); dns_request_list = dns_list_add( dns_request_list, m ); /* relay the query untouched */ forward_dns_query( dns_request_list, m ); /* modified by CMC 8/3/2001 */ }else{ debug("Not connected **\n"); dns_construct_error_reply(m); dns_write_packet( dns_sock, m->src_addr, m->src_port, m ); } break; case 1: dns_construct_reply( m ); dns_write_packet( dns_sock, m->src_addr, m->src_port, m ); debug("Cache hit\n"); break; default: debug("Unknown query type: %d\n", m->message.question[0].type ); debug("CMC: Here is un-reachable code! (2002/12/6)\n"); } }
void dns_handle_new_query(dns_request_t *m) { struct in_addr in; int retval = -1; if( m->message.question[0].type == A || m->message.question[0].type == AAA){ /* standard query */ retval = cache_lookup_name( m->cname, m->ip ); }else if( m->message.question[0].type == PTR ){ /* reverse lookup */ retval = cache_lookup_ip( m->ip, m->cname ); } debug(".......... %s ---- %s\n", m->cname, m->ip ); switch( retval ) { case 0: if( is_connected() ){ debug("Adding to list-> id: %d\n", m->message.header.id); dns_request_list = dns_list_add( dns_request_list, m ); /*!!! relay the query untouched */ inet_aton( config.name_server[0], &in ); debug("Sent Request To %s\n",config.name_server[0]); dns_write_packet( dns_sock, in, PORT, m ); }else{ debug("Not connected **\n"); dns_construct_error_reply(m); dns_write_packet( dns_sock, m->src_addr, m->src_port, m ); } break; case 1: dns_construct_reply( m ); dns_write_packet( dns_sock, m->src_addr, m->src_port, m ); debug("Cache hit\n"); break; default: debug("Unknown query type: %d\n", m->message.question[0].type ); } }
/* This does a lookup of a submodule configuration by name or by path * (key) with on-demand reading of the appropriate .gitmodules from * revisions. */ static const struct submodule *config_from(struct submodule_cache *cache, const unsigned char *treeish_name, const char *key, enum lookup_type lookup_type) { struct strbuf rev = STRBUF_INIT; unsigned long config_size; char *config = NULL; unsigned char sha1[20]; enum object_type type; const struct submodule *submodule = NULL; struct parse_config_parameter parameter; /* * If any parameter except the cache is a NULL pointer just * return the first submodule. Can be used to check whether * there are any submodules parsed. */ if (!treeish_name || !key) { struct hashmap_iter iter; struct submodule_entry *entry; entry = hashmap_iter_first(&cache->for_name, &iter); if (!entry) return NULL; return entry->config; } if (!gitmodule_sha1_from_commit(treeish_name, sha1, &rev)) goto out; switch (lookup_type) { case lookup_name: submodule = cache_lookup_name(cache, sha1, key); break; case lookup_path: submodule = cache_lookup_path(cache, sha1, key); break; } if (submodule) goto out; config = read_sha1_file(sha1, &type, &config_size); if (!config || type != OBJ_BLOB) goto out; /* fill the submodule config into the cache */ parameter.cache = cache; parameter.treeish_name = treeish_name; parameter.gitmodules_sha1 = sha1; parameter.overwrite = 0; git_config_from_mem(parse_config, CONFIG_ORIGIN_SUBMODULE_BLOB, rev.buf, config, config_size, ¶meter); strbuf_release(&rev); free(config); switch (lookup_type) { case lookup_name: return cache_lookup_name(cache, sha1, key); case lookup_path: return cache_lookup_path(cache, sha1, key); default: return NULL; } out: strbuf_release(&rev); free(config); return submodule; }
/* This does a lookup of a submodule configuration by name or by path * (key) with on-demand reading of the appropriate .gitmodules from * revisions. */ static const struct submodule *config_from(struct submodule_cache *cache, const unsigned char *commit_sha1, const char *key, enum lookup_type lookup_type) { struct strbuf rev = STRBUF_INIT; unsigned long config_size; char *config; unsigned char sha1[20]; enum object_type type; const struct submodule *submodule = NULL; struct parse_config_parameter parameter; /* * If any parameter except the cache is a NULL pointer just * return the first submodule. Can be used to check whether * there are any submodules parsed. */ if (!commit_sha1 || !key) { struct hashmap_iter iter; struct submodule_entry *entry; hashmap_iter_init(&cache->for_name, &iter); entry = hashmap_iter_next(&iter); if (!entry) return NULL; return entry->config; } if (!gitmodule_sha1_from_commit(commit_sha1, sha1)) return NULL; switch (lookup_type) { case lookup_name: submodule = cache_lookup_name(cache, sha1, key); break; case lookup_path: submodule = cache_lookup_path(cache, sha1, key); break; } if (submodule) return submodule; config = read_sha1_file(sha1, &type, &config_size); if (!config) return NULL; if (type != OBJ_BLOB) { free(config); return NULL; } /* fill the submodule config into the cache */ parameter.cache = cache; parameter.commit_sha1 = commit_sha1; parameter.gitmodules_sha1 = sha1; parameter.overwrite = 0; git_config_from_buf(parse_config, rev.buf, config, config_size, ¶meter); free(config); switch (lookup_type) { case lookup_name: return cache_lookup_name(cache, sha1, key); case lookup_path: return cache_lookup_path(cache, sha1, key); default: return NULL; } }