… | |
… | |
39 | #include <ctype.h> |
39 | #include <ctype.h> |
40 | #include <stdarg.h> |
40 | #include <stdarg.h> |
41 | #include <X11/Xlib.h> |
41 | #include <X11/Xlib.h> |
42 | #include <X11/Xatom.h> |
42 | #include <X11/Xatom.h> |
43 | #include <X11/Xutil.h> |
43 | #include <X11/Xutil.h> |
|
|
44 | #include <X11/extensions/shape.h> |
|
|
45 | #include <X11/extensions/Xfixes.h> |
44 | |
46 | |
45 | #if HAS_REGEX |
47 | #if HAS_REGEX |
46 | #include <regex.h> |
48 | #include <regex.h> |
47 | #endif |
49 | #endif |
48 | |
50 | |
… | |
… | |
105 | int buffer_size; |
107 | int buffer_size; |
106 | unsigned long color; |
108 | unsigned long color; |
107 | }; |
109 | }; |
108 | |
110 | |
109 | /* global variables */ |
111 | /* global variables */ |
110 | struct line_node *linelist = NULL, *linelist_tail = NULL; |
112 | static struct line_node *linelist = NULL, *linelist_tail = NULL; |
111 | struct displaymatrix *display; |
113 | static struct displaymatrix *display; |
112 | int continuation_width = -1; |
114 | static int continuation_width = -1; |
113 | int continuation_color; |
115 | static int continuation_color; |
114 | int continuation_length; |
116 | static int continuation_length; |
115 | |
117 | |
116 | /* HACK - ideally listlen will start at however many '~'s will fit on |
118 | /* HACK - ideally listlen will start at however many '~'s will fit on |
117 | * the screen */ |
119 | * the screen */ |
118 | int width = STD_WIDTH, height = STD_HEIGHT, listlen = 50; |
120 | static unsigned int width = STD_WIDTH, height = STD_HEIGHT; |
|
|
121 | static int listlen = 50; |
119 | int win_x = LOC_X, win_y = LOC_Y; |
122 | static int win_x = LOC_X, win_y = LOC_Y; |
120 | int effect_x_space, effect_y_space; /* how much space does shading / outlining take up */ |
123 | static int effect_x_space, effect_y_space; /* how much space does shading / outlining take up */ |
121 | int effect_x_offset, effect_y_offset; /* and how does it offset the usable space */ |
124 | static int effect_x_offset, effect_y_offset; /* and how does it offset the usable space */ |
122 | int do_reopen; |
125 | static int do_reopen; |
123 | struct timeval interval = { 2, 400000 }; |
126 | static struct timeval interval = { 2, 400000 }; |
124 | |
127 | |
125 | /* command line options */ |
128 | /* command line options */ |
126 | int opt_noinitial, opt_shade, opt_frame, opt_reverse, opt_nofilename, |
129 | static int opt_noinitial, opt_shade, opt_frame, opt_reverse, opt_nofilename, |
127 | opt_outline, opt_noflicker, opt_whole, opt_update, opt_wordwrap, |
130 | opt_outline, opt_noflicker, opt_whole, opt_update, opt_wordwrap, |
128 | opt_justify, geom_mask, opt_minspace, reload; |
131 | opt_justify, geom_mask, opt_minspace, opt_windowed, reload; |
129 | const char *command = NULL, |
132 | static const char *command = NULL, |
130 | *fontname = USE_FONT, *dispname = NULL, *def_color = DEF_COLOR, |
133 | *fontname = USE_FONT, *dispname = NULL, *def_color = DEF_COLOR, |
131 | *continuation = "|| ", *cont_color = DEF_CONT_COLOR; |
134 | *continuation = "|| ", *cont_color = DEF_CONT_COLOR; |
132 | |
135 | |
133 | struct logfile_entry *loglist = NULL, *loglist_tail = NULL; |
136 | struct logfile_entry *loglist = NULL, *loglist_tail = NULL; |
134 | |
137 | |
135 | Display *disp; |
138 | static Display *disp; |
136 | Window root; |
139 | static Window root; |
137 | GC WinGC; |
140 | static GC WinGC; |
138 | |
141 | |
139 | #if HAS_REGEX |
142 | #if HAS_REGEX |
140 | struct re_list |
143 | struct re_list |
141 | { |
144 | { |
142 | regex_t from; |
145 | regex_t from; |
143 | const char *to; |
146 | const char *to; |
144 | struct re_list *next; |
147 | struct re_list *next; |
145 | }; |
148 | }; |
146 | struct re_list *re_head, *re_tail; |
149 | static struct re_list *re_head, *re_tail; |
147 | char *transform_to = NULL; |
150 | static char *transform_to = NULL; |
148 | regex_t *transformre; |
151 | static regex_t *transformre; |
149 | #endif |
152 | #endif |
150 | |
153 | |
151 | |
154 | |
152 | /* prototypes */ |
155 | /* prototypes */ |
153 | void list_files (int); |
156 | static void list_files (int); |
154 | void force_reopen (int); |
157 | static void force_reopen (int); |
155 | void force_refresh (int); |
158 | static void force_refresh (int); |
156 | void blank_window (int); |
159 | static void blank_window (int); |
157 | #ifdef USE_TOON_GET_ROOT_WINDOW |
160 | #ifdef USE_TOON_GET_ROOT_WINDOW |
158 | Window ToonGetRootWindow(Display *, int, Window *); |
161 | static Window ToonGetRootWindow(Display *, int, Window *); |
159 | #endif /* USE_TOON_GET_ROOT_WINDOW */ |
162 | #endif /* USE_TOON_GET_ROOT_WINDOW */ |
160 | |
163 | |
161 | void InitWindow (void); |
164 | static void InitWindow (void); |
162 | unsigned long GetColor (const char *); |
165 | static unsigned long GetColor (const char *); |
163 | void redraw (int); |
166 | static void redraw (int); |
164 | void refresh (int, int, int, int); |
167 | static void refresh (int, int, int, int); |
165 | |
168 | |
166 | void transform_line (char *s); |
|
|
167 | int lineinput (struct logfile_entry *); |
169 | static int lineinput (struct logfile_entry *); |
168 | void reopen (void); |
170 | static void reopen (void); |
169 | void check_open_files (void); |
171 | static void check_open_files (void); |
170 | FILE *openlog (struct logfile_entry *); |
172 | static FILE *openlog (struct logfile_entry *); |
171 | static void main_loop (void); |
173 | static void main_loop (void); |
172 | |
174 | |
173 | void display_version (void); |
175 | static void display_version (void); |
174 | void display_help (char *); |
176 | static void display_help (char *); |
175 | void install_signal (int, void (*)(int)); |
177 | static void install_signal (int, void (*)(int)); |
176 | void *xstrdup (const char *); |
178 | static void *xstrdup (const char *); |
177 | void *xmalloc (size_t); |
179 | static void *xmalloc (size_t); |
178 | void *xrealloc (void *, size_t); |
180 | static void *xrealloc (void *, size_t); |
179 | int daemonize (void); |
181 | static int daemonize (void); |
180 | |
182 | |
181 | /* signal handlers */ |
183 | /* signal handlers */ |
182 | void |
184 | static void |
183 | list_files (int dummy) |
185 | list_files (int dummy) |
184 | { |
186 | { |
185 | struct logfile_entry *e; |
187 | struct logfile_entry *e; |
186 | |
188 | |
187 | fprintf (stderr, "Files opened:\n"); |
189 | fprintf (stderr, "Files opened:\n"); |
188 | for (e = loglist; e; e = e->next) |
190 | for (e = loglist; e; e = e->next) |
189 | fprintf (stderr, "\t%s (%s)\n", e->fname, e->desc); |
191 | fprintf (stderr, "\t%s (%s)\n", e->fname, e->desc); |
190 | } |
192 | } |
191 | |
193 | |
192 | void |
194 | static void |
193 | force_reopen (int dummy) |
195 | force_reopen (int dummy) |
194 | { |
196 | { |
195 | do_reopen = 1; |
197 | do_reopen = 1; |
196 | } |
198 | } |
197 | |
199 | |
198 | void |
200 | static void |
199 | force_refresh (int dummy) |
201 | force_refresh (int dummy) |
200 | { |
202 | { |
201 | redraw (1); |
203 | redraw (1); |
202 | } |
204 | } |
203 | |
205 | |
204 | void |
206 | static void |
205 | blank_window (int dummy) |
207 | blank_window (int dummy) |
206 | { |
208 | { |
207 | XClearArea (disp, root, win_x, win_y, width + MARGIN_OF_ERROR, height, False); |
209 | XClearArea (disp, root, win_x, win_y, width + MARGIN_OF_ERROR, height, False); |
208 | XFlush (disp); |
210 | XFlush (disp); |
209 | exit (0); |
211 | exit (0); |
210 | } |
212 | } |
211 | |
213 | |
212 | /* X related functions */ |
214 | /* X related functions */ |
213 | unsigned long |
215 | static unsigned long |
214 | GetColor (const char *ColorName) |
216 | GetColor (const char *ColorName) |
215 | { |
217 | { |
216 | XColor Color; |
218 | XColor Color; |
217 | XWindowAttributes Attributes; |
219 | XWindowAttributes Attributes; |
218 | |
220 | |
… | |
… | |
281 | fprintf (stderr, "Can't query tree on root window 0x%lx", root); |
283 | fprintf (stderr, "Can't query tree on root window 0x%lx", root); |
282 | } |
284 | } |
283 | } |
285 | } |
284 | #endif /* USE_TOON_GET_ROOT_WINDOW */ |
286 | #endif /* USE_TOON_GET_ROOT_WINDOW */ |
285 | |
287 | |
286 | void |
288 | static void |
287 | InitWindow (void) |
289 | InitWindow (void) |
288 | { |
290 | { |
289 | XGCValues gcv; |
291 | XGCValues gcv; |
290 | unsigned long gcm; |
292 | unsigned long gcm; |
291 | int screen, ScreenWidth, ScreenHeight; |
293 | int screen, ScreenWidth, ScreenHeight; |
… | |
… | |
299 | |
301 | |
300 | screen = DefaultScreen (disp); |
302 | screen = DefaultScreen (disp); |
301 | ScreenHeight = DisplayHeight (disp, screen); |
303 | ScreenHeight = DisplayHeight (disp, screen); |
302 | ScreenWidth = DisplayWidth (disp, screen); |
304 | ScreenWidth = DisplayWidth (disp, screen); |
303 | |
305 | |
|
|
306 | if (opt_windowed) |
|
|
307 | { |
|
|
308 | XRectangle rect = { }; |
|
|
309 | XSetWindowAttributes attr; |
|
|
310 | |
|
|
311 | attr.background_pixmap = ParentRelative; |
|
|
312 | attr.override_redirect = True; |
|
|
313 | |
|
|
314 | root = XCreateWindow ( |
|
|
315 | disp, DefaultRootWindow (disp), 0, 0, DisplayWidth (disp, screen), DisplayHeight (disp, screen), |
|
|
316 | 0, CopyFromParent, InputOutput, CopyFromParent, |
|
|
317 | CWOverrideRedirect | CWBackPixmap, &attr); |
|
|
318 | |
|
|
319 | XMapWindow (disp, root); |
|
|
320 | XLowerWindow (disp, root); |
|
|
321 | |
|
|
322 | XserverRegion region = XFixesCreateRegion (disp, &rect, 1); |
|
|
323 | XFixesSetWindowShapeRegion (disp, root, ShapeInput, 0, 0, region); |
|
|
324 | XFixesDestroyRegion (disp, region); |
|
|
325 | } |
|
|
326 | else |
304 | find_root_window (disp, screen); |
327 | find_root_window (disp, screen); |
305 | |
328 | |
306 | gcm = GCBackground; |
329 | gcm = GCBackground; |
307 | gcv.graphics_exposures = True; |
330 | gcv.graphics_exposures = True; |
308 | WinGC = XCreateGC (disp, root, gcm, &gcv); |
331 | WinGC = XCreateGC (disp, root, gcm, &gcv); |
309 | XMapWindow (disp, root); |
332 | XMapWindow (disp, root); |
… | |
… | |
317 | char *def_string; |
340 | char *def_string; |
318 | |
341 | |
319 | e->fontset = XCreateFontSet (disp, e->fontname, |
342 | e->fontset = XCreateFontSet (disp, e->fontname, |
320 | &missing_charset_list, &missing_charset_count, |
343 | &missing_charset_list, &missing_charset_count, |
321 | &def_string); |
344 | &def_string); |
322 | |
|
|
323 | if (missing_charset_count) |
345 | if (missing_charset_count) |
324 | { |
346 | { |
|
|
347 | #if 0 |
325 | fprintf (stderr, |
348 | fprintf (stderr, |
326 | "Missing charsets in String to FontSet conversion (%s)\n", |
349 | "Missing charsets in String to FontSet conversion (%s)\n", |
327 | missing_charset_list[0]); |
350 | missing_charset_list[0]); |
|
|
351 | #endif |
328 | XFreeStringList (missing_charset_list); |
352 | XFreeStringList (missing_charset_list); |
329 | } |
353 | } |
330 | |
354 | |
331 | if (!e->fontset) |
355 | if (!e->fontset) |
332 | { |
356 | { |
… | |
… | |
376 | * -noflicker is in effect) then only the lines which have changed |
400 | * -noflicker is in effect) then only the lines which have changed |
377 | * since the last draw are redrawn. |
401 | * since the last draw are redrawn. |
378 | * |
402 | * |
379 | * the rest is handled by regular refresh ()'es |
403 | * the rest is handled by regular refresh ()'es |
380 | */ |
404 | */ |
381 | void |
405 | static void |
382 | redraw (int redraw_all) |
406 | redraw (int redraw_all) |
383 | { |
407 | { |
384 | XSetClipMask (disp, WinGC, None); |
408 | XSetClipMask (disp, WinGC, None); |
385 | refresh (0, 32768, 1, redraw_all); |
409 | refresh (0, 32768, 1, redraw_all); |
386 | } |
410 | } |
387 | |
411 | |
|
|
412 | static void |
388 | void draw_text (Display *disp, Window root, GC WinGC, int x, int y, struct line_node *line, int foreground) |
413 | draw_text (Display *disp, Window root, GC WinGC, int x, int y, struct line_node *line, int foreground) |
389 | { |
414 | { |
390 | if (line->wrapped_right && opt_justify && line->breaks) |
415 | if (line->wrapped_right && opt_justify && line->breaks) |
391 | { |
416 | { |
392 | int i; |
417 | int i; |
393 | for (i = 0; i < line->num_words; i++) |
418 | for (i = 0; i < line->num_words; i++) |
… | |
… | |
415 | } |
440 | } |
416 | } |
441 | } |
417 | } |
442 | } |
418 | |
443 | |
419 | /* Just redraw everything without clearing (i.e. after an EXPOSE event) */ |
444 | /* Just redraw everything without clearing (i.e. after an EXPOSE event) */ |
420 | void |
445 | static void |
421 | refresh (int miny, int maxy, int clear, int refresh_all) |
446 | refresh (int miny, int maxy, int clear, int refresh_all) |
422 | { |
447 | { |
423 | int lin = 0; |
448 | int lin = 0; |
424 | int space = height; |
449 | int space = height; |
425 | int offset; |
450 | int offset; |
… | |
… | |
593 | XDrawRectangle (disp, root, WinGC, win_x - 0, win_y - 0, width - 1, height - 1); |
618 | XDrawRectangle (disp, root, WinGC, win_x - 0, win_y - 0, width - 1, height - 1); |
594 | } |
619 | } |
595 | } |
620 | } |
596 | |
621 | |
597 | #if HAS_REGEX |
622 | #if HAS_REGEX |
598 | void |
623 | void void |
599 | transform_line (char *s) |
624 | transform_line (char *s) |
600 | { |
625 | { |
601 | #ifdef I_AM_Md |
626 | #ifdef I_AM_Md |
602 | int i; |
627 | int i; |
603 | if (1) |
628 | if (1) |
… | |
… | |
648 | |
673 | |
649 | /* |
674 | /* |
650 | * appends p2 to the end of p1, if p1 is not null |
675 | * appends p2 to the end of p1, if p1 is not null |
651 | * otherwise allocates a new string and copies p2 to it |
676 | * otherwise allocates a new string and copies p2 to it |
652 | */ |
677 | */ |
653 | char * |
678 | static char * |
654 | concat_line (char *p1, const char *p2) |
679 | concat_line (char *p1, const char *p2) |
655 | { |
680 | { |
656 | int l1 = p1 ? strlen (p1) : 0; |
681 | int l1 = p1 ? strlen (p1) : 0; |
657 | int l2 = strlen (p2); |
682 | int l2 = strlen (p2); |
658 | char *r; |
683 | char *r; |
… | |
… | |
671 | } |
696 | } |
672 | |
697 | |
673 | /* |
698 | /* |
674 | * This routine can read a line of any length if it is called enough times. |
699 | * This routine can read a line of any length if it is called enough times. |
675 | */ |
700 | */ |
676 | int |
701 | static int |
677 | lineinput (struct logfile_entry *logfile) |
702 | lineinput (struct logfile_entry *logfile) |
678 | { |
703 | { |
679 | char buff[1024], *p; |
704 | char buff[1024], *p; |
680 | int ch; |
705 | int ch; |
681 | /* HACK-2: add on the length of any partial line which we will be appending to */ |
706 | /* HACK-2: add on the length of any partial line which we will be appending to */ |
… | |
… | |
740 | /* input: reads file->fname |
765 | /* input: reads file->fname |
741 | * output: fills file->fp, file->inode |
766 | * output: fills file->fp, file->inode |
742 | * returns file->fp |
767 | * returns file->fp |
743 | * in case of error, file->fp is NULL |
768 | * in case of error, file->fp is NULL |
744 | */ |
769 | */ |
745 | FILE * |
770 | static FILE * |
746 | openlog (struct logfile_entry * file) |
771 | openlog (struct logfile_entry *file) |
747 | { |
772 | { |
748 | struct stat stats; |
773 | struct stat stats; |
749 | |
774 | |
750 | if ((file->fp = fopen (file->fname, "r")) == NULL) |
775 | if ((file->fp = fopen (file->fname, "r")) == NULL) |
751 | { |
776 | { |
… | |
… | |
772 | |
797 | |
773 | file->last_size = stats.st_size; |
798 | file->last_size = stats.st_size; |
774 | return file->fp; |
799 | return file->fp; |
775 | } |
800 | } |
776 | |
801 | |
777 | void |
802 | static void |
778 | reopen (void) |
803 | reopen (void) |
779 | { |
804 | { |
780 | struct logfile_entry *e; |
805 | struct logfile_entry *e; |
781 | |
806 | |
782 | for (e = loglist; e; e = e->next) |
807 | for (e = loglist; e; e = e->next) |
… | |
… | |
791 | } |
816 | } |
792 | |
817 | |
793 | do_reopen = 0; |
818 | do_reopen = 0; |
794 | } |
819 | } |
795 | |
820 | |
796 | void |
821 | static void |
797 | check_open_files (void) |
822 | check_open_files (void) |
798 | { |
823 | { |
799 | struct logfile_entry *e; |
824 | struct logfile_entry *e; |
800 | struct stat stats; |
825 | struct stat stats; |
801 | |
826 | |
… | |
… | |
1271 | region = XCreateRegion (); |
1296 | region = XCreateRegion (); |
1272 | } |
1297 | } |
1273 | } |
1298 | } |
1274 | } |
1299 | } |
1275 | |
1300 | |
1276 | |
|
|
1277 | int |
1301 | int |
1278 | main (int argc, char *argv[]) |
1302 | main (int argc, char *argv[]) |
1279 | { |
1303 | { |
1280 | int i; |
1304 | int i; |
1281 | int opt_daemonize = 0; |
1305 | int opt_daemonize = 0; |
… | |
… | |
1324 | else if (!strcmp (arg, "-reload")) |
1348 | else if (!strcmp (arg, "-reload")) |
1325 | { |
1349 | { |
1326 | reload = atoi (argv[++i]); |
1350 | reload = atoi (argv[++i]); |
1327 | command = argv[++i]; |
1351 | command = argv[++i]; |
1328 | } |
1352 | } |
|
|
1353 | else if (!strcmp (arg, "-windowed")) |
|
|
1354 | opt_windowed = 1; |
1329 | else if (!strcmp (arg, "-shade")) |
1355 | else if (!strcmp (arg, "-shade")) |
1330 | opt_shade = 1; |
1356 | opt_shade = 1; |
1331 | else if (!strcmp (arg, "-outline")) |
1357 | else if (!strcmp (arg, "-outline")) |
1332 | opt_outline = 1; |
1358 | opt_outline = 1; |
1333 | else if (!strcmp (arg, "-minspace")) |
1359 | else if (!strcmp (arg, "-minspace")) |
… | |
… | |
1537 | main_loop (); |
1563 | main_loop (); |
1538 | |
1564 | |
1539 | exit (1); /* to make gcc -Wall stop complaining */ |
1565 | exit (1); /* to make gcc -Wall stop complaining */ |
1540 | } |
1566 | } |
1541 | |
1567 | |
1542 | void |
1568 | static void |
1543 | install_signal (int sig, void (*handler) (int)) |
1569 | install_signal (int sig, void (*handler) (int)) |
1544 | { |
1570 | { |
1545 | struct sigaction action; |
1571 | struct sigaction action; |
1546 | |
1572 | |
1547 | action.sa_handler = handler; |
1573 | action.sa_handler = handler; |
… | |
… | |
1550 | |
1576 | |
1551 | if (sigaction (sig, &action, NULL) < 0) |
1577 | if (sigaction (sig, &action, NULL) < 0) |
1552 | fprintf (stderr, "sigaction (%d): %s\n", sig, strerror (errno)), exit (1); |
1578 | fprintf (stderr, "sigaction (%d): %s\n", sig, strerror (errno)), exit (1); |
1553 | } |
1579 | } |
1554 | |
1580 | |
1555 | void * |
1581 | static void * |
1556 | xstrdup (const char *string) |
1582 | xstrdup (const char *string) |
1557 | { |
1583 | { |
1558 | void *p; |
1584 | void *p; |
1559 | |
1585 | |
1560 | while ((p = strdup (string)) == NULL) |
1586 | while ((p = strdup (string)) == NULL) |
… | |
… | |
1564 | } |
1590 | } |
1565 | |
1591 | |
1566 | return p; |
1592 | return p; |
1567 | } |
1593 | } |
1568 | |
1594 | |
1569 | void * |
1595 | static void * |
1570 | xmalloc (size_t size) |
1596 | xmalloc (size_t size) |
1571 | { |
1597 | { |
1572 | void *p; |
1598 | void *p; |
1573 | |
1599 | |
1574 | while ((p = malloc (size)) == NULL) |
1600 | while ((p = malloc (size)) == NULL) |
… | |
… | |
1578 | } |
1604 | } |
1579 | |
1605 | |
1580 | return p; |
1606 | return p; |
1581 | } |
1607 | } |
1582 | |
1608 | |
1583 | void * |
1609 | static void * |
1584 | xrealloc (void *ptr, size_t size) |
1610 | xrealloc (void *ptr, size_t size) |
1585 | { |
1611 | { |
1586 | void *p; |
1612 | void *p; |
1587 | |
1613 | |
1588 | while ((p = realloc (ptr, size)) == NULL) |
1614 | while ((p = realloc (ptr, size)) == NULL) |
… | |
… | |
1592 | } |
1618 | } |
1593 | |
1619 | |
1594 | return p; |
1620 | return p; |
1595 | } |
1621 | } |
1596 | |
1622 | |
1597 | void |
1623 | static void |
1598 | display_help (char *myname) |
1624 | display_help (char *myname) |
1599 | { |
1625 | { |
1600 | printf ("Usage: %s [options] file1[,color[,desc]]" |
1626 | printf ("Usage: %s [options] file1[,color[,desc]]" |
1601 | "[options] [file2[,color[,desc]] ...]\n", myname); |
1627 | "[options] [file2[,color[,desc]] ...]\n", myname); |
1602 | printf (" -g | -geometry geometry -g WIDTHxHEIGHT+X+Y\n" |
1628 | printf (" -g | -geometry geometry -g WIDTHxHEIGHT+X+Y\n" |
1603 | " -color color use color $color as default\n" |
1629 | " -color color use color $color as default\n" |
1604 | " -reload sec command reload after $sec and run command\n" |
1630 | " -reload sec command reload after $sec and run command\n" |
1605 | " -id id window id to use instead of the root window\n" |
1631 | " -id id window id to use instead of the root window\n" |
|
|
1632 | " -windowed create a window instead of writing to the root\n" |
1606 | " -font FONTSPEC (-fn) font to use\n" |
1633 | " -font FONTSPEC (-fn) font to use\n" |
1607 | " -f | -fork fork into background\n" |
1634 | " -f | -fork fork into background\n" |
1608 | " -reverse print new lines at the top\n" |
1635 | " -reverse print new lines at the top\n" |
1609 | " -whole wait for \\n before showing a line\n" |
1636 | " -whole wait for \\n before showing a line\n" |
1610 | " -partial show lines even if they don't end with a \\n\n" |
1637 | " -partial show lines even if they don't end with a \\n\n" |
… | |
… | |
1624 | printf ("Example:\n%s -g 800x250+100+50 -font fixed /var/log/messages,green " |
1651 | printf ("Example:\n%s -g 800x250+100+50 -font fixed /var/log/messages,green " |
1625 | "/var/log/secure,red,'ALERT'\n", myname); |
1652 | "/var/log/secure,red,'ALERT'\n", myname); |
1626 | exit (0); |
1653 | exit (0); |
1627 | } |
1654 | } |
1628 | |
1655 | |
1629 | void |
1656 | static void |
1630 | display_version (void) |
1657 | display_version (void) |
1631 | { |
1658 | { |
1632 | printf ("root-tail version " VERSION "\n"); |
1659 | printf ("root-tail version " VERSION "\n"); |
1633 | exit (0); |
1660 | exit (0); |
1634 | } |
1661 | } |
1635 | |
1662 | |
1636 | int |
1663 | static int |
1637 | daemonize (void) |
1664 | daemonize (void) |
1638 | { |
1665 | { |
1639 | pid_t pid; |
1666 | pid_t pid; |
1640 | |
1667 | |
1641 | switch (pid = fork ()) |
1668 | switch (pid = fork ()) |
… | |
… | |
1652 | if (setsid () == -1) |
1679 | if (setsid () == -1) |
1653 | return -1; |
1680 | return -1; |
1654 | |
1681 | |
1655 | return 0; |
1682 | return 0; |
1656 | } |
1683 | } |
|
|
1684 | |