Advertisement
Guest User

Untitled

a guest
May 6th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.54 KB | None | 0 0
  1. int loadPrefs(){
  2.         char todo[256],*uname,*password;
  3.         printf("Cagando configuraciones.%s \n","lista de archivos");
  4.         FILE *in;
  5.         in=fopen("configs/authusers.spa","r");
  6.  
  7.         lista=NULL;
  8.  
  9.         if (in==NULL){
  10.         printf("Error al abrir el archivo de configuracion configs/authusers.spa");
  11.         return -1;
  12.         }
  13.         while (fgets(&todo,256,in)!=NULL)
  14.         {
  15.                 uname=strtok(&todo,"=");
  16.                 password =strtok(NULL,"\n");
  17.                 printf("added %s : %s\n",uname,password);
  18.                 lista=addUser(uname,password,lista);
  19.                 //auxu=auxu->proximo;
  20.         }
  21.         fclose(in);
  22.         printList();
  23.         return 1;
  24. }
  25.  
  26.  
  27.  
  28.  
  29. ///////////////////////////////////////////////////////////////////////////////////////////////////
  30. USUARIO * addUser(char *uname,char *passwd,USUARIO *lista)
  31. {
  32.         USUARIO *aux=lista;
  33.         if (lista!=NULL)
  34.         {
  35.                 while(lista->proximo!=NULL)
  36.                 {                        lista= lista->proximo;
  37.                 }
  38.                 lista->proximo =(USUARIO *) malloc(sizeof(USUARIO *));
  39.                 lista = lista->proximo;
  40.                 lista->username= uname;
  41.                 lista->password=passwd;
  42.                 lista->proximo=NULL;
  43.                 printf("here second\nuname to add %s\npasswd :%s\n",lista->username,lista->passwor
  44. d);                return aux;
  45.         }else
  46.         {
  47.                 lista = (USUARIO *)malloc(sizeof(USUARIO *));
  48.                 lista->proximo=NULL;
  49.                 lista->username=uname;
  50.                 lista->password=passwd;
  51.                 printf("empty\nuname to add :%s\npasword to add :%s\n",lista->username,lista->pass
  52. word);
  53.                 return lista;
  54.         }
  55.  
  56. }
  57.  
  58. //////////////////////////////
  59.  
  60.  
  61.  
  62. void printList()
  63. {
  64.         if (lista==NULL){
  65.                 printf("Lista vacia\n");
  66.         }else
  67.         {
  68.                 USUARIO *current = lista;
  69.                 int asd =0;
  70.                 while (current!=NULL)
  71.                 {
  72.                         printf("nodo %d : %s -> %s|longitud :%d \n",asd,current->username,current->password,strlen(current->password));
  73.                         current=current->proximo;
  74.                         asd++;
  75.                 }
  76.         }
  77. }
  78.  
  79.  
  80.  
  81.  
  82. //////////
  83.  
  84.  
  85.  
  86.  
  87. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  88. ////////////////////////////////////////////////////////////Sample/////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////output/////////////////////////////////////////////////////////////////////////////////////
  89.  
  90.  
  91.  
  92.  
  93. added cromestant : 12345
  94. empty
  95. uname to add :cromestant
  96. pasword to add :12345
  97. added alebe : 54321
  98. here second
  99. uname to add alebe
  100. passwd :54321
  101. added chris : poisa
  102. here second
  103. uname to add chris
  104. passwd :poisa
  105. added chachopo : asdas
  106. here second
  107. uname to add chachopo
  108. passwd :asdas
  109. nodo 0 : chachopo -> das|longitud :3
  110. nodo 1 : chachopo -> po|longitud :2
  111. nodo 2 : chachopo -> po|longitud :2
  112. nodo 3 : chachopo -> asdas|longitud :5
  113. Abri dispositivo : eth0
  114.  
  115.  
  116.  
  117. //////
  118.  
  119. ////// 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