xref: /onnv-gate/usr/src/cmd/wbem/provider/tools/rds/rdprot.h (revision 0:68f95e015346)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 2001 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef	_RDPROT_H
28 #define	_RDPROT_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <stdio.h>
37 #include <strings.h>
38 #include <sys/utsname.h>
39 
40 #include "rdimpl.h"
41 
42 #define	offsetof(s, m)  ((size_t)(&(((s *)0)->m)))
43 
44 /* some maximal values */
45 #define	P_MAXLEN	80
46 #define	P_MAXKEY	20
47 #define	P_MAXVAL	59
48 #define	MAX_RETRIES 	20
49 
50 /* Tags definitions */
51 
52 #define	PROTM "@RDS-MAG@"
53 #define	RDERR "RDERR"
54 #define	PROTV "PROTV"
55 #define	LISTT "LISTT"
56 #define	LISTN "LISTN"
57 #define	ELEMN "ELEMN"
58 #define	ELMID "ELMID"
59 #define	FILDN "FILDN"
60 #define	PROMPT "@RDS@>"
61 #define	PROMPT_OK ""
62 #define	PROMPT_WHAT " ?"
63 #define	CRETURN		"\n"
64 
65 #define	PROT_VERSION 100
66 
67 /* list types */
68 #define	L_PRC_SI 1
69 #define	L_USR_SI 2
70 #define	L_PRJ_SI 3
71 #define	L_AC_USR 4
72 #define	L_AC_PRJ 5
73 #define	L_SYSTEM 6
74 #define	L_LWP	 8
75 #define	L_LWP__I 9
76 #define	L_LWP__U 10
77 
78 #define	CMD_EMPTY 0
79 #define	CMD_GETALL   	"-pUuJjS"
80 #define	CMD_GETPL	"-p"
81 #define	CMD_GETUL	"-u"
82 #define	CMD_GETAUL	"-U"
83 #define	CMD_GETJL	"-j"
84 #define	CMD_GETAJL	"-J"
85 #define	CMD_GETASL	"-S"
86 #define	CMD_SETINTERVAL "-i100"
87 #define	CMD_ALIVE 	"alive"
88 #define	CMD_EXIT  	"exit"
89 
90 extern int open_prot(int fd, char *rw);
91 extern void close_prot(void);
92 extern void wr_error(char *err);
93 extern int wr_phead(void);
94 extern int wr_lshead(int n);
95 extern int wr_lhead(int type, int n);
96 extern int wr_element(int stubidx, char *src, char *elemid);
97 extern int wr_ctrl(int code);
98 extern int wr_prompt(char *code);
99 extern int wr_string(char *code);
100 extern int wr_value(char *key, int64_t v);
101 extern int skip_line(void);
102 extern int r_phead(void);
103 extern int r_lshead();
104 extern int r_lhead(int *type);
105 extern int r_element(char *src, char *elemid);
106 extern int64_t r_value(char *key);
107 extern int r_ctrl(void);
108 extern char *r_cmd(void);
109 
110 extern char rderr[];
111 
112 typedef struct {
113 	int (* format)(int, char *, char *, int);
114 	size_t   off;
115 } info_t;
116 
117 typedef struct {
118 	char *key;
119 	info_t info;
120 } kv_pair_t;
121 
122 typedef struct {
123 	int size;
124 	kv_pair_t *stub;
125 } stub_t;
126 
127 typedef struct {
128 	int32_t pr_pid;
129 	int32_t pr_lwpid;
130 	int32_t pr_pctcpu;
131 	int64_t	pr_time_tv_sec;
132 	int64_t	pr_time_tv_nsec;
133 	int32_t pr_bindpset;
134 } lwpinfo_t;
135 
136 typedef struct {
137 	int command;
138 } cmd_t;
139 
140 #ifdef	__cplusplus
141 }
142 #endif
143 
144 #endif /* _RDPROT_H */
145