Changeset 120

Show
Ignore:
Timestamp:
12/25/98 23:15:48 (14 years ago)
Author:
frodo
Message:

Some library cleanup; no interface changes

Location:
lm-sensors/trunk/lib
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/lib/access.c

    r119 r120  
    5959   you want the match that was latest in the config file. */ 
    6060sensors_chip *sensors_for_all_config_chips(sensors_chip_name chip_name,  
    61                                            sensors_chip *last) 
     61                                           const sensors_chip *last) 
    6262{ 
    6363  int nr,i; 
     
    7878   Do not modify the struct the return value points to! Returns NULL if  
    7979   not found.*/ 
    80 sensors_chip_feature *sensors_lookup_feature_nr(const char *prefix, int feature) 
     80const sensors_chip_feature *sensors_lookup_feature_nr(const char *prefix,  
     81                                                      int feature) 
    8182{ 
    8283  int i,j; 
    83   sensors_chip_feature *features; 
     84  const sensors_chip_feature *features; 
    8485  for (i = 0; sensors_chip_features_list[i].prefix; i++) 
    8586    if (!strcmp(sensors_chip_features_list[i].prefix,prefix)) { 
     
    9596   Do not modify the struct the return value points to! Returns NULL if  
    9697   not found.*/ 
    97 sensors_chip_feature *sensors_lookup_feature_name(const char *prefix, 
    98                                                   const char *feature) 
     98const sensors_chip_feature *sensors_lookup_feature_name(const char *prefix, 
     99                                                        const char *feature) 
    99100{ 
    100101  int i,j; 
    101   sensors_chip_feature *features; 
     102  const sensors_chip_feature *features; 
    102103  for (i = 0; sensors_chip_features_list[i].prefix; i++) 
    103104    if (!strcmp(sensors_chip_features_list[i].prefix,prefix)) { 
     
    130131int sensors_get_label(sensors_chip_name name, int feature, char **result) 
    131132{ 
    132   sensors_chip *chip; 
    133   sensors_chip_feature *featureptr; 
     133  const sensors_chip *chip; 
     134  const sensors_chip_feature *featureptr; 
    134135  int i; 
    135136 
     
    152153/* Read the value of a feature of a certain chip. Note that chip should not 
    153154   contain wildcard values! This function will return 0 on success, and <0 
    154    on failure.  */ 
     155   on failure. */ 
    155156int sensors_get_feature(sensors_chip_name name, int feature, double *result) 
    156157{ 
    157   sensors_chip_feature *main_feature; 
    158   sensors_chip_feature *alt_feature; 
    159   sensors_chip *chip; 
    160   sensors_expr *expr = NULL; 
     158  const sensors_chip_feature *main_feature; 
     159  const sensors_chip_feature *alt_feature; 
     160  const sensors_chip *chip; 
     161  const sensors_expr *expr = NULL; 
    161162  double val; 
    162163  int res,i; 
     
    195196/* Set the value of a feature of a certain chip. Note that chip should not 
    196197   contain wildcard values! This function will return 0 on success, and <0 
    197    on failure. */ 
     198   on failure. BUGGY! */ 
    198199int sensors_set_feature(sensors_chip_name name, int feature, double value) 
    199200{ 
    200   sensors_chip_feature *featureptr; 
    201   sensors_chip *chip; 
    202   sensors_expr *expr = NULL; 
     201  const sensors_chip_feature *featureptr; 
     202  const sensors_chip *chip; 
     203  const sensors_expr *expr = NULL; 
    203204  int i,res; 
    204205 
     
    281282} 
    282283 
    283 int sensors_eval_expr(sensors_chip_name chipname, sensors_expr *expr, 
     284int sensors_eval_expr(sensors_chip_name chipname, const sensors_expr *expr, 
    284285                      double val, double *result) 
    285286{ 
    286287  double res1,res2; 
    287288  int res; 
    288   sensors_chip_feature *feature; 
     289  const sensors_chip_feature *feature; 
    289290 
    290291  if (expr->kind == sensors_kind_val) { 
     
    330331  return 0; 
    331332} 
    332  
    333        
  • lm-sensors/trunk/lib/access.h

    r119 r120  
    3232   you want the match that was latest in the config file. */ 
    3333extern sensors_chip *sensors_for_all_config_chips(sensors_chip_name chip_name, 
    34                                                   sensors_chip *last); 
     34                                                  const sensors_chip *last); 
    3535 
    3636/* Look up a resource in the intern chip list, and return a pointer to it. 
    3737   Do not modify the struct the return value points to! Returns NULL if 
    3838   not found. */ 
    39 extern sensors_chip_feature *sensors_lookup_feature_nr(const char *prefix, 
    40                                                        int feature); 
     39extern const sensors_chip_feature *sensors_lookup_feature_nr(const char *prefix, 
     40                                                             int feature); 
    4141 
    4242/* Look up a resource in the intern chip list, and return a pointer to it. 
    4343   Do not modify the struct the return value points to! Returns NULL if 
    4444   not found.*/ 
    45 extern sensors_chip_feature *sensors_lookup_feature_name(const char *prefix, 
    46                                                         const char *feature); 
     45extern const sensors_chip_feature *sensors_lookup_feature_name 
     46                                  (const char *prefix, const char *feature); 
    4747 
    4848/* Substitute configuration bus numbers with real-world /proc bus numbers 
     
    5656 
    5757/* Evaluate an expression */ 
    58 extern int sensors_eval_expr(sensors_chip_name chipname, sensors_expr *expr, 
     58extern int sensors_eval_expr(sensors_chip_name chipname,  
     59                             const sensors_expr *expr, 
    5960                             double val, double *result); 
    6061 
  • lm-sensors/trunk/lib/error.c

    r97 r120  
    5353void sensors_default_parse_error(const char *err, int lineno) 
    5454{ 
    55   fprintf(stderr,"Line %d: %s\n",lineno,err); 
     55  fprintf(stderr,"Error: Line %d: %s\n",lineno,err); 
    5656} 
    5757 
  • lm-sensors/trunk/lib/proc.c

    r101 r120  
    6868  char *bufptr = buf; 
    6969  sensors_proc_chips_entry entry; 
    70   int res; 
     70  int res,lineno; 
    7171 
    7272  if (sysctl(name, 3, bufptr, &buflen, NULL, 0)) 
    7373    return -SENSORS_ERR_PROC; 
    7474 
     75  lineno = 1; 
    7576  while (buflen >= sizeof(struct sensors_chips_data)) { 
    7677    if ((res =  
    7778          sensors_parse_chip_name(((struct sensors_chips_data *) bufptr)->name,  
    78                                    &entry.name))) 
     79                                   &entry.name))) { 
     80      sensors_parse_error("Parsing /proc/sys/dev/sensors/chips",lineno); 
    7981      return res; 
     82    } 
    8083    entry.sysctl = ((struct sensors_chips_data *) bufptr)->sysctl_id; 
    8184    add_proc_chips(&entry); 
    8285    bufptr += sizeof(struct sensors_chips_data); 
    8386    buflen -= sizeof(struct sensors_chips_data); 
     87    lineno++; 
    8488  } 
    8589  return 0; 
     
    9296  char *border; 
    9397  sensors_bus entry; 
     98  int lineno; 
     99 
    94100  f = fopen("/proc/bus/i2c","r"); 
    95101  if (!f) 
    96102    return -SENSORS_ERR_PROC; 
     103  lineno=1; 
    97104  while (fgets(line,255,f)) { 
    98105    if (strlen(line) > 0) 
     
    118125    sensors_strip_of_spaces(entry.adapter); 
    119126    add_bus(&entry); 
     127    lineno++; 
    120128  } 
    121129  fclose(f); 
     
    124132  sensors_fatal_error("sensors_read_proc_bus","Allocating entry"); 
    125133ERROR: 
     134  sensors_parse_error("Parsing /proc/bus/i2c",lineno); 
    126135  fclose(f); 
    127136  return -SENSORS_ERR_PROC; 
     
    143152{ 
    144153  int sysctl_name[4] = { CTL_DEV, DEV_SENSORS }; 
    145   sensors_chip_feature *the_feature; 
     154  const sensors_chip_feature *the_feature; 
    146155  int buflen = BUF_LEN; 
    147156  int mag; 
     
    165174{ 
    166175  int sysctl_name[4] = { CTL_DEV, DEV_SENSORS }; 
    167   sensors_chip_feature *the_feature; 
     176  const sensors_chip_feature *the_feature; 
    168177  int buflen = BUF_LEN; 
    169178  int mag;