Another useful case is to make Python's
ConfigParser accessible in some way from C; ideally, all we really want is to have a function to which we pass the path to a config file to receive a
STATUS OK/FAIL message and a filled buffer of the configuration that we need:
from ConfigParser import SafeConfigParser, NoSectionError cdef extern from "main.h": struct config: char * path int number cdef config myconfig
Here, we've Cythoned our struct and declared an instance on the stack for easier management:
cdef public config * parseConfig (char * cfg): # initialize the global stack variable for our config... myconfig.path = NULL myconfig.number = 0 # buffers for assigning python types into C types cdef char * path = NULL cdef number ...