NetSurf
Macros | Functions
utils.h File Reference

Interface to a number of general purpose functionality. More...

#include <stdbool.h>
Include dependency graph for utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define NOF_ELEMENTS(array)   (sizeof(array)/sizeof(*(array)))
 
#define ABS(x)   (((x)>0)?(x):(-(x)))
 
#define min(x, y)   (((x)<(y))?(x):(y))
 
#define max(x, y)   (((x)>(y))?(x):(y))
 
#define clamp(x, low, high)   (min(max((x),(low)),(high)))
 
#define nsmkdir(dir, mode)   mkdir((dir), (mode))
 POSIX mkdir function. More...
 
#define FLEX_ARRAY_LEN_DECL
 
#define SLEN(x)   (sizeof((x)) - 1)
 Calculate length of constant C string. More...
 
#define fallthrough   do {} while(0)
 switch fall through More...
 

Functions

bool is_dir (const char *path)
 Check if a directory exists. More...
 

Detailed Description

Interface to a number of general purpose functionality.

Todo:
Many of these functions and macros should have their own headers.

Definition in file utils.h.

Macro Definition Documentation

◆ ABS

#define ABS (   x)    (((x)>0)?(x):(-(x)))

Definition at line 36 of file utils.h.

◆ clamp

#define clamp (   x,
  low,
  high 
)    (min(max((x),(low)),(high)))

Definition at line 54 of file utils.h.

◆ fallthrough

#define fallthrough   do {} while(0)

switch fall through

Definition at line 119 of file utils.h.

◆ FLEX_ARRAY_LEN_DECL

#define FLEX_ARRAY_LEN_DECL

Definition at line 70 of file utils.h.

◆ max

#define max (   x,
 
)    (((x)>(y))?(x):(y))

Definition at line 50 of file utils.h.

◆ min

#define min (   x,
 
)    (((x)<(y))?(x):(y))

Definition at line 46 of file utils.h.

◆ NOF_ELEMENTS

#define NOF_ELEMENTS (   array)    (sizeof(array)/sizeof(*(array)))

Definition at line 32 of file utils.h.

◆ nsmkdir

#define nsmkdir (   dir,
  mode 
)    mkdir((dir), (mode))

POSIX mkdir function.

Definition at line 64 of file utils.h.

◆ SLEN

#define SLEN (   x)    (sizeof((x)) - 1)

Calculate length of constant C string.

Parameters
xa constant C string.
Returns
The length of C string without its terminator.

Definition at line 88 of file utils.h.

Function Documentation

◆ is_dir()

bool is_dir ( const char *  path)

Check if a directory exists.

Definition at line 94 of file utils.c.

References path().

Referenced by filename_create_directory(), handle_filesystem_select_button(), menu_save_page(), ro_gui_choose_language(), and ro_gui_default_language().

Here is the call graph for this function:
Here is the caller graph for this function: