aboutsummaryrefslogtreecommitdiff
path: root/vo/votools/console.x
blob: b49846db5c4b461431aeda378c28b79cc903cf89 (plain) (blame)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#
#  CONSOLE -- Small VO Client console/utility tasks


#  VOCDCTL -- VO Client daemon control

procedure t_vocdctl ()

int     fdi, fdo
char	cmd[SZ_FNAME], buf[SZ_FNAME]

int	vx_initVOClient()
int     ndopen(), reopen()
bool	streq()

define	start_ 	99

begin
	call aclrs (cmd, SZ_FNAME)

	call clgstr ("cmd", cmd, SZ_FNAME)

	if (streq (cmd, "start")) {
	    # Initialize the VO Client interface.
start_	    if (vx_initVOClient("console") == ERR) {		
	        call clputi ("status", ERR)
	        call error (0, "Error initializing VO Client")
	        return
	    }

	} else if (streq (cmd, "stop")) {
	    # Close the VO Client interface.  It's possible we might not
	    # already be connected, so open a raw socket and send the text
	    # string directly.

	    iferr {
            	fdi = ndopen ("inet:6200", READ_WRITE)
            	fdo = reopen (fdi, READ_WRITE)

		# Pack and pad the string so we can speak C.
		call strpak ("END ", buf, 4)
            	call write (fdo, buf, 4)
            	call flush (fdo)

            	call close (fdi)
            	call close (fdo)
	    } then {
		call eprintf ("Shutdown failed -- no server?\n")
	    }


	} else if (streq (cmd, "restart")) {
	    # Restart the VO Client interface.
	    call vx_closeVOClient (1)
	    goto start_

	} else {
	    call eprintf ("Invalid command: '%s'\n")
		call pargstr (cmd)
	}
end


#  DBGLEVEL -- Set the VO Client debug level.

procedure t_dbglevel ()

int	level

int	vx_initVOClient(), clgeti()

begin
	# Initialize the VO Client interface.
	if (vx_initVOClient("") == ERR) {		
	    call clputi ("status", ERR)
	    call error (0, "Error initializing VO Client")
	    return
	}

	level = clgeti ("level")
	call vx_dbglevel (level)

	call vx_closeVOClient (0)
end