mirror of
https://github.com/yoboujon/tsock.git
synced 2025-06-08 05:50:50 +02:00
Merge pull request #11 from yoboujon/simon
recuperationParam et int2String
This commit is contained in:
commit
df63755693
3 changed files with 45 additions and 4 deletions
|
@ -27,4 +27,6 @@ int convertion(int nbr,char *numbuffer);
|
|||
int gestionOffset(char *actualMessage,int encadrementHaut,int encadrementBas,int nbr);
|
||||
int testProtocol(void);
|
||||
|
||||
int recuperationParam(char * msgParam);
|
||||
int int2String(char *msgParam, int offset);
|
||||
#endif
|
|
@ -7,7 +7,7 @@ int main (int argc, char **argv)
|
|||
{
|
||||
char usageChar[100]="usage: cmd [-p|-s]|[-u][-u|-r ##|-e ##|-b][-n ##][-l ##] port ipAdress\n";
|
||||
testProtocol();
|
||||
bal();
|
||||
//bal();
|
||||
char *ipAddress;
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
|
|
45
src/tsock.c
45
src/tsock.c
|
@ -83,14 +83,53 @@ int exitMax(int var,int tailleMax){
|
|||
|
||||
int testProtocol(void)
|
||||
{
|
||||
char * msg;
|
||||
char * msg,*msg2;
|
||||
msg=formatTextParam(7, 8, 64, 1);
|
||||
printf("%s\n",msg);
|
||||
msg=formatTextMessage("aaaaaa",6);
|
||||
printf("%s\n",msg);
|
||||
msg2=formatTextMessage("aaaaaa",6);
|
||||
printf("%s\n",msg2);
|
||||
|
||||
recuperationParam(msg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int recuperationParam(char * msgParam)
|
||||
{
|
||||
|
||||
int messageOrPram;
|
||||
int numEmetteurParam;
|
||||
int numRecepeteurParam;
|
||||
int numTailleMessageParam;
|
||||
int nbMessageParam;
|
||||
printf("Message param %s\n",msgParam);
|
||||
messageOrPram=msgParam[0]-0x30;
|
||||
printf("messageOrPram = %d \n",messageOrPram);
|
||||
|
||||
numEmetteurParam = int2String(msgParam,1);
|
||||
printf("Param Emetteur = %d\n",numEmetteurParam);
|
||||
|
||||
numRecepeteurParam= int2String(msgParam,5);
|
||||
printf("Param numRecepeteurParam = %d\n",numRecepeteurParam);
|
||||
|
||||
numTailleMessageParam= int2String(msgParam,9);
|
||||
printf("Param numTailleMessageParam = %d\n",numTailleMessageParam);
|
||||
|
||||
nbMessageParam=int2String(msgParam,13);
|
||||
printf("Param nbMessageParam = %d\n",nbMessageParam);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int int2String(char *msgParam, int offset)
|
||||
{
|
||||
int taille =4;
|
||||
char buffEntier[taille];
|
||||
for(int i=offset,j=0;i<=offset+taille;i++,j++){
|
||||
buffEntier[j]=msgParam[i];
|
||||
}
|
||||
return atoi(buffEntier);
|
||||
}
|
||||
|
||||
char * formatTextParam(int numEmetteur, int numRecepteur, int tailleMessage, int nbMessage)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue