More cleanup
This commit is contained in:
parent
cc8ff45cc1
commit
9a9c5ea1c3
2 changed files with 16 additions and 7 deletions
3
Makefile
3
Makefile
|
@ -1,6 +1,9 @@
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -O0 -I include
|
CFLAGS = -O0 -I include
|
||||||
|
|
||||||
|
DEBUG = true
|
||||||
|
|
||||||
|
|
||||||
ifdef DEBUG
|
ifdef DEBUG
|
||||||
CFLAGS += -g3
|
CFLAGS += -g3
|
||||||
endif
|
endif
|
||||||
|
|
20
protoutils.c
20
protoutils.c
|
@ -636,6 +636,14 @@ char * address_string_to_bytes(struct protocol * xx, const char * abc,size_t get
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* convert a string address into bytes
|
||||||
|
* @param finalbytes the destination
|
||||||
|
* @param realbbsize the ultimate size of the destination
|
||||||
|
* @param strx the incoming string
|
||||||
|
* @param strsize the string length
|
||||||
|
*/
|
||||||
int string_to_bytes(uint8_t * finalbytes, size_t* realbbsize, char * strx, size_t strsize)
|
int string_to_bytes(uint8_t * finalbytes, size_t* realbbsize, char * strx, size_t strsize)
|
||||||
{
|
{
|
||||||
if(strx[0] != '/')
|
if(strx[0] != '/')
|
||||||
|
@ -643,13 +651,11 @@ int string_to_bytes(uint8_t * finalbytes, size_t* realbbsize, char * strx, size_
|
||||||
printf("Error, must start with '/'\n");
|
printf("Error, must start with '/'\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
char xxx[800];
|
|
||||||
bzero(xxx,800);
|
|
||||||
//Getting total words
|
//Getting total words
|
||||||
int totalwords = 0;
|
int totalwords = 0;
|
||||||
char * totp;
|
char* totp;
|
||||||
char totalwordstest[strsize];
|
char totalwordstest[strsize + 1];
|
||||||
bzero(totalwordstest,strsize);
|
bzero(totalwordstest,strsize + 1);
|
||||||
strcat(totalwordstest, strx);
|
strcat(totalwordstest, strx);
|
||||||
totp = strtok(totalwordstest, "/");
|
totp = strtok(totalwordstest, "/");
|
||||||
while(totp != NULL)
|
while(totp != NULL)
|
||||||
|
@ -664,8 +670,8 @@ int string_to_bytes(uint8_t * finalbytes, size_t* realbbsize, char * strx, size_
|
||||||
//Now Setting up variables for calculating which is the first
|
//Now Setting up variables for calculating which is the first
|
||||||
//and second word:
|
//and second word:
|
||||||
int firstorsecond = 1; //1=Protocol && 2 = Address
|
int firstorsecond = 1; //1=Protocol && 2 = Address
|
||||||
char pstring[800];//We do not want to harm the initial string.
|
char pstring[strsize + 1];//We do not want to harm the initial string.
|
||||||
bzero(pstring,800);
|
bzero(pstring,strsize + 1);
|
||||||
strcat(pstring,strx);
|
strcat(pstring,strx);
|
||||||
//Starting to extract words and process them:
|
//Starting to extract words and process them:
|
||||||
char * wp;
|
char * wp;
|
||||||
|
|
Loading…
Reference in a new issue