aboutsummaryrefslogtreecommitdiff
path: root/vendor/voclient/libvoclient/vocLib_spp.c
blob: 5e2b0ce08cb3e204cf82c28b198820ec20df5465 (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/***************************************************************************
 *
 *  SPP Language binding for the VOClient interface.
 *
 *  Michael Fitzpatrick, NOAO, Jul 2006
 *
 **************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>

#define _VOCLIENT_LIB_
#include "VOClient.h"


/*  SPP Name mapping macros.  SPP procedure names are mappad as the first-5
**  plus the last character of a name minus any underscores.  This should
**  be done such that a unique 6-character name is produced for each SPP
**  symbol.  In these definitions the SPP code may use the long form of the
**  name in the code, the mapping is done automatically and so we need the
**  macros here so the symbol entered in the library is actually the short
**  name.
*/

#ifdef _NO_US_
#define	vx_initvoclient 	vxinit
#define	vx_closevoclient	vxclot
#define	vx_abortvoclient 	vxabot
#define	vx_validate 		vxvale
#define	vx_dbglevel 		vxdbgl

#else

#define	vx_initvoclient 	vxinit_
#define	vx_closevoclient 	vxclot_
#define	vx_abortvoclient 	vxabot_
#define	vx_validate 		vxvale_
#define	vx_dbglevel 		vxdbgl_

#endif



/* SPP Type definitions.
*/
#define XCHAR		short
#define PKCHAR		char
#define XINT		int
#define XEOS		NULL


/*  Public interface procedures.
**
*/
int	vx_initvoclient (XCHAR *opts);
void	vx_closevoclient (int *shutdown);
void	vx_abortvoclient (int *code, XCHAR *msg);
int	vx_validate (int *hcode);
void	vx_dbglevel (int *level);



/*  Private interface procedures.
*/
extern PKCHAR *spp2c (XCHAR *instr,  int maxch);
extern int     c2spp (PKCHAR *instr, XCHAR *outstr, int maxch);
extern int    spplen (XCHAR *str);
extern int  dal_typecode (char *typestr);
extern int  out_typecode (char *typestr);




/******************************************************************************
**  OPENVOCLIENT --  Open and initialize the VOClient interface.
*/
int
vx_initvoclient (XCHAR *opts)
{
    char *_opts = spp2c (opts, spplen (opts));

    int ier = voc_initVOClient (_opts);

    free ((char *) _opts);
    return (ier);
}


/******************************************************************************
**  CLOSEVOCLIENT -- Close and free the VOClient interface.
*/
void
vx_closevoclient (int *shutdown)
{
    voc_closeVOClient (*shutdown);
}



/******************************************************************************
**  ABORTVOCLIENT -- Close the VOClient interface and abort the application.
*/
void
vx_abortvoclient (int *code, XCHAR *msg)
{
    char *_msg = spp2c (msg, spplen (msg));

    voc_abortVOClient (*code, _msg);

    free ((char *) _msg);
}


/******************************************************************************
** VALIDATE -- Validate and object handle in the daemon.
*/
int 
vx_validate (int *hcode) { return (voc_validateObject (*hcode)); }


/******************************************************************************
** DEBUGLEVEL -- Set the package debugging output level.
*/
void 
vx_dbglevel (int *level) { 
    extern void voc_debugLevel ();
    voc_debugLevel (*level); 
}