Advertisement
Guest User

Untitled

a guest
Mar 14th, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. Output
  2.  
  3. 192.168.2.2|
  4. -------
  5. ===================================================================
  6.  
  7. file to read:
  8. Cycle           : 7
  9. Server          : 192.168.2.2|
  10. Mac             : B8:27:EB:BF:08:BB
  11. =======================================================================
  12. Code:
  13.  
  14. #include "Read.h"
  15.  
  16. char temp[30];
  17. r.readAED(temp);
  18.  
  19. std::cout << temp << "-----------" std::endl;
  20. server = gethostbyname(temp);
  21.  
  22. void Read::readServer(char* type){
  23.     FILE *f = fopen("/etc/device", "r");
  24.     if (!f) {
  25.        //Send Serial to Server.
  26.     //return "e";
  27.     }
  28.  
  29.     char line[256];
  30.  
  31.     char serial_string[30];
  32.     while (fgets(line, 50, f)) {
  33.         if (strncmp(line, "Server", 6) == 0) {
  34.  
  35.             atoi(strcpy(serial_string, strchr(line, ':') + 2));
  36.             for (int i = 0; i < 30; ++i) {
  37.                 if (serial_string != " ")
  38.                     type[i] = serial_string[i];
  39.                 else
  40.                     type[i] = '_';
  41.             }
  42.  
  43.             fclose(f);
  44.  
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement