LibInsane 1.0.10
Cross-platform Cross-API Cross-driver Cross-image-scanner Image Scan Library
Loading...
Searching...
No Matches
util.h File Reference
#include "capi.h"
#include "error.h"
Include dependency graph for util.h:

Go to the source code of this file.

Macros

#define LIS_UNUSED(x)
 
#define LIS_COUNT_OF(x)
 
#define FREE(x)
 
#define MIN(x, y)
 
#define MAX(x, y)
 

Functions

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.
 
void lis_free (const enum lis_value_type type, union lis_value *value)
 Free a copied value.
 
enum lis_error lis_set_option (struct lis_item *item, const char *opt_name, const char *opt_value)
 helper to set quickly an option
 
int lis_compare (enum lis_value_type type, union lis_value val1, union lis_value val2)
 compare values
 
union lis_value lis_add (enum lis_value_type type, union lis_value a, union lis_value b)
 
union lis_value lis_sub (enum lis_value_type type, union lis_value a, union lis_value b)
 
int lis_getenv (const char *var, int default_val)
 return the value of an environment variable.
 
const char * lis_get_version (void)
 return Libinsane version.
 
void lis_hexdump (const char *prefix, const void *data, size_t nb_bytes)
 

Macro Definition Documentation

◆ FREE

#define FREE ( x)
Value:
do { \
free(((void*)(x))); \
(x) = NULL; \
} while(0);

Definition at line 16 of file util.h.

◆ LIS_COUNT_OF

#define LIS_COUNT_OF ( x)
Value:
(sizeof(x) / sizeof((x)[0]))

Definition at line 13 of file util.h.

◆ LIS_UNUSED

#define LIS_UNUSED ( x)
Value:
(void)(x)

Definition at line 12 of file util.h.

◆ MAX

#define MAX ( x,
y )
Value:
((x) > (y) ? (x) : (y))

Definition at line 26 of file util.h.

◆ MIN

#define MIN ( x,
y )
Value:
((x) < (y) ? (x) : (y))

Definition at line 23 of file util.h.

Function Documentation

◆ lis_add()

union lis_value lis_add ( enum lis_value_type type,
union lis_value a,
union lis_value b )

◆ lis_compare()

int lis_compare ( enum lis_value_type type,
union lis_value val1,
union lis_value val2 )

compare values

Return values
1if values are identical
0if values are different

◆ 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.

Parameters
[in]typedefine the value type.
[in]originalvalue to copy.
[out]copyduplicated value.

◆ lis_free()

void lis_free ( const enum lis_value_type type,
union lis_value * value )

Free a copied value.

Parameters
[in]typedefine a the value type.
[in]valuevalue to free. Do not use it after calling this function.

◆ lis_get_version()

const char * lis_get_version ( void )

return Libinsane version.

Returns
never NULL

◆ lis_getenv()

int lis_getenv ( const char * var,
int default_val )

return the value of an environment variable.

Parameters
[in]varenv variable name
[in]default_valdefault value if the variable is not set

◆ lis_hexdump()

void lis_hexdump ( const char * prefix,
const void * data,
size_t nb_bytes )

◆ 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_sub()

union lis_value lis_sub ( enum lis_value_type type,
union lis_value a,
union lis_value b )