-
Notifications
You must be signed in to change notification settings - Fork 2
API kr_close
JoungKyun Kim edited this page Jul 13, 2016
·
6 revisions
kr_close - close libkrisp database and free memory
#include <krisp.h>
void kr_close (KR_API **db);
kr_close api close db handle that opened by kr_open api and free memory. KR_API structure that opened by kr_open is must free by kr_close api.
#include <krisp.h>
int main (void) {
KR_API * db;
KRNET_API isp;
char * addr = "kns.kornet.net";
char * database = NULL;
char err[1024];
if ( kr_open (&db, database, err) == false ) {
fprintf (stderr, "ERROR Connect: %s\n", err);
return 1;
}
isp.verbose = false;
// defined safecpy_256 in krispapi.h
safecpy_256 (isp.ip, addr);
if ( kr_search (&isp, db) ) {
printf ("ERROR: %s\n", isp.err);
kr_close (&db);
return 1;
}
kr_close (&db);
/*
* long2ip is include libipcalc.
* https://github.com/Joungkyun/libipcalc/wiki/API-long2ip
* long2ip is returned in a statically allocated buffer, which
* subsequent calls will overwrite. For thread safe, use long2ip_r.
*/
printf ("%-15s %-15s %-20s", ip, isp.ip, isp.icode);
printf ("%-15s ", long2ip (isp.start));
printf ("%-15s %s", long2ip (isp.end), isp.iname);
return 0;
}
JoungKyun.Kim <http://joungkyun.github.com>
Report to https://github.com/Joungkyun/libkrisp/issues
Copyright (c) 2016 JoungKyun.Kim <http://oops.org>
This api is follows LGPL 2.1