#include "misc/auxiliary.h"
#include <unistd.h>
#include <stdio.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <gmp.h>
#include "omalloc/omalloc.h"
#include "reporter/s_buff.h"
#include "reporter/si_signals.h"
Go to the source code of this file.
◆ S_BUFF_LEN
#define S_BUFF_LEN (4096-SIZEOF_LONG) |
◆ s_close()
int s_close |
( |
s_buff & |
F | ) |
|
Definition at line 45 of file s_buff.cc.
46{
48 {
49 int r=close(F->fd);
53 return r;
54 }
55 return 0;
56}
#define omFreeSize(addr, size)
◆ s_getc()
Definition at line 58 of file s_buff.cc.
59{
61 {
62 printf("link closed");
63 return 0;
64 }
65 if (F->bp>=F->end)
66 {
69 if (r<=0)
70 {
71 F->is_eof=1;
72 return -1;
73 }
74 else
75 {
76 F->end=r-1;
77 F->bp=0;
78 return F->buff[0];
79 }
80 }
81
82 F->bp++;
83 return F->buff[F->bp];
84}
◆ s_iseof()
Definition at line 254 of file s_buff.cc.
255{
256 if (F!=
NULL)
return F->is_eof;
257 else return 1;
258}
◆ s_isready()
int s_isready |
( |
s_buff |
F | ) |
|
Definition at line 85 of file s_buff.cc.
86{
88 {
89 printf("link closed");
90 return 0;
91 }
92 if (F->bp>=F->end) return 0;
94 while((p<F->end)&&(F->buff[
p]<=
' '))
p++;
95 if (
p>=F->end)
return 0;
96 return 1;
97}
◆ s_open()
Definition at line 31 of file s_buff.cc.
32{
33 s_buff F=(s_buff)
omAlloc0(
sizeof(*F));
36 return F;
37}
◆ s_open_by_name()
s_buff s_open_by_name |
( |
const char * |
n | ) |
|
◆ s_readbytes()
int s_readbytes |
( |
char * |
buff, |
|
|
int |
len, |
|
|
s_buff |
F |
|
) |
| |
Definition at line 168 of file s_buff.cc.
169{
171 {
172 printf("link closed");
173 return 0;
174 }
176 while((!F->is_eof)&&(
i<len))
177 {
180 }
182}
◆ s_readint()
int s_readint |
( |
s_buff |
F | ) |
|
Definition at line 112 of file s_buff.cc.
113{
115 {
116 printf("link closed");
117 return 0;
118 }
119 char c;
120 int neg=1;
121 int r=0;
122
123 do
124 {
126 } while((!F->is_eof) && (c<=' '));
127 if (c==
'-') { neg=-1; c=
s_getc(F); }
128 while(isdigit(c))
129 {
130
131 r=r*10+(c-'0');
133 }
135
136
137 return r*neg;
138}
void s_ungetc(int c, s_buff F)
◆ s_readlong()
long s_readlong |
( |
s_buff |
F | ) |
|
Definition at line 140 of file s_buff.cc.
141{
143 {
144 printf("link closed");
145 return 0;
146 }
147 char c;
148 long neg=1;
149 long r=0;
150
151 do
152 {
154 } while((!F->is_eof) && (c<=' '));
155 if (c==
'-') { neg=-1; c=
s_getc(F); }
156 while(isdigit(c))
157 {
158
159 r=r*10+(c-'0');
161 }
163
164
165 return r*neg;
166}
◆ s_readmpz()
void s_readmpz |
( |
s_buff |
F, |
|
|
mpz_t |
a |
|
) |
| |
Definition at line 184 of file s_buff.cc.
185{
187 {
188 printf("link closed");
189 return;
190 }
191 mpz_set_ui(a,0);
192 char c;
193 int neg=1;
194 do
195 {
197 } while((!F->is_eof) && (c<=' '));
198 if (c==
'-') { neg=-1; c=
s_getc(F); }
199 while(isdigit(c))
200 {
201 mpz_mul_ui(a,a,10);
202 mpz_add_ui(a,a,(c-'0'));
204 }
206 if (neg==-1) mpz_neg(a,a);
207}
◆ s_readmpz_base()
void s_readmpz_base |
( |
s_buff |
F, |
|
|
mpz_ptr |
a, |
|
|
int |
base |
|
) |
| |
Definition at line 209 of file s_buff.cc.
210{
212 {
213 printf("link closed");
214 return;
215 }
216 mpz_set_ui(a,0);
217 char c;
218 int neg=1;
219 do
220 {
222 } while((!F->is_eof) && (c<=' '));
223 if (c==
'-') { neg=-1; c=
s_getc(F); }
225 int str_l=128;
226 int str_p=0;
227 while(c>' ')
228 {
229 if ((isdigit(c))
230 || ((c>='a') && (c<='z'))
231 || ((c>='A') && (c<='Z')))
232 {
234 str_p++;
235 }
236 else
237 {
239 break;
240 }
241 if (str_p>=str_l)
242 {
243 int old_str_l=str_l;
244 str_l=str_l*2;
246 memset(str+old_str_l,0,old_str_l);
247 }
249 }
250 mpz_set_str(a,str,base);
252 if (neg==-1) mpz_neg(a,a);
253}
#define omRealloc(addr, size)
◆ s_ungetc()
void s_ungetc |
( |
int |
c, |
|
|
s_buff |
F |
|
) |
| |
Definition at line 99 of file s_buff.cc.
100{
102 {
103 printf("link closed");
104 }
105 else if (F->bp>=0)
106 {
107 F->buff[F->bp]=c;
108 F->bp--;
109 }
110}