nfs-ganesha 1.4
Defines | Functions

common_utils.c File Reference

#include "common_utils.h"
#include <strings.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>

Go to the source code of this file.

Defines

#define IS_HEXA(c)   ( (((c) >= '0') && ((c) <= '9')) || (((c) >= 'A') && ((c) <= 'F')) || (((c) >= 'a') && ((c) <= 'f')) )
#define HEXA2BYTE(c)

Functions

int s_read_int (char *str)
int s_read_octal (char *str)
int s_read_int64 (char *str, unsigned long long *out64)
int s_read_size (char *str, size_t *p_size)
int StrToBoolean (char *str)
int snprintmem (char *target, int tgt_size, caddr_t source, int mem_size)
int sscanmem (caddr_t target, int tgt_size, const char *str_source)
int find_space (char c)
int find_comma (char c)
int find_colon (char c)
int find_endLine (char c)
int find_slash (char c)

Define Documentation

#define HEXA2BYTE (   c)
Value:
((unsigned char)(((c) >= '0') && ((c) <= '9')?((c) - '0'):\
                        (((c) >= 'A') && ((c) <= 'F')?((c)-'A'+10) :\
                        (((c) >= 'a') && ((c) <= 'f')?((c)-'a'+10) : /*error :*/ 0 ))))

Definition at line 218 of file common_utils.c.

#define IS_HEXA (   c)    ( (((c) >= '0') && ((c) <= '9')) || (((c) >= 'A') && ((c) <= 'F')) || (((c) >= 'a') && ((c) <= 'f')) )

Definition at line 215 of file common_utils.c.


Function Documentation

int find_colon ( char  c)

find_colon : return TRUE is argument is ':'.

return TRUE is argument is ':'

Parameters:
ccharacter to test.
Returns:
TRUE is argument is ':'.

Definition at line 325 of file common_utils.c.

int find_comma ( char  c)

find_comma : return TRUE is argument is ','.

return TRUE is argument is ','

Parameters:
ccharacter to test.
Returns:
TRUE is argument is ','.

Definition at line 309 of file common_utils.c.

int find_endLine ( char  c)

find_endLine : return TRUE if character is a end of line.

return TRUE if character is a end of line.

Parameters:
ccharacter to test.
Returns:
TRUE if character is a end of line.

Definition at line 341 of file common_utils.c.

int find_slash ( char  c)

find_slash : return TRUE is argument is '/'.

return TRUE is argument is '/'

Parameters:
ccharacter to test.
Returns:
TRUE is argument is '/'.

Definition at line 357 of file common_utils.c.

int find_space ( char  c)

find_space : return TRUE is argument is a space character.

return TRUE is argument is a space character.

Parameters:
ccharacter to test.
Returns:
TRUE is argument is a space character.

Definition at line 293 of file common_utils.c.

int s_read_int ( char *  str)

Common tools for printing, parsing, .... This function converts a string to an integer.

Parameters:
str(in char *) The string to be converted.
Returns:
A negative value on error. Else, the converted integer.

Definition at line 29 of file common_utils.c.

int s_read_int64 ( char *  str,
unsigned long long *  out64 
)

This function converts a string to an integer.

Parameters:
str(in char *) The string to be converted.
Returns:
A non null value on error. Else, 0.

Definition at line 95 of file common_utils.c.

int s_read_octal ( char *  str)

This function converts an octal to an integer.

Parameters:
str(in char *) The string to be converted.
Returns:
A negative value on error. Else, the converted integer.

Definition at line 62 of file common_utils.c.

int s_read_size ( char *  str,
size_t *  p_size 
)

Definition at line 124 of file common_utils.c.

int snprintmem ( char *  target,
int  tgt_size,
caddr_t  source,
int  mem_size 
)

snprintmem: Print the content of a handle, a cookie,... to an hexa string.

Parameters:
target(output): The target buffer where memory is to be printed in ASCII.
tgt_size(input): Size (in bytes) of the target buffer.
source(input): The buffer to be printed.
mem_size(input): Size of the buffer to be printed.
Returns:
The number of bytes written in the target buffer.

Definition at line 187 of file common_utils.c.

int sscanmem ( caddr_t  target,
int  tgt_size,
const char *  str_source 
)

snscanmem: Read the content of a string and convert it to a handle, a cookie,...

Parameters:
target(output): The target address where memory is to be written.
tgt_size(input): Size (in bytes) of the target memory buffer.
str_source(input): A hexadecimal string that represents the data to be stored into memory.
Returns:
- The number of bytes read in the source string.
  • -1 on error.

Definition at line 237 of file common_utils.c.

int StrToBoolean ( char *  str)

string to boolean convertion.

Returns:
1 for TRUE, 0 for FALSE, -1 on error

Definition at line 157 of file common_utils.c.