koliseo 0.4.9
Loading...
Searching...
No Matches
kls_gulp.h File Reference
#include "koliseo.h"
#include "ctype.h"

Go to the source code of this file.

Data Structures

struct  Kstr

Macros

#define KSTR(c_lit)
#define KSTR_NULL   kstr_new(NULL, 0)
#define Kstr_Fmt   "%.*s"
 Format macro for a Kstr.
#define Kstr_Arg(kstr)
 Format matching macro for a Kstr.
#define ONEGB_DEC_INT   1073741824
 Defines a one GB size as decimal integer representation.
#define GULP_MAX_FILE_SIZE   ONEGB_DEC_INT
 Defines max size allowed for a file passed to KLS_GULP_FILE().
#define Gulp_Res_Fmt   "%s"
 Format macro for a Gulp_Res.
#define Gulp_Res_Arg(gr)
 Format matching macro for a Gulp_Res.
#define KLS_GULP_FILE(kls, filepath)
#define KLS_GULP_FILE_KSTR(kls, filepath)

Typedefs

typedef struct Kstr Kstr
typedef enum Gulp_Res Gulp_Res
 Defines possible results for kls_gulp_file_sized().

Enumerations

enum  Gulp_Res {
  GULP_FILE_OK =0 , GULP_FILE_NOT_EXIST , GULP_FILE_TOO_LARGE , GULP_FILE_READ_ERROR ,
  GULP_FILE_CONTAINS_NULLCHAR , GULP_FILE_KLS_NULL , TOT_GULP_RES
}
 Defines possible results for kls_gulp_file_sized(). More...

Functions

Kstr kstr_new (const char *str, size_t len)
Kstr kstr_from_c_lit (const char *c_lit)
bool kstr_eq (Kstr left, Kstr right)
bool kstr_eq_ignorecase (Kstr left, Kstr right)
Kstr kstr_cut_l (Kstr *k, size_t n)
Kstr kstr_cut_r (Kstr *k, size_t n)
Kstr kstr_trim_left (Kstr kstr)
Kstr kstr_trim_right (Kstr kstr)
Kstr kstr_trim (Kstr kstr)
bool kstr_indexof (Kstr k, char c, int *idx)
Kstr kstr_token (Kstr *k, char delim)
bool kstr_try_token (Kstr *k, char delim, Kstr *part)
Kstr kstr_token_kstr (Kstr *k, Kstr delim)
const char * string_from_Gulp_Res (Gulp_Res g)
char * kls_gulp_file_sized (Koliseo *kls, const char *filepath, Gulp_Res *err, size_t max_size)
char * try_kls_gulp_file (Koliseo *kls, const char *filepath, size_t max_size)
Kstrkls_gulp_file_sized_to_kstr (Koliseo *kls, const char *filepath, Gulp_Res *err, size_t max_size, bool allow_nullchar)
Kstrtry_kls_gulp_file_to_kstr (Koliseo *kls, const char *filepath, size_t max_size, bool allow_nullchar)

Variables

const char * gulp_res_names [TOT_GULP_RES+1]
 String array for representations of Gulp_Res.

Macro Definition Documentation

◆ GULP_MAX_FILE_SIZE

#define GULP_MAX_FILE_SIZE   ONEGB_DEC_INT

Defines max size allowed for a file passed to KLS_GULP_FILE().

Use try_kls_gulp_file() if you want a different upper limit.

◆ Gulp_Res_Arg

#define Gulp_Res_Arg ( gr)
Value:
const char * string_from_Gulp_Res(Gulp_Res g)

Format matching macro for a Gulp_Res.

◆ Gulp_Res_Fmt

#define Gulp_Res_Fmt   "%s"

Format macro for a Gulp_Res.

◆ KLS_GULP_FILE

#define KLS_GULP_FILE ( kls,
filepath )
Value:
#define GULP_MAX_FILE_SIZE
Defines max size allowed for a file passed to KLS_GULP_FILE().
Definition kls_gulp.h:71
char * try_kls_gulp_file(Koliseo *kls, const char *filepath, size_t max_size)

◆ KLS_GULP_FILE_KSTR

