]> git.mdlowis.com Git - proto/aos.git/commitdiff
move standard library functions to helper header so i can work toward their removal
authorMichael D. Lowis <mike.lowis@gentex.com>
Tue, 1 Nov 2022 18:39:05 +0000 (14:39 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Tue, 1 Nov 2022 18:39:05 +0000 (14:39 -0400)
28 files changed:
bin/dial.c
bin/init.c
bin/listen.c
bin/screenlock.c
bin/shell.c
inc/liba.h
inc/std.h [new file with mode: 0644]
lib/a/Net.c
lib/a/Options.c
lib/a/UTF8.c
lib/a/defaults/options.c
lib/a/defaults/set_option.c
lib/a/gc.c
lib/a/stdlib/ecalloc.c
lib/a/stdlib/efopen.c
lib/a/stdlib/efreadline.c
lib/a/stdlib/emalloc.c
lib/a/stdlib/eraise.c
lib/a/stdlib/erealloc.c
lib/a/stdlib/esignal.c
lib/a/stdlib/estrdup.c
lib/a/stdlib/fatal.c
lib/a/stdlib/forkexec.c
lib/a/stdlib/smprintf.c
lib/a/stdlib/strmcat.c
lib/a/stdlib/warn.c
lib/ui/font_load.c
lib/ui/window_create.c

index 507241b6d95069804708a0b69cb6897d72dc4f94..27baa443490bdc7535ff2bd7054fc42ab2e4f713 100644 (file)
@@ -1,3 +1,4 @@
+#include <std.h>
 #include <liba.h>
 #include <sys/poll.h>
 
index 0e276ef549125c2efb4904bdc5e2868991863627..50925743365217a24add23f31e105ea3167102f8 100644 (file)
@@ -1,4 +1,4 @@
-#define _XOPEN_SOURCE 700
+#include <std.h>
 #include <liba.h>
 #include <sys/wait.h>
 
index d20587570a6b7af509a2894b4be3fdec9d936797..7525543b89ecac1fd57398473a84bdeceb700722 100644 (file)
@@ -1,10 +1,11 @@
+#include <std.h>
 #include <liba.h>
 #include <sys/types.h>
 
 char* Usage = "listen DIALSTR CMD [ARG...]";
 char** Command = NULL;
 
-void OnNewClient(int cfd)
+void OnNewClient(Int cfd)
 {
     int pid = fork();
     if (pid < 0)
index 6b66458ecd88b01b2e967016107b58dc5c856fa9..3fea960ecbf6965b2657bb9147fda62e86faf219 100644 (file)
@@ -1,3 +1,4 @@
+#include <std.h>
 #include <liba.h>
 #include <libui.h>
 
index 52fe958f0c24f592d8ef278eceee8bb08453b8f8..5b467f48d1d51c83ee534ab193e2ccd240eb67f9 100644 (file)
@@ -1,3 +1,4 @@
+#include <std.h>
 #include <liba.h>
 #include <sys/wait.h>
 #include <sys/types.h>
index 6e5a038923bf3a9f71b73028786ff43ade8de62e..ec96541ef971bd993ee505d07b82d2cfcd79e565 100644 (file)
@@ -1,22 +1,31 @@
-/* Standard Macros and Types */
-#include <stddef.h>
-#define _XOPEN_SOURCE 700
-
-#include <stdint.h>
-#include <stdbool.h>
-#include <errno.h>
-#include <limits.h>
 #include <assert.h>
-
-/* Useful Standard Functions */
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
 #include <stdarg.h>
-#include <string.h>
+#include <errno.h>
 
-/* we're only targeting unixes */
-#include <unistd.h>
+typedef unsigned char Byte;
+typedef long Int;
+typedef unsigned long Uint;
+typedef double Real;
+typedef Int Rune;
+typedef _Bool Bool;
+
+#ifndef true
+#define true  ((Bool)1)
+#endif
+
+#ifndef false
+#define false ((Bool)0)
+#endif
+
+#ifndef NULL
+#define NULL  ((void*)0)
+#endif
+
+#ifndef EOF
+#define EOF   ((Int)-1)
+#endif
+
+void exit(int status);
 
 /* Miscellaneous Macros
  ******************************************************************************/
 
 #ifndef container_of
     #define container_of(obj, type, member) \
-        (type*)((uintptr_t)obj - offsetof(type, member))
+        (type*)((uIntptr_t)obj - offsetof(type, member))
 #endif
 
 /*
     Garbage Collector Interface
 */
-void* GC_Allocate(size_t sz);
+void* GC_Allocate(Int sz);
 void GC_AddRef(void* p);
 void GC_DelRef(void* p);
 
@@ -44,37 +53,20 @@ typedef struct {
     char* l;
     char* d;
     char s;
-    unsigned int a : 1;
+    Uint a : 1;
 } Option_T;
 
-int Options_Parse(int argc, char** argv);
+Int Options_Parse(Int argc, char** argv);
 void Options_PrintHelp(void);
 
-/*
-    Standard Library Helpers
-*/
-void fatal(const char* fmt, ...);
-void warn(const char* fmt, ...);
-void esignal(int sig, void (*func)(int));
-int eraise(int sig);
-void* ecalloc(size_t num, size_t size);
-void* emalloc(size_t size);
-void* erealloc(void* ptr, size_t size);
-char* smprintf(const char* fmt, ...);
-FILE* efopen(const char* filename, const char* mode);
-char* efreadline(FILE* input);
-char* estrdup(const char *s);
-int forkexec(char** cmd);
-char* strmcat(char* first, ...);
-
 /*
     Networking
 */
-int Net_Announce(char* dialstr);
-int Net_Listen(int fd, int backlog);
-int Net_Accept(int fd);
-int Net_Dial(char* dialstr);
-void Net_Serve(char* dialstr, void (*on_client)(int cfd));
+Int Net_Announce(char* dialstr);
+Int Net_Listen(Int fd, Int backlog);
+Int Net_Accept(Int fd);
+Int Net_Dial(char* dialstr);
+void Net_Serve(char* dialstr, void (*on_client)(Int cfd));
 
 /*
     UTF8 Encoding and Decoding
@@ -85,10 +77,8 @@ void Net_Serve(char* dialstr, void (*on_client)(int cfd));
 #define RUNE_MAX  ((Rune)0x10FFFF)
 #define RUNE_EOF  ((Rune)EOF)
 
-typedef uint32_t Rune;
-
-size_t UTF8_Encode(char str[UTF_MAX], Rune rune);
-bool UTF8_Decode(Rune* rune, size_t* length, int byte);
+Int UTF8_Encode(Byte str[UTF_MAX], Rune rune);
+Bool UTF8_Decode(Rune* rune, Int* length, Int byte);
 
 /*
     Basic Runtime Facilities
@@ -98,7 +88,7 @@ bool UTF8_Decode(Rune* rune, size_t* length, int byte);
 #define main usermain
 
 extern int usermain(int argc, char** argv);
-extern void set_option(int sname, char* lname, char* arg);
+extern void set_option(Int sname, char* lname, char* arg);
 
 extern char* ARGV0;
 extern char* Usage;
diff --git a/inc/std.h b/inc/std.h
new file mode 100644 (file)
index 0000000..7f9c1ef
--- /dev/null
+++ b/inc/std.h
@@ -0,0 +1,29 @@
+#define _XOPEN_SOURCE 700
+
+/* Standard Macros and Types */
+#include <stddef.h>
+#include <assert.h>
+
+/* Useful Standard Functions */
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+
+/* we're only targeting unixes */
+#include <unistd.h>
+
+void fatal(const char* fmt, ...);
+void warn(const char* fmt, ...);
+void esignal(int sig, void (*func)(int));
+int eraise(int sig);
+void* ecalloc(int num, int size);
+void* emalloc(int size);
+void* erealloc(void* ptr, int size);
+char* smprintf(const char* fmt, ...);
+FILE* efopen(const char* filename, const char* mode);
+char* efreadline(FILE* input);
+char* estrdup(const char *s);
+int forkexec(char** cmd);
+char* strmcat(char* first, ...);
index 0eea143ba79fe8d3138ebefac72a6374f26ae14a..922e9a514a5c0b8de69602fbd4d8b78e86af4bc0 100644 (file)
@@ -1,3 +1,4 @@
+#include <std.h>
 #include <liba.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -13,7 +14,7 @@ typedef struct {
 } conn_t;
 
 struct socket_t {
-    int fd;
+    Int fd;
     union {
         struct sockaddr_in in;
         struct sockaddr_un un;
@@ -38,7 +39,7 @@ struct in_addr ResolveAddress(char *hostname)
     return addr;
 }
 
-int MakeSocket(char* dialstr, struct socket_t* sock)
+Int MakeSocket(char* dialstr, struct socket_t* sock)
 {
     size_t i;
     /* make a local copy of dial string */
@@ -63,7 +64,7 @@ int MakeSocket(char* dialstr, struct socket_t* sock)
         sock->addr.in.sin_port = htons(strtol(conn.service, NULL, 0));
         sock->addr.in.sin_addr = ResolveAddress(conn.address);
         sock->fd = socket(AF_INET, SOCK_STREAM, 0);
-        setsockopt(sock->fd, SOL_SOCKET, SO_REUSEADDR, &(int){1}, sizeof(int));
+        setsockopt(sock->fd, SOL_SOCKET, SO_REUSEADDR, &(Int){1}, sizeof(Int));
     }
     else if (!strcmp("udp", conn.network))
     {
@@ -71,7 +72,7 @@ int MakeSocket(char* dialstr, struct socket_t* sock)
         sock->addr.in.sin_port = htons(strtol(conn.service, NULL, 0));
         sock->addr.in.sin_addr = ResolveAddress(conn.address);
         sock->fd = socket(AF_INET, SOCK_DGRAM, 0);
-        setsockopt(sock->fd, SOL_SOCKET, SO_REUSEADDR, &(int){1}, sizeof(int));
+        setsockopt(sock->fd, SOL_SOCKET, SO_REUSEADDR, &(Int){1}, sizeof(Int));
     }
     else if (!strcmp("unix", conn.network))
     {
@@ -86,12 +87,12 @@ int MakeSocket(char* dialstr, struct socket_t* sock)
     return sock->fd;
 }
 
-int Net_Announce(char* dialstr)
+Int Net_Announce(char* dialstr)
 {
     struct socket_t sock = { .fd = -1 };
     if (MakeSocket(dialstr, &sock))
     {
-        int rv = -1;
+        Int rv = -1;
         switch (sock.addr.in.sin_family)
         {
             case AF_INET:
@@ -118,19 +119,19 @@ int Net_Announce(char* dialstr)
     return sock.fd;
 }
 
-int Net_Listen(int fd, int backlog)
+Int Net_Listen(Int fd, Int backlog)
 {
     return listen(fd, backlog);
 }
 
-int Net_Accept(int fd)
+Int Net_Accept(Int fd)
 {
     return accept(fd, 0, 0);
 }
 
-int Net_Dial(char* dialstr)
+Int Net_Dial(char* dialstr)
 {
-    int rv = -1;
+    Int rv = -1;
     struct socket_t sock = { .fd = -1 };
     if (MakeSocket(dialstr, &sock))
     {
@@ -148,14 +149,14 @@ int Net_Dial(char* dialstr)
     return (rv == 0 ? sock.fd : rv);
 }
 
-void Net_Serve(char* dialstr, void (*on_client)(int cfd))
+void Net_Serve(char* dialstr, void (*on_client)(Int cfd))
 {
-    int sfd = Net_Announce(dialstr);
+    Int sfd = Net_Announce(dialstr);
     if (sfd >= 0)
     {
         while (!Net_Listen(sfd, 5))
         {
-            int cfd;
+            Int cfd;
             if ((cfd = Net_Accept(sfd)) >= 0)
             {
                 on_client(cfd);
index 72c4cf15da911ab614fbb60b7e5899680b7204f5..5a54aacedd0a6391ce64821e3b6dcc763a6f4cbe 100644 (file)
@@ -1,6 +1,7 @@
+#include <std.h>
 #include <liba.h>
 
-static void HandleOption(int s, char* l, char* arg)
+static void HandleOption(Int s, char* l, char* arg)
 {
     if (s == 'h')
     {
@@ -17,9 +18,9 @@ static Option_T* LookupOption(char* flag)
 {
     Option_T* opt = NULL;
 
-    for (int i = 0; Options[i].s || Options[i].l; i++)
+    for (Int i = 0; Options[i].s || Options[i].l; i++)
     {
-        int match = (
+        Int match = (
                (flag[1]  && !strcmp(Options[i].l, flag))
             || (!flag[1] && flag[0] == Options[i].s)
         );
@@ -33,7 +34,7 @@ static Option_T* LookupOption(char* flag)
     return opt;
 }
 
-static inline void ParseLongOption(int* currp, char** argv)
+static inline void ParseLongOption(Int* currp, char** argv)
 {
     /* get the option and the arg if there is one */
     char* flag = argv[*currp] + 2;
@@ -77,7 +78,7 @@ static inline void ParseLongOption(int* currp, char** argv)
     *currp += 1;
 }
 
-static inline void ParseShortOption(int* currp, char** argv)
+static inline void ParseShortOption(Int* currp, char** argv)
 {
     char* argstr = argv[*currp]+1;
     char flag[] = "\0\0";
@@ -123,13 +124,13 @@ static inline void ParseShortOption(int* currp, char** argv)
     *currp += 1;
 }
 
-int Options_Parse(int argc, char** argv)
+Int Options_Parse(Int argc, char** argv)
 {
     /* Record the program name */
     ARGV0 = argv[0];
 
-    int new_argc = 0;
-    int curr_arg = 1;
+    Int new_argc = 0;
+    Int curr_arg = 1;
     /* now parse the arguments */
     for (; curr_arg < argc;)
     {
@@ -168,10 +169,10 @@ int Options_Parse(int argc, char** argv)
 void Options_PrintHelp(void)
 {
     /* calculate padding */
-    size_t padding = 0;
-    for (int i = 0; Options[i].s || Options[i].l; i++)
+    Int padding = 0;
+    for (Int i = 0; Options[i].s || Options[i].l; i++)
     {
-        size_t pad = 4;
+        Int pad = 4;
         if (Options[i].s)
         {
             pad += 2;
@@ -195,8 +196,8 @@ void Options_PrintHelp(void)
         printf("usage: %s\n\n", Usage);
     }
 
-    /* print option help messages */
-    for (int i = 0; Options[i].s || Options[i].l; i++)
+    /* prInt option help messages */
+    for (Int i = 0; Options[i].s || Options[i].l; i++)
     {
         int remain = padding;
         if (Options[i].s)
index 5a39bb89c0e28c66d903694b536acec75fe4fdc4..428c0c98bbb2b78024105587e76b9f6624a0a337 100644 (file)
@@ -1,17 +1,17 @@
 #include <liba.h>
 
-static const uint8_t UTF8_SeqBits[] = { 0x00u, 0x80u, 0xC0u, 0xE0u, 0xF0u, 0xF8u, 0xFCu, 0xFEu };
-static const uint8_t UTF8_SeqMask[] = { 0x00u, 0xFFu, 0x1Fu, 0x0Fu, 0x07u, 0x03u, 0x01u, 0x00u };
-static const uint8_t UTF8_SeqLens[] = { 0x01u, 0x00u, 0x02u, 0x03u, 0x04u, 0x05u, 0x06u, 0x00u };
+static const Byte UTF8_SeqBits[] = { 0x00u, 0x80u, 0xC0u, 0xE0u, 0xF0u, 0xF8u, 0xFCu, 0xFEu };
+static const Byte UTF8_SeqMask[] = { 0x00u, 0xFFu, 0x1Fu, 0x0Fu, 0x07u, 0x03u, 0x01u, 0x00u };
+static const Byte UTF8_SeqLens[] = { 0x01u, 0x00u, 0x02u, 0x03u, 0x04u, 0x05u, 0x06u, 0x00u };
 
-static bool runevalid(Rune val) {
+static Bool runevalid(Rune val) {
     return (val <= RUNE_MAX)
         && ((val & 0xFFFEu) != 0xFFFEu)
         && ((val < 0xD800u) || (val > 0xDFFFu))
         && ((val < 0xFDD0u) || (val > 0xFDEFu));
 }
 
-static size_t runelen(Rune rune) {
+static Int runelen(Rune rune) {
     if(!runevalid(rune))
         return 0;
     else if(rune <= 0x7F)
@@ -24,26 +24,26 @@ static size_t runelen(Rune rune) {
         return 4;
 }
 
-static uint8_t utfseq(uint8_t byte) {
-    for (int i = 1; i < 8; i++)
+static Byte utfseq(Byte byte) {
+    for (Int i = 1; i < 8; i++)
         if ((byte & UTF8_SeqBits[i]) == UTF8_SeqBits[i-1])
             return UTF8_SeqLens[i-1];
     return 0;
 }
 
-size_t UTF8_Encode(char str[UTF_MAX], Rune rune)
+Int UTF8_Encode(Byte str[UTF_MAX], Rune rune)
 {
-    size_t len = runelen(rune);
+    Int len = runelen(rune);
     str[0] = (len == 1 ? 0x00 : UTF8_SeqBits[len])
            | (UTF8_SeqMask[len] & (rune >> (6 * (len-1))));
-    for (size_t i = 1; i < len; i++)
+    for (Int i = 1; i < len; i++)
     {
         str[i] = 0x80u | (0x3Fu & (rune >> (6 * (len-i-1))));
     }
     return len;
 }
 
-bool UTF8_Decode(Rune* rune, size_t* length, int byte)
+Bool UTF8_Decode(Rune* rune, Int* length, Int byte)
 {
     /* Handle the start of a new rune */
     if (*length == 0)
index 03c70f0f1e80725d73d98c24221d23b498a99100..359b4877dd83f218a8484a8c281874be7df8885a 100644 (file)
@@ -1,6 +1,6 @@
 #include <liba.h>
 
 Option_T Options[] = {
-    { .s = 'h', .l = "help", .a = 0, .d = "print this help message" },
+    { .s = 'h', .l = "help", .a = 0, .d = "prInt this help message" },
     {0}
 };
\ No newline at end of file
index 7d7df2f547a6567ac62f13b4b84d1113f631d6b3..3cc16ecd5902ff1e39d1a8ef5e93657049be0131 100644 (file)
@@ -1,6 +1,6 @@
 #include <liba.h>
 
-void set_option(int sname, char* lname, char* arg)
+void set_option(Int sname, char* lname, char* arg)
 {
     (void)sname;
     (void)lname;
index 7ca71dae6a49dc1e07da370a10fdba4f91041f14..2406e2a4463f3113f47cea44e266e7092ee05ebf 100644 (file)
@@ -7,6 +7,8 @@
 /* the real main lives here */
 #undef main
 
+#include <std.h>
+
 /* TODO:
     * Process all increments *then* all decrements
 */
@@ -14,7 +16,7 @@
 #define THOLD      0.65
 #define DELETED    ((void*)(intptr_t)-1)
 #define LOG_SIZE   1023u
-#define NUM_PRIMES (sizeof(Primes)/sizeof(unsigned int))
+#define NUM_PRIMES (sizeof(Primes)/sizeof(unsigned Int))
 
 enum {
     INCREMENT = 0,
@@ -34,24 +36,24 @@ typedef struct {
 static void obj_addref(object_t* obj);
 static void obj_delref(object_t* obj);
 static void gc_collect(void);
-static void log_add(object_t* obj, int op);
+static void log_add(object_t* obj, Int op);
 
 typedef struct {
-    size_t size;
-    size_t nslots;
-    size_t thold;
+    Int size;
+    Int nslots;
+    Int thold;
     void** slots;
 } hash_t;
 
-static void hash_init(hash_t* hash, int nslots);
+static void hash_init(hash_t* hash, Int nslots);
 static void hash_grow(hash_t* hash);
 static void hash_add(hash_t* hash, void* entry);
-static int hash_del(hash_t* hash, void* entry);
+static Int hash_del(hash_t* hash, void* entry);
 
 static intptr_t* Stack_Bot = 0;
 static buffer_t Log = {0};
 static hash_t ZCT;
-static unsigned int Primes[] = {
+static Int Primes[] = {
     1543, 3079, 6151, 12289, 24593,
     49157, 98317, 196613, 393241, 786433, 1572869, 3145739, 6291469,
     12582917, 25165843, 50331653, 100663319, 201326611, 402653189,
@@ -60,7 +62,7 @@ static unsigned int Primes[] = {
 
 /* Public Routines
  ***************************************/
-void* GC_Allocate(size_t sz)
+void* GC_Allocate(Int sz)
 {
     sz = (sz / sizeof(intptr_t)) + ((sz % sizeof(intptr_t)) ? 1 : 0);
     object_t* obj = ecalloc(1, sizeof(object_t) + sz);
@@ -167,9 +169,9 @@ static void gc_collect(void)
     gc_scan_globals(&oldzct);
 
     /* free the rest as they are dead for sure */
-    size_t nslots = Primes[oldzct.nslots];
+    Int nslots = Primes[oldzct.nslots];
     void** slots = oldzct.slots;
-    for (size_t i = 0; i < nslots; i++)
+    for (Int i = 0; i < nslots; i++)
     {
         if (slots[i] != NULL && slots[i] != DELETED)
         {
@@ -179,7 +181,7 @@ static void gc_collect(void)
     free(slots);
 }
 
-static void log_add(object_t* obj, int op)
+static void log_add(object_t* obj, Int op)
 {
     Log.log[Log.index++] = (((uintptr_t)obj) | op);
     if (Log.index >= ((sizeof(Log)/sizeof(uintptr_t))-1))
@@ -221,24 +223,24 @@ static uint64_t hash64(uint64_t key)
     return key;
 }
 
-static void hash_init(hash_t* hash, int nslots)
+static void hash_init(hash_t* hash, Int nslots)
 {
     memset(hash, 0, sizeof(hash_t));
     hash->nslots = nslots;
-    hash->thold = (size_t)(Primes[hash->nslots] * THOLD);
+    hash->thold = (Int)(Primes[hash->nslots] * THOLD);
     hash->slots = calloc(Primes[hash->nslots], sizeof(void*));
 }
 
 static void hash_grow(hash_t* hash)
 {
-    size_t nslots = Primes[hash->nslots];
+    Int nslots = Primes[hash->nslots];
     void** slots = hash->slots;
     hash->size = 0;
     hash->nslots++;
-    hash->thold = (size_t)(Primes[hash->nslots] * THOLD);
+    hash->thold = (Int)(Primes[hash->nslots] * THOLD);
     hash->slots = calloc(Primes[hash->nslots], sizeof(void*));
 
-    for (size_t i = 0; i < nslots; i++)
+    for (Int i = 0; i < nslots; i++)
     {
         if (slots[i] != NULL)
         {
@@ -258,7 +260,7 @@ static void hash_add(hash_t* hash, void* entry)
 
     /* now hash and add the new item */
     uint64_t hcode = hash64((uint64_t)entry);
-    size_t index = (hcode % Primes[hash->nslots]);
+    Int index = (hcode % Primes[hash->nslots]);
     while (1)
     {
         if (hash->slots[index] == entry)
@@ -278,10 +280,10 @@ static void hash_add(hash_t* hash, void* entry)
     }
 }
 
-static int hash_del(hash_t* hash, void* entry)
+static Int hash_del(hash_t* hash, void* entry)
 {
     uint64_t hcode = hash64((uint64_t)entry);
-    size_t index = (hcode % Primes[hash->nslots]);
+    Int index = (hcode % Primes[hash->nslots]);
 
     while (1)
     {
index f6ad21cdbc571f8c4eacfe34cb40ee5fdff8980d..7756325d1d228a5aaab62a6fee63400e07fae67b 100644 (file)
@@ -1,6 +1,7 @@
 #include <liba.h>
+#include <std.h>
 
-void* ecalloc(size_t num, size_t size)
+void* ecalloc(int num, int size)
 {
     void* ret;
     if (NULL == (ret = calloc(num,size)))
index aa459f95e59de194d0aa74f0f7b21f61bf938e44..1b47115824e1486c7eb150cb267b2e833715d7c8 100644 (file)
@@ -1,4 +1,5 @@
 #include <liba.h>
+#include <std.h>
 
 FILE* efopen(const char* filename, const char* mode)
 {
index c9cef61540425e742b7065dd0383638580d106f0..6d506e20cfa03718f89df9a8a0bef4c7502955cc 100644 (file)
@@ -1,9 +1,10 @@
 #include <liba.h>
+#include <std.h>
 
 char* efreadline(FILE* input)
 {
-    size_t size  = 32;
-    size_t index = 0;
+    Int size  = 32;
+    Int index = 0;
     char*  str = (char*)emalloc(size);
     memset(str, 0, size);
     if (feof(input))
index 9e7470d495bff7505d782ac6b4fc8ea944cbf30c..ac4cd85d03296ac50e4efda2337dea975d086909 100644 (file)
@@ -1,6 +1,7 @@
 #include <liba.h>
+#include <std.h>
 
-void* emalloc(size_t size)
+void* emalloc(int size)
 {
     void* ret;
     if (NULL == (ret = malloc(size)))
index 6a3bd50caf6ca7565151fdb62d7ffd90f96e09e8..a6b1e75eb9fbb3c83ae4eb21aa45cb458789bdd6 100644 (file)
@@ -1,4 +1,5 @@
 #include <liba.h>
+#include <std.h>
 
 int eraise(int sig)
 {
index 3d0db4ab00e43576350fdd2bf56316f41a3d3fee..47c4835270d30283bb8fcd9b3fb6923a5a486524 100644 (file)
@@ -1,6 +1,7 @@
 #include <liba.h>
+#include <std.h>
 
-void* erealloc(void* ptr, size_t size)
+void* erealloc(void* ptr, int size)
 {
     void* ret;
     if (NULL == (ret = realloc(ptr,size)))
index f31b0c53f5335181613193034bd8861f8a1955aa..042039e1a66c9090928d21bf1bda20a00cb5092b 100644 (file)
@@ -1,4 +1,5 @@
 #include <liba.h>
+#include <std.h>
 
 void esignal(int sig, void (*func)(int))
 {
index 4945c474361b30e1d537f8ee6128e775292a2802..210c6364cb0a24d03d7b6492ea997cd4bb0e4dd2 100644 (file)
@@ -1,4 +1,5 @@
 #include <liba.h>
+#include <std.h>
 
 char* estrdup(const char *s)
 {
index 384c9811f3f2c3d40eeb8af20bdcf8d86102b02a..7ddfa836b5912509e6d21268924d3a3abb83f76a 100644 (file)
@@ -1,4 +1,5 @@
 #include <liba.h>
+#include <std.h>
 
 void fatal(const char* fmt, ...)
 {
@@ -16,5 +17,5 @@ void fatal(const char* fmt, ...)
         fprintf(stderr, " %s", strerror(errno));
     }
     fprintf(stderr, "\n");
-    exit(EXIT_FAILURE);
+    exit(1);
 }
index 62d6c4ab6784e74e6dbe17ed2d0e3ec5a1654279..24de21f4d5ad26c6e616e0d5ab4d23d233e6fd60 100644 (file)
@@ -1,4 +1,5 @@
 #include <liba.h>
+#include <std.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <fcntl.h>
index 5ff127a5e43a604c999c6add2723955fad08e4da..1045cbebb4f2776794278d4f257f743563bf1ddf 100644 (file)
@@ -1,10 +1,11 @@
 #include <liba.h>
+#include <std.h>
 
-char* smprintf(const char* fmt, ...)
+char* smprIntf(const char* fmt, ...)
 {
     va_list args;
     va_start(args, fmt);
-    int strsz = vsnprintf(NULL, 0, fmt, args);
+    Int strsz = vsnprintf(NULL, 0, fmt, args);
     va_end(args);
     char* str = emalloc(strsz+1);
     va_start(args, fmt);
index 1cefc62c00611d92bedca3a9215f97233b18b581..b08afe2e385fe5d0345530528810c80d96d7a198 100644 (file)
@@ -1,17 +1,18 @@
 #include <liba.h>
+#include <std.h>
 
 char* strmcat(char* first, ...)
 {
     va_list args;
     /* calculate the length of the final string */
-    size_t len = strlen(first);
+    Int len = strlen(first);
     va_start(args, first);
     for (char* s = NULL; (s = va_arg(args, char*));)
     {
         len += strlen(s);
     }
     va_end(args);
-    /* allocate the final string and copy the args into it */
+    /* allocate the final string and copy the args Into it */
     char *str  = malloc(len+1), *curr = str;
     while (first && *first)
     {
index d9011daf73b524a3b84801b7e0f867dc214db9fb..23960c20bfc9af54383f4e83c2e730b6eec92100 100644 (file)
@@ -1,4 +1,5 @@
 #include <liba.h>
+#include <std.h>
 
 void warn(const char* fmt, ...)
 {
index cbb286b29347eb0a5631608c84d46dfb6d60fdeb..24163efd52ba6996f74a0b9247f0d17384ca14e5 100644 (file)
@@ -1,10 +1,11 @@
+#include <std.h>
 #include <liba.h>
 #include <libui.h>
 #include <impl/libui.h>
 
 UIFont font_load(char* patt)
 {
-    static bool inited = false;
+    static Bool inited = false;
     if (!inited && !FcInit())
     {
         fatal("failed to initialize fontconfig");
index 6d162093b8d7d697d3acd2b20feb9a89a8c263aa..83db56aa326d87787466e734808518f35c33e951 100644 (file)
@@ -1,3 +1,4 @@
+#include <std.h>
 #include <liba.h>
 #include <libui.h>
 #include <impl/libui.h>