#include <glib.h>
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, char *dest) |
Parser for battery info. | |
gint | list_com (gconstpointer a, gconstpointer b) |
Custom list comparison function. | |
int | numsort (const void *stra, const void *strb) |
Sorting function for scandir. |
void find_data_for | ( | ) |
Parser function.
gint list_com | ( | gconstpointer | a, | |
gconstpointer | b | |||
) |
Custom list comparison function.
Custom list elements comparison
a | The first element | |
b | The second element |
Definition at line 275 of file others.c.
References lnode::pid.
00276 { 00277 struct lnode *la,*lb; 00278 00279 la=(struct lnode *)a; 00280 lb=(struct lnode *)b; 00281 00282 if(la->pid==lb->pid) 00283 return 0; 00284 00285 return -1; 00286 }
void lkmonitor_exit | ( | ) |
performs collector cancellation
Stops collector thread and runs outside event loop.
Definition at line 56 of file lkmonitor.c.
References collector_exit.
Referenced by on_quit1_activate().
00057 { 00058 extern gboolean collector_exit; 00059 00060 collector_exit=TRUE; 00061 gtk_main_quit(); 00062 }
int numsort | ( | const void * | stra, | |
const void * | strb | |||
) |
Sorting function for scandir.
Sorting by value, not by alphasort.
stra | First string. ASCII representation of an integer | |
strb | Second string. ASCII representation of an integer |
Definition at line 45 of file others.c.
Referenced by get_proc_list().
00046 { 00047 int a,b; 00048 a=atoi(stra); 00049 b=atoi(strb); 00050 00051 00052 return(a<b?(-1):(a==b?0:1)); 00053 00054 }
char* parse_batt | ( | char * | str, | |
char * | contents, | |||
char * | dest | |||
) |
Parser for battery info.
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 62 of file others.c.
References modules_info::contents.
Referenced by get_settings_info().
00063 { 00064 g_assert(parm!=0 && path!=NULL); 00065 00066 int i; 00067 int *val; 00068 va_list list; 00069 gchar *contents; 00070 char *p; 00071 00072 if(g_file_get_contents((gchar *)path,&contents,NULL,NULL)==FALSE){ 00073 va_start(list,path); 00074 for(i=0; i<parm;i++){ 00075 val=va_arg(list, int *); 00076 *val=-1; 00077 } 00078 va_end(list); 00079 g_warning("Failed to open %s file",path); 00080 return -1; 00081 } 00082 00083 p=contents; 00084 00085 va_start(list,path); 00086 for(i=0; i<parm;i++){ 00087 sscanf(p,"%d",va_arg(list, int *)); 00088 p=strchr(p,'\t')+1; 00089 } 00090 va_end(list); 00091 00092 g_free(contents); 00093 return(0); 00094 }
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.
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 102 of file others.c.
Referenced by lkmonitor_write_settings().
00103 { 00104 g_assert(parm!=0 && path!=NULL); 00105 00106 int i; 00107 va_list list; 00108 FILE *target; 00109 gchar num_trans[15]; //Large enough 00110 GString *ms; 00111 00112 ms=g_string_new(""); 00113 00114 if((target=fopen(path,"w"))==NULL){ 00115 g_warning("Can't write to %s\n",path); 00116 return(-1); 00117 } 00118 00119 /* File is ready to be written */ 00120 00121 va_start(list,path); 00122 for(i=0;i<parm;i++){ 00123 sprintf(num_trans,"%d",va_arg(list,int)); 00124 g_string_append(ms,num_trans); 00125 g_string_append(ms," "); 00126 } 00127 va_end(list); 00128 00129 /* Write */ 00130 fprintf(target,"%s",ms->str); 00131 fclose(target); 00132 return(0); 00133 }