"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/test-geoip-org.c" between
GeoIP-1.6.11.tar.gz and GeoIP-1.6.12.tar.gz

About: GeoIP is a C library that enables the user to find the country that any IP address or hostname originates from (contains an initial free GeoIP Country database).

test-geoip-org.c  (GeoIP-1.6.11):test-geoip-org.c  (GeoIP-1.6.12)
skipping to change at line 18 skipping to change at line 18
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * version 2.1 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 US A * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "GeoIP.h" #include "GeoIP.h"
static const char *_mk_NA(const char *p) static const char *_mk_NA(const char *p) { return p ? p : "N/A"; }
{
return p ? p : "N/A";
}
int main(int argc, char *argv[]) int main(int argc, char *argv[]) {
{
FILE *f; FILE *f;
GeoIP *gi; GeoIP *gi;
char *org; char *org;
char host[50]; char host[50];
char **ret; char **ret;
gi = GeoIP_open("../data/GeoIPOrg.dat", GEOIP_INDEX_CACHE); gi = GeoIP_open("../data/GeoIPOrg.dat", GEOIP_INDEX_CACHE);
if (gi == NULL) { if (gi == NULL) {
fprintf(stderr, "Error opening database\n"); fprintf(stderr, "Error opening database\n");
skipping to change at line 57 skipping to change at line 53
exit(1); exit(1);
} }
printf("IP\torganization\tnetmask\tbeginIp\tendIp\n"); printf("IP\torganization\tnetmask\tbeginIp\tendIp\n");
while (fscanf(f, "%s", host) != EOF) { while (fscanf(f, "%s", host) != EOF) {
org = GeoIP_name_by_name(gi, (const char *)host); org = GeoIP_name_by_name(gi, (const char *)host);
if (org != NULL) { if (org != NULL) {
ret = GeoIP_range_by_ip(gi, (const char *)host); ret = GeoIP_range_by_ip(gi, (const char *)host);
printf("%s\t%s\t%d\t%s\t%s\n", host, _mk_NA(org), printf("%s\t%s\t%d\t%s\t%s\n",
GeoIP_last_netmask(gi), ret[0], ret[1]); host,
_mk_NA(org),
GeoIP_last_netmask(gi),
ret[0],
ret[1]);
GeoIP_range_by_ip_delete(ret); GeoIP_range_by_ip_delete(ret);
free(org); free(org);
} }
} }
fclose(f); fclose(f);
GeoIP_delete(gi); GeoIP_delete(gi);
return 0; return 0;
} }
 End of changes. 4 change blocks. 
9 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)