Hi:

This is how I get info from the server. The server sends it in "struct risp" format
Qt Code:
  1. void MainWindow::getSysStat() {
  2. /* create the system info strusture that will hold information about the server */
  3. sysInfo = (struct risp *)malloc(sizeof(struct risp));
  4. //sysInfo->running_kernel = (char *)malloc(sizeof(char) * LONGEST_KERNEL_NAME);
  5. //sysInfo->fsStat->name = (char *)malloc(sizeof(char) * LONGEST_NAME);
  6. //sysInfo->fsStat->devName = (char *)malloc(sizeof(char) * LONGEST_NAME);
  7.  
  8. /* wait until the socket gets connected */
  9. if(socket->waitForConnected(-1)) {
  10. /* wait until data gets available */
  11. if(socket->waitForReadyRead(-1)) {
  12. /* read from the socket */
  13. char *dataRead = (char *)malloc(sizeof(char)*sizeof(struct risp));
  14. if((socket->read(dataRead, sizeof(struct risp))) == -1)
  15. qDebug() << "Error reading data from server";
  16.  
  17. /* cast the data to match the risp structure */
  18. sysInfo = (struct risp *)dataRead;
  19. //qDebug() << "total cpu is: " << sysInfo->total_cpu;
  20. }
  21. }
  22.  
  23. }
To copy to clipboard, switch view to plain text mode 

Here is struct risp:

Qt Code:
  1. struct risp {
  2. /* cpu info */
  3. unsigned long cpu_usage; /* /proc/ */
  4. unsigned long total_cpu; /* /proc/cpuinfo */
  5. //char proc_name[LONGEST_PROC_NAME]; /* /proc/ */
  6. //char *cpu_processes[NUMBER_OF_PROCESSES]; /* /proc/ */
  7.  
  8. /* ram info */
  9. unsigned int ram_usage; /* /proc/meminfo */
  10. unsigned int total_ram; /* /proc/meminfo */
  11. //char *ram_processes[NUMBER_OF_PROCESSES]; /* /proc/ */
  12.  
  13. /* swap info */
  14. unsigned int swap_usage; /* /proc/meminfo */
  15. unsigned int total_swap; /* /proc/swaps */
  16.  
  17. /* filesystems */
  18. struct fsMountList *fsStat;
  19. unsigned short int numFs;
  20.  
  21. /* kernel info */
  22. char *running_kernel; /* /proc/ */
  23.  
  24. float uptime; /* /proc/uptime -> the first number is the uptime in seconds */
  25. unsigned short int num_users; /* /proc */
  26. unsigned short int num_processes;
  27. unsigned short int num_running_processes; /* /proc/stat -> procs_running */
  28. char arips_included; /* 0/1 */
  29.  
  30. };
To copy to clipboard, switch view to plain text mode 


The problem is this:

Qt Code:
  1. qDebug("Kernel: %s", sysInfo->running_kernel);
To copy to clipboard, switch view to plain text mode 
it displays noting like ti should: it should display: "2.5.25"

So does anybody see what's the problem ?