source: tags/ms_r16q3/TOOLS/arb_notify.cxx

Last change on this file was 15176, checked in by westram, 8 years ago
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.8 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : arb_notify.cxx                                    //
4//   Purpose   : report termination of external jobs to ARB        //
5//                                                                 //
6//   Coded by Ralf Westram (coder@reallysoft.de) in May 2007       //
7//   Institute of Microbiology (Technical University Munich)       //
8//   http://www.arb-home.de/                                       //
9//                                                                 //
10// =============================================================== //
11
12#include <arbdbt.h>
13
14int ARB_main(int argc, char *argv[]) {
15    if (argc == 1) {
16        fprintf(stderr, "Usage: arb_notify ID \"message\"\n");
17        fprintf(stderr, "Used by ARB itself to report termination of external jobs - see GB_notify()\n");
18        return -1;
19    }
20
21    const char *progname = argv[0];
22    if (!progname || progname[0] == 0) progname = "arb_notify";
23
24    GB_shell shell;
25    GBDATA *gb_main = GB_open(":", "r");
26    if (!gb_main) {
27        fprintf(stderr, "%s: Can't notify (connect to ARB failed)\n", progname);
28    }
29    else {
30        char       *the_message = ARB_strdup(argv[2]);
31        const char *idstr       = argv[1];
32        int         id          = atoi(idstr);
33        GB_ERROR    error       = 0;
34
35        if (!id) {
36            error = GBS_global_string("Illegal ID '%s'", idstr);
37        }
38
39        if (!error) {
40            GB_transaction ta(gb_main);
41            error = GB_notify(gb_main, id, the_message);
42        }
43
44        free(the_message);
45
46        if (error) {
47            GBT_message(gb_main, GBS_global_string("Error in %s: %s", progname, error));
48        }
49        GB_close(gb_main);
50    }
51
52    return 0;
53}
Note: See TracBrowser for help on using the repository browser.