#define KLS_GULP_FILE_KSTR ( kls,
filepath )
Value:
Kstr * try_kls_gulp_file_to_kstr(Koliseo *kls, const char *filepath, size_t max_size, bool allow_nullchar)

◆ KSTR

#define KSTR ( c_lit)
Value:
kstr_new(c_lit, sizeof(c_lit) - 1)
Kstr kstr_new(const char *str, size_t len)

◆ Kstr_Arg

#define Kstr_Arg ( kstr)
Value:
(int) (kstr.len), (kstr.data)

Format matching macro for a Kstr.

◆ Kstr_Fmt

#define Kstr_Fmt   "%.*s"

Format macro for a Kstr.

◆ KSTR_NULL

#define KSTR_NULL   kstr_new(NULL, 0)

◆ ONEGB_DEC_INT

#define ONEGB_DEC_INT   1073741824

Defines a one GB size as decimal integer representation.

See also
GULP_MAX_FILE_SIZE
GULP_FILE_TOO_LARGE
kls_gulp_file_sized()
KLS_GULP_FILE()

Typedef Documentation

◆ Gulp_Res

typedef enum Gulp_Res Gulp_Res

Defines possible results for kls_gulp_file_sized().

See also
kls_gulp_file_sized().

◆ Kstr

typedef struct Kstr Kstr

Enumeration Type Documentation

◆ Gulp_Res

enum Gulp_Res

Defines possible results for kls_gulp_file_sized().

See also
kls_gulp_file_sized().
Enumerator
GULP_FILE_OK 
GULP_FILE_NOT_EXIST 
GULP_FILE_TOO_LARGE 
GULP_FILE_READ_ERROR 
GULP_FILE_CONTAINS_NULLCHAR 
GULP_FILE_KLS_NULL 
TOT_GULP_RES 

Function Documentation

◆ kls_gulp_file_sized()

char * kls_gulp_file_sized ( Koliseo * kls,
const char * filepath,
Gulp_Res * err,
size_t max_size )

◆ kls_gulp_file_sized_to_kstr()

Kstr * kls_gulp_file_sized_to_kstr ( Koliseo * kls,
const char * filepath,
Gulp_Res * err,
size_t max_size,
bool allow_nullchar )

◆ kstr_cut_l()

Kstr kstr_cut_l ( Kstr * k,
size_t n )

◆ kstr_cut_r()

Kstr kstr_cut_r ( Kstr * k,
size_t n )

◆ kstr_eq()

bool kstr_eq ( Kstr left,
Kstr right )

◆ kstr_eq_ignorecase()

bool kstr_eq_ignorecase ( Kstr left,
Kstr right )

◆ kstr_from_c_lit()

Kstr kstr_from_c_lit ( const char * c_lit)

◆ kstr_indexof()

bool kstr_indexof ( Kstr k,
char c,
int * idx )

◆ kstr_new()

Kstr kstr_new ( const char * str,
size_t len )

◆ kstr_token()

Kstr kstr_token ( Kstr * k,
char delim )

◆ kstr_token_kstr()

Kstr kstr_token_kstr ( Kstr * k,
Kstr delim )

◆ kstr_trim()

Kstr kstr_trim ( Kstr kstr)

◆ kstr_trim_left()

Kstr kstr_trim_left ( Kstr kstr)

◆ kstr_trim_right()

Kstr kstr_trim_right ( Kstr kstr)

◆ kstr_try_token()

bool kstr_try_token ( Kstr * k,
char delim,
Kstr * part )

◆ string_from_Gulp_Res()

const char * string_from_Gulp_Res ( Gulp_Res g)

◆ try_kls_gulp_file()

char * try_kls_gulp_file ( Koliseo * kls,
const char * filepath,
size_t max_size )

◆ try_kls_gulp_file_to_kstr()

Kstr * try_kls_gulp_file_to_kstr ( Koliseo * kls,
const char * filepath,
size_t max_size,
bool allow_nullchar )

Variable Documentation

◆ gulp_res_names

const char* gulp_res_names[TOT_GULP_RES+1]
extern

String array for representations of Gulp_Res.

See also
string_from_Gulp_Res()