OpenCores
URL https://opencores.org/ocsvn/funbase_ip_library/funbase_ip_library/trunk

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [ip.application/] [h.263_encoder_main/] [1.0/] [src/] [linux_init_main.c] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
#include <stdlib.h>
2
#include <stdio.h>
3
#include <signal.h>
4
#include <getopt.h>
5
 
6
#include <mcapi.h>
7
 
8
extern void startup(unsigned int local, unsigned int remote);
9
extern void demo(unsigned int local, int listen);
10
extern int encoder();
11
 
12
 
13
static struct sigaction oldactions[32];
14
 
15
static void usage(const char *name)
16
{
17
        printf("Usage: %s [options] <local node id> <remote node id>\n"
18
                        "Options:\n"
19
                        "  -l, --loop      send and receive messages until killed.\n",
20
                        name);
21
        exit(1);
22
}
23
 
24
static void cleanup(void)
25
{
26
        mcapi_status_t status;
27
        printf("%s\n", __func__);
28
        mcapi_finalize(&status);
29
}
30
 
31
static void signalled(int signal, siginfo_t *info, void *context)
32
{
33
        struct sigaction *action;
34
 
35
        action = &oldactions[signal];
36
 
37
        if ((action->sa_flags & SA_SIGINFO) && action->sa_sigaction)
38
                action->sa_sigaction(signal, info, context);
39
        else if (action->sa_handler)
40
                action->sa_handler(signal);
41
 
42
        exit(signal);
43
}
44
 
45
struct sigaction action = {
46
        .sa_sigaction = signalled,
47
        .sa_flags = SA_SIGINFO,
48
};
49
 
50
int main(int argc, char *argv[])
51
{
52
        unsigned long local;
53
        unsigned long remote;
54
        int c;
55
        int loop = 0;
56
 
57
        /* while (1) { */
58
        /*      static struct option long_options[] = { */
59
        /*              {"loop", 0, 0, 'l'}, */
60
        /*              {NULL, 0, 0, 0}, */
61
        /*      }; */
62
        /*      int option_index = 0; */
63
 
64
        /*      c = getopt_long(argc, argv, "l", long_options, &option_index); */
65
 
66
        /*      if (c == -1) */
67
        /*              break; */
68
 
69
        /*      switch (c) { */
70
        /*      case 'l': */
71
        /*              loop = 1; */
72
        /*              break; */
73
        /*      default: */
74
        /*              usage(argv[0]); */
75
        /*              break; */
76
        /*      } */
77
        /* } */
78
 
79
        /* if (optind == argc - 2) { */
80
        /*      local = strtoul(argv[optind], NULL, 0); */
81
        /*      remote = strtoul(argv[optind + 1], NULL, 0); */
82
        /* } else */
83
        /*      usage(argv[0]); */
84
 
85
        atexit(cleanup);
86
        sigaction(SIGQUIT, &action, &oldactions[SIGQUIT]);
87
        sigaction(SIGABRT, &action, &oldactions[SIGABRT]);
88
        sigaction(SIGTERM, &action, &oldactions[SIGTERM]);
89
        sigaction(SIGINT,  &action, &oldactions[SIGINT]);
90
 
91
        //startup(local, remote);
92
 
93
        encoder();
94
 
95
        return 0;
96
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.