Enlightenment CVS committal Author : sebastid Project : e17 Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore_con Modified Files: ecore_con_dns.c Log Message: Remove _ from global variables. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_con/ecore_con_dns.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -3 -r1.17 -r1.18 --- ecore_con_dns.c 30 Aug 2005 10:05:26 -0000 1.17 +++ ecore_con_dns.c 30 Aug 2005 10:17:10 -0000 1.18 @@ -85,19 +85,19 @@ static int _ecore_con_hostname_get(unsigned char *buf, char *hostname, int pos, int length); -static int _init = 0; +static int dns_init = 0; -static struct in_addr _servers[SERVERS]; -static int _server_count; +static struct in_addr servers[SERVERS]; +static int server_count; -static char *_search[6]; -static int _search_count = 0; +static char *search[6]; +static int search_count = 0; -static char *_domain = NULL; +static char *domain = NULL; -static uint16_t _id = 0; +static uint16_t dns_id = 0; -static Ecore_Con_Dns_Cache *_cache = NULL; +static Ecore_Con_Dns_Cache *dns_cache = NULL; #define SET_16BIT(p, v) \ (((p)[0]) = ((v) >> 8) & 0xff), \ @@ -114,11 +114,11 @@ char *p, *p2; int ret; - _init++; - if (_init > 1) return 1; + dns_init++; + if (dns_init > 1) return 1; - memset(_servers, 0, sizeof(_servers)); - _server_count = 0; + memset(servers, 0, sizeof(servers)); + server_count = 0; file = fopen("/etc/resolv.conf", "rb"); if (!file) return 0; @@ -141,10 +141,10 @@ if (!strncmp(buf, "nameserver", 10)) { - if (_server_count >= SERVERS) continue; + if (server_count >= SERVERS) continue; - _servers[_server_count].s_addr = inet_addr(p); - _server_count++; + servers[server_count].s_addr = inet_addr(p); + server_count++; } else if (!strncmp(buf, "domain", 6)) { @@ -154,18 +154,18 @@ if (*p == '.') p++; /* Get the domain */ - _domain = strdup(p); + domain = strdup(p); /* clear search */ - for (i = 0; i < _search_count; i++) + for (i = 0; i < search_count; i++) { - free(_search[i]); - _search[i] = NULL; + free(search[i]); + search[i] = NULL; } - _search_count = 0; + search_count = 0; } else if (!strncmp(buf, "search", 6)) { - while ((p) && (_search_count < 6)) + while ((p) && (search_count < 6)) { /* Remove whitespace */ while ((*p) && (isspace(*p))) @@ -180,15 +180,15 @@ if (p2) *p2 = 0; /* Get this element */ - _search[_search_count] = strdup(p); - _search_count++; + search[search_count] = strdup(p); + search_count++; if (p2) p = p2 + 1; else p = NULL; } - if (_domain) + if (domain) { - free(_domain); - _domain = NULL; + free(domain); + domain = NULL; } } else if (!strncmp(buf, "sortlist", 8)) @@ -202,13 +202,13 @@ } fclose(file); - if (!_server_count) + if (!server_count) { /* We should try localhost */ - _servers[_server_count].s_addr = inet_addr("127.0.0.1"); - _server_count++; + servers[server_count].s_addr = inet_addr("127.0.0.1"); + server_count++; } - if ((!_search_count) && (!_domain)) + if ((!search_count) && (!domain)) { /* Get domain from hostname */ ret = gethostname(buf, sizeof(buf)); @@ -218,7 +218,7 @@ if (p) { p++; - _domain = strdup(p); + domain = strdup(p); } } } @@ -229,19 +229,30 @@ void ecore_con_dns_shutdown(void) { + Ecore_List2 *l; int i; - _init--; - if (_init > 0) return; + dns_init--; + if (dns_init > 0) return; + + for (l = (Ecore_List2 *)dns_cache; l;) + { + Ecore_Con_Dns_Cache *current; + + current = (Ecore_Con_Dns_Cache *)l; + l = l->next; + _ecore_con_dns_cache_free(current); + } + dns_cache = NULL; - if (_domain) + if (domain) { - free(_domain); - _domain = NULL; + free(domain); + domain = NULL; } - for (i = 0; i < _search_count; i++) - free(_search[i]); - _search_count = 0; + for (i = 0; i < search_count; i++) + free(search[i]); + search_count = 0; } int @@ -253,10 +264,10 @@ Ecore_Con_Dns_Cache *current; Ecore_List2 *l; - if (!_server_count) return 0; + if (!server_count) return 0; if ((!name) || (!*name)) return 0; - for (l = (Ecore_List2 *)_cache; l;) + for (l = (Ecore_List2 *)dns_cache; l;) { double time; int i; @@ -267,7 +278,7 @@ time = ecore_time_get(); if ((time - current->time) > current->ttl) { - _cache = _ecore_list2_remove(_cache, current); + dns_cache = _ecore_list2_remove(dns_cache, current); _ecore_con_dns_cache_free(current); } else @@ -277,8 +288,8 @@ { if (done_cb) done_cb(data, current->he); - _cache = _ecore_list2_remove(_cache, current); - _cache = _ecore_list2_prepend(_cache, current); + dns_cache = _ecore_list2_remove(dns_cache, current); + dns_cache = _ecore_list2_prepend(dns_cache, current); return 1; } for (i = 0; current->he->h_aliases[i]; i++) @@ -287,8 +298,8 @@ { if (done_cb) done_cb(data, current->he); - _cache = _ecore_list2_remove(_cache, current); - _cache = _ecore_list2_prepend(_cache, current); + dns_cache = _ecore_list2_remove(dns_cache, current); + dns_cache = _ecore_list2_prepend(dns_cache, current); return 1; } } @@ -387,7 +398,7 @@ total_len += QFIXEDSZ; /* We're crazy, just ask all servers! */ - for (i = 0; i < _server_count; i++) + for (i = 0; i < server_count; i++) { struct sockaddr_in sin; @@ -400,7 +411,7 @@ memset(&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; - sin.sin_addr = _servers[i]; + sin.sin_addr = servers[i]; sin.sin_port = htons(NAMESERVER_PORT); if (connect(query->socket[i], (struct sockaddr *) &sin, sizeof(sin)) == -1) { @@ -412,7 +423,7 @@ } /* qid */ - query->id[i] = ++_id; + query->id[i] = ++dns_id; SET_16BIT(buf, query->id[i]); if (send(query->socket[i], buf, total_len, 0) == -1) @@ -470,7 +481,7 @@ /* Check if this message is for us */ id = GET_16BIT(buf); found = 0; - for (i = 0; i < _server_count; i++) + for (i = 0; i < server_count; i++) { if (query->id[i] == id) { @@ -584,19 +595,19 @@ cache->ttl = ttl; cache->time = ecore_time_get(); cache->he = he; - _cache = _ecore_list2_prepend(_cache, cache); + dns_cache = _ecore_list2_prepend(dns_cache, cache); /* Check cache size */ i = 1; - l = (Ecore_List2 *)_cache; + l = (Ecore_List2 *)dns_cache; while ((l = l->next)) i++; /* Remove old stuff if cache to big */ if (i > 16) { - cache = (Ecore_Con_Dns_Cache *)((Ecore_List2 *)_cache)->last; - _cache = _ecore_list2_remove(_cache, cache); + cache = (Ecore_Con_Dns_Cache *)((Ecore_List2 *)dns_cache)->last; + dns_cache = _ecore_list2_remove(dns_cache, cache); _ecore_con_dns_cache_free(cache); } } @@ -624,7 +635,7 @@ } found = 0; - for (i = 0; i < _server_count; i++) + for (i = 0; i < server_count; i++) { if (query->fd_handlers[i] == fd_handler) { @@ -645,9 +656,9 @@ char buf[256]; /* Should we look more? */ - if ((_domain) && (query->search++)) + if ((domain) && (query->search++)) { - if (snprintf(buf, sizeof(buf), "%s.%s", query->searchname, _domain) < sizeof(buf)) + if (snprintf(buf, sizeof(buf), "%s.%s", query->searchname, domain) < sizeof(buf)) { _ecore_con_dns_ghbn(query, buf); } @@ -658,9 +669,9 @@ _ecore_con_dns_query_free(query); } } - else if ((++query->search) < _search_count) + else if ((++query->search) < search_count) { - if (snprintf(buf, sizeof(buf), "%s.%s", query->searchname, _search[query->search]) < sizeof(buf)) + if (snprintf(buf, sizeof(buf), "%s.%s", query->searchname, search[query->search]) < sizeof(buf)) { _ecore_con_dns_ghbn(query, buf); } @@ -687,7 +698,7 @@ { int i; - for (i = 0; i < _server_count; i++) + for (i = 0; i < server_count; i++) { if (query->socket[i]) close(query->socket[i]); query->socket[i] = 0; ------------------------------------------------------- SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs