~vorlon/ubuntu/raring/upstart/lp.1199778

« back to all changes in this revision

Viewing changes to logd/main.c

  • Committer: Scott James Remnant
  • Date: 2006-08-19 19:02:17 UTC
  • Revision ID: scott@netsplit.com-20060819190217-3b1599dce88cceeb
* logd/main.c (main): Write the basic main function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#endif /* HAVE_CONFIG_H */
24
24
 
25
25
 
 
26
#include <stdio.h>
 
27
#include <stdlib.h>
 
28
 
26
29
#include <nih/macros.h>
27
30
#include <nih/signal.h>
28
31
#include <nih/main.h>
 
32
#include <nih/option.h>
29
33
#include <nih/logging.h>
30
34
 
31
35
 
 
36
/**
 
37
 * options:
 
38
 *
 
39
 * Command-line options accepted for all arguments.
 
40
 **/
 
41
static NihOption options[] = {
 
42
        NIH_OPTION_LAST
 
43
};
 
44
 
 
45
 
32
46
int
33
47
main (int   argc,
34
48
      char *argv[])
35
49
{
36
 
        int ret;
 
50
        char **args;
 
51
        int    ret;
37
52
 
38
53
        nih_main_init (argv[0]);
39
54
 
40
 
        nih_log_set_priority (NIH_LOG_DEBUG);
 
55
        args = nih_option_parser (NULL, argc, argv, options, FALSE);
 
56
        if (! args)
 
57
                exit (1);
 
58
 
 
59
        if (args[0] != NULL) {
 
60
                fprintf (stderr, _("%s: unexpected argument\n"), program_name);
 
61
                nih_main_suggest_help ();
 
62
                exit (1);
 
63
        }
 
64
 
41
65
 
42
66
        nih_signal_set_handler (SIGTERM, nih_signal_handler);
43
67
        nih_signal_add_callback (NULL, SIGTERM, nih_main_term_signal, NULL);
44
68
 
45
 
        nih_signal_set_handler (SIGINT, nih_signal_handler);
46
 
        nih_signal_add_callback (NULL, SIGINT, nih_main_term_signal, NULL);
47
 
 
48
 
 
49
 
        nih_main_version ();
50
 
 
51
69
        ret = nih_main_loop ();
52
70
 
53
71
        return ret;