#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"
#include "reporter/reporter.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 46 of file s_buff.cc.
47{
49 {
50 int r=close(F->fd);
54 return r;
55 }
56 return 0;
57}
#define omFreeSize(addr, size)
◆ s_getc()
Definition at line 59 of file s_buff.cc.
60{
62 {
63 printf("link closed");
64 return 0;
65 }
66 if (F->bp>=F->end)
67 {
70 if (r<=0)
71 {
72 F->is_eof=1;
73 return -1;
74 }
75 else
76 {
77 F->end=r-1;
78 F->bp=0;
79 return F->buff[0];
80 }
81 }
82
83 F->bp++;
84 return F->buff[F->bp];
85}
◆ s_iseof()
Definition at line 352 of file s_buff.cc.
353{
354 if (F!=
NULL)
return F->is_eof;
355 else return 1;
356}
◆ s_isready()
| int s_isready |
( |
s_buff | F | ) |
|
Definition at line 86 of file s_buff.cc.
87{
89 {
90 printf("link closed");
91 return 0;
92 }
93 if (F->bp>=F->end) return 0;
95 while((
p<F->end)&&(F->buff[
p]<=
' '))
p++;
96 if (
p>=F->end)
return 0;
97 return 1;
98}
◆ s_open()
Definition at line 32 of file s_buff.cc.
33{
34 s_buff F=(s_buff)
omAlloc0(
sizeof(*F));
37 return F;
38}
◆ 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 203 of file s_buff.cc.
204{
206 {
207 printf("link closed");
208 return 0;
209 }
211 while((!F->is_eof)&&(
i<len))
212 {
215 }
217}
◆ s_readint()
| int s_readint |
( |
s_buff | F | ) |
|
Definition at line 113 of file s_buff.cc.
114{
116 {
117 printf("link closed");
118 return 0;
119 }
120 char c;
121 int neg=1;
122 int r=0;
123
124 do
125 {
127 } while((!F->is_eof) && (c<=' '));
128 if (c==
'-') { neg=-1; c=
s_getc(F); }
129 while(isdigit(c))
130 {
131
132 r=r*10+(c-'0');
134 }
136
137
138 return r*neg;
139}
void s_ungetc(int c, s_buff F)
◆ s_readint_S()
| int s_readint_S |
( |
char ** | s | ) |
|
Definition at line 141 of file s_buff.cc.
142{
144 int n=0;
145 int neg=1;
146 while(*c<=' ')
147 {
148 c++;
149 }
150 if (*c=='-') { neg=-1; c++; }
151 while(isdigit(*c))
152 {
153 n=n*10+(*c-'0');
154 c++;
155 }
157 return n*neg;
158}
const CanonicalForm int s
◆ s_readlong()
| long s_readlong |
( |
s_buff | F | ) |
|
Definition at line 160 of file s_buff.cc.
161{
163 {
164 printf("link closed");
165 return 0;
166 }
167 char c;
168 long neg=1;
169 long r=0;
170 do
171 {
173 } while((!F->is_eof) && (c<=' '));
174 if (c==
'-') { neg=-1; c=
s_getc(F); }
175 while(isdigit(c))
176 {
177 r=r*10+(c-'0');
179 }
181 return r*neg;
182}
◆ s_readlong_S()
| long s_readlong_S |
( |
char ** | s | ) |
|
Definition at line 184 of file s_buff.cc.
185{
187 long n=0;
188 long neg=1;
189 while(*c<=' ')
190 {
191 c++;
192 }
193 if (*c=='-') { neg=-1; c++; }
194 while(isdigit(*c))
195 {
196 n=n*10+(*c-'0');
197 c++;
198 }
200 return n*neg;
201}
◆ s_readmpz()
| void s_readmpz |
( |
s_buff | F, |
|
|
mpz_t | a ) |
Definition at line 219 of file s_buff.cc.
220{
222 {
223 printf("link closed");
224 return;
225 }
226 mpz_set_ui(a,0);
227 char c;
228 int neg=1;
229 do
230 {
232 } while((!F->is_eof) && (c<=' '));
233 if (c==
'-') { neg=-1; c=
s_getc(F); }
234 while(isdigit(c))
235 {
236 mpz_mul_ui(a,a,10);
237 mpz_add_ui(a,a,(c-'0'));
239 }
241 if (neg==-1) mpz_neg(a,a);
242}
◆ s_readmpz_base()
| void s_readmpz_base |
( |
s_buff | F, |
|
|
mpz_ptr | a, |
|
|
int | base ) |
Definition at line 264 of file s_buff.cc.
265{
267 {
268 printf("link closed");
269 return;
270 }
271 mpz_set_ui(a,0);
272 char c;
273 int neg=1;
274 do
275 {
277 } while((!F->is_eof) && (c<=' '));
278 if (c==
'-') { neg=-1; c=
s_getc(F); }
280 int str_l=128;
281 int str_p=0;
282 while(c>' ')
283 {
284 if ((isdigit(c))
285 || ((c>='a') && (c<='z'))
286 || ((c>='A') && (c<='Z')))
287 {
289 str_p++;
290 }
291 else
292 {
294 break;
295 }
296 if (str_p>=str_l-1)
297 {
298 int old_str_l=str_l;
299 str_l=str_l*2;
301 memset(str+old_str_l,0,old_str_l);
302 }
304 }
305 if(mpz_set_str(a,str,base)!=0)
WerrorS(
"wrong mpz number");
307 if (neg==-1) mpz_neg(a,a);
308}
void WerrorS(const char *s)
#define omRealloc(addr, size)
◆ s_readmpz_base_S()
| void s_readmpz_base_S |
( |
char ** | s, |
|
|
mpz_ptr | a, |
|
|
int | base ) |
Definition at line 310 of file s_buff.cc.
311{
312 mpz_set_ui(a,0);
314 int neg=1;
315 do
316 {
317 c++;
318 } while(*c<=' ');
319 if (*c=='-') { neg=-1; c++; }
321 int str_l=128;
322 int str_p=0;
323 while(*c>' ')
324 {
325 if ((isdigit(*c))
326 || ((*c>='a') && (*c<='z'))
327 || ((*c>='A') && (*c<='Z')))
328 {
330 str_p++;
331 }
332 else
333 {
334 c--;
335 break;
336 }
337 if (str_p>=str_l-1)
338 {
339 int old_str_l=str_l;
340 str_l=str_l*2;
342 memset(str+old_str_l,0,old_str_l);
343 }
344 c++;
345 }
346 if(mpz_set_str(a,str,base)!=0)
WerrorS(
"wrong mpz number");
348 if (neg==-1) mpz_neg(a,a);
350}
◆ s_readmpz_S()
| void s_readmpz_S |
( |
char ** | s, |
|
|
mpz_t | a ) |
Definition at line 244 of file s_buff.cc.
245{
246 mpz_set_ui(a,0);
247 char c;
248 int neg=1;
249 do
250 {
252 } while (c<=' ');
253 if (c==
'-') { neg=-1; c=**
s;(*s)++; }
254 while(isdigit(c))
255 {
256 mpz_mul_ui(a,a,10);
257 mpz_add_ui(a,a,(c-'0'));
259 }
260 (*s)--;
261 if (neg==-1) mpz_neg(a,a);
262}
◆ s_ungetc()
| void s_ungetc |
( |
int | c, |
|
|
s_buff | F ) |
Definition at line 100 of file s_buff.cc.
101{
103 {
104 printf("link closed");
105 }
106 else if (F->bp>=0)
107 {
108 F->buff[F->bp]=c;
109 F->bp--;
110 }
111}