#include "./libipg.h"
Go to the source code of this file.
Functions | |
| ipgeo_t * | ipgeo_init (char *file, u_int8_t flags, char *err_buf) |
| void | ipgeo_destroy (ipgeo_t *ipg) |
| char * | ipgeo_geterror (ipgeo_t *ipg) |
| int | ipgeo_getdbt (ipgeo_t *ipg) |
| int | ipgeo_getfd (ipgeo_t *ipg) |
Definition in file libipg_init.c.
|
||||||||||||||||
|
only CSV db type currently supported control flags are currently undefined Definition at line 49 of file libipg_init.c. References ipgeo_context::db, ipgeo_context::dbt, ipgeo_context::flags, and ipgeo_t.
00050 {
00051 ipgeo_t *ipg = NULL;
00052
00053 ipg = (ipgeo_t *)malloc(sizeof (ipgeo_t));
00054 if (ipg == NULL)
00055 {
00056 snprintf(err_buf, IPGEO_ERRBUF_SIZE, "malloc(): %s\n", strerror(errno));
00057 goto bad;
00058 }
00059
00060 memset(ipg, 0, sizeof (ipg));
00061
00062 ipg->db = fopen(file, "r");
00063 if (ipg->db == NULL)
00064 {
00065 snprintf(err_buf, IPGEO_ERRBUF_SIZE, "fopen() (%s): %s\n", file,
00066 strerror(errno));
00067 goto bad;
00068 }
00069
00071 ipg->dbt = 6;
00072
00074 ipg->flags = flags;
00075
00076 return (ipg);
00077
00078 bad:
00079 if (ipg)
00080 {
00081 if (ipg->db)
00082 {
00083 fclose(ipg->db);
00084 }
00085 free (ipg);
00086 }
00087 return (NULL);
00088 }
|
|
|
Shuts down the libipg session and frees all memory referenced by ipg.
Definition at line 91 of file libipg_init.c. References ipgeo_context::db, and ipgeo_t.
|
|
|
Returns the last error set inside of the referenced libipg context. This function should be called anytime a function fails or an error condition is detected inside of libipg.
Definition at line 104 of file libipg_init.c. References ipgeo_context::err_buf, and ipgeo_t.
00105 {
00106 return (ipg->err_buf);
00107 }
|
|
|
Returns the type of IP2LOCATION db libipg has open.
Definition at line 110 of file libipg_init.c. References ipgeo_context::db, ipgeo_context::dbt, and ipgeo_t.
|
|
|
we should not return -1 here since any error should be caught during initialization Definition at line 120 of file libipg_init.c. References ipgeo_context::db, and ipgeo_t.
|
1.3.4