diff --git a/src/base/cptr.c b/src/base/cptr.c index 22a6b36..a4080fe 100644 --- a/src/base/cptr.c +++ b/src/base/cptr.c @@ -34,3 +34,16 @@ char* char_multiply(char c, uint32 n){ rez[n]=c; return rez; } + +bool cptr_startsWith(char* ptr, char* fragment){ + for(char cs=*ptr, cf=*fragment; cf; cs=*++ptr, cf=*++fragment) + if(cs!=cf) return false; + return true; +} + +bool cptr_endsWith(char* ptr, char* fragment){ + ptr+=cptr_length(ptr)-cptr_length(fragment); + for(char cs=*ptr, cf=*fragment; cf; cs=*++ptr, cf=*++fragment) + if(cs!=cf) return false; + return true; +} \ No newline at end of file diff --git a/src/base/cptr.h b/src/base/cptr.h index ccce381..b750842 100644 --- a/src/base/cptr.h +++ b/src/base/cptr.h @@ -18,6 +18,10 @@ bool cptr_compare(char* key0, char* key1); // multiplies char n times char* char_multiply(char c, uint32 n); +bool cptr_startsWith(char* ptr, char* fragment); + +bool cptr_endsWith(char* ptr, char* fragment); + #if __cplusplus } #endif \ No newline at end of file