libexpress 0.0.1
Express Server Framework in C
Loading...
Searching...
No Matches
Macros | Functions
util.h File Reference

This contains all the utilities used through the library. More...

#include <libcol/col.h>

Go to the source code of this file.

Macros

#define success(msg)   print_info(msg, GREEN, false, false, NULL, 0);
 Macros to print success, warning and error in colors and bold as well exit the process if required.
 
#define warning(msg)   print_info(msg, YELLOW, false, true, __FILE__, __LINE__);
 
#define error(msg)   print_info(msg, RED, true, true, __FILE__, __LINE__);
 

Functions

void print_info (const char *msg, color_t color, bool exit_process, bool print_line, const char *file, int line)
 An internal function used by error, warning and success to print the messages, along with necessary elements like line number or file name and even the option to exit out of the process with an exit(1) More...
 
char * tokenize (char *s, char c)
 This splits the string s at the first occurence of character c in s. More...
 

Detailed Description

This contains all the utilities used through the library.

Author
Saurav Pal (resyfer)
Bug:
No known bugs

Function Documentation

◆ print_info()

void print_info ( const char *  msg,
color_t  color,
bool  exit_process,
bool  print_line,
const char *  file,
int  line 
)

An internal function used by error, warning and success to print the messages, along with necessary elements like line number or file name and even the option to exit out of the process with an exit(1)

Please don't use this outside of util.c

◆ tokenize()

char * tokenize ( char *  s,
char  c 
)

This splits the string s at the first occurence of character c in s.

Then s becomes the original string till that character, while the returned value points to the string that was split from it. It can be used like this:

char s[] = "hello world foo bye";

char *k = tokenize(s, ' ');

now s is "hello" while k is "world foo bye"

Parameters
s
c
Returns
char*