This is the C API for smisk.core.
Callback signature for probably_call() callbacks:
int probably_call_cb ( void *userdata )
The module itself.
New in version 1.1.
New in version 1.1.
New in version 1.1.
New in version 1.1.
Macro for getting an arbitrary attribute from object.
This is the only way to set/get Type/Class properties. Based on the python interal function PyObject **_PyObject_GetDictPtr(PyObject *)
| Returns: | A PyString or NULL if an exception was raised. |
|---|
New in version 1.1.
Macro for setting an arbitrary attribute of object.
This is the only way to set/get Type/Class properties. Based on the python interal function PyObject **_PyObject_GetDictPtr(PyObject *)
| Returns: | -1 is an error occured or 0 on success. |
|---|
New in version 1.1.
Macro for testing if object is a kind of string (either str or unicode). Workaround for a nasty bug in PyString_Check().
| Returns: | 1 if object is a kind of string, otherwise 0. |
|---|
| Returns: | PyStringObject (new reference). Does NOT clear exception. |
|---|
Parse input data (query string, post url-encoded, cookie, etc).
| Returns: | 0 on success. |
|---|
| Returns: | Current time in microseconds |
|---|
Encode bytes into printable ASCII characters.
Returns a pointer to the byte after the last valid character in out:
nbits=4: out need to fit 40+1 bytes (base 16) (0-9, a-f) nbits=5: out need to fit 32+1 bytes (base 32) (0-9, a-v) nbits=6: out need to fit 27+1 bytes (base 64) (0-9, a-z, A-Z, "-", ",")
Pack bytes into printable ASCII characters.
| Returns: | a PyString. |
|---|---|
| See: | smisk_encode_bin for more information. |
| Parameters: |
|
|---|---|
| Returns: | int |
Calls cb depending on probability.
| Parameters: |
|
|---|---|
| Returns: | -1 on error (if so, a Python Error have been set) or 0 on success. |
Calculate a hash from any python object.
If obj support hash out-of-the-box, the equivalent of hash(obj) will be used. Otherwise obj will be marshalled and the resulting bytes are used for calculating the hash.
Log an error to stderr.
The message actually being written has the following format:
<MOD_IDENT> [<PID>] ERROR <FILE>:<LINE>: <fmt % ...><LF>
| Returns: | Number of characters printed (not including the trailing \0 used to end output to strings) or a negative value if an output error occured. |
|---|
Log something to stderr.
Enabled if SMISK_DEBUG evaluates to true, otherwise all instances of log_debug are removed a compile time.
The message actually being written has the following format:
<MOD_IDENT> [<PID>] DEBUG <FILE>:<LINE>: <fmt % ...><LF>
| Returns: | Number of characters printed (not including the trailing \0 used to end output to strings) or a negative value if an output error occured. |
|---|
Log a trace message to stderr.
Enabled if SMISK_TRACE evaluates to true, otherwise all instances of log_trace are removed a compile time.
The message actually being written has the following format:
<MOD_IDENT> [<PID>] TRACE <FILE>:<LINE> in <FUNCTION> <fmt % ...><LF>
| Returns: | Number of characters printed (not including the trailing \0 used to end output to strings) or a negative value if an output error occured. |
|---|
Macro to assert refcount on object matches count_test.
Evaluated only if SMISK_DEBUG is true.
Asserting my_dict has 3 or less references:
assert_refcount(my_dict, <= 3)
Wrap the value of another macro in double quotes.
Example:
MY_VERSION_MAJOR 2
puts("Program version " QUOTE(MY_VERSION_MAJOR))
// Is equivalent to:
puts("Program version 2")
Expands to:
PyErr_SetFromErrnoWithFilename(PyExc_IOError, __FILE__)
If defined and evaluates to true, enables Smisk debugging features, like log_debug() and setting SMISK_TRACE to true (thus in turn activating log_trace()).
Automatically enabled when passing --debug-smisk to setup.py build.
Evaluates only if SMISK_DEBUG is true and expands to:
log_debug(" *** %s: %ld", #o, (o) ? (Py_ssize_t)(o)->ob_refcnt : 0)
Like repr() in interpreted Python or PyObject_Repr in CPython, but takes care of NULL values and refcounting.
Evaluates only if SMISK_DEBUG is true and expands to something like this:
log_debug("repr(%s) = %s", #o, PyObject_Repr(object));
Inspired by Igor Sysoev.
These macros evaluate to true if string equals, or starts with, abc....
Example:
char *string = "Help";
if (smisk_str4cmp(string, 'H', 'e', 'l', 'p'))
fprint("Yes, string == \"Help\"");
// Output: Yes, string == "Help"
Macros defined in config.h.
Session ID compactness.
New in version 1.1.