X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=sigrok.h;h=89109afd4d1254a20fdfd079f4c472d1ca2e6852;hb=37aea2d35c981239e630254fe74f0a411bbc34cb;hp=1d11aff7fc45b10d3b8b069855bb41a193b67f8f;hpb=5a8fda158bd9cc040b36fb3b016808c59ccf89f3;p=libsigrok.git diff --git a/sigrok.h b/sigrok.h index 1d11aff7..89109afd 100644 --- a/sigrok.h +++ b/sigrok.h @@ -27,11 +27,27 @@ #include #include -/* Returned status/error codes */ -#define SIGROK_STATUS_DISABLED 0 -#define SIGROK_OK 1 -#define SIGROK_NOK 2 -#define SIGROK_ERR_BADVALUE 20 +/* + * Status/error codes returned by libsigrok functions. + * + * All possible return codes of libsigrok functions must be listed here. + * Functions should never return hardcoded numbers as status, but rather + * use these #defines instead. All error codes are negative numbers. + * + * The error codes are globally unique in libsigrok, i.e. if one of the + * libsigrok functions returns a "malloc error" it must be exactly the same + * return value as used by all other functions to indicate "malloc error". + * There must be no functions which indicate two different errors via the + * same return code. + * + * Also, for compatibility reasons, no defined return codes are ever removed + * or reused for different #defines later. You can only add new #defines and + * return codes, but never remove or redefine existing ones. + */ +#define SIGROK_OK 0 /* No error */ +#define SIGROK_ERR -1 /* Generic/unspecified error */ +#define SIGROK_ERR_MALLOC -2 /* Malloc/calloc/realloc error */ +#define SIGROK_ERR_SAMPLERATE -3 /* Incorrect samplerate */ /* Handy little macros */ #define KHZ(n) (n * 1000) @@ -111,6 +127,8 @@ int filter_probes(int in_unitsize, int out_unitsize, int *probelist, char *data_in, uint64_t length_in, char **data_out, uint64_t *length_out); +char *sigrok_samplerate_string(uint64_t samplerate); + /*--- analyzer.c ------------------------------------------------------------*/ struct analyzer {