File: arb_notify.cxx

package info (click to toggle)
arb 6.0.2-1
  • links: PTS, VCS
  • area: non-free
  • in suites: jessie-kfreebsd
  • size: 65,852 kB
  • sloc: ansic: 394,903; cpp: 250,252; makefile: 19,635; sh: 15,878; perl: 10,461; fortran: 6,019; ruby: 683; xml: 503; python: 53; awk: 32
file content (53 lines) | stat: -rw-r--r-- 1,859 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// =============================================================== //
//                                                                 //
//   File      : arb_notify.cxx                                    //
//   Purpose   : report termination of external jobs to ARB        //
//                                                                 //
//   Coded by Ralf Westram (coder@reallysoft.de) in May 2007       //
//   Institute of Microbiology (Technical University Munich)       //
//   http://www.arb-home.de/                                       //
//                                                                 //
// =============================================================== //

#include <arbdbt.h>

int ARB_main(int argc, char *argv[]) {
    if (argc == 1) {
        fprintf(stderr, "Usage: arb_notify ID \"message\"\n");
        fprintf(stderr, "Used by ARB itself to report termination of external jobs - see GB_notify()\n");
        return -1;
    }

    const char *progname = argv[0];
    if (!progname || progname[0] == 0) progname = "arb_notify";

    GB_shell shell;
    GBDATA *gb_main = GB_open(":", "r");
    if (!gb_main) {
        fprintf(stderr, "%s: Can't notify (connect to ARB failed)\n", progname);
    }
    else {
        char       *the_message = strdup(argv[2]);
        const char *idstr       = argv[1];
        int         id          = atoi(idstr);
        GB_ERROR    error       = 0;

        if (!id) {
            error = GBS_global_string("Illegal ID '%s'", idstr);
        }

        if (!error) {
            GB_transaction ta(gb_main);
            error = GB_notify(gb_main, id, the_message);
        }

        free(the_message);

        if (error) {
            GBT_message(gb_main, GBS_global_string("Error in %s: %s", progname, error));
        }
        GB_close(gb_main);
    }

    return 0;
}