2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 /***************************************************************************
19 * Description: Data marshaling. XDR like *
20 * Author: Costin <costin@costin.dnt.ro> *
21 * Author: Gal Shachor <shachor@il.ibm.com> *
22 * Version: $Revision: 530674 $ *
23 ***************************************************************************/
32 #endif /* __cplusplus */
34 #define DEF_BUFFER_SZ (8 * 1024)
36 /* XXX replace all return values with error codes */
37 #define ERR_BAD_PACKET -5
42 - one parameter - use a structure for more. The method
43 is encoded as part of the request
51 typedef struct jk_msg_buf_t jk_msg_buf_t;
62 /* -------------------- Setup routines -------------------- */
64 /** Allocate a buffer.
66 jk_msg_buf_t *jk_b_new(jk_pool_t *p);
68 /** Set up a buffer with an existing buffer
70 int jk_b_set_buffer(jk_msg_buf_t *msg, unsigned char *data, int buffSize);
73 * Set up a buffer with a new buffer of buffSize
75 int jk_b_set_buffer_size(jk_msg_buf_t *msg, int buffSize);
78 * Finalize the buffer before sending - set length fields, etc
80 void jk_b_end(jk_msg_buf_t *msg, int protoh);
83 * Recycle the buffer - z for a new invocation
85 void jk_b_reset(jk_msg_buf_t *msg);
87 /* -------------------- Real encoding -------------------- */
89 int jk_b_append_byte(jk_msg_buf_t *msg, unsigned char val);
91 int jk_b_append_bytes(jk_msg_buf_t *msg,
92 const unsigned char *param, int len);
94 int jk_b_append_int(jk_msg_buf_t *msg, unsigned short val);
96 int jk_b_append_long(jk_msg_buf_t *msg, unsigned long val);
98 int jk_b_append_string(jk_msg_buf_t *msg, const char *param);
100 #if defined(AS400) && !defined(AS400_UTF8)
101 int jk_b_append_asciistring(jk_msg_buf_t *msg, const char *param);
104 int jk_b_append_bytes(jk_msg_buf_t *msg,
105 const unsigned char *param, int len);
107 /* -------------------- Decoding -------------------- */
109 /** Get a byte from the current position
111 unsigned char jk_b_get_byte(jk_msg_buf_t *msg);
113 /** Get an int from the current position
115 unsigned short jk_b_get_int(jk_msg_buf_t *msg);
117 /** Get a long from the current position
119 unsigned long jk_b_get_long(jk_msg_buf_t *msg);
121 /** Get a String from the current position
123 unsigned char *jk_b_get_string(jk_msg_buf_t *msg);
125 /** Get Bytes from the current position
127 int jk_b_get_bytes(jk_msg_buf_t *msg, unsigned char *buf, int len);
129 /** Get a byte from an arbitrary position
131 unsigned char jk_b_pget_byte(jk_msg_buf_t *msg, int pos);
133 /** Get an int from an arbitrary position
135 unsigned short jk_b_pget_int(jk_msg_buf_t *msg, int pos);
137 /** Get a long from an arbitrary position
139 unsigned long jk_b_pget_long(jk_msg_buf_t *msg, int pos);
141 /* --------------------- Help ------------------------ */
142 void jk_dump_buff(jk_logger_t *l,
144 int line, const char *funcname,
145 int level, char *what, jk_msg_buf_t *msg);
147 /** Copy a msg buf into another one
149 int jk_b_copy(jk_msg_buf_t *smsg, jk_msg_buf_t *dmsg);
153 #endif /* __cplusplus */
154 #endif /* JK_MSG_BUF_H */