Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int loadPrefs(){
- char todo[256],*uname,*password;
- printf("Cagando configuraciones.%s \n","lista de archivos");
- FILE *in;
- in=fopen("configs/authusers.spa","r");
- lista=NULL;
- if (in==NULL){
- printf("Error al abrir el archivo de configuracion configs/authusers.spa");
- return -1;
- }
- while (fgets(&todo,256,in)!=NULL)
- {
- uname=strtok(&todo,"=");
- password =strtok(NULL,"\n");
- printf("added %s : %s\n",uname,password);
- lista=addUser(uname,password,lista);
- //auxu=auxu->proximo;
- }
- fclose(in);
- printList();
- return 1;
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- USUARIO * addUser(char *uname,char *passwd,USUARIO *lista)
- {
- USUARIO *aux=lista;
- if (lista!=NULL)
- {
- while(lista->proximo!=NULL)
- { lista= lista->proximo;
- }
- lista->proximo =(USUARIO *) malloc(sizeof(USUARIO *));
- lista = lista->proximo;
- lista->username= uname;
- lista->password=passwd;
- lista->proximo=NULL;
- printf("here second\nuname to add %s\npasswd :%s\n",lista->username,lista->passwor
- d); return aux;
- }else
- {
- lista = (USUARIO *)malloc(sizeof(USUARIO *));
- lista->proximo=NULL;
- lista->username=uname;
- lista->password=passwd;
- printf("empty\nuname to add :%s\npasword to add :%s\n",lista->username,lista->pass
- word);
- return lista;
- }
- }
- //////////////////////////////
- void printList()
- {
- if (lista==NULL){
- printf("Lista vacia\n");
- }else
- {
- USUARIO *current = lista;
- int asd =0;
- while (current!=NULL)
- {
- printf("nodo %d : %s -> %s|longitud :%d \n",asd,current->username,current->password,strlen(current->password));
- current=current->proximo;
- asd++;
- }
- }
- }
- //////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////Sample/////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////output/////////////////////////////////////////////////////////////////////////////////////
- added cromestant : 12345
- empty
- uname to add :cromestant
- pasword to add :12345
- added alebe : 54321
- here second
- uname to add alebe
- passwd :54321
- added chris : poisa
- here second
- uname to add chris
- passwd :poisa
- added chachopo : asdas
- here second
- uname to add chachopo
- passwd :asdas
- nodo 0 : chachopo -> das|longitud :3
- nodo 1 : chachopo -> po|longitud :2
- nodo 2 : chachopo -> po|longitud :2
- nodo 3 : chachopo -> asdas|longitud :5
- Abri dispositivo : eth0
- //////
- ////// Da peo como se puede ver los recorridos por los nodos no imprimen los valores impresos y verificados un poco mas arriba..
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement