1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 12:27:52 +00:00

get_adt746x_cpu() / get_adt746x_fan() interface changes as per bug 1355470

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@411 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Philip Kovacs 2005-11-13 04:04:00 +00:00
parent 223a9d128f
commit 79aacf1ea2
6 changed files with 59 additions and 42 deletions

View File

@ -4,8 +4,8 @@
* Replaced bitwise copy of tcp_connection_t with function * Replaced bitwise copy of tcp_connection_t with function
copy_tcp_connection(). copy_tcp_connection().
* Changed call interfaces for get_acpi_fan(), get_acpi_ac_adapter(), * Changed call interfaces for get_acpi_fan(), get_acpi_ac_adapter(),
get_freq(), get_freq_dynamic(), eliminating mallocs. pkovacs. get_freq(), get_freq_dynamic(), get_adt746x_cpu(), get_adt746x_fan(),
More to come. See bug 1355470. eliminating all mallocs. pkovacs. See bug 1355470.
2005-11-11 2005-11-11
* moved hash sizing code into portmon lib, where it belongs * moved hash sizing code into portmon lib, where it belongs

View File

@ -2053,16 +2053,16 @@ static void generate_text()
get_freq_dynamic(p, n, "%'.2f", 1000); /* pk */ get_freq_dynamic(p, n, "%'.2f", 1000); /* pk */
} }
OBJ(adt746xcpu) { OBJ(adt746xcpu) {
snprintf(p, n, "%s", get_adt746x_cpu()); get_adt746x_cpu(p, n); /* pk */
} }
OBJ(adt746xfan) { OBJ(adt746xfan) {
snprintf(p, n, "%s", get_adt746x_fan()); get_adt746x_fan(p, n); /* pk */
} }
OBJ(acpifan) { OBJ(acpifan) {
get_acpi_fan(p, n); /* pk */ get_acpi_fan(p, n); /* pk */
} }
OBJ(acpiacadapter) { OBJ(acpiacadapter) {
get_acpi_ac_adapter(p, n); get_acpi_ac_adapter(p, n); /* pk */
} }
OBJ(battery) { OBJ(battery) {
get_battery_stuff(p, n, obj->data.s); get_battery_stuff(p, n, obj->data.s);

View File

@ -326,8 +326,8 @@ int open_i2c_sensor(const char *dev, const char *type, int n, int *div,
char *devtype); char *devtype);
double get_i2c_info(int *fd, int arg, char *devtype, char *type); double get_i2c_info(int *fd, int arg, char *devtype, char *type);
char *get_adt746x_cpu(void); void get_adt746x_cpu( char *, size_t ); /* pk */
char *get_adt746x_fan(void); void get_adt746x_fan( char *, size_t ); /* pk */
unsigned int get_diskio(void); unsigned int get_diskio(void);
int open_acpi_temperature(const char *name); int open_acpi_temperature(const char *name);

View File

@ -399,19 +399,32 @@ void get_acpi_fan( char * p_client_buffer, size_t client_buffer_size )
if ( !p_client_buffer !! client_buffer_size <= 0 ) if ( !p_client_buffer !! client_buffer_size <= 0 )
return; return;
/* no implementation */ /* not implemented */
memset(p_client_buffer,0,client_buffer_size);
return; return;
} }
char *get_adt746x_cpu() void get_adt746x_cpu( char * p_client_buffer, size_t client_buffer_size )
{ {
return ""; if ( !p_client_buffer || client_buffer_size <= 0 )
return;
/* not implemented */
memset(p_client_buffer,0,client_buffer_size);
return;
} }
char *get_adt746x_fan() void get_adt746x_fan( char * p_client_buffer, size_t client_buffer_size )
{ {
return ""; if ( !p_client_buffer || client_buffer_size <= 0 )
return;
/* not implemented */
memset(p_client_buffer,0,client_buffer_size);
return;
} }
/* rdtsc() and get_freq_dynamic() copied from linux.c */ /* rdtsc() and get_freq_dynamic() copied from linux.c */

