ARB
Main Page
Namespaces
Classes
Files
File List
File Members
WETC
WETC_main.cxx
Go to the documentation of this file.
1
// ================================================================ //
2
// //
3
// File : WETC_main.cxx //
4
// Purpose : provide minor windowed tasks for CLI //
5
// //
6
// Institute of Microbiology (Technical University Munich) //
7
// http://www.arb-home.de/ //
8
// //
9
// ================================================================ //
10
11
#include <
app.hxx
>
12
13
#include <
asciiprint.hxx
>
14
15
#include <
aw_window.hxx
>
16
#include <
aw_root.hxx
>
17
#include <
aw_question.hxx
>
18
19
#include <
arbdb.h
>
20
21
AW_HEADER_MAIN
22
23
24
int
ARB_main
(
int
argc,
char
*argv[]) {
25
GB_ERROR
error
=
NULp
;
26
27
if
(argc < 3) {
28
error =
"Missing arguments"
;
29
}
30
else
{
31
const
char
*cmd = argv[1];
32
const
char
*param = argv[2];
33
const
char
*option =
NULp
;
34
const
char
*optparam =
NULp
;
35
36
enum
{
UNKNOWN
, FILEEDIT, NOTIFY } mode =
UNKNOWN
;
37
38
if
(strcmp(cmd,
"-fileedit"
) == 0) mode = FILEEDIT;
39
else
if
(strcmp(cmd,
"-notify"
) == 0) {
40
mode = NOTIFY;
41
if
(argc != 3) {
42
if
(argc == 5) {
43
option = argv[3];
44
optparam = argv[4];
45
46
if
(strcmp(option,
"-button"
) != 0) {
47
error =
GBS_global_string
(
"unknown option '%s'"
, option);
48
}
49
}
50
else
{
51
error =
"invalid number of arguments"
;
52
}
53
}
54
}
55
56
if
(!error) {
57
if
(mode ==
UNKNOWN
) {
58
error =
GBS_global_string
(
"Unexpected parameter '%s'"
, cmd);
59
}
60
else
{
61
GB_shell
shell;
62
AW_root
*aw_root =
AWT_create_root
(
"ntree.arb"
,
"ARB_WETC"
,
new
NullTracker
);
// no macro recording here
63
64
switch
(mode) {
65
case
FILEEDIT:
66
AWT_show_file
(aw_root, param);
67
break
;
68
69
case
NOTIFY: {
70
aw_question
(
NULp
, param, option ? optparam :
"Ok"
,
true
,
NULp
);
71
break
;
72
}
73
74
case
UNKNOWN
:
75
arb_assert
(0);
// should not be reached!
76
break
;
77
}
78
79
aw_root->
window_hide
(
NULp
);
80
AWT_install_cb_guards
();
81
aw_root->
main_loop
();
82
}
83
}
84
}
85
86
if
(error) {
87
fprintf(stderr,
88
"arb_wetc -- ARB Window Environment To CLI -- start GUI tasks from CLI\n"
89
"\n"
90
"Syntax: arb_wetc -fileedit filename\n"
91
" edit a file before sending it to printer.\n"
92
"\n"
93
"Syntax: arb_wetc -notify message [-button buttontext]\n"
94
" display a message. Allow user to press OK button.\n"
95
"\n"
96
"Error: %s\n"
,
97
error);
98
return
EXIT_FAILURE
;
99
}
100
101
return
EXIT_SUCCESS
;
102
}
103
arb_assert
#define arb_assert(cond)
Definition:
arb_assert.h:245
GB_ERROR
const char * GB_ERROR
Definition:
arb_core.h:25
AWT_show_file
void AWT_show_file(AW_root *awr, const char *filename)
Definition:
asciiprint.cxx:518
aw_question.hxx
UNKNOWN
Definition:
fun.h:25
GBS_global_string
const char * GBS_global_string(const char *templat,...)
Definition:
arb_msg.cxx:203
arbdb.h
EXIT_SUCCESS
#define EXIT_SUCCESS
Definition:
arb_a2ps.c:154
AWT_create_root
AW_root * AWT_create_root(const char *properties, const char *program, UserActionTracker *user_tracker)
Definition:
db_browser.cxx:1292
AWT_install_cb_guards
void AWT_install_cb_guards()
Definition:
db_browser.cxx:1361
asciiprint.hxx
error
static void error(const char *msg)
Definition:
mkptypes.cxx:96
aw_root.hxx
app.hxx
EXIT_FAILURE
#define EXIT_FAILURE
Definition:
arb_a2ps.c:157
NullTracker
Definition:
aw_root.hxx:76
AW_HEADER_MAIN
#define AW_HEADER_MAIN
Definition:
aw_window.hxx:36
aw_window.hxx
GB_shell
Definition:
arbdb.h:159
AW_root::main_loop
void main_loop()
Definition:
AW_root.cxx:625
aw_question
int aw_question(const char *unique_id, const char *question, const char *buttons, bool sameSizeButtons, const char *helpfile)
Definition:
AW_question.cxx:26
AW_root
Definition:
aw_root.hxx:86
NULp
#define NULp
Definition:
cxxforward.h:116
ARB_main
AW_HEADER_MAIN int ARB_main(int argc, char *argv[])
Definition:
WETC_main.cxx:24
AW_root::window_hide
void window_hide(AW_window *aww)
Definition:
AW_root.cxx:477
Generated by
1.8.8