equal
deleted
inserted
replaced
19 #include <glib.h> |
19 #include <glib.h> |
20 #include <gmodule.h> |
20 #include <gmodule.h> |
21 #include <time.h> |
21 #include <time.h> |
22 #include <stdio.h> |
22 #include <stdio.h> |
23 #include <string.h> |
23 #include <string.h> |
|
24 #include <unistd.h> |
24 |
25 |
25 #include <mcabber/modules.h> |
26 #include <mcabber/modules.h> |
26 #include <mcabber/logprint.h> |
27 #include <mcabber/logprint.h> |
27 #include <mcabber/commands.h> |
28 #include <mcabber/commands.h> |
28 #include <mcabber/settings.h> |
29 #include <mcabber/settings.h> |
150 while (*p && isspace (*p)) p++; |
151 while (*p && isspace (*p)) p++; |
151 char *u = p; |
152 char *u = p; |
152 while (*u && isdigit (*u)) u++; |
153 while (*u && isdigit (*u)) u++; |
153 *u = '\0'; |
154 *u = '\0'; |
154 if (!sscanf (p, "%llu", &mstime)) { |
155 if (!sscanf (p, "%llu", &mstime)) { |
155 scr_log_print (LPRINT_LOGNORM, "uptime: now at %u/%u, remaining string: %s.", p - line -> str, line -> len, p); |
156 scr_log_print (LPRINT_LOGNORM, "uptime: now at " |
|
157 "%" G_GSIZE_MODIFIER "u/%" G_GSIZE_MODIFIER "u, " |
|
158 "remaining string: %s.", |
|
159 p - line -> str, line -> len, p); |
156 g_string_free (line, TRUE); |
160 g_string_free (line, TRUE); |
157 return "Malformed own start time."; |
161 return "Malformed own start time."; |
158 } |
162 } |
159 |
163 |
160 channel = g_io_channel_new_file ("/proc/stat", "r", &error); |
164 channel = g_io_channel_new_file ("/proc/stat", "r", &error); |
182 |
186 |
183 g_string_free (line, TRUE); |
187 g_string_free (line, TRUE); |
184 |
188 |
185 guint hz = settings_opt_get_int ("uptime_hz"); |
189 guint hz = settings_opt_get_int ("uptime_hz"); |
186 if (!hz) |
190 if (!hz) |
187 hz = 100; |
191 hz = sysconf(_SC_CLK_TCK); |
188 starttime = kbtime + (mstime / hz); |
192 starttime = kbtime + (mstime / hz); |
189 } else |
193 } else |
190 starttime = time (NULL); |
194 starttime = time (NULL); |
191 |
195 |
192 cmd_add ("uptime", "", 0, 0, do_uptime, NULL); |
196 cmd_add ("uptime", "", 0, 0, do_uptime, NULL); |