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 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
|
/*
* The Regina Rexx Interpreter
* Copyright (C) 2000 Mark Hessling <M.Hessling@qut.edu.au>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* $Id: extstack.h,v 1.9 2003/07/17 09:32:22 florian Exp $
*/
#include "rexxbif.h" /* C functions that mimic REXX BIFs */
#define FIFO_LINE(buf,line) { \
/* This macro adds a line to a buffer in FIFO manner. \
* The line's higher/lower elements will be overwritten both. \
*/ \
(line)->lower = NULL ; \
(line)->higher = (buf)->bottom ; \
(buf)->bottom = line ; \
if ( (line)->higher != NULL ) \
(line)->higher->lower = (line) ; \
else \
{ \
(buf)->top = (line) ; /* buffer was empty previously */ \
assert( (buf)->elements == 0 ) ; \
} \
(buf)->elements++ ; \
}
#define LIFO_LINE(buf,line) { \
/* This macro adds a line to a buffer in LIFO manner. \
* The line's higher/lower elements will be overwritten both. \
*/ \
(line)->higher = NULL ; \
(line)->lower = (buf)->top ; \
(buf)->top = line ; \
if ( (line)->lower != NULL ) \
(line)->lower->higher = (line) ; \
else \
{ \
(buf)->bottom = (line) ; /* buffer was empty previously */ \
assert( (buf)->elements == 0 ) ; \
} \
(buf)->elements++ ; \
}
#define POP_LINE(buf,line) { \
/* This macro removes a line from a buffer. The argument "line" \
* will be overwritten. The higher/older elements of that value \
* won't be overwritten. \
*/ \
if ( ( (line) = (buf)->top ) != NULL ) \
{ \
(buf)->elements-- ; \
if ( ( (buf)->top = (line)->lower ) == NULL ) \
{ \
(buf)->bottom = NULL ; \
assert( (buf)->elements == 0 ) ; \
(buf)->elements = 0 ; /* if assert is defined out */ \
} \
else \
{ \
(buf)->top->higher = NULL ; \
} \
} \
}
#define GLUE_BUFFER1(buf1,buf2) { \
/* This macro glues buf2 at the top of buf1 and writes the result \
* to buf1. buf2's top/bottom/elements fields are reset. \
*/ \
if ( (buf2)->bottom != NULL ) \
{ \
if ( (buf1)->top == NULL ) \
{ \
assert( ( (buf1)->bottom == NULL ) && ( (buf1)->elements == 0 ) ) ;\
(buf1)->top = (buf2)->top ; \
(buf1)->bottom = (buf2)->bottom ; \
(buf1)->elements = (buf2)->elements ; \
} \
else \
{ \
(buf1)->top->higher = (buf2)->bottom ; \
(buf2)->bottom->lower = (buf1)->top ; \
(buf1)->top = (buf2)->top ; \
(buf1)->elements += (buf2)->elements ; \
} \
} \
else \
{ \
assert( ( (buf2)->top == NULL ) && ( (buf2)->elements == 0 ) ) ; \
} \
(buf2)->top = NULL ; \
(buf2)->bottom = NULL ; \
(buf2)->elements = 0 ; \
}
#define GLUE_BUFFER2(buf1,buf2) { \
/* This macro glues buf2 at the top of buf1 and writes the result \
* to buf2. buf1's top/bottom/elements fields are reset. \
*/ \
if ( (buf1)->bottom != NULL ) \
{ \
if ( (buf2)->top == NULL ) \
{ \
assert( ( (buf2)->bottom == NULL ) && ( (buf2)->elements == 0 ) ) ;\
(buf2)->top = (buf1)->top ; \
(buf2)->bottom = (buf1)->bottom ; \
(buf2)->elements = (buf1)->elements ; \
} \
else \
{ \
(buf1)->top->higher = (buf2)->bottom ; \
(buf2)->bottom->lower = (buf1)->top ; \
(buf2)->bottom = (buf1)->bottom ; \
(buf2)->elements += (buf2)->elements ; \
} \
} \
else \
{ \
assert( ( (buf1)->top == NULL ) && ( (buf1)->elements == 0 ) ) ; \
} \
(buf1)->top = NULL ; \
(buf1)->bottom = NULL ; \
(buf1)->elements = 0 ; \
}
void showerror( int err, int suberr, char *tmpl, ...);
int init_external_queue( const tsd_t *TSD );
void term_external_queue( void );
int default_port_number( void ) ;
int default_external_address( void ) ;
streng *default_external_name( const tsd_t *TSD ) ;
int connect_to_rxstack( tsd_t *TSD, Queue *q ) ;
int disconnect_from_rxstack( const tsd_t *TSD, Queue *q ) ;
int parse_queue( tsd_t *TSD, streng *queue, Queue *q ) ;
int send_command_to_rxstack( const tsd_t *TSD, int sock, const char *action, const char *str, int len );
streng *read_result_from_rxstack( const tsd_t *TSD, int sock, int result_size );
int delete_queue_from_rxstack( const tsd_t *TSD, int sock, const streng *queue_name );
int set_queue_in_rxstack( const tsd_t *TSD, int sock, const streng *queue_name );
int get_number_in_queue_from_rxstack( const tsd_t *TSD, int sock, int *errcode );
int clear_queue_on_rxstack( const tsd_t *TSD, int sock ) ;
int get_queue_from_rxstack( const tsd_t *TSD, const Queue *q, streng **result );
int create_queue_on_rxstack( const tsd_t *TSD, const Queue *q, const streng *queue, streng **result );
int timeout_queue_on_rxstack( const tsd_t *TSD, int sock, long timeout );
int get_line_from_rxstack( const tsd_t *TSD, int sock, streng **result, int nowait );
int queue_line_lifo_to_rxstack( const tsd_t *TSD, int sock, const streng *line );
int queue_line_fifo_to_rxstack( const tsd_t *TSD, int sock, const streng *line );
int get_length_from_header( const tsd_t *TSD, const streng *header );
#define RXSTACK_EXIT 'X'
#define RXSTACK_EXIT_STR "X"
#define RXSTACK_KILL 'Z'
#define RXSTACK_KILL_STR "Z"
#define RXSTACK_QUEUE_FIFO 'F'
#define RXSTACK_QUEUE_FIFO_STR "F"
#define RXSTACK_QUEUE_LIFO 'L'
#define RXSTACK_QUEUE_LIFO_STR "L"
#define RXSTACK_CREATE_QUEUE 'C'
#define RXSTACK_CREATE_QUEUE_STR "C"
#define RXSTACK_DELETE_QUEUE 'D'
#define RXSTACK_DELETE_QUEUE_STR "D"
#define RXSTACK_EMPTY_QUEUE 'E'
#define RXSTACK_EMPTY_QUEUE_STR "E"
#define RXSTACK_PULL 'P'
#define RXSTACK_PULL_STR "P"
#define RXSTACK_FETCH 'p'
#define RXSTACK_FETCH_STR "p"
#define RXSTACK_SET_QUEUE 'S'
#define RXSTACK_SET_QUEUE_STR "S"
#define RXSTACK_GET_QUEUE 'G'
#define RXSTACK_GET_QUEUE_STR "G"
#define RXSTACK_NUMBER_IN_QUEUE 'N'
#define RXSTACK_NUMBER_IN_QUEUE_STR "N"
#define RXSTACK_TIMEOUT_QUEUE 'T'
#define RXSTACK_TIMEOUT_QUEUE_STR "T"
#define RXSTACK_UNKNOWN '?'
#define RXSTACK_UNKNOWN_STR "?"
#define RXSTACK_HEADER_SIZE 7
#define RXSTACK_TIMEOUT_SIZE 6
#ifndef RXSOCKET
# define RXSOCKET 5757
#endif
#define ERR_RXSTACK_CANT_CONNECT 101
#define ERR_RXSTACK_CANT_CONNECT_TMPL "Error connecting to %s on port %d: \"%s\""
#define ERR_RXSTACK_NO_IP 102
#define ERR_RXSTACK_NO_IP_TMPL "Unable to obtain IP address for %s"
#define ERR_RXSTACK_INVALID_SERVER 103
#define ERR_RXSTACK_INVALID_SERVER_TMPL "Invalid format for server in specified queue name: \"%s\""
#define ERR_RXSTACK_INVALID_QUEUE 104
#define ERR_RXSTACK_INVALID_QUEUE_TMPL "Invalid format for queue name: \"%s\""
#define ERR_RXSTACK_NO_WINSOCK 105
#define ERR_RXSTACK_NO_WINSOCK_TMPL "Unable to start Windows Socket interface: %s"
#define ERR_RXSTACK_TOO_MANY_QUEUES 106
#define ERR_RXSTACK_TOO_MANY_QUEUES_TMPL "Maximum number of external queues exceeded: %d"
#define ERR_RXSTACK_READING_SOCKET 107
#define ERR_RXSTACK_READING_SOCKET_TMPL "Error occured reading socket: %s"
#define ERR_RXSTACK_INVALID_SWITCH 108
#define ERR_RXSTACK_INVALID_SWITCH_TMPL "Invalid switch passed. Must be one of \"%s\""
#define ERR_RXSTACK_INTERNAL 99
#define ERR_RXSTACK_INTERNAL_TMPL "Internal error with external queue interface: %d \"%s\""
#define ERR_RXSTACK_GENERAL 100
#define ERR_RXSTACK_GENERAL_TMPL "General system error with external queue interface. %s. %s"
#define ERR_STORAGE_EXHAUSTED_TMPL "System resources exhausted"
|