]> git.cryptolib.org Git - avr-crypto-lib.git/blob - test_src/dbz_strings.c
fixing E-Mail-Address & Copyright
[avr-crypto-lib.git] / test_src / dbz_strings.c
1 /* dbz_strings.c */
2 /*
3  *   This file is part of AnonAccess, an access system which can be used
4  *    to open door or doing other things with an anonymity featured
5  *    account managment.
6  *   Copyright (C) 2006-2015 Daniel Otte (bg@nerilex.org)
7  *
8  *   This program is free software: you can redistribute it and/or modify
9  *   it under the terms of the GNU General Public License as published by
10  *   the Free Software Foundation, either version 3 of the License, or
11  *   (at your option) any later version.
12  *
13  *   This program is distributed in the hope that it will be useful,
14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *   GNU General Public License for more details.
17  *
18  *   You should have received a copy of the GNU General Public License
19  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  */
21
22
23 /*
24  * author: Daniel Otte
25  * email:  bg@nerilex.org
26  * license: GPLv3
27  * 
28  * */
29
30 #include <stdint.h>
31 #include <string.h>
32 #include <avr/pgmspace.h>
33  
34 /******************************************************************************/
35
36 uint8_t dbz_strcount(const char *str){
37         uint8_t ret=1;
38         if(*str=='\0' && *(str+1)=='\0')
39                         return 0;
40         for(;;){
41                 while(*str++)
42                         ;
43                 if(*str=='\0')
44                         return ret;
45                 ++ret;
46         }       
47 }
48
49 /******************************************************************************/
50
51 void dbz_splitup(char *dbzstr, char** strings){
52         if(*dbzstr=='\0' && *(dbzstr+1)=='\0')
53                 return;
54         *strings++ = dbzstr;
55         for(;;){        
56                 while(*dbzstr++)
57                         ;
58                 if(*dbzstr=='\0')
59                         return;
60                 *strings++ = dbzstr;
61         }
62 }
63
64 /******************************************************************************/
65
66 uint8_t dbz_strcount_P(PGM_P str){
67         uint8_t ret=1;
68         if(pgm_read_byte(str)=='\0' && pgm_read_byte(str+1)=='\0')
69                         return 0;
70         for(;;){
71                 while(pgm_read_byte(str++))
72                         ;
73                 if(pgm_read_byte(str)=='\0')
74                         return ret;
75                 ++ret;
76         }       
77 }
78
79 /******************************************************************************/
80
81 void dbz_splitup_P(PGM_P dbzstr, PGM_P *strings){
82         if(pgm_read_byte(dbzstr)=='\0' && pgm_read_byte(dbzstr+1)=='\0')
83                 return;
84         *strings++ = dbzstr;
85         for(;;){        
86                 while(pgm_read_byte(dbzstr++))
87                         ;
88                 if(pgm_read_byte(dbzstr)=='\0')
89                         return;
90                 *strings++ = dbzstr;
91         }
92 }
93
94 /******************************************************************************/
95