X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=test_src%2Fdbz_strings.c;fp=test_src%2Fdbz_strings.c;h=436bf8c151b72c145b115bfbb223be7fa37bebb8;hb=65b5512d92a8b13973ae65201b18922b856328e5;hp=0000000000000000000000000000000000000000;hpb=170835f03e35ac53d7930d42590ad525e763999c;p=avr-crypto-lib.git diff --git a/test_src/dbz_strings.c b/test_src/dbz_strings.c new file mode 100644 index 0000000..436bf8c --- /dev/null +++ b/test_src/dbz_strings.c @@ -0,0 +1,95 @@ +/* dbz_strings.c */ +/* + * This file is part of AnonAccess, an access system which can be used + * to open door or doing other things with an anonymity featured + * account managment. + * Copyright (C) 2006, 2007, 2008, 2009 Daniel Otte (daniel.otte@rub.de) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +/* + * author: Daniel Otte + * email: daniel.otte@rub.de + * license: GPLv3 + * + * */ + +#include +#include +#include + +/******************************************************************************/ + +uint8_t dbz_strcount(const char* str){ + uint8_t ret=1; + if(*str=='\0' && *(str+1)=='\0') + return 0; + for(;;){ + while(*str++) + ; + if(*str=='\0') + return ret; + ++ret; + } +} + +/******************************************************************************/ + +void dbz_splitup(char* dbzstr, char** strings){ + if(*dbzstr=='\0' && *(dbzstr+1)=='\0') + return; + *strings++ = dbzstr; + for(;;){ + while(*dbzstr++) + ; + if(*dbzstr=='\0') + return; + *strings++ = dbzstr; + } +} + +/******************************************************************************/ + +uint8_t dbz_strcount_P(PGM_P str){ + uint8_t ret=1; + if(pgm_read_byte(str)=='\0' && pgm_read_byte(str+1)=='\0') + return 0; + for(;;){ + while(pgm_read_byte(str++)) + ; + if(pgm_read_byte(str)=='\0') + return ret; + ++ret; + } +} + +/******************************************************************************/ + +void dbz_splitup_P(PGM_P dbzstr, PGM_P* strings){ + if(pgm_read_byte(dbzstr)=='\0' && pgm_read_byte(dbzstr+1)=='\0') + return; + *strings++ = dbzstr; + for(;;){ + while(pgm_read_byte(dbzstr++)) + ; + if(pgm_read_byte(dbzstr)=='\0') + return; + *strings++ = dbzstr; + } +} + +/******************************************************************************/ +