1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 04:17:33 +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
copy_tcp_connection().
* Changed call interfaces for get_acpi_fan(), get_acpi_ac_adapter(),
get_freq(), get_freq_dynamic(), eliminating mallocs. pkovacs.
More to come. See bug 1355470.
get_freq(), get_freq_dynamic(), get_adt746x_cpu(), get_adt746x_fan(),
eliminating all mallocs. pkovacs. See bug 1355470.
2005-11-11
* 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 */
}
OBJ(adt746xcpu) {
snprintf(p, n, "%s", get_adt746x_cpu());
get_adt746x_cpu(p, n); /* pk */
}
OBJ(adt746xfan) {
snprintf(p, n, "%s", get_adt746x_fan());
get_adt746x_fan(p, n); /* pk */
}
OBJ(acpifan) {
get_acpi_fan(p, n); /* pk */
}
OBJ(acpiacadapter) {
get_acpi_ac_adapter(p, n);
get_acpi_ac_adapter(p, n); /* pk */
}
OBJ(battery) {
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);
double get_i2c_info(int *fd, int arg, char *devtype, char *type);
char *get_adt746x_cpu(void);
char *get_adt746x_fan(void);
void get_adt746x_cpu( char *, size_t ); /* pk */
void get_adt746x_fan( char *, size_t ); /* pk */
unsigned int get_diskio(void);
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 )
return;
/* no implementation */
/* not implemented */
memset(p_client_buffer,0,client_buffer_size);
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 */

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"
static char *adt746x_fan_state;
char *get_adt746x_fan()
void get_adt746x_fan( char * p_client_buffer, size_t client_buffer_size )
{
static int rep;
char adt746x_fan_state[64];
FILE *fp;
if (adt746x_fan_state == NULL) {
adt746x_fan_state = (char *) malloc(100);
assert(adt746x_fan_state != NULL);
}
if ( !p_client_buffer || client_buffer_size <= 0 )
return;
fp = open_file(ADT746X_FAN, &rep);
if (!fp) {
strcpy(adt746x_fan_state,
"No fan found! Hey, you don't have one?");
return adt746x_fan_state;
if (!fp)
{
sprintf(adt746x_fan_state, "adt746x not found");
}
else
{
fscanf(fp, "%s", adt746x_fan_state);
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"
static char *adt746x_cpu_state;
char *get_adt746x_cpu()
void get_adt746x_cpu( char * p_client_buffer, size_t client_buffer_size )
{
static int rep;
char adt746x_cpu_state[64];
FILE *fp;
if (adt746x_cpu_state == NULL) {
adt746x_cpu_state = (char *) malloc(100);
assert(adt746x_cpu_state != NULL);
}
if ( !p_client_buffer || client_buffer_size <= 0 )
return;
fp = open_file(ADT746X_CPU, &rep);
if (!fp)
{
sprintf(adt746x_cpu_state, "adt746x not found");
}
else
{
fscanf(fp, "%2s", adt746x_cpu_state);
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> */

View File

@ -345,15 +345,14 @@ int open_acpi_temperature(const char *name)
return -1;
}
/*char *get_acpi_ac_adapter(void)*/
void get_acpi_ac_adapter( char * p_client_buffer, size_t client_buffer_size )
{
if ( !p_client_buffer !! client_buffer_size <= 0 )
return;
/* no implementation */
/* not implemented */
memset(p_client_buffer,0,client_buffer_size);
/*return "N/A";*/
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 )
return;
/* no implementation */
/* not implemented */
memset(p_client_buffer,0,client_buffer_size);
/*return "N/A";*/
return;
}