Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 165989
Collapse All | Expand All

(-)panel-plugin/libacpi.c~ (-3 / +20 lines)
Lines 30-35 Link Here
30
#include <stdlib.h>
30
#include <stdlib.h>
31
#include <sys/types.h>
31
#include <sys/types.h>
32
#include <dirent.h>
32
#include <dirent.h>
33
#include <glob.h>
33
34
34
#if HAVE_SYSCTL
35
#if HAVE_SYSCTL
35
36
Lines 181-186 Link Here
181
#endif
182
#endif
182
#endif
183
#endif
183
184
185
/* expand file name and fopen first match */
186
static FILE *
187
fopen_glob(const char *name, const char *mode)
188
{
189
  glob_t globbuf;
190
  FILE *fd;
191
192
  if (glob(name, 0, NULL, &globbuf) != 0)
193
    return NULL;
194
195
  fd = fopen(globbuf.gl_pathv[0], mode);
196
  globfree(&globbuf);
197
198
  return fd;
199
}
200
184
/* see if we have ACPI support */
201
/* see if we have ACPI support */
185
int check_acpi(void)
202
int check_acpi(void)
186
{
203
{
Lines 693-699 Link Here
693
    	  else return 0;
710
    	  else return 0;
694
    }
711
    }
695
    proc_fan_status="/proc/acpi/fan/*/state";
712
    proc_fan_status="/proc/acpi/fan/*/state";
696
    if ( (fp=fopen(proc_fan_status, "r")) == NULL ) return 0;
713
    if ( (fp=fopen_glob(proc_fan_status, "r")) == NULL ) return 0;
697
714
698
    fgets(line,255,fp);
715
    fgets(line,255,fp);
699
    fclose(fp);
716
    fclose(fp);
Lines 706-715 Link Here
706
{
723
{
707
#ifdef __linux__
724
#ifdef __linux__
708
  FILE *fp;
725
  FILE *fp;
709
  char *proc_temperature="/proc/acpi/thermal_zone/*0/temperature";
726
  char *proc_temperature="/proc/acpi/thermal_zone/*/temperature";
710
  static char *p,line[256];
727
  static char *p,line[256];
711
728
712
  if ( (fp=fopen(proc_temperature, "r")) == NULL) return NULL;
729
  if ( (fp=fopen_glob(proc_temperature, "r")) == NULL) return NULL;
713
  fgets(line,255,fp);
730
  fgets(line,255,fp);
714
  fclose(fp);
731
  fclose(fp);
715
  p=strtok(line," ");
732
  p=strtok(line," ");

Return to bug 165989