fiss

Friedel's Initialization and Service Supervision
Log | Files | Refs | LICENSE

util.h (1019B)


      1 #pragma once
      2 
      3 #include <stdio.h>
      4 
      5 #define LEN(arr) (sizeof(arr) / sizeof(*arr))
      6 
      7 #define streq(a, b) (!strcmp((a), (b)))
      8 
      9 #define print_errno(msg, ...) (fprint(1, "%s: " msg, current_prog(), ##__VA_ARGS__, strerror(errno)))
     10 #define print_error(msg, ...) (fprint(1, "%s: " msg, current_prog(), ##__VA_ARGS__))
     11 
     12 // void errprint(const char* format, ...);
     13 
     14 // extern const char* prog;    // has to be defined per program
     15 const char* current_prog(void);
     16 
     17 ssize_t      dgetline(int fd, char* line, size_t line_buffer);
     18 ssize_t      readstr(int fd, char* str);
     19 ssize_t      writestr(int fd, const char* str);
     20 unsigned int stat_mode(const char* format, ...);
     21 int          fork_dup_cd_exec(int dir, const char* path, int fd0, int fd1, int fd2);
     22 int          reclaim_console(void);
     23 void         sigblock_all(int unblock);
     24 long         parse_long(const char* str, const char* name);
     25 char*        progname(char* path);
     26 int          fd_set_flag(int fd, int flags);
     27 void         path_join(char* buffer, const char* component, ...);