Started fleshing out the storage API

This commit is contained in:
2023-02-21 14:36:20 +01:00
parent 81f7351fe6
commit ef2bba5c1c
49 changed files with 661 additions and 475 deletions

View File

@ -55,4 +55,44 @@ int strncmp ( const char* str1, const char* str2, size_t num ){
}
return 0;
}
char* strchr(const char* s , int c){
while(*s) {
if(*s == c) return const_cast<char*>(s);
s++;
}
return NULL;
}
char* strtok(char* str, const char* delim , char**saveptr){
char *begin;
if(str) {
begin = str;
}
else if (*saveptr) {
begin = *saveptr;
}
else {
return NULL;
}
while(strchr(delim, begin[0])) {
begin++;
}
char *next = NULL;
for(int i = 0; i < strlen(delim); i++) {
char *temp = strchr(begin, delim[i]);
if(temp < next || next == NULL) {
next = temp;
}
}
if(!next) {
*saveptr = NULL;
return begin;
}
*next = 0;
*saveptr=next+1;
return begin;
}

View File

@ -9,4 +9,6 @@ int memcmp( const void* ptr1, const void* ptr2, size_t num);
size_t strlen(const char* str);
int strncmp ( const char* str1, const char* str2, size_t num );
int strncmp ( const char* str1, const char* str2, size_t num );
char* strtok(char* str, const char* delim , char**saveptr);