Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

ANONIX libc

Name: CUDDERfan 2011-06-17 16:23

To further the development of ANONIX, I present you:

ctype.h
#ifndef CTYPE_H_
int isalnum(int c);
int isalpha(int c);
int iscntrl(int c);
int isdigit(int c);
int isgraph(int c);
int islower(int c);
int isprint(int c);
int ispunct(int c);
int isspace(int c);
int isupper(int c);
int isxdigit(int c);
int tolower(int c);
int toupper(int c);
#endif


ctype.c
#include "ctype.h"
int isalnum(int c) { return isalpha(c) | isdigit(c); }
int isalpha(int c) { return isupper(c) | islower(c); }
int iscntrl(int c) { return ((c < 0x20) || (c == 0x7f)) ? 1 : 0; }
int isdigit(int c) { return ((c >= '0') && (c <= '9')) ? 1 : 0; }
int isgraph(int c) { return ((c != ' ') && isprint(c)) ? 1 : 0; }
int islower(int c) { return ((c >= 'a') && (c <= 'z')) ? 1 : 0; }
int isprint(int c) { return ((c >= ' ') && (c <= '~')) ? 1 : 0; }
int ispunct(int c) { return ((c != ' ') && !isalnum(c)) ? 1 : 0; }
int isspace(int c) { return ((c == ' ') || (c == '\f') || (c == '\n') || (c == '\r') || (c == '\t') || (c == '\v')) ? 1 : 0; }
int isupper(int c) { return ((c >= 'A') && (c <= 'Z')) ? 1 : 0; }
int isxdigit(int c) { return (((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'f')) || ((c >= 'A') && (c <= 'F'))) ? 1 : 0; }
int tolower(int c) { return isupper(c) ? c - 'A' + 'a' : c; }
int toupper(int c) { return islower(c) ? c - 'a' + 'A' : c; }

Name: Anonymous 2011-06-19 13:21

assert.h
#include <stdio.h>
#include <stdlib.h>

#ifndef ASSERT_H_
#ifndef NDEBUG
#define assert(exp) \
    do{\
        if(!(exp)) { \
            fprintf(stderr, __FILE__ ":%d: Assertion '" #exp "' failed.\n", __LINE__);\
            abort(); \
        }\
    } while(0);
#else
#define assert(exp)
#endif  /* NDEBUG */
#endif  /* ASSERT_H_ */


Implementation of stdio.h and stdlib.h left as an exercise for the reader.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List