Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //EL STRUCT
- typedef struct{
- char *username;
- char *password;
- struct USUARIO *proximo;
- }USUARIO;
- //LO LLENO ASI :
- lista = (USUARIO *)malloc(sizeof(USUARIO *));
- lista->username ="cromestant";
- lista->password="12345";
- USUARIO *auxu =(USUARIO *)lista->proximo;
- auxu = (USUARIO *)malloc(sizeof(USUARIO *));
- auxu->username ="cromestant";
- auxu->password ="testpassword";
- //funcion que hace el tokenizing del payload ( payload es del tipo username::password::action
- //y busca hacer un match
- //lista es una variable global que es el primer nodo de la lista enlazada de USUARIO.
- int processAP(unsigned char * tempap,int sizeAP)
- {
- char *token;
- char delims[]=":";
- unsigned char AP[sizeAP];
- int i=0;
- memcpy(AP,tempap,sizeAP);
- USUARIO *temp ;
- printf("LLEGUE");
- char *uname = NULL;
- char *passwd =NULL;
- char *action =NULL;
- uname = strtok( AP, delims );
- if( uname != NULL )
- {
- passwd = strtok(NULL,delims);
- }
- if (passwd !=NULL)
- {
- action = strtok(NULL,delims);
- }//se recibio un token semi-valido, por lo menos tiene la estructura adecuada.
- if ((uname!=NULL)&&(passwd!=NULL)&&(action!=NULL)){
- temp = lista;
- while(temp!= NULL){
- if (strcmp(temp->username,uname)==0)
- {
- //username exists
- printf("username OK! %d\n",i);
- if(strcmp(temp->password,passwd)==0)
- {
- //password ok
- printf("password OK!\n");
- return 1;
- }else{
- printf("password not ok %d\n",i);
- }
- }
- temp =(USUARIO *)temp->proximo;
- i++;
- }
- }
- return 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement