This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #define s_foreach(str, index) for(size_t index=0;str[index]!=0;index++) | |
| char isnum(char* str){ | |
| s_foreach(str, i){ | |
| switch(str[i]){ | |
| case '1': break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| double ExecuteAC(char** argv){ | |
| pid_t pid=fork(); | |
| if(pid==0){ | |
| // child process | |
| execv(argv[0], argv); | |
| exit(127); | |
| }else{ | |
| // parent process | |
| long before=clock(); | |
| waitpid(pid, 0, 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| typedef struct _table{ | |
| size_t x; | |
| size_t y; | |
| char** table; | |
| }table_t; | |
| table_t new_table(size_t x, size_t y, size_t s){ | |
| table_t table; | |
| table.x=x; | |
| table.y=y; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| char* unix_read_file(char* filenm, long unsigned int* len){ | |
| int fd=open(filenm, O_RDONLY); | |
| char* buf=0x0; | |
| if(fd>0){ | |
| struct stat stats; | |
| fstat(fd, &stats); | |
| buf=malloc(stats.st_size+1); | |
| *len=stats.st_size; | |
| if(buf){ | |
| read(fd, buf, stats.st_size); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| size_t unix_get_filesz(char* filenm){ | |
| size_t sz=0; | |
| int fd=open(filenm, O_RDONLY); | |
| if(fd>0){ | |
| struct stat stats; | |
| fstat(fd, &stats); | |
| sz=stats.st_size; | |
| close(fd); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| char** atokl(char* InC, char* delim, long unsigned int* len){ | |
| long unsigned int capacity=32; | |
| char** tok=(char**)malloc((capacity+1)*sizeof(char**)); | |
| //printf("%p\n", tok); | |
| char* pass=strdup(InC); | |
| { | |
| long unsigned int i=0; | |
| while(tok[i-1]!=NULL){ | |
| if(i+2>=capacity){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| char ismapped(void* ptr){ | |
| int fd[2]; | |
| char valid=1; | |
| pipe(fd); | |
| if(write(fd[1], ptr, 1)<0){ | |
| if(errno==EFAULT){ | |
| valid=0; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| typedef struct _table{ | |
| size_t x, y; | |
| char** table; | |
| }table_t; | |
| table_t new_table(size_t x, size_t y, size_t s){ | |
| table_t table; | |
| table.x=x; | |
| table.y=y; | |
| table.table=malloc(x*sizeof(void*)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <string.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #define BUFSIZE (sizeof(long) * 8 + 1) | |
| ldiv_t ldiv (long int numer, long int denom); | |
| char *ltoa(long N, char *str, int base) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| char* onesep_s(char* in, char sep, char** save_ptr){ | |
| long unsigned int until=until_byte(in, strlen(in), sep); | |
| if(until==strlen(in))return 0; | |
| *save_ptr+=until+1; | |
| return strndupx(in, until); | |
| } |