repo_name
stringlengths
5
122
path
stringlengths
3
232
text
stringlengths
6
1.05M
justinian/poplibc
src/stdio/fgets.c
/* fgets( char *, int, FILE * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> #include "j6libc/glue.h" char * fgets( char * restrict s, int size, struct _PDCLIB_file_t * restrict stream ) { char * dest =...
justinian/poplibc
src/tests/test_string.c
#include "_PDCLIB_test.h" START_TEST( memchr ) { TESTCASE( memchr( abcde, 'c', 5 ) == &abcde[2] ); TESTCASE( memchr( abcde, 'a', 1 ) == &abcde[0] ); TESTCASE( memchr( abcde, 'a', 0 ) == NULL ); TESTCASE( memchr( abcde, '\0', 5 ) == NULL ); TESTCASE( memchr( abcde, '\0', 6 ) == &abcde[5] ); } END_TE...
justinian/poplibc
src/stdio/feof.c
<reponame>justinian/poplibc /* feof( FILE * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> int feof( struct _PDCLIB_file_t * stream ) { return stream->status & _PDCLIB_EOFFLAG; }
justinian/poplibc
src/include/j6libc/wctype_t.h
<filename>src/include/j6libc/wctype_t.h #pragma once /* Type definitions: wctype_t wctrans_t */ typedef uint32_t wctrans_t; typedef uint32_t wctype_t ;
justinian/poplibc
src/include/j6libc/null.h
#pragma once /* Constant definition: NULL */ #define NULL 0
justinian/poplibc
src/j6libc/digits.c
/* _PDCLIB_digits This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include "j6libc/int.h" const char _PDCLIB_digits[] = "0123456789abcdefghijklmnopqrstuvwxyz"; /* For _PDCLIB/print.c only; obsolete with ctype.h */ const char _P...
justinian/poplibc
src/include/j6libc/int.h
<filename>src/include/j6libc/int.h #pragma once /* PDCLib internal integer logic <int.h> This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ /* -------------------------------------------------------------------------- */ /* You shou...
justinian/poplibc
src/stdio/fputs.c
/* fputs( const char *, FILE * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> #include "j6libc/glue.h" int fputs( const char * restrict s, struct _PDCLIB_file_t * restrict stream ) { if ( _PDCLIB_prepwr...
justinian/poplibc
src/j6libc/load_lc_time.c
/* _PDCLIB_load_lc_time( const char *, const char * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <locale.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "j6libc/int.h" s...
justinian/poplibc
src/stdio/getc.c
<filename>src/stdio/getc.c /* getc( FILE * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> int getc( struct _PDCLIB_file_t * stream ) { return fgetc( stream ); }
justinian/poplibc
src/ctype/toupper.c
/* toupper( int ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <ctype.h> #include <locale.h> int toupper( int c ) { return _PDCLIB_lc_ctype.entry[c].upper; }
justinian/poplibc
src/string/strxfrm.c
<gh_stars>1-10 /* strxfrm( char *, const char *, size_t ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <string.h> #include <locale.h> size_t strxfrm( char * restrict s1, const char * restrict s2, size_t n ) { siz...
justinian/poplibc
src/include/j6libc/size_t.h
<filename>src/include/j6libc/size_t.h #pragma once /* Type definition: size_t */ #if __is_identifier(size_t) typedef __SIZE_TYPE__ size_t; #endif
justinian/poplibc
src/j6libc/prepread.c
/* _PDCLIB_prepread( struct _PDCLIB_file_t * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> #include "j6libc/glue.h" int _PDCLIB_prepread( struct _PDCLIB_file_t * stream ) { if ( ( stream->bufidx > str...
justinian/poplibc
src/stdlib/abort.c
/* abort( void ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdlib.h> #include <signal.h> void abort( void ) { raise( SIGABRT ); exit( EXIT_FAILURE ); }
justinian/poplibc
src/j6libc/load_lc_monetary.c
<reponame>justinian/poplibc /* _PDCLIB_load_lc_monetary( const char *, const char * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <locale.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <strin...
justinian/poplibc
src/stdio/rename.c
<gh_stars>1-10 /* rename( const char *, const char * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> #include "j6libc/glue.h" #include <string.h> extern struct _PDCLIB_file_t * _PDCLIB_filelist; int rename...
justinian/poplibc
src/ctype/isxdigit.c
<reponame>justinian/poplibc /* isxdigit( int ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <ctype.h> #include <locale.h> int isxdigit( int c ) { return ( isdigit( c ) || ( c >= _PDCLIB_lc_ctype.Xdigi...
justinian/poplibc
src/stdio/scanf.c
/* scanf( const char *, ... ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> #include <stdarg.h> int scanf( const char * restrict format, ... ) { va_list ap; va_start( ap, format ); return vfscanf...
justinian/poplibc
src/ctype/isprint.c
/* isprint( int ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <ctype.h> #include <locale.h> int isprint( int c ) { /* FIXME: Space as of current locale charset, not source charset. */ return ( _PDCLIB_lc_cty...
justinian/poplibc
src/string/strcpy.c
/* strcpy( char *, const char * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <string.h> char * strcpy( char * restrict s1, const char * restrict s2 ) { char * rc = s1; while ( ( *s1++ = *s2++ ) ); retur...
justinian/poplibc
src/stdlib/_Exit.c
<reponame>justinian/poplibc<filename>src/stdlib/_Exit.c<gh_stars>1-10 /* _Exit( int ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdlib.h> #include <stdio.h> #include "j6libc/glue.h" void _Exit( int status ) { ...
justinian/poplibc
src/include/wchar.h
<reponame>justinian/poplibc #pragma once /* Wide character functions <wchar.h> */ #include "j6libc/cpp.h" #include "j6libc/int.h" #include "j6libc/null.h" #include "j6libc/size_t.h" #include "j6libc/wchar_t.h" #include "j6libc/wctype_t.h" #include "j6libc/wint_t.h" #include <stdarg.h> #include <stdio.h> CPP_CHECK_BE...
justinian/poplibc
src/tests/test_assert.c
<gh_stars>1-10 #include "_PDCLIB_test.h" #define NDEBUG #include <assert.h> #define enabled_assert( expression ) ( ( expression ) ? (void) 0 \ : _PDCLIB_assert( "Assertion failed: " #expression \ ", function ", __func__, \ ", file " __FILE__ \ ...
justinian/poplibc
src/include/wctype.h
<filename>src/include/wctype.h #pragma once /* Wide character classification and mapping utilities <wctype.h> This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include "j6libc/cpp.h" #include "j6libc/int.h" #include "j6libc/wint_t...
justinian/poplibc
src/j6libc/allocpages.c
<reponame>justinian/poplibc /* _PDCLIB_allocpages( int const ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ /* This is an example implementation of _PDCLIB_allocpages() fit for use with POSIX kernels. */ #include "j6libc/g...
justinian/poplibc
src/j6libc/close.c
<reponame>justinian/poplibc<filename>src/j6libc/close.c /* _PDCLIB_close( _PDCLIB_fd_t ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ /* This is an example implementation of _PDCLIB_close() fit for use with POSIX kernels. *...
justinian/poplibc
src/stdio/fgetpos.c
<gh_stars>1-10 /* fgetpos( FILE * , fpos_t * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> int fgetpos( struct _PDCLIB_file_t * restrict stream, struct _PDCLIB_fpos_t * restrict pos ) { pos->offset = s...
justinian/poplibc
src/j6libc/scan.c
/* _PDCLIB_scan( const char *, struct _PDCLIB_status_t * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> #include <stdlib.h> #include <stdarg.h> #include <stdint.h> #include <ctype.h> #include <string.h> #inc...
justinian/poplibc
src/stdio/putchar.c
<gh_stars>1-10 /* putchar( int ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> int putchar( int c ) { return fputc( c, stdout ); }
justinian/poplibc
src/j6libc/open.c
<gh_stars>1-10 /* _PDCLIB_open( const char * const, int ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ /* This is an example implementation of _PDCLIB_open() fit for use with POSIX kernels. */ #include "j6libc/glue.h" int...
justinian/poplibc
src/include/limits.h
#pragma once /* Sizes of integer types <limits.h> This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include "j6libc/int.h" /* TODO: Defined to 1 as multibyte characters are not supported yet. */ #define MB_LEN_MAX 1 #define SCHA...
justinian/poplibc
src/stdio/fread.c
/* fwrite( void *, size_t, size_t, FILE * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> #include <string.h> #include "j6libc/glue.h" size_t fread( void * restrict ptr, size_t size, size_t nmemb, struct _PD...
justinian/poplibc
src/stdlib/atol.c
/* atol( const char * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdlib.h> long int atol( const char * s ) { return (long int) _PDCLIB_atomax( s ); }
justinian/poplibc
src/stdio/setvbuf.c
/* setvbuf( FILE *, char *, int, size_t ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> #include <stdlib.h> #include <limits.h> int setvbuf( struct _PDCLIB_file_t * restrict stream, char * restrict buf, int ...
justinian/poplibc
src/tests/test_stdio.c
<reponame>justinian/poplibc #include "_PDCLIB_test.h" #include "_PDCLIB_iotest.h" #include <assert.h> extern struct _PDCLIB_file_t *_PDCLIB_filelist; START_TEST( clearerr ) { FILE * fh = tmpfile(); TESTCASE_REQUIRE( fh != NULL ); /* Flags should be clear */ TESTCASE( ! ferror( fh ) ); TESTCASE( ...
justinian/poplibc
src/string/strrchr.c
<reponame>justinian/poplibc /* strrchr( const char *, int ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <string.h> char * strrchr( const char * s, int c ) { size_t i = 0; while ( s[i++] ); do { ...
justinian/poplibc
src/stdlib/srand.c
/* srand( unsigned int ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdlib.h> void srand( unsigned int seed ) { _PDCLIB_seed = seed; }
justinian/poplibc
src/tests/test_ctype.c
<filename>src/tests/test_ctype.c #include "_PDCLIB_test.h" START_TEST( isalnum ) { TESTCASE( isalnum( 'a' ) ); TESTCASE( isalnum( 'z' ) ); TESTCASE( isalnum( 'A' ) ); TESTCASE( isalnum( 'Z' ) ); TESTCASE( isalnum( '0' ) ); TESTCASE( isalnum( '9' ) ); TESTCASE( ! isalnum( ' ' ) ); TESTCA...
justinian/poplibc
src/include/time.h
#pragma once /* Date and time <time.h> This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include "j6libc/cpp.h" #include "j6libc/int.h" #include "j6libc/null.h" #include "j6libc/size_t.h" CPP_CHECK_BEGIN /* These are defined to ...
justinian/poplibc
src/j6libc/prepwrite.c
<filename>src/j6libc/prepwrite.c /* _PDCLIB_prepwrite( struct _PDCLIB_file_t * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> int _PDCLIB_prepwrite( struct _PDCLIB_file_t * stream ) { if ( ( stream->buf...
justinian/poplibc
src/stdio/ftell.c
<reponame>justinian/poplibc<filename>src/stdio/ftell.c /* ftell( FILE * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> #include <limits.h> long int ftell( struct _PDCLIB_file_t * stream ) { /* ftell() m...
justinian/poplibc
src/include/j6libc/int_widths.h
#pragma once /* Type definitions: fixed-width integral types */ /* 7.18.1.1 Exact-width integer types. */ typedef __INT8_TYPE__ int8_t; typedef __INT16_TYPE__ int16_t; typedef __INT32_TYPE__ int32_t; typedef __INT64_TYPE__ int64_t; typedef __UINT8_TYPE__ uint8_t; typedef __UINT16_TYPE__ uint16_t; typedef __UINT32_...
justinian/poplibc
src/time/timespec_get.c
<reponame>justinian/poplibc /* timespec_get( struct timespec *, int ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <time.h> int timespec_get( struct timespec * ts, int base ) { return 0; }
justinian/poplibc
src/include/stddef.h
#pragma once /* Common definitions <stddef.h> This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include "j6libc/int.h" #include "j6libc/null.h" #include "j6libc/max_align_t.h" #include "j6libc/size_t.h" #include "j6libc/wchar_t.h"...
justinian/poplibc
src/include/assert.h
#pragma once /* Diagnostics <assert.h> This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include "j6libc/aux.h" #include "j6libc/cpp.h" CPP_CHECK_BEGIN void _PDCLIB_assert( const char * const, const char * const, const char * co...
justinian/poplibc
src/j6libc/is_leap.c
/* _PDCLIB_is_leap( int ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include "j6libc/int.h" int _PDCLIB_is_leap( int year_offset ) { /* year given as offset from 1900, matching tm.tm_year in <time.h> */ long long y...
justinian/poplibc
src/locale/localeconv.c
/* localeconv( void ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <locale.h> struct lconv * localeconv( void ) { return _PDCLIB_lc_numeric_monetary.lconv; }
justinian/poplibc
src/j6libc/load_lc_ctype.c
/* _PDCLIB_load_lc_ctype( const char *, const char * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <inttypes.h> #include <limits.h> #include <locale.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #inc...
justinian/poplibc
src/string/strcoll.c
<gh_stars>1-10 /* strcoll( const char *, const char * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <string.h> #include <locale.h> int strcoll( const char * s1, const char * s2 ) { return strcmp( s1, s2 ); ...
justinian/poplibc
src/j6libc/strtox_main.c
<gh_stars>1-10 /* _PDCLIB_strtox_main( const char * *, int, uintmax_t, uintmax_t, int ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <ctype.h> #include <errno.h> #include <string.h> #include <stdint.h> uintmax_t _PDC...
justinian/poplibc
src/include/stdnoreturn.h
<reponame>justinian/poplibc<gh_stars>1-10 #pragma once /* _Noreturn <stdnoreturn.h> This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #define noreturn _Noreturn
justinian/poplibc
src/stdio/printf.c
/* printf( const char *, ... ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> #include <stdarg.h> int printf( const char * restrict format, ... ) { int rc; va_list ap; va_start( ap, format ); ...
justinian/poplibc
src/tests/test_stdlib.c
#include "_PDCLIB_test.h" #include <assert.h> static int test_exit() { _Exit(0); return 0; } START_TEST( _Exit ) { TESTCASE( test_exit() ); } END_TEST static void aborthandler(int s) { _exit(0); } static int test_abort() { abort(); return 0; } START_TEST( abort ) { TESTCASE( signal( SIGABRT, &aborthandler ...
justinian/poplibc
src/time/time.c
/* time( time_t * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <time.h> /* See comments in time.h on the semantics of time_t. */ time_t time( time_t * timer ) { return -1; }
justinian/poplibc
src/tests/test_signal.c
<reponame>justinian/poplibc #include "_PDCLIB_test.h" #include <stdlib.h> static volatile sig_atomic_t flag = 0; static int expected_signal = 0; static int received_signal = 0; static void test_handler( int sig ) { flag = 1; } START_TEST( raise ) { /* Could be other than SIG_DFL if you changed the implement...
justinian/poplibc
src/time/strftime.c
<filename>src/time/strftime.c /* strftime( char * restrict, size_t, const char * restrict, const struct tm * restrict ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <time.h> #include <stdlib.h> #include <locale.h> #in...
justinian/poplibc
src/stdio/clearerr.c
/* clearerr( FILE * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> void clearerr( struct _PDCLIB_file_t * stream ) { stream->status &= ~( _PDCLIB_ERRORFLAG | _PDCLIB_EOFFLAG ); }
justinian/poplibc
src/stdio/vsnprintf.c
/* vsnprintf( char *, size_t, const char *, va_list ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> #include <stdarg.h> int vsnprintf( char * restrict s, size_t n, const char * restrict format, _PDCLIB_va_li...
justinian/poplibc
src/include/errno.h
#pragma once /* Errors <errno.h> This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include "j6libc/int.h" #define errno (*_PDCLIB_errno_func()) #define ERANGE _PDCLIB_ERANGE #define EDOM _PDCLIB_EDOM #define ENOMEM _PDCLIB_ENOME...
justinian/poplibc
src/include/j6libc/wint_t.h
<reponame>justinian/poplibc #pragma once /* Type definition: wint_t */ typedef __WINT_TYPE__ wint_t;
justinian/poplibc
src/string/memcmp.c
/* memcmp( const void *, const void *, size_t ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <string.h> int memcmp( const void * s1, const void * s2, size_t n ) { const unsigned char * p1 = (const unsigned char *...
justinian/poplibc
src/j6libc/flushbuffer.c
/* _PDCLIB_flushbuffer( struct _PDCLIB_file_t * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ /* This is an example implementation of _PDCLIB_flushbuffer() fit for use with POSIX kernels. */ #include <stdio.h> #include "j...
justinian/poplibc
src/stdio/perror.c
<filename>src/stdio/perror.c<gh_stars>1-10 /* perror( const char * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> #include <errno.h> #include <locale.h> /* TODO: Doing this via a static array is not the way...
justinian/poplibc
src/stdlib/div.c
<reponame>justinian/poplibc<filename>src/stdlib/div.c<gh_stars>1-10 /* div( int, int ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdlib.h> div_t div( int numer, int denom ) { div_t rc; rc.quot = numer / d...
justinian/poplibc
src/string/strncmp.c
/* strncmp( const char *, const char *, size_t ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <string.h> int strncmp( const char * s1, const char * s2, size_t n ) { while ( n && *s1 && ( *s1 == *s2 ) ) { ...
justinian/poplibc
src/stdio/ferror.c
<filename>src/stdio/ferror.c<gh_stars>1-10 /* ferror( FILE * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> int ferror( struct _PDCLIB_file_t * stream ) { return stream->status & _PDCLIB_ERRORFLAG; }
justinian/poplibc
src/stdio/fseek.c
/* fseek( FILE *, long, int ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> #include "j6libc/glue.h" int fseek( struct _PDCLIB_file_t * stream, long offset, int whence ) { if ( stream->status & _PDCLIB_F...
justinian/poplibc
src/j6libc/closeall.c
/* _PDCLIB_closeall( void ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> extern struct _PDCLIB_file_t * _PDCLIB_filelist; void _PDCLIB_closeall( void ) { struct _PDCLIB_file_t * stream = _PDCLIB_fileli...
justinian/poplibc
src/include/j6libc/config.h
#pragma once /* Internal PDCLib configuration <config.h> (Generic Template) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <j6libc/int_widths.h> /* -------------------------------------------------------------------...
justinian/poplibc
src/inttypes/imaxabs.c
<reponame>justinian/poplibc<gh_stars>1-10 /* imaxabs( intmax_t ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <inttypes.h> intmax_t imaxabs( intmax_t j ) { return ( j >= 0 ) ? j : -j; }
justinian/poplibc
src/stdio/vscanf.c
/* vscanf( const char *, va_list ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> #include <stdarg.h> int vscanf( const char * restrict format, _PDCLIB_va_list arg ) { return vfscanf( stdin, format, arg )...
justinian/poplibc
src/j6libc/rename.c
/* _PDCLIB_rename( const char *, const char * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ /* This is an example implementation of _PDCLIB_rename() fit for use with POSIX kernels. */ #include <stdio.h> #include "j6libc/...
justinian/poplibc
src/j6libc/errno.c
<filename>src/j6libc/errno.c /* _PDCLIB_errno This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include "j6libc/int.h" int _PDCLIB_errno = 0; int * _PDCLIB_errno_func() { return &_PDCLIB_errno; }
justinian/poplibc
src/stdlib/atexit.c
<reponame>justinian/poplibc /* atexit( void (*)( void ) ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdlib.h> extern void (*_PDCLIB_exitstack[])( void ); extern size_t _PDCLIB_exitptr; int atexit( void (*func)( ...
justinian/poplibc
src/time/asctime.c
/* asctime( const struct tm * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <time.h> char * asctime( const struct tm * timeptr ) { return NULL; }
justinian/poplibc
src/stdlib/bsearch.c
/* bsearch( const void *, const void *, size_t, size_t, int(*)( const void *, const void * ) ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdlib.h> void * bsearch( const void * key, const void * base, size_t nmemb...
justinian/poplibc
src/stdlib/getenv.c
/* getenv( const char * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <string.h> #include <stdlib.h> char **environ __attribute__ ((weak)); extern char **environ; char * getenv( const char * name ) { size_t le...
justinian/poplibc
src/stdio/puts.c
<reponame>justinian/poplibc /* puts( const char * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> #include "j6libc/glue.h" extern char * _PDCLIB_eol; int puts( const char * s ) { if ( _PDCLIB_prepwrite(...
justinian/poplibc
src/string/strchr.c
/* strchr( const char *, int ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <string.h> char * strchr( const char * s, int c ) { do { if ( *s == (char) c ) { return (char *) s; ...
justinian/poplibc
src/tests/test_inttypes.c
#include "_PDCLIB_test.h" START_TEST( imaxabs ) { TESTCASE( imaxabs( (intmax_t)0 ) == 0 ); TESTCASE( imaxabs( INTMAX_MAX ) == INTMAX_MAX ); TESTCASE( imaxabs( INTMAX_MIN + 1 ) == -( INTMAX_MIN + 1 ) ); } END_TEST START_TEST( imaxdiv ) { imaxdiv_t result; result = imaxdiv( (intmax_t)5, (intmax_t)2 ...
justinian/poplibc
src/include/j6libc/cpp.h
#pragma once #ifdef __cplusplus #define CPP_CHECK_BEGIN extern "C" { #define CPP_CHECK_END } #else #define CPP_CHECK_BEGIN #define CPP_CHECK_END #endif
justinian/poplibc
src/j6libc/assert.c
<reponame>justinian/poplibc<gh_stars>1-10 /* _PDCLIB_assert( const char * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> #include <stdlib.h> #include <assert.h> #include "j6libc/aux.h" void _PDCLIB_assert(...
justinian/poplibc
src/string/strncat.c
<gh_stars>1-10 /* strncat( char *, const char *, size_t ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <string.h> char * strncat( char * restrict s1, const char * restrict s2, size_t n ) { char * rc = s1; whi...
justinian/poplibc
src/tests/test_stdarg.c
<gh_stars>1-10 #include <stdarg.h> #include <limits.h> #include <float.h> #include "_PDCLIB_test.h" typedef int (*intfunc_t)( void ); enum tag_t { TAG_END, TAG_INT, TAG_LONG, TAG_LLONG, TAG_DBL, TAG_LDBL, TAG_INTPTR, TAG_LDBLPTR, TAG_FUNCPTR }; static int dummy( void ) { retu...
justinian/poplibc
src/include/stdbool.h
<gh_stars>1-10 #pragma once /* Boolean type and values <stdbool.h> This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #ifndef __cplusplus #define bool _Bool #define true 1 #define fa...
justinian/poplibc
src/stdio/vfprintf.c
<filename>src/stdio/vfprintf.c<gh_stars>1-10 /* vfprintf( FILE *, const char *, va_list ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> #include <stdarg.h> #include <stdint.h> int vfprintf( struct _PDCLIB_fi...
justinian/poplibc
src/include/j6libc/max_align_t.h
<gh_stars>1-10 #pragma once #if __has_include("__stddef_max_align_t.h") #include "__stddef_max_align_t.h" #elif __BIGGEST_ALIGNMENT__ == __SIZEOF_LONG_DOUBLE__ typedef long double max_align_t; #elif __BIGGEST_ALIGNMENT__ == __SIZEOF_DOUBLE__ typedef double max_align_t; #elif __BIGGEST_ALIGNMENT__ == __SIZEOF_LONG_LONG...
justinian/poplibc
src/string/strerror.c
/* strerror( int ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <string.h> #include <locale.h> /* TODO: Doing this via a static array is not the way to do it. */ char * strerror( int errnum ) { if ( errnum >= _PD...
justinian/poplibc
src/ctype/iscntrl.c
<reponame>justinian/poplibc /* iscntrl( int ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <ctype.h> #include <locale.h> int iscntrl( int c ) { return ( _PDCLIB_lc_ctype.entry[c].flags & _PDCLIB_CTYPE_CNTRL ); }
justinian/poplibc
src/stdio/snprintf.c
/* snprintf( char *, size_t, const char *, ... ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> #include <stdarg.h> int snprintf( char * restrict s, size_t n, const char * restrict format, ...) { int rc; ...
justinian/poplibc
src/stdio/getchar.c
<filename>src/stdio/getchar.c /* getchar( void ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> int getchar( void ) { return fgetc( stdin ); }
justinian/poplibc
src/tests/test_locale.c
#include "_PDCLIB_test.h" START_SUITE( locale ) { } END_SUITE
justinian/poplibc
src/stdio/putc.c
<filename>src/stdio/putc.c /* putc( int, FILE * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> int putc( int c, struct _PDCLIB_file_t * stream ) { return fputc( c, stream ); }
justinian/poplibc
src/tests/main.c
#include "_PDCLIB_test.h" DECLARE_SUITE(internal); DECLARE_SUITE(assert); DECLARE_SUITE(ctype); DECLARE_SUITE(inttypes); DECLARE_SUITE(locale); DECLARE_SUITE(stdarg); DECLARE_SUITE(stdio); DECLARE_SUITE(stdlib); DECLARE_SUITE(string); DECLARE_SUITE(time); int main(int argc, const char **argv) { int result = 0; re...
justinian/poplibc
src/stdio/tmpnam.c
/* tmpnam( char * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> #include "j6libc/glue.h" #include <string.h> char * tmpnam( char * s ) { static char filename[ L_tmpnam ]; FILE * file = tmpfile(); ...
justinian/poplibc
src/stdio/fprintf.c
/* fprintf( FILE *, const char *, ... ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ #include <stdio.h> #include <stdarg.h> int fprintf( struct _PDCLIB_file_t * restrict stream, const char * restrict format, ... ) { int r...
KKothuri/Data-Structures
util/String.h
<gh_stars>0 #ifndef STRING_H #define STRING_H #include "Vector.h" #include <cstring> //String class to mimic the STL string class class String { Vector<char> elements_; public: String() : elements_(1, 0) {}; String(const char* inp); String(const String& str); String(const char& inp); const String& operator= (co...
KKothuri/Data-Structures
util/Vector.h
<filename>util/Vector.h<gh_stars>0 #ifndef VECTOR_H #define VECTOR_H #include <iostream> #include <algorithm> using namespace std; using ull = unsigned long long int; //Vector class to mimic the STL vector class template <class Object> class Vector { static const ull maxsize = 4611686018427387903; ull size; Obj...
KKothuri/Data-Structures
containers/Container.h
<reponame>KKothuri/Data-Structures #ifndef CONTAINER_H #define CONTAINER_H #include <vector> using ull = unsigned long long int; using namespace std; /* Container Abstract Class All structures will be derived from this */ template <class Object> class Container { protected: ull size_; public: Container() : size_...