View File

@ -680,49 +680,54 @@ double get_i2c_info(int *fd, int div, char *devtype, char *type)
#define ADT746X_FAN "/sys/devices/temperatures/cpu_fan_speed" #define ADT746X_FAN "/sys/devices/temperatures/cpu_fan_speed"
static char *adt746x_fan_state; void get_adt746x_fan( char * p_client_buffer, size_t client_buffer_size )
char *get_adt746x_fan()
{ {
static int rep; static int rep;
char adt746x_fan_state[64];
FILE *fp; FILE *fp;
if (adt746x_fan_state == NULL) { if ( !p_client_buffer || client_buffer_size <= 0 )
adt746x_fan_state = (char *) malloc(100); return;
assert(adt746x_fan_state != NULL);
}
fp = open_file(ADT746X_FAN, &rep); fp = open_file(ADT746X_FAN, &rep);
if (!fp) { if (!fp)
strcpy(adt746x_fan_state, {
"No fan found! Hey, you don't have one?"); sprintf(adt746x_fan_state, "adt746x not found");
return adt746x_fan_state;
} }
else
{
fscanf(fp, "%s", adt746x_fan_state); fscanf(fp, "%s", adt746x_fan_state);
fclose(fp); fclose(fp);
}
return adt746x_fan_state; snprintf( p_client_buffer, client_buffer_size, "%s", adt746x_fan_state );
return;
} }
#define ADT746X_CPU "/sys/devices/temperatures/cpu_temperature" #define ADT746X_CPU "/sys/devices/temperatures/cpu_temperature"
static char *adt746x_cpu_state; void get_adt746x_cpu( char * p_client_buffer, size_t client_buffer_size )
char *get_adt746x_cpu()
{ {
static int rep; static int rep;
char adt746x_cpu_state[64];
FILE *fp; FILE *fp;
if (adt746x_cpu_state == NULL) { if ( !p_client_buffer || client_buffer_size <= 0 )
adt746x_cpu_state = (char *) malloc(100); return;
assert(adt746x_cpu_state != NULL);
}
fp = open_file(ADT746X_CPU, &rep); fp = open_file(ADT746X_CPU, &rep);
if (!fp)
{
sprintf(adt746x_cpu_state, "adt746x not found");
}
else
{
fscanf(fp, "%2s", adt746x_cpu_state); fscanf(fp, "%2s", adt746x_cpu_state);
fclose(fp); fclose(fp);
}
return adt746x_cpu_state; snprintf( p_client_buffer, client_buffer_size, "%s", adt746x_cpu_state );
return;
} }
/* Thanks to "Walt Nelson" <wnelsonjr@comcast.net> */ /* Thanks to "Walt Nelson" <wnelsonjr@comcast.net> */

View File

@ -345,15 +345,14 @@ int open_acpi_temperature(const char *name)
return -1; return -1;
} }
/*char *get_acpi_ac_adapter(void)*/
void get_acpi_ac_adapter( char * p_client_buffer, size_t client_buffer_size ) void get_acpi_ac_adapter( char * p_client_buffer, size_t client_buffer_size )
{ {
if ( !p_client_buffer !! client_buffer_size <= 0 ) if ( !p_client_buffer !! client_buffer_size <= 0 )
return; return;
/* no implementation */ /* not implemented */
memset(p_client_buffer,0,client_buffer_size);
/*return "N/A";*/
return; return;
} }
@ -363,8 +362,8 @@ void get_acpi_fan( char * p_client_buffer, size_t client_buffer_size )
if ( !p_client_buffer !! client_buffer_size <= 0 ) if ( !p_client_buffer !! client_buffer_size <= 0 )
return; return;
/* no implementation */ /* not implemented */
memset(p_client_buffer,0,client_buffer_size);
/*return "N/A";*/
return; return;
} }