LibInsane: /build/libinsane/src/libinsane/subprojects/libinsane/include/libinsane/util.h Source File

| LibInsane 1.0.10 Cross-platform Cross-API Cross-driver Cross-image-scanner Image Scan Library

Loading...
Searching...
No Matches
util.h
Go to the documentation of this file.
1#ifndef __LIBINSANE_UTIL_H
2#define __LIBINSANE_UTIL_H
3
4#include "capi.h"
5#include "error.h"
6
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#define LIS_UNUSED(x) (void)(x)
13#define LIS_COUNT_OF(x) (sizeof(x) / sizeof((x)[0]))
14
15#ifndef FREE
16#define FREE(x) do { \
17 free(((void*)(x))); \
18 (x) = NULL; \
19 } while(0);
20#endif
21
22#ifndef MIN
23#define MIN(x, y) ((x) < (y) ? (x) : (y))
24#endif
25#ifndef MAX
26#define MAX(x, y) ((x) > (y) ? (x) : (y))
27#endif
28
36 enum lis_error lis_copy(
37 const enum lis_value_type type, const union lis_value *original, union lis_value *copy
38);
39
40
46 void lis_free(const enum lis_value_type type, union lis_value *value);
47
48
52 enum lis_error lis_set_option(struct lis_item *item, const char *opt_name, const char *opt_value);
53
54
60 int lis_compare(enum lis_value_type type, union lis_value val1, union lis_value val2);
61
62
63 union lis_value lis_add(enum lis_value_type type, union lis_value a, union lis_value b);
64 union lis_value lis_sub(enum lis_value_type type, union lis_value a, union lis_value b);
65
71 int lis_getenv(const char *var, int default_val);
72
73
78 const char *lis_get_version(void);
79
80
81 void lis_hexdump(const char *prefix, const void *data, size_t nb_bytes);
82
83#ifdef __cplusplus
84}
85#endif
86
87#endif
capi.h
lis_value_type
lis_value_type
Variable type.
Definition capi.h:32
error.h
lis_error
lis_error
Definition error.h:13
lis_item
Definition capi.h:355
lis_value
Variable.
Definition capi.h:94
lis_compare
int lis_compare(enum lis_value_type type, union lis_value val1, union lis_value val2)
compare values
lis_set_option
enum lis_error lis_set_option(struct lis_item *item, const char *opt_name, const char *opt_value)
helper to set quickly an option
lis_add
union lis_value lis_add(enum lis_value_type type, union lis_value a, union lis_value b)
lis_get_version
const char * lis_get_version(void)
return Libinsane version.
lis_hexdump
void lis_hexdump(const char *prefix, const void *data, size_t nb_bytes)
lis_copy
enum lis_error lis_copy(const enum lis_value_type type, const union lis_value *original, union lis_value *copy)
Copy a value. You must free the copy once you're done with it.
lis_free
void lis_free(const enum lis_value_type type, union lis_value *value)
Free a copied value.
lis_getenv
int lis_getenv(const char *var, int default_val)
return the value of an environment variable.
lis_sub
union lis_value lis_sub(enum lis_value_type type, union lis_value a, union lis_value b)