libguac  0.9.12-incubating
parser.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
20 
21 #ifndef _GUAC_PARSER_H
22 #define _GUAC_PARSER_H
23 
30 #include "parser-types.h"
31 #include "parser-constants.h"
32 #include "socket-types.h"
33 
34 struct guac_parser {
35 
39  char* opcode;
40 
44  int argc;
45 
49  char** argv;
50 
55 
59  int __element_length;
60 
64  int __elementc;
65 
69  char* __elementv[GUAC_INSTRUCTION_MAX_ELEMENTS];
70 
75  char* __instructionbuf_unparsed_start;
76 
80  char* __instructionbuf_unparsed_end;
81 
87  char __instructionbuf[32768];
88 
89 };
90 
98 
113 int guac_parser_append(guac_parser* parser, void* buffer, int length);
114 
122 int guac_parser_length(guac_parser* parser);
123 
133 int guac_parser_shift(guac_parser* parser, void* buffer, int length);
134 
140 void guac_parser_free(guac_parser* parser);
141 
163 int guac_parser_read(guac_parser* parser, guac_socket* socket, int usec_timeout);
164 
186 int guac_parser_expect(guac_parser* parser, guac_socket* socket, int usec_timeout, const char* opcode);
187 
188 #endif
189 
char ** argv
Array of all arguments passed to this instruction.
Definition: parser.h:49
guac_parser * guac_parser_alloc()
Allocates a new parser.
int guac_parser_read(guac_parser *parser, guac_socket *socket, int usec_timeout)
Reads a single instruction from the given guac_socket connection.
int guac_parser_expect(guac_parser *parser, guac_socket *socket, int usec_timeout, const char *opcode)
Reads a single instruction from the given guac_socket.
Type definitions related to the guac_socket object.
int guac_parser_append(guac_parser *parser, void *buffer, int length)
Appends data from the given buffer to the given parser.
The core I/O object of Guacamole.
Definition: socket.h:39
Type definitions related to parsing the Guacamole protocol.
int guac_parser_length(guac_parser *parser)
Returns the number of unparsed bytes stored in the given parser's internal buffers.
void guac_parser_free(guac_parser *parser)
Frees all memory allocated to the given parser.
char * opcode
The opcode of the instruction.
Definition: parser.h:39
guac_parse_state
All possible states of the instruction parser.
Definition: parser-types.h:33
guac_parse_state state
The parse state of the instruction.
Definition: parser.h:54
int argc
The number of arguments passed to this instruction.
Definition: parser.h:44
int guac_parser_shift(guac_parser *parser, void *buffer, int length)
Removes up to length bytes from internal buffer of unparsed bytes, storing them in the given buffer...
#define GUAC_INSTRUCTION_MAX_ELEMENTS
The maximum number of elements per instruction, including the opcode.
Definition: parser-constants.h:42
A Guacamole protocol parser, which reads individual instructions, filling its own internal structure ...
Definition: parser.h:34
Constants related to the Guacamole protocol parser.