1
/* TN5250 - An implementation of the 5250 telnet protocol.
2
* Copyright (C) 1997-2008 Michael Madore
4
* This file is part of TN5250.
6
* TN5250 is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as published by
8
* the Free Software Foundation; either version 2.1, or (at your option)
11
* TN5250 is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with this software; see the file COPYING. If not, write to
18
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19
* Boston, MA 02111-1307 USA
22
#include "tn5250-private.h"
24
/****f* lib5250/tn5250_record_new
28
* ret = tn5250_record_new ();
34
Tn5250Record *tn5250_record_new()
36
Tn5250Record *This = tn5250_new(Tn5250Record, 1);
40
tn5250_buffer_init (&(This->data));
48
/****f* lib5250/tn5250_record_destroy
50
* tn5250_record_destroy
52
* tn5250_record_destroy (This);
54
* Tn5250Record * This -
58
void tn5250_record_destroy(Tn5250Record * This)
61
tn5250_buffer_free (&(This->data));
66
/****f* lib5250/tn5250_record_get_byte
68
* tn5250_record_get_byte
70
* ret = tn5250_record_get_byte (This);
72
* Tn5250Record * This -
76
unsigned char tn5250_record_get_byte(Tn5250Record * This)
79
TN5250_ASSERT(This->cur_pos <= tn5250_record_length(This));
80
return (tn5250_buffer_data (&(This->data)))[This->cur_pos - 1];
83
/****f* lib5250/tn5250_record_unget_byte
85
* tn5250_record_unget_byte
87
* tn5250_record_unget_byte (This);
89
* Tn5250Record * This -
93
void tn5250_record_unget_byte(Tn5250Record * This)
95
TN5250_LOG(("Record::UnGetByte: entered.\n"));
96
TN5250_ASSERT(This->cur_pos > 0);
100
/****f* lib5250/tn5250_record_is_chain_end
102
* tn5250_record_is_chain_end
104
* ret = tn5250_record_is_chain_end (This);
106
* Tn5250Record * This -
110
int tn5250_record_is_chain_end(Tn5250Record * This)
112
return tn5250_record_length(This) == This->cur_pos;
115
/****f* lib5250/tn5250_record_is_chain_end
117
* tn5250_record_skip_to_end
119
* ret = tn5250_record_skip_to_end (This);
121
* Tn5250Record * This -
125
void tn5250_record_skip_to_end(Tn5250Record * This)
127
This->cur_pos = tn5250_record_length(This);
130
/****f* lib5250/tn5250_record_dump
134
* tn5250_record_dump (This);
136
* Tn5250Record * This -
140
void tn5250_record_dump(Tn5250Record * This)
142
tn5250_buffer_log (&(This->data),"@record");
143
TN5250_LOG (("@eor\n"));
146
/****f* lib5250/tn5250_record_list_add
148
* tn5250_record_list_add
150
* ret = tn5250_record_list_add (list, record);
152
* Tn5250Record * list -
153
* Tn5250Record * record -
155
* Add a record to the end of a list of records.
157
Tn5250Record *tn5250_record_list_add(Tn5250Record * list, Tn5250Record * record)
160
list = record->next = record->prev = record;
164
record->prev = list->prev;
165
record->prev->next = record;
166
record->next->prev = record;
170
/****f* lib5250/tn5250_record_list_remove
172
* tn5250_record_list_remove
174
* ret = tn5250_record_list_remove (list, record);
176
* Tn5250Record * list -
177
* Tn5250Record * record -
179
* Remove a record from a list of records.
181
Tn5250Record *tn5250_record_list_remove(Tn5250Record * list, Tn5250Record * record)
185
if (list->next == list) {
186
record->prev = record->next = NULL;
193
record->next->prev = record->prev;
194
record->prev->next = record->next;
195
record->next = record->prev = NULL;
199
/****f* lib5250/tn5250_record_list_destroy
201
* tn5250_record_list_destroy
203
* ret = tn5250_record_list_destroy (list);
205
* Tn5250Record * list -
207
* Destroy all records in a record list and return NULL.
209
Tn5250Record *tn5250_record_list_destroy(Tn5250Record * list)
211
Tn5250Record *iter, *next;
213
if ((iter = list) != NULL) {
216
tn5250_record_destroy(iter);
218
} while (iter != list);