muMECH  1.0
librw.cpp
Go to the documentation of this file.
1 #include "librw.h"
2 
3 #include "gelib.h"
4 #include "arrays.h"
5 
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <ctype.h>
10 
11 
12 namespace gelibspace {
13 
14 #define CHECK_DEST if (!dest) _errorr("destination is not allocated")
15 
16 
17 bool get_confirm (const char *s, bool expected)
18 {
19  fprintf(stdin, "\n%s", s);
20  if (expected == true) fprintf (stdin, " (Y or n): ");
21  else fprintf (stdin, " (y or N): ");
22  fflush(stdin);
23  scanf("%*c"); printf("\n");
24  return true;
25 }
26 
31 bool isWordChar (char C)
32 {
33  return ( ( C == ' ' || C == '\t' || C == '\n' || C == '\0' || C == '\r' || C == EOF) ? false : true);
34 }
35 
37 bool isLineChar (char C)
38 {
39  return ( ( C == '\n' || C == '\0' || C == '\r' || C == EOF) ? false : true);
40 }
41 
43 bool isSpaceChar (char C)
44 {
45  return ( ( C == ' ' || C == '\t' ) ? true : false);
46 }
47 
48 bool isDigitChar (char C)
49 {
50  return ( ( C < 48 || C > 57 ) ? false : true);
51 }
52 
54 long giveLineLength (const char *src)
55 {
56  long n = 0;
57  while (isLineChar(src[n])) n++;
58 
59  return n;
60 }
61 
64 char* strdupl (const char *src)
65 {
66  if (src==NULL) return NULL;
67  long len = strlen (src) + 1;
68  char *dest = new char[len];
69  return (char *) memcpy (dest, src, len);
70 }
71 char* strdupl (const char *src1, const char *src2)
72 {
73  char *aux = new char[strlen(src1) + strlen(src2) + 1];
74  sprintf (aux, "%s%s", src1, src2);
75  return aux;
76 }
77 char* strdupl (const char *src1, const char *src2, const char *src3)
78 {
79  char *aux = new char[strlen(src1) + strlen(src2) + strlen(src3) + 1];
80  sprintf (aux, "%s%s%s", src1, src2, src3);
81  return aux;
82 }
83 
84 char* pathstrdupl (const char *src)
85 {
86  long len = strlen (src) + 2;
87  char *dest = new char[len];
88  memcpy (dest, src, len);
89  if (dest[len-3] != DIRSEPARATOR) {
90  dest[len-2] = DIRSEPARATOR;
91  dest[len-1] = '\0';
92  }
93  return (char *) dest;
94 }
95 
96 
105 
108 long AP_find_option (int argc, char *argv[], const char *s)
109 {
110  for (int i=1; i<argc; i++)
111  if (!_STRCASECMP(s,argv[i])) return i;
112 
113  return 0;
114 }
115 
117 void AP_fprint_arguments (FILE *stream, int argc, char *argv[])
118 {
119  fprintf (stream,"\n Command line:");
120  fprintf (stream,"\n %s ",argv[0]);
121  for (int i=1;i<argc;i++)
122  fprintf (stream," %c",argv[i][0]);
123 
124  fprintf (stream,"\n options: ");
125  for (int i=1;i<argc;i++)
126  fprintf (stream," %s",argv[i]);
127 
128  fprintf (stream,"\n\n");
129 }
130 
131 
132 
138 
139 
141 bool FP_skip_comment (FILE *stream)
142 {
143  char c;
144  while (true) {
145  c = getc(stream);
146  if (c == EOF) { ungetc(c, stream); return false; }
147  if (! isWordChar(c)) continue;
148  if (c == '#') FP_skip_line (stream);
149  else { ungetc(c, stream); return true; }
150  }
151 
152  return false;
153 }
154 
156 void FP_skip_line_commented (FILE *stream)
157 {
158  char c;
159  while ((c = getc(stream)) == '#')
160  FP_skip_line (stream);
161 
162  ungetc (c, stream);
163 }
164 
166 void FP_skip_line_fast_skip_commented (FILE *stream, int n)
167 {
168  char c;
169  while (n--) {
170  c = getc(stream);
171  if (c == '\n') continue;
172  if (c == '#' ) n++;
173  while ( getc(stream) != '\n') ;
174  }
175 }
176 
178 bool FP_skip_line (FILE *stream, int n)
179 {
180  char c;
181  while (n--)
182  while (true) {
183  c = getc(stream);
184  if (c == '\n') break;
185  if (c == EOF ) { ungetc(c, stream); return false; }
186  }
187 
188  return true;
189 }
190 
192 bool FP_skip_behind_line_starting_with (FILE *stream, const char *string, bool cs)
193 {
194  while (true) {
195  if (!FP_skip_space(stream)) return false;
196  if ( FP_skip_expected_string (stream, string, cs)) return (FP_skip_line (stream));
197  if (!FP_skip_line (stream)) return false;
198  }
199 }
200 
202 bool FP_skip_to_line_starting_with (FILE *stream, const char *string, bool cs)
203 {
204  while (true) {
205  if (!FP_skip_space(stream)) return false;
206  if ( FP_skip_expected_string (stream, string, cs)) return true;
207  if (!FP_skip_line (stream)) return false;
208  }
209 }
210 
212 bool FP_skip_to_line_starting_With (FILE *stream, const char *string, bool cs)
213 {
214  while (true) {
215  //if (!FP_skip_space(stream)) return false;
216  if ( FP_skip_expected_string (stream, string, cs)) return true;
217  if (!FP_skip_line (stream)) return false;
218  }
219 }
220 
221 
223 void FP_copy_file (FILE *sour,FILE *dest)
224 {
225  int c;
226  while ((c = getc(sour)) != EOF) putc (c,dest);
227 }
228 
230 bool FP_cmp_files (const char *file1, const char *file2)
231 {
232  FILE *f1 = _openFileN ("r", "The first compared file", file1);
233  FILE *f2 = _openFileN ("r", "The second compared file", file2);
234 
235  bool status = false;
236  int c1, c2;
237 
238  while (true) {
239  c1 = getc(f1);
240  c2 = getc(f2);
241 
242  if (c1 != c2) {
243  status = true;
244  break;
245  }
246 
247  if (c1 == EOF) break;
248  }
249 
250  fclose (f1);
251  fclose (f2);
252 
253  return status;
254 }
255 
256 
257 
259 bool FP_copy_behind_line (FILE *sour, FILE *dest, int n)
260 {
261  char c;
262  while (n--) {
263  do {
264  c = getc(sour);
265  if (c == EOF) return false;
266  putc(c,dest);
267  }
268  while(c!='\n');
269  }
270  return true;
271 }
272 
273 
274 
276 bool FP_copy_behind_line_starting_with (FILE *src, FILE *dest, const char *expctd, bool cs)
277 {
278  char c;
279  int n;
280  while (true) {
281  c = fgetc (src); ungetc(c, src);
282  if (c == EOF) return false;
283 
284  // copy untill expected string is same
285  n = 0;
286  if (cs) while (expctd[n] != '\0') { c = getc(src); fprintf (dest, "%c", c); if ( c != expctd[n] ) break; n++; }
287  else while (expctd[n] != '\0') { c = getc(src); fprintf (dest, "%c", c); if (tolower(c) != tolower(expctd[n])) break; n++; }
288 
289  // copy to endfile
290  if (c != '\n') FP_copy_behind_line (src, dest, cs);
291 
292  if (expctd[n] == '\0') return true;
293  }
294 }
295 
296 
299 bool FP_skip_to_line_starting_with (FILE *stream, char C)
300 {
301  char c;
302  while ( (c = fgetc (stream)) != C )
303  while (c != '\n')
304  if (c == EOF ) { ungetc(c, stream); return false; }
305  else c = fgetc(stream);
306 
307  ungetc (c, stream);
308  return true;
309 }
310 
311 
313 bool FP_scan_array (FILE *stream, int n, int *dest) { while (n--) if (fscanf (stream, "%d", dest++) == 0) return false; return true; }
314 bool FP_scan_array (FILE *stream, int n, long *dest) { while (n--) if (fscanf (stream, "%ld", dest++) == 0) return false; return true; }
315 bool FP_scan_array (FILE *stream, int n, double *dest) { while (n--) if (fscanf (stream, "%lf", dest++) == 0) return false; return true; }
316 
317 
319 long FP_number_of_words (FILE *stream)
320 {
321  char c;
322  long answer = 0;
323  bool space = true;
324 
325  while ((c = getc(stream)) != EOF)
326  if (isWordChar(c)) {
327  if (space) {
328  answer++;
329  space = false;
330  }
331  }
332  else
333  space = true;
334 
335  return answer;
336 }
337 
339 long FP_number_of_lines (FILE *stream, bool rwd)
340 {
341  int c;
342  long lines = 0, fp = 0;
343 
344  if (rwd) fp = ftell(stream);
345 
346  while ((c = getc(stream)) != EOF)
347  if(c == '\n')
348  lines++;
349 
350  if (rwd) fseek(stream, fp, SEEK_SET);
351 
352  return lines;
353 }
354 
355 
356 
361 
363 bool FP_skip_nonword (FILE *stream)
364 {
365  char c;
366  while ((c = getc(stream)) != EOF)
367  if (isWordChar(c)) {
368  ungetc (c, stream);
369  return true;
370  }
371 
372  ungetc (c, stream);
373  return false;
374 }
376 bool FP_skip_space (FILE *stream)
377 {
378  char c;
379  while ((c = getc(stream)) != EOF)
380  if (!isSpaceChar(c)) {
381  ungetc (c, stream);
382  return true;
383  }
384 
385  ungetc (c, stream);
386  return false;
387 }
389 bool FP_skip_word (FILE *stream)
390 {
391  //FP_skip_space (stream); toto odkomentuj a pust testy !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
392  char c;
393  while (true) {
394  c = getc(stream);
395  if (!isWordChar(c)) break;
396  }
397 
398  ungetc (c, stream);
399  return true;
400 }
401 
406 
408 long FP_scan_line_skip_emptyORcommented (FILE *stream, char *dest)
409 {
410  char c;
411  FP_skip_space (stream);
412  while ((c = getc(stream)) == '#' || c == '\n')
413  if (c == '#') FP_skip_line (stream);
414 
415  ungetc (c, stream);
416 
417  return FP_scan_line (stream, dest);
418 }
420 long FP_scan_line (FILE *stream, char *dest)
421 {
422  long n=0;
423  while (isLineChar(dest[n] = getc(stream)))
424  n++;
425 
426  if (dest[n] == EOF) {
427  ungetc(EOF, stream);
428  if (n==0) return -1;
429  }
430 
431  if (dest[n] == '\r') getc(stream); // win end of line
432  //if (dest[n] == '\r') { dest[n+1] = getc(stream); if (dest[n+1] == '\r') getc(stream); } // vorlasovo docasne
433 
434  dest[n] = '\0';
435 
436  return n;
437 }
439 long FP_scan_line_alloc (FILE *stream, char *&dest)
440 {
441  if (dest) _errorr("allocated");
442 
443  char aux[10001];
444  long n = FP_scan_line (stream, aux);
445 
446  dest = new char[n+1];
447 
448  long i = n+1;
449  while (i--) dest[i] = aux[i];
450 
451  return n;
452 }
453 
455 int FP_scan_word (FILE *src, char *dest)
456 {
457  if (! FP_skip_nonword (src)) return 0;
458 
459  // scan word
460  char c;
461  register int n = 0;
462  while (true) {
463  c = getc(src);
464  if (isWordChar(c)) dest[n++] = c;
465  else break;
466  }
467 
468  ungetc (c, src);
469  dest[n] = '\0';
470 
471  return n;
472 }
473 
475 bool FP_skip_expected_string (FILE *src, const char *expctd, bool cs)
476 {
477  char c;
478  register int n = 0;
479 
480  if (cs) while (expctd[n] != '\0') { c = getc(src); if ( c != expctd[n] ) { ungetc (c, src); break; } n++; }
481  else while (expctd[n] != '\0') { c = getc(src); if (tolower(c) != tolower(expctd[n])) { ungetc (c, src); break; } n++; }
482 
483  return (expctd[n] == '\0');
484 }
485 
487 bool FP_scan_expected_word (FILE *src, const char *expctd, bool cs)
488 {
489  if (! FP_skip_nonword (src)) return false;
490  if (! FP_skip_expected_string (src, expctd, cs)) return false;
491 
492  FP_skip_word (src);
493  return true;
494 }
495 
497 void FP_scan_expected_word_FL (const char* file, int line, FILE *src, const char *expctd, const char *msg, bool cs)
498 {
499  if (!FP_scan_expected_word (src, expctd, cs)) errorr_expected (file, line, msg, expctd, NULL);
500 }
501 
503 bool FP_scan_expected_line (FILE *src, const char *expctd, bool cs)
504 {
505  if (! FP_skip_space (src)) return false;
506  if (! FP_skip_expected_string (src, expctd, cs)) return false;
507  if (! FP_skip_space (src)) return false;
508 
509  char c = getc(src);
510  if (c == '\r') c = getc(src);
511  if (c == EOF) ungetc(c, src);
512  if (c == '\n') return true;
513 
514  return false;
515 }
516 
518 void FP_scan_expected_line_FL (const char* file, int line, FILE *src, const char *expctd, const char *msg, bool cs)
519 {
520  if (!FP_scan_expected_line (src, expctd, cs)) errorr_expected (file, line, msg, expctd, NULL);
521 }
522 
524 bool FP_scan_expected_number (FILE *src, long expctd)
525 {
526  long aux;
527  return (fscanf (src, "%ld", &aux) == 1 && aux == expctd);
528 }
529 
530 
536 
537 void errorr_expected (const char* file, int line, const char *msg, const char *expctd, const char *src) { errorr (file, line, "%s, expected \"%s\" != \"%s\"", msg, expctd, src); }
538 void errorr_expected (const char* file, int line, const char *msg, int expctd, const char *src) { errorr (file, line, "%s, expected \"%d\" != \"%s\"", msg, expctd, src); }
539 void errorr_expected (const char* file, int line, const char *msg, long expctd, const char *src) { errorr (file, line, "%s, expected \"%ld\" != \"%s\"", msg, expctd, src); }
540 void errorr_expected (const char* file, int line, const char *msg, double expctd, const char *src) { errorr (file, line, "%s, expected \"%lf\" != \"%s\"", msg, expctd, src); }
541 
543 bool SP_cutcomment (char *src)
544 {
545  while (*src != '\0')
546  if (*src != '#') src++;
547  else {
548  while (*(--src) == ' ') ;
549  src[1] = '\0';
550  return true;
551  }
552 
553  return false;
554 }
556 bool SP_replace_char (char *str, char s, char d)
557 {
558  bool retval = false;
559 
560  while (*str != '\0') {
561  if (*str == s) {
562  str[0] = d;
563  retval = true;
564  }
565  str = str + 1;
566  }
567  return retval;
568 }
569 
570 
575 
577 bool SP_unskip_space (const char *&src)
578 {
579  while (src[-1]==' ' || src[-1]=='\t') src--;
580  return true;
581 }
582 
584 bool SP_skip_space (const char *&src)
585 {
586  while (src[0]==' ' || src[0]=='\t') src++;
587  return true;
588 }
589 
591 bool SP_skip_word (const char *&src, int n)
592 {
593  while (n--) {
594  SP_skip_space (src);
595  // check word presence
596  if (src[0]=='\n' || src[0]=='\0') return false;
597  // skip word
598  while ( isWordChar(src[0]) ) src++;
599  }
600 
601  return true;
602 }
603 
605 bool SP_skip_int (const char *&src)
606 {
607  SP_skip_space (src);
608  // check word presence
609  if (src[0]=='\n' || src[0]=='\0') return false;
610 
611  // skip sign
612  if (src[0]=='+' || src[0]=='-') src++;
613  // skip word
614  while ( isDigitChar(src[0]) ) src++;
615 
616  return true;
617 }
618 
623 void SP_unscan_word (const char *&src, const char *w)
624 {
625  SP_unskip_space (src);
626  // find length of word
627  long n = strlen(w);
628  src = src-n;
629 
630  while (n--) if (src[n] != w[n]) _errorr ("unscan error");
631 }
632 
634 
636 bool SP_scan_character (const char *&src, char &dest)
637 {
638  SP_skip_space (src);
639  //
640  if (src[0]=='\n' || src[0]=='\0' || src[0]=='\r')
641  return false;
642 
643  dest = src[0]; src++;
644  return true;
645 }
647 long SP_scan_word (const char *&src, char *dest)
648 {
649  SP_skip_space (src);
650 
651  // find length of word
652  long n=0;
653  while (isWordChar(src[n])) n++;
654  // copy word
655  strncpy (dest, src, n);
656  dest[n] = '\0';
657  // shift src pointer
658  src += n;
659 
660  return n;
661 }
663 long SP_scan_line (const char *&src, char *dest)
664 {
665  CHECK_DEST;
666 
667  long n=0;
668  while (isLineChar(src[n])) {
669  dest[n] = src[n];
670  n++;
671  }
672  dest[n] = '\0';
673  src += n;
674 
675  return n;
676 }
678 long SP_scan_line_alloc (const char *&src, char *&dest)
679 {
680  if (dest) _errorr("allocated");
681 
682  SP_skip_space (src);
683 
684  long n = giveLineLength (src);
685 
686  dest = new char[n+1];
687 
688  long i = n;
689  while (i--) dest[i] = src[i];
690 
691  dest[n] = '\0';
692 
693  src += n;
694 
695  return n;
696 }
697 
699 bool SP_scan_expected_word (const char *&src, const char *expctd, bool cs)
700 {
701  SP_skip_space (src);
702  register int n = -1;
703  if (cs) { while (expctd[++n] != '\0') if ( src[n] != expctd[n] ) return false; }
704  else { while (expctd[++n] != '\0') if (tolower(src[n]) != tolower(expctd[n])) return false; }
705  src += n;
706  return true;
707 }
709 void SP_scan_expected_word_FL (const char* file, int line, const char *&src, const char *expctd, const char *msg, bool cs) { if ( !SP_scan_expected_word (src, expctd, cs)) errorr_expected (file, line, msg, expctd, src); }
710 void SP_scan_expected_word_FL (const char* file, int line, const char *&src, const char *expctd1, const char *expctd2, const char *msg, bool cs) { if ( !SP_scan_expected_word (src, expctd2, cs) && !SP_scan_expected_word (src, expctd1, cs)) errorr (file, line, "%s, expected \"%s\" or \"%s\" != \"%s\"", msg, expctd1, expctd2, src); }
711 void SP_scan_expected_word_FL (const char* file, int line, const char *&src, const char *expctd1, const char *expctd2, const char *expctd3, const char *msg, bool cs) { if (!SP_scan_expected_word (src, expctd3, cs) && !SP_scan_expected_word (src, expctd2, cs) && !SP_scan_expected_word (src, expctd1, cs)) errorr (file, line, "%s, expected \"%s\" or \"%s\" or \"%s\" != \"%s\"", msg, expctd1, expctd2, expctd2, src); }
712 
714 bool SP_scan_number (const char *&src, int &dest) { sscanf (src, "%d", &dest); return SP_skip_int (src); }
715 bool SP_scan_number (const char *&src, long &dest) { sscanf (src, "%ld", &dest); return SP_skip_int (src); }
716 bool SP_scan_number (const char *&src, double &dest) { sscanf (src, "%lf", &dest); return SP_skip_word (src); }
717 
718 
720 bool SP_scan_array_L (const char *&src, int L, double *a)
721 {
722  if (!SP_scan_expected_number (src, L)) {
723  _warningg2 ("The length of array of doubles is not \"%d\"", L);
724  return false;
725  }
726  return SP_scan_array (src, L, a);
727 }
728 
729 #ifdef _ARRAYS
730 bool SP_scan_Dvctr_exit (const char *&src, int n, Dvctr *v)
732 {
733  if (!SP_scan_expected_number (src, n)) _errorr("unexpected number of components in scanned array");
734  v->resize_ignore_vals(n);
735  return SP_scan_array (src, n, v->give_ptr2val());
736 }
737 #endif
738 
739 
744 
746 bool SP_print_space (const char *&src, FILE *stream)
747 {
748  while ( isSpaceChar(src[0]) ) {
749  fprintf (stream, "%c", src[0]);
750  src++;
751  }
752  return true;
753 }
754 
756 bool SP_print_word (const char *&src, FILE *stream)
757 {
758  SP_skip_space (src);
759  while ( isWordChar(src[0]) ) {
760  fprintf (stream, "%c", src[0]);
761  src++;
762  }
763  return true;
764 }
765 
766 
770 long find_double (long n, long* p)
771 {
772  int i, j;
773 
774  for (i=0; i<n; i++)
775  for (j=i+1; j<n; j++)
776  if (p[i]==p[j]) return i+1;
777 
778  return 0;
779 }
780 
781 
782 void sprint_param (char *s, char *argv[], int n)
783 {
784  ; sprintf (strchr(s,'\0'), " ");
785  while (n--) sprintf (strchr(s,'\0'), " %s", *(argv-n));
786 }
787 
788 
789 void read_star_end (FILE *stream,int n)
790 {
791  while (n--) { read_star (stream); FP_skip_line (stream); }
792 }
793 void read_star (FILE *stream)
794 {
795  char c;
796  while ((c = getc (stream)) != '*' ) ;
797  ungetc (c,stream);
798 }
799 
800 void copy_star_end (FILE *sour,FILE *dest,int n)
801 {
802  while (n--) { copy_star (sour,dest); FP_copy_behind_line (sour,dest); }
803 }
804 void copy_star (FILE *sour,FILE *dest)
805 {
806  char c;
807  while ((c = getc (sour)) != '*') putc (c,dest);
808  ungetc (c,sour);
809 }
810 
811 void copy_to_end_line (FILE *sour,FILE *dest)
812 {
813  char c;
814  while ((c = getc (sour)) != '\n') putc (c,dest);
815  ungetc ('\n',sour);
816 }
817 
818 
819 int extract_long (const char *s1, const char *s2, long &a)
820 {
821  const char *ss = strstr (s1,s2);
822  if (ss==NULL) return 1;
823  ss += strlen(s2);
824  sscanf (ss,"%ld",&a);
825  return 0;
826 }
827 
829 int extract_double (const char *s1, const char *s2, double &a)
830 {
831  const char *ss = strstr (s1,s2);
832  if (ss==NULL) return 1;
833  ss += strlen(s2);
834  sscanf (ss,"%lf",&a);
835  return 0;
836 }
837 
838 void extract_double_array (const char *s1, const char *s2, long n, double *a)
839 {
840  const char *ss = strstr (s1,s2);
841  //if (ss==NULL) return 1;
842  ss += strlen(s2);
843  SP_scan_array_L (ss, n, a);
844 }
845 
846 void ad_line (FILE *stream,char *s)
847 {
848  char c;
849  long l = strlen (s);
850  char* ss = s + l;
851  register long i=0;
852  while ((c = getc(stream)) != '\n') ss[i++] = c;
853  ss[i] = '\0';
854 }
855 
856 } // namespace gelibspace
bool isLineChar(char C)
return true if character C is "normal" char or "space" char –> C != &#39; &#39; &#39;\0&#39; &#39;&#39;
Definition: librw.cpp:37
bool SP_print_word(const char *&src, FILE *stream)
... word
Definition: librw.cpp:756
bool FP_skip_expected_string(FILE *src, const char *expctd, bool cs)
... word and compare with expected one
Definition: librw.cpp:475
bool SP_cutcomment(char *src)
cut of comment == end of line starting by &#39;#&#39;
Definition: librw.cpp:543
void FP_skip_line_commented(FILE *stream)
move file descriptor to the start of the new noncommented line, without checking of EOF ...
Definition: librw.cpp:156
void sprint_param(char *s, char *argv[], int n)
Definition: librw.cpp:782
Dvctr * resize_ignore_vals(long newsize)
Definition: arrays.h:622
long giveLineLength(const char *src)
return length of line == sting compount of "line chars"
Definition: librw.cpp:54
bool FP_skip_line(FILE *stream, int n)
move file descriptor to the start of the n-th new line //[former read_line]
Definition: librw.cpp:178
int extract_long(const char *s1, const char *s2, long &a)
Definition: librw.cpp:819
bool get_confirm(const char *s, bool expected)
Definition: librw.cpp:17
General functions.
#define _openFileN(_1, _2, _3)
Definition: gelib.h:182
bool isSpaceChar(char C)
return true if character C is "space" char –> C == &#39; &#39; &#39;&#39;
Definition: librw.cpp:43
Input / output function.
void FP_scan_expected_line_FL(const char *file, int line, FILE *src, const char *expctd, const char *msg, bool cs)
... line and compare with expected one, exit if false
Definition: librw.cpp:518
bool FP_scan_expected_line(FILE *src, const char *expctd, bool cs)
... line and compare with expected one
Definition: librw.cpp:503
char * strdupl(const char *src)
standard strdup - Memory for the new string is obtained with malloc(3), and can be freed with free(3)...
Definition: librw.cpp:64
void copy_to_end_line(FILE *sour, FILE *dest)
Definition: librw.cpp:811
int extract_double(const char *s1, const char *s2, double &a)
v retezci s1 se najde key retezec s2 a za nim se precte double
Definition: librw.cpp:829
#define DIRSEPARATOR
Definition: gelib.h:35
long SP_scan_word(const char *&src, char *dest)
... word; return value is length of the word
Definition: librw.cpp:647
bool SP_scan_array(const char *&src, int n, ArgType *a)
... array of numbers
Definition: librw.h:253
bool FP_skip_word(FILE *stream)
... word
Definition: librw.cpp:389
void FP_copy_file(FILE *sour, FILE *dest)
[former copy_file]
Definition: librw.cpp:223
bool isWordChar(char C)
*** *** *** *** GENERAL FUNCTIONS *** *** *** *** return true if character C is "normal" char –> C...
Definition: librw.cpp:31
void extract_double_array(const char *s1, const char *s2, long n, double *a)
Definition: librw.cpp:838
bool SP_skip_space(const char *&src)
... space == &#39; &#39; and &#39;&#39; characters
Definition: librw.cpp:584
void AP_fprint_arguments(FILE *stream, int argc, char *argv[])
print arguments to stream
Definition: librw.cpp:117
bool FP_scan_array(FILE *stream, int n, int *dest)
scan/copy array of numbers from src to dest, src pointer is shifted over the field ...
Definition: librw.cpp:313
void SP_scan_expected_word_FL(const char *file, int line, const char *&src, const char *expctd, const char *msg, bool cs)
... word and compare with expected one/two/three, exit if false
Definition: librw.cpp:709
bool FP_skip_comment(FILE *stream)
*** *** *** *** FILE PROCESSING *** *** *** *** general rules for file processing: ...
Definition: librw.cpp:141
long FP_number_of_words(FILE *stream)
count number of words (see isWordChar) in file
Definition: librw.cpp:319
long FP_scan_line(FILE *stream, char *dest)
scan/copy line == string without &#39; &#39; from stream
Definition: librw.cpp:420
void read_star(FILE *stream)
Definition: librw.cpp:793
void read_star_end(FILE *stream, int n)
Definition: librw.cpp:789
bool FP_skip_space(FILE *stream)
... space
Definition: librw.cpp:376
Structs Elem3D, PoinT and VectoR; classes Array, Array1d, Xscal, Dscal, Xvctr, Lvctr, Dvctr, Xmtrx, Lmtrx and Dmtrx.
long FP_scan_line_alloc(FILE *stream, char *&dest)
scan/copy line == string without &#39; &#39; from stream; dest is NULL and allocated here ...
Definition: librw.cpp:439
bool SP_skip_int(const char *&src)
... word compound of digits and space before
Definition: librw.cpp:605
bool SP_scan_number(const char *&src, int &dest)
... number of type int/long/double
Definition: librw.cpp:714
void errorr_expected(const char *file, int line, const char *msg, const char *expctd, const char *src)
*** *** *** *** STRING PROCESSING *** *** *** *** src pointer is always shifted over the skipped/sc...
Definition: librw.cpp:537
bool FP_scan_expected_word(FILE *src, const char *expctd, bool cs)
... word and compare with expected one
Definition: librw.cpp:487
void FP_skip_line_fast_skip_commented(FILE *stream, int n)
move file descriptor to the start of the n-th new line, without checking of EOF
Definition: librw.cpp:166
bool FP_skip_to_line_starting_With(FILE *stream, const char *string, bool cs)
move file descriptor to the line starting with string, exactly behind the string; NO white space can ...
Definition: librw.cpp:212
#define _warningg2(_1, _2)
Definition: gelib.h:166
void SP_unscan_word(const char *&src, const char *w)
*** *** *** SCANNING *** *** *** unscan word == shift pointer back over word
Definition: librw.cpp:623
long SP_scan_line(const char *&src, char *dest)
... line; return value is length of the line
Definition: librw.cpp:663
long find_double(long n, long *p)
*** *** *** *** OBSOLETE FUNCTIONS *** *** *** ***
Definition: librw.cpp:770
bool SP_scan_Dvctr_exit(const char *&src, int n, Dvctr *v)
Definition: librw.cpp:731
long SP_scan_line_alloc(const char *&src, char *&dest)
... line; return value is length of the line; dest is NULL and allocated here
Definition: librw.cpp:678
bool SP_unskip_space(const char *&src)
*** *** *** SKIPING *** *** *** (un)skiping == shift src pointer at the end(start) of ...
Definition: librw.cpp:577
#define _STRCASECMP
Definition: gelib.h:47
bool SP_replace_char(char *str, char s, char d)
replace src char to dest char
Definition: librw.cpp:556
bool FP_cmp_files(const char *file1, const char *file2)
Return false if no differences.
Definition: librw.cpp:230
bool FP_skip_behind_line_starting_with(FILE *stream, const char *string, bool cs)
move file descriptor to the start of the new line after the one starting with string ...
Definition: librw.cpp:192
long AP_find_option(int argc, char *argv[], const char *s)
*** *** *** *** ARGUMENTS PROCESSING *** *** *** *** terminology: tar -cz -f archiv.tgz archiv/ /// fce name | arguments /// fce name | options | parameters /// fce name | opt | opt | opt argum.
Definition: librw.cpp:108
bool SP_scan_array_L(const char *&src, int L, double *a)
Definition: librw.cpp:720
#define _errorr(_1)
Definition: gelib.h:160
bool SP_scan_character(const char *&src, char &dest)
scanning == scan ... to variable dest and shift src pointer at the end of ...
Definition: librw.cpp:636
bool FP_skip_to_line_starting_with(FILE *stream, const char *string, bool cs)
move file descriptor to the line starting with string, exactly behind the string; white space can be ...
Definition: librw.cpp:202
long FP_scan_line_skip_emptyORcommented(FILE *stream, char *dest)
*** *** *** SCANNING *** *** *** scanning == scan ...
Definition: librw.cpp:408
bool SP_print_space(const char *&src, FILE *stream)
*** *** *** PRINTING *** *** *** printing == print ...
Definition: librw.cpp:746
void copy_star_end(FILE *sour, FILE *dest, int n)
read line of file until , no save, dava bacha na EOF
Definition: librw.cpp:800
long FP_number_of_lines(FILE *stream, bool rwd)
count number of lines in file
Definition: librw.cpp:339
bool FP_copy_behind_line(FILE *sour, FILE *dest, int n)
copy from file to file behind the line [former copy_line]
Definition: librw.cpp:259
bool isDigitChar(char C)
Definition: librw.cpp:48
bool FP_copy_behind_line_starting_with(FILE *src, FILE *dest, const char *expctd, bool cs)
copy from file to file behind the line starting with string
Definition: librw.cpp:276
bool FP_skip_nonword(FILE *stream)
*** *** *** SKIPING *** *** *** skiping == shift stream pointer at the first char which is not ...
Definition: librw.cpp:363
bool SP_scan_expected_number(const char *&src, ArgType expctd)
... number and compare with expected one
Definition: librw.h:236
bool FP_scan_expected_number(FILE *src, long expctd)
... number and compare with expected one
Definition: librw.cpp:524
void FP_scan_expected_word_FL(const char *file, int line, FILE *src, const char *expctd, const char *msg, bool cs)
... word and compare with expected one, exit if false
Definition: librw.cpp:497
int FP_scan_word(FILE *src, char *dest)
... word; return value is length of the word
Definition: librw.cpp:455
double * give_ptr2val(long i=0)
return pointer to
Definition: arrays.h:645
void ad_line(FILE *stream, char *s)
Definition: librw.cpp:846
void errorr(const char *file, int line, const char *format,...)
*** *** *** *** ERROR FCE *** *** *** ***
Definition: gelib.cpp:10
bool SP_skip_word(const char *&src, int n)
... word and space before
Definition: librw.cpp:591
void copy_star(FILE *sour, FILE *dest)
Definition: librw.cpp:804
char * pathstrdupl(const char *src)
Definition: librw.cpp:84
bool SP_scan_expected_word(const char *&src, const char *expctd, bool cs)
... word and compare with expected one
Definition: librw.cpp:699
#define CHECK_DEST
Definition: librw.cpp:14