Move static stream helper functions to parse.c
This commit is contained in:
parent
0954ac3ca5
commit
4cbfda90fd
@ -25,7 +25,7 @@ SOUNDOBJ = @SOUNDOBJ@
|
||||
SCARDOBJ = @SCARDOBJ@
|
||||
CREDSSPOBJ = @CREDSSPOBJ@
|
||||
|
||||
RDPOBJ = tcp.o asn.o iso.o mcs.o secure.o licence.o rdp.o orders.o bitmap.o cache.o rdp5.o channels.o rdpdr.o serial.o printer.o disk.o parallel.o printercache.o mppc.o pstcache.o lspci.o seamless.o ssl.o utils.o
|
||||
RDPOBJ = tcp.o asn.o iso.o mcs.o secure.o licence.o rdp.o orders.o bitmap.o cache.o rdp5.o channels.o rdpdr.o serial.o printer.o disk.o parallel.o printercache.o mppc.o pstcache.o lspci.o seamless.o ssl.o utils.o parse.o
|
||||
X11OBJ = rdesktop.o xwin.o xkeymap.o ewmhints.o xclip.o cliprdr.o ctrl.o
|
||||
|
||||
.PHONY: all
|
||||
|
28
cssp.c
28
cssp.c
@ -30,34 +30,6 @@ extern char *g_sc_container_name;
|
||||
static gss_OID_desc _gss_spnego_krb5_mechanism_oid_desc =
|
||||
{ 9, (void *) "\x2a\x86\x48\x86\xf7\x12\x01\x02\x02" };
|
||||
|
||||
|
||||
static void
|
||||
s_realloc(STREAM s, unsigned int size)
|
||||
{
|
||||
unsigned char *data;
|
||||
|
||||
if (s->size >= size)
|
||||
return;
|
||||
|
||||
data = s->data;
|
||||
s->size = size;
|
||||
s->data = xrealloc(data, size);
|
||||
s->p = s->data + (s->p - data);
|
||||
s->end = s->data + (s->end - data);
|
||||
s->iso_hdr = s->data + (s->iso_hdr - data);
|
||||
s->mcs_hdr = s->data + (s->mcs_hdr - data);
|
||||
s->sec_hdr = s->data + (s->sec_hdr - data);
|
||||
s->rdp_hdr = s->data + (s->rdp_hdr - data);
|
||||
s->channel_hdr = s->data + (s->channel_hdr - data);
|
||||
}
|
||||
|
||||
static void
|
||||
s_free(STREAM s)
|
||||
{
|
||||
free(s->data);
|
||||
free(s);
|
||||
}
|
||||
|
||||
static STREAM
|
||||
ber_wrap_hdr_data(int tagval, STREAM in)
|
||||
{
|
||||
|
61
parse.c
Normal file
61
parse.c
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
rdesktop: A Remote Desktop Protocol client.
|
||||
Parsing primitives
|
||||
Copyright 2017 Henrik Andersson <hean01@cendio.se> for Cendio AB
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "rdesktop.h"
|
||||
|
||||
#include "parse.h"
|
||||
|
||||
void
|
||||
s_realloc(STREAM s, unsigned int size)
|
||||
{
|
||||
unsigned char *data;
|
||||
|
||||
if (s->size >= size)
|
||||
return;
|
||||
|
||||
data = s->data;
|
||||
s->size = size;
|
||||
s->data = xrealloc(data, size);
|
||||
s->p = s->data + (s->p - data);
|
||||
s->end = s->data + (s->end - data);
|
||||
s->iso_hdr = s->data + (s->iso_hdr - data);
|
||||
s->mcs_hdr = s->data + (s->mcs_hdr - data);
|
||||
s->sec_hdr = s->data + (s->sec_hdr - data);
|
||||
s->rdp_hdr = s->data + (s->rdp_hdr - data);
|
||||
s->channel_hdr = s->data + (s->channel_hdr - data);
|
||||
}
|
||||
|
||||
void
|
||||
s_reset(STREAM s)
|
||||
{
|
||||
struct stream tmp;
|
||||
tmp = *s;
|
||||
memset(s, 0, sizeof(struct stream));
|
||||
s->size = tmp.size;
|
||||
s->end = s->p = s->data = tmp.data;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
s_free(STREAM s)
|
||||
{
|
||||
free(s->data);
|
||||
free(s);
|
||||
}
|
13
parse.h
13
parse.h
@ -2,7 +2,7 @@
|
||||
rdesktop: A Remote Desktop Protocol client.
|
||||
Parsing primitives
|
||||
Copyright (C) Matthew Chapman 1999-2008
|
||||
Copyright 2012 Henrik Andersson <hean01@cendio.se> for Cendio AB
|
||||
Copyright 2012-2017 Henrik Andersson <hean01@cendio.se> for Cendio AB
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -18,6 +18,9 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _PARSE_H
|
||||
#define _PARSE_H
|
||||
|
||||
/* Parser state */
|
||||
typedef struct stream
|
||||
{
|
||||
@ -36,6 +39,10 @@ typedef struct stream
|
||||
}
|
||||
*STREAM;
|
||||
|
||||
void s_realloc(STREAM s, unsigned int size);
|
||||
void s_free(STREAM s);
|
||||
void s_reset(STREAM s);
|
||||
|
||||
#define s_push_layer(s,h,n) { (s)->h = (s)->p; (s)->p += n; }
|
||||
#define s_pop_layer(s,h) (s)->p = (s)->h;
|
||||
#define s_mark_end(s) (s)->end = (s)->p;
|
||||
@ -43,7 +50,6 @@ typedef struct stream
|
||||
#define s_check_rem(s,n) ((s)->p + n <= (s)->end)
|
||||
#define s_check_end(s) ((s)->p == (s)->end)
|
||||
#define s_length(s) ((s)->end - (s)->data)
|
||||
#define s_reset(s) ((s)->end = (s)->p = (s)->data)
|
||||
|
||||
#if defined(L_ENDIAN) && !defined(NEED_ALIGN)
|
||||
#define in_uint16_le(s,v) { v = *(uint16 *)((s)->p); (s)->p += 2; }
|
||||
@ -95,3 +101,6 @@ typedef struct stream
|
||||
#define out_uint8s(s,n) { memset((s)->p,0,n); (s)->p += n; }
|
||||
|
||||
#define next_be(s,v) v = ((v) << 8) + *((s)->p++);
|
||||
|
||||
|
||||
#endif /* _PARSE_H */
|
||||
|
Loading…
Reference in New Issue
Block a user