# Path: pyczmq/_cffi.py
# C = ffi.dlopen('czmq')
# Z = ffi.dlopen('zmq')
# def ptop(typ, val):
# def cdef(decl, returns_string=False, nullable=False):
#     def wrap(f):
#         def inner_f(*args):


from pyczmq._cffi import C, ffi, ptop, cdef

cdef('typedef struct _zcertstore_t zcertstore_t;')


@cdef('void zcertstore_destroy (zcertstore_t **self_p);')
def destroy(store):
    """
    Destroy a certificate store object in memory. Does not affect anything
    stored on disk.
    """
    C.zcertstore_destroy(ptop('zcertstore_t', store))


@cdef('zcertstore_t * zcertstore_new (char *location, ...);')
def new(location):
    """
    Create a new certificate store from a disk directory, loading and
    indexing all certificates in that location. The directory itself may be
    absent, and created later, or modified at any time. The certificate store
    is automatically refreshed on any zcertstore_lookup() call. If the
    location is specified as NULL, creates a pure-memory store, which you
    can work with by inserting certificates at runtime. The location is
    treated as a printf format.
    """

# Path: pyczmq/_cffi.py
# C = ffi.dlopen('czmq')
# Z = ffi.dlopen('zmq')
# def ptop(typ, val):
# def cdef(decl, returns_string=False, nullable=False):
#     def wrap(f):
#         def inner_f(*args):


# Path: pyczmq/zcertstore.py
from pyczmq._cffi import C, ffi, ptop, cdef


cdef('typedef struct _zcertstore_t zcertstore_t;')


@cdef('void zcertstore_destroy (zcertstore_t **self_p);')
def destroy(store):
    """
    Destroy a certificate store object in memory. Does not affect anything
    stored on disk.
    """
    C.zcertstore_destroy(ptop('zcertstore_t', store))


@cdef('zcertstore_t * zcertstore_new (char *location, ...);')
def new(location):
    """
    Create a new certificate store from a disk directory, loading and
    indexing all certificates in that location. The directory itself may be
    absent, and created later, or modified at any time. The certificate store
    is automatically refreshed on any zcertstore_lookup() call. If the
    location is specified as NULL, creates a pure-memory store, which you
    can work with by inserting certificates at runtime. The location is
    treated as a printf format.
    """

    return ffi.gc(C.zcertstore_new(location), destroy)