More cleanup

This commit is contained in:
John Jones 2017-02-13 17:49:20 -05:00
parent cc8ff45cc1
commit 9a9c5ea1c3
2 changed files with 16 additions and 7 deletions

View file

@ -1,6 +1,9 @@
CC = gcc
CFLAGS = -O0 -I include
DEBUG = true
ifdef DEBUG
CFLAGS += -g3
endif

View file

@ -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)
{
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");
return 0;
}
char xxx[800];
bzero(xxx,800);
//Getting total words
int totalwords = 0;
char * totp;
char totalwordstest[strsize];
bzero(totalwordstest,strsize);
char* totp;
char totalwordstest[strsize + 1];
bzero(totalwordstest,strsize + 1);
strcat(totalwordstest, strx);
totp = strtok(totalwordstest, "/");
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
//and second word:
int firstorsecond = 1; //1=Protocol && 2 = Address
char pstring[800];//We do not want to harm the initial string.
bzero(pstring,800);
char pstring[strsize + 1];//We do not want to harm the initial string.
bzero(pstring,strsize + 1);
strcat(pstring,strx);
//Starting to extract words and process them:
char * wp;