src/power/linux/SDL_syspower.c
changeset 3186 51750b7a966f
parent 3174 c8b9c6d27476
child 3203 790cbbda6429
     1.1 --- a/src/power/linux/SDL_syspower.c	Wed Jun 10 08:09:04 2009 +0000
     1.2 +++ b/src/power/linux/SDL_syspower.c	Wed Jun 10 13:34:20 2009 +0000
     1.3 @@ -34,28 +34,28 @@
     1.4  #include "SDL_power.h"
     1.5  
     1.6  SDL_bool
     1.7 -SDL_GetPowerInfo_Linux_sys_power(SDL_PowerState *state,
     1.8 +SDL_GetPowerInfo_Linux_sys_power(SDL_PowerState * state,
     1.9                                   int *seconds, int *percent)
    1.10  {
    1.11 -    return SDL_FALSE;  /* !!! FIXME: write me. */
    1.12 +    return SDL_FALSE;           /* !!! FIXME: write me. */
    1.13  #if 0
    1.14      const int fd = open("/sys/power", O_RDONLY);
    1.15      if (fd == -1) {
    1.16 -        return SDL_FALSE;  /* can't use this interface. */
    1.17 +        return SDL_FALSE;       /* can't use this interface. */
    1.18      }
    1.19      return SDL_TRUE;
    1.20  #endif
    1.21  }
    1.22  
    1.23  SDL_bool
    1.24 -SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState *state,
    1.25 -				 int *seconds, int *percent)
    1.26 +SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState * state,
    1.27 +                                 int *seconds, int *percent)
    1.28  {
    1.29 -    return SDL_FALSE;  /* !!! FIXME: write me. */
    1.30 +    return SDL_FALSE;           /* !!! FIXME: write me. */
    1.31  #if 0
    1.32      const int fd = open("/proc/acpi", O_RDONLY);
    1.33      if (fd == -1) {
    1.34 -        return SDL_FALSE;  /* can't use this interface. */
    1.35 +        return SDL_FALSE;       /* can't use this interface. */
    1.36      }
    1.37      return SDL_TRUE;
    1.38  #endif
    1.39 @@ -67,7 +67,7 @@
    1.40      char *ptr = *_ptr;
    1.41      char *str = *_str;
    1.42  
    1.43 -    while (*ptr == ' ') {  /* skip any spaces... */
    1.44 +    while (*ptr == ' ') {       /* skip any spaces... */
    1.45          ptr++;
    1.46      }
    1.47  
    1.48 @@ -91,14 +91,14 @@
    1.49  int_string(char *str, int *val)
    1.50  {
    1.51      char *endptr = NULL;
    1.52 -    *val = (int) strtol(str+2, &endptr, 16);
    1.53 +    *val = (int) strtol(str + 2, &endptr, 16);
    1.54      return ((*str != '\0') && (*endptr == '\0'));
    1.55  }
    1.56  
    1.57  /* http://lxr.linux.no/linux+v2.6.29/drivers/char/apm-emulation.c */
    1.58  SDL_bool
    1.59 -SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState *state,
    1.60 -				int *seconds, int *percent)
    1.61 +SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState * state,
    1.62 +                                int *seconds, int *percent)
    1.63  {
    1.64      SDL_bool need_details = SDL_FALSE;
    1.65      int ac_status = 0;
    1.66 @@ -113,44 +113,44 @@
    1.67      ssize_t br;
    1.68  
    1.69      if (fd == -1) {
    1.70 -        return SDL_FALSE;  /* can't use this interface. */
    1.71 +        return SDL_FALSE;       /* can't use this interface. */
    1.72      }
    1.73  
    1.74 -    br = read(fd, buf, sizeof (buf) - 1);
    1.75 +    br = read(fd, buf, sizeof(buf) - 1);
    1.76      close(fd);
    1.77  
    1.78      if (br < 0) {
    1.79          return SDL_FALSE;
    1.80      }
    1.81  
    1.82 -    buf[br] = '\0';  // null-terminate the string.
    1.83 -    if (!next_string(&ptr, &str)) {  /* driver version */
    1.84 +    buf[br] = '\0';             // null-terminate the string.
    1.85 +    if (!next_string(&ptr, &str)) {     /* driver version */
    1.86          return SDL_FALSE;
    1.87      }
    1.88 -    if (!next_string(&ptr, &str)) {  /* BIOS version */
    1.89 +    if (!next_string(&ptr, &str)) {     /* BIOS version */
    1.90          return SDL_FALSE;
    1.91      }
    1.92 -    if (!next_string(&ptr, &str)) {  /* APM flags */
    1.93 +    if (!next_string(&ptr, &str)) {     /* APM flags */
    1.94          return SDL_FALSE;
    1.95      }
    1.96  
    1.97 -    if (!next_string(&ptr, &str)) {  /* AC line status */
    1.98 +    if (!next_string(&ptr, &str)) {     /* AC line status */
    1.99          return SDL_FALSE;
   1.100      } else if (!int_string(str, &ac_status)) {
   1.101          return SDL_FALSE;
   1.102      }
   1.103  
   1.104 -    if (!next_string(&ptr, &str)) {  /* battery status */
   1.105 +    if (!next_string(&ptr, &str)) {     /* battery status */
   1.106          return SDL_FALSE;
   1.107      } else if (!int_string(str, &battery_status)) {
   1.108          return SDL_FALSE;
   1.109      }
   1.110 -    if (!next_string(&ptr, &str)) {  /* battery flag */
   1.111 +    if (!next_string(&ptr, &str)) {     /* battery flag */
   1.112          return SDL_FALSE;
   1.113      } else if (!int_string(str, &battery_flag)) {
   1.114          return SDL_FALSE;
   1.115      }
   1.116 -    if (!next_string(&ptr, &str)) {  /* remaining battery life percent */
   1.117 +    if (!next_string(&ptr, &str)) {     /* remaining battery life percent */
   1.118          return SDL_FALSE;
   1.119      }
   1.120      if (str[strlen(str) - 1] == '%') {
   1.121 @@ -160,27 +160,27 @@
   1.122          return SDL_FALSE;
   1.123      }
   1.124  
   1.125 -    if (!next_string(&ptr, &str)) {  /* remaining battery life time */
   1.126 +    if (!next_string(&ptr, &str)) {     /* remaining battery life time */
   1.127          return SDL_FALSE;
   1.128      } else if (!int_string(str, &battery_time)) {
   1.129          return SDL_FALSE;
   1.130      }
   1.131  
   1.132 -    if (!next_string(&ptr, &str)) {  /* remaining battery life time units */
   1.133 +    if (!next_string(&ptr, &str)) {     /* remaining battery life time units */
   1.134          return SDL_FALSE;
   1.135      } else if (strcmp(str, "min") == 0) {
   1.136          battery_time *= 60;
   1.137      }
   1.138  
   1.139 -    if (battery_flag == 0xFF) {  /* unknown state */
   1.140 +    if (battery_flag == 0xFF) { /* unknown state */
   1.141          *state = SDL_POWERSTATE_UNKNOWN;
   1.142 -    } else if (battery_flag & (1 << 7)) {  /* no battery */
   1.143 +    } else if (battery_flag & (1 << 7)) {       /* no battery */
   1.144          *state = SDL_POWERSTATE_NO_BATTERY;
   1.145 -    } else if (battery_flag & (1 << 3)) {  /* charging */
   1.146 +    } else if (battery_flag & (1 << 3)) {       /* charging */
   1.147          *state = SDL_POWERSTATE_CHARGING;
   1.148          need_details = SDL_TRUE;
   1.149      } else if (ac_status == 1) {
   1.150 -        *state = SDL_POWERSTATE_CHARGED;  /* on AC, not charging. */
   1.151 +        *state = SDL_POWERSTATE_CHARGED;        /* on AC, not charging. */
   1.152          need_details = SDL_TRUE;
   1.153      } else {
   1.154          *state = SDL_POWERSTATE_ON_BATTERY;
   1.155 @@ -193,10 +193,10 @@
   1.156          const int pct = battery_percent;
   1.157          const int secs = battery_time;
   1.158  
   1.159 -        if (pct >= 0) {  /* -1 == unknown */
   1.160 -            *percent = (pct > 100) ? 100 : pct;  /* clamp between 0%, 100% */
   1.161 +        if (pct >= 0) {         /* -1 == unknown */
   1.162 +            *percent = (pct > 100) ? 100 : pct; /* clamp between 0%, 100% */
   1.163          }
   1.164 -        if (secs >= 0) {  /* -1 == unknown */
   1.165 +        if (secs >= 0) {        /* -1 == unknown */
   1.166              *seconds = secs;
   1.167          }
   1.168      }
   1.169 @@ -208,4 +208,3 @@
   1.170  #endif /* SDL_POWER_DISABLED */
   1.171  
   1.172  /* vi: set ts=4 sw=4 expandtab: */
   1.173 -