Go to the source code of this file.
Functions | |
char * | skip_lines () |
Skips lines in a string. | |
void | find_data_for () |
Parser function. | |
char * | trim () |
delete blanks at the begining of string | |
char * | rtrim () |
delete blanks at the end of string | |
void | lkmonitor_exit () |
performs collector cancellation | |
void | set_tooltiptext () |
int | read_values_from_file (int parm, char *path,...) |
Read integer values from file. | |
int | write_values_to_file (int parm, char *path,...) |
Write integer values to file. | |
int | write_string_to_file (char *str, char *path) |
Write string to file. | |
char * | parse_batt (char *str, char *contents) |
Parser for battery info. |
void find_data_for | ( | ) |
Parser function.
void lkmonitor_exit | ( | ) |
performs collector cancellation
Stops collector thread and runs outside event loop.
Definition at line 54 of file lkmonitor.c.
References collector_exit.
Referenced by on_quit1_activate().
00055 { 00056 extern gboolean collector_exit; 00057 00058 collector_exit=TRUE; 00059 gtk_main_quit(); 00060 }
char* parse_batt | ( | char * | str, | |
char * | contents | |||
) |
Parser for battery info.
Parse battery information.
str | String to search in contents | |
contents | String that contents text |
Definition at line 230 of file others.c.
Referenced by get_acpi_info(), and get_battery_info().
00231 { 00232 g_assert(str!=NULL && contents!=NULL); 00233 00234 char data[10]; 00235 char *p; 00236 00237 p=strstr(contents,str); 00238 if(p==NULL){ 00239 return(_("Unknown")); 00240 } 00241 p=strstr(p,":")+1; 00242 sscanf(p,"%s",data); 00243 p=malloc(sizeof(data)); 00244 strcpy(p,data); 00245 return p; 00246 }
int read_values_from_file | ( | int | parm, | |
char * | path, | |||
... | ||||
) |
Read integer values from file.
Read integer values from file.
parm | Number of parameters | |
path | File to read | |
... | variable list of parameters to read. Should be (int*) |
Definition at line 44 of file others.c.
Referenced by get_settings_info().
00045 { 00046 g_assert(parm!=0 && path!=NULL); 00047 00048 int i; 00049 int *val; 00050 va_list list; 00051 gchar *contents; 00052 char *p; 00053 00054 if(g_file_get_contents((gchar *)path,&contents,NULL,NULL)==FALSE){ 00055 va_start(list,path); 00056 for(i=0; i<parm;i++){ 00057 val=va_arg(list, int *); 00058 *val=-1; 00059 } 00060 va_end(list); 00061 g_warning("Failed to open %s file",path); 00062 return -1; 00063 } 00064 00065 p=contents; 00066 00067 va_start(list,path); 00068 for(i=0; i<parm;i++){ 00069 sscanf(p,"%d",va_arg(list, int *)); 00070 p=strchr(p,'\t')+1; 00071 } 00072 va_end(list); 00073 00074 g_free(contents); 00075 return(0); 00076 }
char* rtrim | ( | ) |
delete blanks at the end of string
void set_tooltiptext | ( | ) |
char* skip_lines | ( | ) |
Skips lines in a string.
char* trim | ( | ) |
delete blanks at the begining of string
int write_string_to_file | ( | char * | str, | |
char * | path | |||
) |
Write string to file.
Write a string to file.
str | String to be written | |
path | File to write |
Definition at line 122 of file others.c.
Referenced by lkmonitor_write_settings().
00123 { 00124 g_assert(str!=NULL && path!=NULL); 00125 00126 FILE *f; 00127 00128 if((f=fopen(path,"w"))==NULL){ 00129 g_warning("Couldn't open file %s",path); 00130 return -1; 00131 } 00132 00133 fprintf(f,"%s",str); 00134 printf("%s",str); 00135 fclose(f); 00136 00137 return(0); 00138 }
int write_values_to_file | ( | int | parm, | |
char * | path, | |||
... | ||||
) |
Write integer values to file.
Write integer values from file.
parm | Number of parameters | |
path | File to read | |
... | variable list of parameters to write. Should be int |
Definition at line 84 of file others.c.
Referenced by lkmonitor_write_settings().
00085 { 00086 g_assert(parm!=0 && path!=NULL); 00087 00088 int i; 00089 va_list list; 00090 FILE *target; 00091 gchar num_trans[15]; //Large enough 00092 GString *ms; 00093 00094 ms=g_string_new(""); 00095 00096 if((target=fopen(path,"w"))==NULL){ 00097 g_warning("Can't write to %s\n",path); 00098 return(-1); 00099 } 00100 00101 /* File is ready to be written */ 00102 00103 va_start(list,path); 00104 for(i=0;i<parm;i++){ 00105 sprintf(num_trans,"%d",va_arg(list,int)); 00106 g_string_append(ms,num_trans); 00107 g_string_append(ms," "); 00108 } 00109 va_end(list); 00110 00111 /* Write */ 00112 fprintf(target,"%s",ms->str); 00113 fclose(target); 00114 return(0); 00115 }