yigtuyumz / utils

C utilities

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Utilites for C

libutils is a dynamic C library of the functions which i am using mostly.

Folder Structure

  • ./include/

    Contains header file(s).

     /* utils.h */
    
     /* if _UTILS_MACRO */
     #define    ABS(X)           ((X) < 0x00 ? ((X) = (-X)) : ((X) = (X)))
     #define    CLEARBIT(X, N)   ((X) = ((X) & (~(0x01 << (N)))))
     #define    GETBIT(X, N)     (((X) >> (N)) & 0x01)
     #define    SETBIT(X, N)     ((X) = ((X) | (0x01 << (N))))
     #define    TOGGLEBIT(X, N)  ((X) = ((X) ^ (0x01 << (N))))
     /* endif _UTILS_MACRO */
    
     int
     utils_atoi(const char *nbr);
    
     void
     utils_bzero(void *s, size_t n);
    
     double
     utils_floor(double x);
    
     int
     utils_isprime(unsigned int nb);
    
     int
     utils_isspace(int c);
    
     int
     utils_isxdigit(int c);
    
     char *
     utils_itoa(int nb);
    
     void *
     utils_memcpy(void *dest, const void *src, size_t n);
    
     void *
     utils_memset(void *dest, int c, size_t n);
    
     void
     utils_putchar(int fd, char c);
    
     void
     utils_putnbr(int fd, int nb);
    
     void
     utils_putstr(int fd, const char *str);
    
     char *
     utils_strcat(char *dest, const char *src);
    
     char *
     utils_strchr(const char *str, int val);
    
     int
     utils_strcmp(const char *a, const char *b);
    
     char *
     utils_strcpy(char * restrict dest, const char * restrict src);
    
     char *
     utils_strdup(const char *str);
    
     size_t
     utils_strlen(const char *str);
    
     char *
     utils_strncat(char *dest, const char *src, size_t n);
    
     int 
     utils_strncmp(const char *a, const char *b, size_t n);
    
     char *
     utils_strncpy(char * restrict dest, const char * restrict src, size_t n);
    
     char *
     utils_strndup(const char *str, size_t len);
    
     size_t
     utils_strnlen(const char *str, size_t n);
    
     char *
     utils_strnstr(const char *haystack, const char *needle, size_t n);
    
     char *
     utils_strrchr(const char *str, int val);
    
     char *
     utils_strstr(const char *haystack, const char *needle);
    
     void
     utils_swapn(void *a, void *b, size_t n);
    
     void
     utils_vaput(int fd, char *fmt, ...);
     /* end of utils.h */
     # include libutils.so file to the project
     FLAGS = -L/path/to/so/file -llibnamewithoutextension -Wl,-rpath=/path/to/so/file
  • ./tests/

    Test environment. Contains files related to test cases.

  • ./src/

    Contains source files named same as the function name.

TODO's

  • Improve infrastructure of autotools build system. (consider re-write configure.ac and Makefile.am files)
  • Create an extra header file for macros and constants (?)

Tools

See Also

About

C utilities


Languages

Language:C 78.3%Language:Makefile 17.1%Language:M4 2.6%Language:Shell 2.1%