Don't use sscanf

SVN revision: 17955
This commit is contained in:
sebastid 2005-10-25 10:41:28 +00:00 committed by sebastid
parent 8bcf7ebd02
commit 12a0d6d9bd
1 changed files with 13 additions and 5 deletions

View File

@ -1059,21 +1059,29 @@ _temperature_cb_check(void *data)
{ {
char *name; char *name;
ret = 1;
while ((name = ecore_list_next(therms))) while ((name = ecore_list_next(therms)))
{ {
char units[32]; char *p, *q;
FILE *f; FILE *f;
snprintf(buf, sizeof(buf), "/proc/acpi/thermal_zone/%s/temperature", name); snprintf(buf, sizeof(buf), "/proc/acpi/thermal_zone/%s/temperature", name);
f = fopen(buf, "rb"); f = fopen(buf, "rb");
if (f) if (f)
{ {
fgets(buf, sizeof(buf), f); buf[sizeof(buf) - 1] = 0; fgets(buf, sizeof(buf), f); buf[sizeof(buf) - 1] = 0;
units[0] = 0;
if (sscanf(buf, "%*[^:]: %i %20s", &temp, units) == 2)
ret = 1;
fclose(f); fclose(f);
p = strchr(buf, ':');
if (!p)
{
ret = 0;
continue;
}
p++;
while (*p == ' ') p++;
q = strchr(p, ' ');
if (q) *q = 0;
temp = atoi(p);
} }
} }
ecore_list_destroy(therms); ecore_list_destroy(therms);