2 * seti.c: information about SETI for Conky
12 char *seti_dir = NULL;
15 * Need to code for BOINC, because the old SETI@Home does not use xml to store data.
16 * Perhaps in the .conkyrc file there could be an option for BOINC or old SETI.
19 /*static float seti_get_float (FILE *fp, const char *name)
24 while (!feof(fp) && !ferror (fp))
26 fgets(buffer, 80, fp);
27 token = strtok(buffer, ">");
29 if (strcmp(token, name) == 0)
31 token = strtok(NULL, "<");
40 float seti_get_data(FILE * fp, const char *name)
46 while (fgets(token, 1000, fp) != NULL) //read the file
47 if (strncmp(token, name, strlen(name)) == 0) { //and search for the data in name
48 strcpy(buffer, strchr(token, '=') + 1); //copy just the number
62 struct information *current_info = &info;
64 current_info->seti_prog = current_info->seti_credit = 0.0f;
66 /* read total user credit */
68 /*FILE *fp = fopen(filename, "r");
72 seti_credit = seti_get_float(fp, "<user_total_credit");
76 snprintf(filename, 80, "%s/user_info.sah", seti_dir);
78 FILE *fp = fopen(filename, "r");
84 current_info->seti_credit = seti_get_data(fp, "nresults");
88 /* read current progress */
90 /*snprintf(filename, 80, "%s/slots/0/state.sah", seti_dir);
91 fp = fopen(filename, "r");
95 seti_prog = seti_get_float(fp, "<prog");
99 snprintf(filename, 80, "%s/slots/0/init_data.xml", seti_dir); */
101 snprintf(filename, 80, "%s/state.sah", seti_dir);
103 fp = fopen(filename, "r");
107 current_info->seti_prog = seti_get_data(fp, "prog");