|
Last change
on this file was
16763,
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.7 KB
|
| Line | |
|---|
| 1 | // =============================================================== // |
|---|
| 2 | // // |
|---|
| 3 | // File : arb_message.cxx // |
|---|
| 4 | // Purpose : raise aw_message from external scripts // |
|---|
| 5 | // // |
|---|
| 6 | // Coded by Ralf Westram (coder@reallysoft.de) in November 2003 // |
|---|
| 7 | // Institute of Microbiology (Technical University Munich) // |
|---|
| 8 | // http://www.arb-home.de/ // |
|---|
| 9 | // // |
|---|
| 10 | // =============================================================== // |
|---|
| 11 | |
|---|
| 12 | #include <arbdbt.h> |
|---|
| 13 | |
|---|
| 14 | int ARB_main(int argc, char *argv[]) { |
|---|
| 15 | if (argc == 1) { |
|---|
| 16 | fprintf(stderr, "Usage: arb_message \"the message\"\n"); |
|---|
| 17 | return EXIT_FAILURE; |
|---|
| 18 | } |
|---|
| 19 | |
|---|
| 20 | const char *progname = argv[0]; |
|---|
| 21 | if (!progname || progname[0] == 0) progname = "arb_message"; |
|---|
| 22 | |
|---|
| 23 | char *the_message = ARB_strdup(argv[1]); |
|---|
| 24 | size_t len = strlen(the_message); |
|---|
| 25 | char *unencoded_lf = NULp; |
|---|
| 26 | while ((unencoded_lf = strstr(the_message, "\\n"))) { |
|---|
| 27 | unencoded_lf[0] = '\n'; |
|---|
| 28 | size_t restlen = len-(unencoded_lf-the_message)-1; // len - "chars before \n" - "\n" |
|---|
| 29 | memmove(unencoded_lf+1, unencoded_lf+2, restlen+1); // copy restlen plus 0-terminator |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | { |
|---|
| 33 | GB_shell shell; |
|---|
| 34 | GBDATA *gb_main = GB_open(":", "r"); |
|---|
| 35 | if (!gb_main) { |
|---|
| 36 | fprintf(stderr, "%s: %s\n", progname, the_message); |
|---|
| 37 | } |
|---|
| 38 | else { |
|---|
| 39 | GBT_message(gb_main, the_message); |
|---|
| 40 | GB_close(gb_main); |
|---|
| 41 | } |
|---|
| 42 | } |
|---|
| 43 | free(the_message); |
|---|
| 44 | return EXIT_SUCCESS; |
|---|
| 45 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.