Skip to content

API kr_close

JoungKyun Kim edited this page Jul 13, 2016 · 6 revisions

NAME

kr_close - close libkrisp database and free memory

SYNOPSIS

#include <krisp.h>
void kr_close (KR_API **db);

DESCRIPTION

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.

EXAMPLE

#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;
}

AUTHORS

JoungKyun.Kim <http://joungkyun.github.com>

BUGS

Report to https://github.com/Joungkyun/libkrisp/issues

COPYRIGHT

Copyright (c) 2016 JoungKyun.Kim <http://oops.org>

This api is follows LGPL 2.1

SEE ALSO

kr_open(3), kr_search(3)

Clone this wiki locally