source: tags/arb_5.0/TOOLS/arb_notify.cxx

Last change on this file was 4551, checked in by westram, 17 years ago
  • callback tool (used to send notification when some external program finishes)
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.2 KB
Line 
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <arbdb.h>
5#include <arbdbt.h>
6
7int main(int argc,char **argv)
8{
9    if (argc == 1)  {
10        fprintf(stderr, "Usage: arb_notify ID \"message\"\n");
11        fprintf(stderr, "Used by ARB itself to report termination of external jobs - see GB_notify()\n");
12        return -1;
13    }
14
15    const char *progname = argv[0];
16    if (!progname || progname[0] == 0) progname = "arb_notify";
17
18    GBDATA *gb_main = GB_open(":","r");
19    if (!gb_main){
20        fprintf(stderr, "%s: Can't notify (connect to ARB failed)\n", progname);
21    }
22    else {
23        char       *the_message = strdup(argv[2]);
24        const char *idstr       = argv[1];
25        int         id          = atoi(idstr);
26        GB_ERROR    error       = 0;
27
28        if (!id) {
29            error = GBS_global_string("Illegal ID '%s'", idstr);
30        }
31
32        if (!error) {
33            GB_transaction ta(gb_main);
34            error = GB_notify(gb_main, id, the_message);
35        }
36
37        free(the_message);
38
39        if (error) {
40            GBT_message(gb_main, GBS_global_string("Error in %s: %s", progname, error));
41        }
42        GB_close(gb_main);
43    }
44
45    return 0;
46}
Note: See TracBrowser for help on using the repository browser.