Debian Codegraph @

rudeconfig/src/ParserJuly2004.cpp

raw
1 // ParserJuly2004.cc
2 //
3 // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007 Matthew Flood
4 // See file AUTHORS for contact information
5 //
6 // This file is part of RudeConfig.
7 //
8 // RudeConfig is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2, or (at your option)
11 // any later version.
12 //
13 // RudeConfig is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with RudeConfig; (see COPYING) if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 // 02111-1307, USA.
22 //------------------------------------------------------------------------
23
24 #include "../config.h"
25
26 #include "ParserJuly2004.h"
27
28 #ifndef INCLUDED_AbstractOrganiser_h
29 #include "AbstractOrganiser.h"
30 #endif
31
32 #ifndef INCLUDED_CCTYPE
33 #include <cctype>
34 #define INCLUDED_CCTYPE
35 #endif
36
37 #ifndef INCLUDED_IOSTREAM
38 #include <iostream>
39 #define INCLUDED_IOSTREAM
40 #endif
41
42 #include <cstdio>
43
44 using namespace rude::config;
45 using namespace std;
46
47 namespace rude{
48 namespace config{
49
50 enum SectionState{ STARTSECTION, SECTIONID, ESCAPEID, ENDSECTIONID, SECTIONCOMMENT, FOUNDIDONLY, FOUNDIDCOMMENT, SECTIONERROR, ENDSECTION };
51 /* remedius
52 * GETCOMMTYPE, GETPROCMETHOD were added in order to support runtime configuration options for choosing communication type and pre-/post-processing method
53 */
54 enum KeyValueState{ KEY, KEYESCAPE, STARTVALUE, COMMENT, FINDCOMMENT, KVERROR, ENDKV, VALUE, QUOTEVALUE, NONQUOTEVALUE, QUOTEESCAPE, NONQUOTEESCAPE, ENDKEYVALUE, LEFTARROW, RIGHTARROW, GETSOURCE, GETDEST, GETWIDTH, GETCOMMTYPE, GETPROCMETHOD, SDCOMMENT, ENDSOURCEDEST};
55
56 void ParserJuly2004::stripTrailing(std::string& buffer)
57 {
58 int bufferLength = buffer.size();
59
60 for (int x = bufferLength - 1; x >= 0; x--)
61 {
62 char c = buffer[x];
63
64 if (isspace(c))
65 {
66 buffer.erase(x);
67 }
68 else
69 {
70 break;
71 }
72 }
73 }
74
75
76 bool ParserJuly2004::isEOL(char c)
77 {
78 return (c == '\r' || c == '\f' || c == '\n');
79 }
80
81 bool ParserJuly2004::chompEOL(std::istream& inputstream)
82 {
83 char c = inputstream.peek();
84 if(isEOL(c))
85 {
86 inputstream.get();
87 char next_c = inputstream.peek();
88 if( (c != next_c) && isEOL(next_c) )
89 {
90 inputstream.get();
91 }
92 }
93 return true;
94 }
95
96 bool ParserJuly2004::parse(std::istream& infile, AbstractOrganiser& organiser)
97 {
98 if (d_delimiter == '\\' || isEOL(d_delimiter) || d_delimiter == d_commentchar || d_delimiter == '[')
99 {
100 setError("110", "Illegal delimiter.");
101 return false;
102 }
103
104 if (d_commentchar == '\\' || d_commentchar == '"' || isspace(d_commentchar))
105 {
106 setError("111", "Illegal comment character.");
107 return false;
108 }
109
110 register int c;
111
112 // eof only gets set when error_flag is set on previous operation
113 // as such, you need to peek() at the end ot the while loop
114 // in order for eof to happen when you want it to!!
115 // one peek() triggers infile.eof(), but it does not reveal it!!!!
116 // you gotta call peek() twice.
117 //
118 while( (c = infile.peek()) != EOF)
119 {
120 // We're looking for:
121 // '[' beggining of section
122 // '#' (d_commentchar) comment character
123 // any non-whitespace character
124
125 if(isspace(c))
126 {
127 std::string whitespace = "";
128
129 while(c != EOF && isspace(c))
130 {
131 whitespace += infile.get();
132 c = infile.peek();
133 }
134 organiser.foundWhiteSpace(whitespace.c_str());
135 }
136 else if(c == '[')
137 {
138 // discard '[' character
139 //
140 infile.get();
141
142 register SectionState sectionState = STARTSECTION;
143
144 std::string sectionID = "";
145 std::string comment = "";
146
147 while (sectionState != ENDSECTION)
148 {
149 switch (sectionState)
150 {
151 case STARTSECTION:
152 {
153 c = infile.peek();
154 if(c == EOF)
155 {
156 setError("102", "End of stream found before section ID.");
157 sectionState = SECTIONERROR;
158 }
159 else if(isEOL(c))
160 {
161 setError("101", "End of line found before section ID.");
162 sectionState = SECTIONERROR;
163 }
164 else if(c == ' ' || c == '\t')
165 {
166 // discard whitespace
167 //
168 infile.get();
169
170 // LOOP
171 }
172 else if(c == ']')
173 {
174 // discard ']'
175 //
176 infile.get();
177
178 sectionState = ENDSECTIONID;
179 }
180 else
181 {
182 sectionState = SECTIONID;
183 }
184 break;
185 }
186 case SECTIONID:
187 {
188 c = infile.peek();
189 if(c == EOF)
190 {
191 setError("104", "End of stream found before end-of-section marker.");
192 sectionState = SECTIONERROR;
193 }
194 else if(isEOL(c))
195 {
196 setError("103", "End of line found before end-of-section marker.");
197 sectionState = SECTIONERROR;
198 }
199 else if(c == '\\')
200 {
201 // discard backslash
202 //
203 infile.get();
204
205 sectionState = ESCAPEID;
206 }
207 else if(c == ']')
208 {
209 // discard ']'
210 //
211 infile.get();
212
213 // Strip Trailing Whitespace from ID
214 //
215 stripTrailing(sectionID);
216
217 sectionState = ENDSECTIONID;
218 }
219 else
220 {
221 sectionID += infile.get();
222
223 // LOOP
224 }
225 break;
226 }
227 case ESCAPEID:
228 {
229 c = infile.peek();
230 if(c == EOF)
231 {
232 setError("107", "End of stream found after un-escaped backslash.");
233 sectionState = SECTIONERROR;
234 }
235 else if(isEOL(c))
236 {
237 setError("108", "Escaped new-line is not allowed in section ID or key.");
238 sectionState = SECTIONERROR;
239 }
240 else
241 {
242 sectionID += infile.get();
243 sectionState = SECTIONID;
244 }
245 break;
246 }
247 case ENDSECTIONID:
248 {
249 c = infile.peek();
250 if(c == EOF || isEOL(c))
251 {
252 sectionState = FOUNDIDONLY;
253 }
254 else if(d_commentchar != 0 && c == d_commentchar)
255 {
256 // discard '#'
257 //
258 infile.get();
259
260 sectionState = SECTIONCOMMENT;
261 }
262 else if(c == ' ' || c == '\t')
263 {
264 // discard whitespace
265 //
266 infile.get();
267
268 // LOOP
269 }
270 else
271 {
272 setError("105", "Illegal character found after end-of-section marker.");
273 sectionState = SECTIONERROR;
274 }
275 break;
276 }
277 case SECTIONCOMMENT:
278 {
279 c = infile.peek();
280 if(c == EOF || isEOL(c))
281 {
282 sectionState = FOUNDIDCOMMENT;
283 stripTrailing(comment);
284 }
285 else
286 {
287 // append to comment
288 //
289 comment += infile.get();
290
291 // LOOP
292 }
293 break;
294 }
295 case SECTIONERROR:
296 case ENDSECTION: // dummy
297 {
298 return false;
299 }
300 case FOUNDIDONLY:
301 {
302 organiser.foundSection(sectionID.c_str(), 0);
303 chompEOL(infile);
304 sectionState = ENDSECTION;
305 break;
306 }
307 case FOUNDIDCOMMENT:
308 {
309 organiser.foundSection(sectionID.c_str(), comment.c_str());
310 chompEOL(infile);
311 sectionState = ENDSECTION;
312 break;
313 }
314 }
315 }
316 }
317 else if(c == d_commentchar)
318 {
319 // found a comment line
320 // discard the comment character
321 //
322 infile.get();
323
324 // put the rest of the line into a string
325 //
326 std::string line="";
327 while(infile.good())
328 {
329 c=infile.get();
330 if( isEOL(c))
331 {
332 break;
333 }
334 line += c;
335 }
336
337 chompEOL(infile);
338
339 // PROCESS THE COMMENT LINE
340 //
341 stripTrailing(line);
342 organiser.foundComment(line.c_str());
343 }
344 else
345 {
346 register KeyValueState kvState = KEY;
347 std::string key = "";
348 std::string value = "";
349 std::string comment = "";
350
351
352 // Added to handle source -> dest
353
354 std::string srcApp = "";
355 std::string srcObj = "";
356 std::string destApp = "";
357 std::string destObj = "";
358 std::string width = "";
359 /* remedius */
360 std::string commType = "";
361 /* remedius */
362 std::string procMethod = "";
363
364 while (kvState != ENDKEYVALUE)
365 {
366
367 switch (kvState)
368 {
369 case KEY:
370 {
371 //std::cout << "KEY\n";
372
373 int c = infile.peek();
374
375 if(c == EOF || isEOL(c))
376 {
377 kvState = ENDKV;
378 }
379 else if(d_delimiter && c == d_delimiter)
380 {
381 // discard '='
382 //
383 infile.get();
384
385 kvState = STARTVALUE;
386 }
387 else if(!d_delimiter && (c == ' ' || c == '\t'))
388 {
389 // discard whitespace
390 //
391 infile.get();
392 kvState = STARTVALUE;
393 }
394 else if(d_commentchar != 0 && c == d_commentchar)
395 {
396 // discard '#'
397 //
398 infile.get();
399
400 kvState = COMMENT;
401 }
402 else if(c == '\\')
403 {
404 // discard '\\'
405 //
406 infile.get();
407
408 kvState = KEYESCAPE;
409 }
410 else if(c == '-')
411 {
412 // Is it -> ??
413 infile.get();
414 c = infile.peek();
415
416 if(c == '>')
417 {
418 infile.get();
419
420 kvState = RIGHTARROW;
421 // We need to split up the key into srcApp.srcObj and store them
422 size_t dotPos = key.find_first_of('.');
423
424 if(dotPos != string::npos)
425 {
426 srcApp = key.substr(0,dotPos);
427 srcObj = key.substr(dotPos+1,key.length()-dotPos-1);
428
429 //std::cout << "Found srcApp: " << srcApp << " srcObj: " << srcObj << "\n";
430
431 }
432 else
433 {
434 srcApp = "";
435 srcObj = key;
436 }
437 }
438 else
439 {
440 key += '-';
441 }
442 }
443 else if(c == '<')
444 {
445 // IS it <- ??
446 infile.get();
447 c = infile.peek();
448
449 if(c == '-')
450 {
451 infile.get();
452
453 kvState = LEFTARROW;
454 // We need to split up the key into destApp.destObj and store them
455 size_t dotPos = key.find_first_of('.');
456
457 if(dotPos != string::npos)
458 {
459
460 destApp = key.substr(0,dotPos);
461 destObj = key.substr(dotPos+1,key.length()-dotPos-1);
462
463 //std::cout << "Found destApp: " << destApp << " destObj: " << destObj << "\n";
464
465 }
466 else
467 {
468 destApp = "";
469 destObj = key;
470 }
471 }
472 else
473 {
474 key += '<';
475 }
476 }
477 else
478 {
479 // append to key
480 //
481 key += infile.get();
482
483 // LOOP
484 }
485 break;
486 }
487 case KEYESCAPE:
488 {
489 //std::cout << "KEYESCAPE\n";
490 int c = infile.peek();
491 if(c == EOF)
492 {
493 setError("107", "End of stream found after un-escaped backslash.");
494 kvState = KVERROR;
495 }
496 else if(isEOL(c))
497 {
498 setError("108", "Escaped new-line is not allowed in key.");
499 kvState = KVERROR;
500 }
501 else
502 {
503 // append to key
504 //
505 key += infile.get();
506
507 kvState = KEY;
508 }
509 break;
510 }
511 case STARTVALUE:
512 {
513 //std::cout << "STARTVALUE\n";
514 int c = infile.peek();
515
516 if(c == EOF || isEOL(c))
517 {
518 kvState = ENDKV;
519 }
520 else if(d_commentchar != 0 && c == d_commentchar)
521 {
522 // discard '#'
523 //
524 infile.get();
525
526 kvState = COMMENT;
527 }
528 else if(c == ' ' || c == '\t')
529 {
530 // discard whitespace
531 //
532 infile.get();
533
534 // LOOP
535 }
536 else
537 {
538 kvState = VALUE;
539 }
540 break;
541 }
542 case KVERROR:
543 case ENDKEYVALUE: // dummy for compiler
544 {
545 //std::cout << "KVERROR\n";
546 return false;
547 }
548 case FINDCOMMENT:
549 {
550
551 //std::cout << "FINDCOMMENT\n";
552 int c = infile.peek();
553
554 if(c == EOF || isEOL(c))
555 {
556 kvState = ENDKV;
557 }
558 else if(d_commentchar != 0 && c == d_commentchar)
559 {
560 // discard '#'
561 //
562 infile.get();
563
564 kvState = COMMENT;
565 }
566 else if(c == ' ' || c == '\t')
567 {
568 // discard whitespace
569 //
570 infile.get();
571
572 // LOOP
573 }
574 else
575 {
576 setError("109", "Illegal Character Found after quoted value.");
577 kvState = KVERROR;
578 }
579 break;
580 }
581 case COMMENT:
582 {
583 //std::cout << "COMMENT\n";
584
585 int c = infile.peek();
586
587 if(c == EOF || isEOL(c))
588 {
589 stripTrailing(comment);
590 kvState = ENDKV;
591 }
592 else
593 {
594 // Append to comment
595 //
596 comment += infile.get();
597
598 // LOOP
599 }
600 break;
601 }
602 case VALUE:
603 {
604 //std::cout << "VALUE\n";
605
606 int c = infile.peek();
607 if(c == '"')
608 {
609 // discard '"'
610 //
611 infile.get();
612
613 kvState = QUOTEVALUE;
614 }
615 else
616 {
617 kvState = NONQUOTEVALUE;
618 }
619 break;
620 }
621 case QUOTEVALUE:
622 {
623 //std::cout << "QUOTEVALUE\n";
624 int c = infile.peek();
625 if(c == EOF)
626 {
627 setError("106", "End of stream found before final quote (\") in value.");
628 kvState = KVERROR;
629 }
630 else if(c == '"')
631 {
632 // discard '"'
633 //
634 infile.get();
635
636 kvState = FINDCOMMENT;
637 }
638 else if(c == '\\')
639 {
640 // discard backslash
641 //
642 infile.get();
643
644 kvState = QUOTEESCAPE;
645 }
646 else
647 {
648 // append to value
649 //
650 value += infile.get();
651
652 // LOOP
653 }
654 break;
655 }
656 case QUOTEESCAPE:
657 {
658 //std::cout << "QUOTEESCAPE\n";
659
660 int c = infile.peek();
661 if(c == EOF)
662 {
663 setError("107", "End of stream found after un-escaped backslash.");
664 kvState = KVERROR;
665 }
666 else
667 {
668 // append to value
669 //
670 value += infile.get();
671
672 kvState = QUOTEVALUE;
673 }
674 break;
675 }
676 case NONQUOTEVALUE:
677 {
678 //std::cout << "NONQUOTEVALUE\n";
679 int c = infile.peek();
680
681 if(c == EOF || isEOL(c))
682 {
683 stripTrailing(value);
684
685 kvState = ENDKV;
686 }
687 else if(d_commentchar != 0 && c == d_commentchar)
688 {
689 // discard '#'
690 //
691 infile.get();
692
693 stripTrailing(value);
694
695 kvState = COMMENT;
696 }
697 else if(c == '\\')
698 {
699 // discard backslash
700 //
701 infile.get();
702
703 kvState = NONQUOTEESCAPE;
704 }
705 else
706 {
707 // append to value
708 //
709 value += infile.get();
710
711 // LOOP
712 }
713 break;
714 }
715 case NONQUOTEESCAPE:
716 {
717 //std::cout << "NONQUOTEESCAPE\n";
718
719 int c = infile.peek();
720 if(c == EOF)
721 {
722 setError("107", "End of stream found after un-escaped backslash.");
723 kvState = KVERROR;
724 }
725 else
726 {
727 // append to value
728 //
729 c = infile.get();
730 value += c;
731
732 // SPECIAL CASE FOR ESCAPED CRLFs:
733 //
734 // if c is newline and next character is also newline,
735 // we keep both of them if they are different forms of newline
736 //
737 char next_c = infile.peek();
738 if(isEOL(c) && isEOL(next_c) && (c != next_c))
739 {
740 value += infile.get();
741 }
742 kvState = NONQUOTEVALUE;
743 }
744 break;
745 }
746 case ENDKV:
747 {
748 //std::cout << "ENDKV\n";
749
750 chompEOL(infile);
751
752 stripTrailing(key);
753 organiser.foundData(key.c_str(), value.c_str(), comment.c_str());
754
755 kvState = ENDKEYVALUE;
756 break;
757 }
758 case LEFTARROW:
759 {
760 //std::cout << "LEFTARROW\n";
761
762 int c = infile.peek();
763
764 if(c == EOF || isEOL(c))
765 {
766 kvState = ENDSOURCEDEST;
767
768 stripTrailing(value);
769
770 size_t dotPos = value.find_first_of('.');
771
772 if(dotPos != string::npos)
773 {
774 srcApp = value.substr(0,dotPos);
775 srcObj = value.substr(dotPos+1,value.length()-dotPos-1);
776
777 //std::cout << "srcApp: " << srcApp << " srcObj: " << srcObj << "\n";
778 }
779 else
780 {
781 //std::cout << "srcObj: " << value << "\n";
782
783 srcApp = "";
784 srcObj = value;
785 }
786 }
787 else if(c == ' ' || c == '\t')
788 {
789 // Discard whitespace
790 infile.get();
791 }
792 else if(d_commentchar != 0 && c == d_commentchar)
793 {
794 // discard '#'
795 infile.get();
796
797 kvState = SDCOMMENT;
798 }
799 else
800 {
801 kvState = GETSOURCE;
802 }
803
804
805 break;
806 }
807 case RIGHTARROW:
808 {
809 //std::cout << "RIGHTARROW\n";
810
811 int c = infile.peek();
812
813 if(c == EOF || isEOL(c))
814 {
815 kvState = ENDSOURCEDEST;
816
817 stripTrailing(value);
818
819 size_t dotPos = value.find_first_of('.');
820
821 if(dotPos != string::npos)
822 {
823 destApp = value.substr(0,dotPos);
824 destObj = value.substr(dotPos+1,value.length()-dotPos-1);
825 }
826 else
827 {
828 destApp = "";
829 destObj = value;
830 }
831 }
832 else if(c == ' ' || c == '\t')
833 {
834 // Discard whitespace
835 infile.get();
836 }
837 else if(d_commentchar != 0 && c == d_commentchar)
838 {
839 // discard '#'
840 infile.get();
841
842 kvState = SDCOMMENT;
843 }
844 else
845 {
846 kvState = GETDEST;
847 }
848
849 break;
850 }
851 case GETSOURCE:
852 {
853 //std::cout << "GETSOURCE\n";
854
855 int c = infile.peek();
856
857 if(c == EOF || isEOL(c))
858 {
859 stripTrailing(value);
860
861 kvState = ENDSOURCEDEST;
862
863 size_t dotPos = value.find_first_of('.');
864
865 if(dotPos != string::npos)
866 {
867 srcApp = value.substr(0,dotPos);
868 srcObj = value.substr(dotPos+1,value.length()-dotPos-1);
869
870 //std::cout << "srcApp: " << srcApp << " srcObj: " << srcObj << "\n";
871 }
872 else
873 {
874 //std::cout << "srcObj: " << value << "\n";
875
876 srcApp = "";
877 srcObj = value;
878 }
879 }
880 else if((d_commentchar != 0 && c == d_commentchar) || c == '[')
881 {
882 // discard '#' or '['
883 //
884 infile.get();
885
886 stripTrailing(value);
887
888 size_t dotPos = value.find_first_of('.');
889
890 if(dotPos != string::npos)
891 {
892 srcApp = value.substr(0,dotPos);
893 srcObj = value.substr(dotPos+1,value.length()-dotPos-1);
894
895 //std::cout << "srcApp: " << srcApp << " srcObj: " << srcObj << "\n";
896 }
897 else
898 {
899 //std::cout << "srcObj: " << value << "\n";
900
901 srcApp = "";
902 srcObj = value;
903 }
904
905 // Which one was it, comment about to start or width info?
906 if(c == '[')
907 kvState = GETWIDTH;
908 else
909 kvState = SDCOMMENT;
910 }
911 else
912 {
913 // append to value (temp storage for
914 //
915 value += infile.get();
916
917 // LOOP
918 }
919
920 break;
921 }
922 case GETDEST:
923 {
924
925 //std::cout << "GETDEST\n";
926
927 int c = infile.peek();
928
929 if(c == EOF || isEOL(c))
930 {
931 stripTrailing(value);
932
933 kvState = ENDSOURCEDEST;
934
935 size_t dotPos = value.find_first_of('.');
936
937 if(dotPos != string::npos)
938 {
939 destApp = value.substr(0,dotPos);
940 destObj = value.substr(dotPos+1,value.length()-dotPos-1);
941
942 //std::cout << "Found destApp: " << destApp << " destObj: " << destObj << "\n";
943
944 }
945 else
946 {
947 destApp = "";
948 destObj = value;
949 }
950 }
951 else if((d_commentchar != 0 && c == d_commentchar) || c == '[')
952 {
953 // discard '#' or '['
954 //
955 infile.get();
956
957 stripTrailing(value);
958
959 size_t dotPos = value.find_first_of('.');
960
961 if(dotPos != string::npos)
962 {
963 destApp = value.substr(0,dotPos);
964 destObj = value.substr(dotPos+1,value.length()-dotPos-1);
965
966 //std::cout << "Found destApp: " << destApp << " destObj: " << destObj << "\n";
967
968 }
969 else
970 {
971 destApp = "";
972 destObj = value;
973 }
974
975 // Which one was it, comment about to start or width info?
976 if(c == '[')
977 kvState = GETWIDTH;
978 else
979 kvState = SDCOMMENT;
980 }
981 else
982 {
983 // append to value (temp storage for
984 //
985 value += infile.get();
986
987 // LOOP
988 }
989
990 break;
991 }
992 case GETWIDTH:
993 {
994 //std::cout << "GETWIDTH\n";
995
996 int c = infile.peek();
997
998 if(c == EOF || isEOL(c))
999 {
1000 setError("901", "Partial width found. No terminating ']'.");
1001 kvState = KVERROR;
1002 }
1003 else if(d_commentchar != 0 && c == d_commentchar)
1004 {
1005 // discard '#'
1006 //
1007 infile.get();
1008
1009 kvState = SDCOMMENT;
1010 }
1011 else if(c == ' ' || c == '\t')
1012 {
1013 // discard whitespace
1014 //
1015 infile.get();
1016
1017
1018 c = infile.peek();
1019
1020 if('0' <= c && c <= '9' && width.length() > 0)
1021 {
1022 setError("902", "Two numbers detected in the width declaration.");
1023 kvState = KVERROR;
1024 }
1025
1026 // LOOP
1027 }
1028 /* remedius
1029 * communication type (GETCOMMTYPE) and processing method(GETPROCMETHOD) parameters are optional.
1030 */
1031 else if(c == ',')
1032 {
1033 stripTrailing(width);
1034 infile.get(); // Throw away ,
1035 kvState = GETCOMMTYPE;
1036
1037 }
1038 else if(c == ']')
1039 {
1040 stripTrailing(width);
1041 infile.get(); // Throw away ]
1042 kvState = ENDSOURCEDEST;
1043
1044 // Ignoring any comments that might be here...
1045 }
1046 else if('0' <= c && c <= '9')
1047 {
1048 width += infile.get();
1049 }
1050 else {
1051 setError("903", "Non integer number detected.");
1052 kvState = KVERROR;
1053 }
1054 break;
1055 }
1056 /* remedius */
1057 case GETCOMMTYPE:
1058 {
1059 int c = infile.peek();
1060
1061 if(c == EOF || isEOL(c))
1062 {
1063 setError("901", "Partial communication type is found. No terminating ']'.");
1064 kvState = KVERROR;
1065 }
1066 else if(d_commentchar != 0 && c == d_commentchar)
1067 {
1068 // discard '#'
1069 //
1070 infile.get();
1071
1072 kvState = SDCOMMENT;
1073 }
1074 else if(c == ' ' || c == '\t')
1075 {
1076 // discard whitespace
1077 //
1078 infile.get();
1079
1080 // LOOP
1081 }
1082 else if(c == ']')
1083 {
1084 stripTrailing(commType);
1085 infile.get(); // Throw away ]
1086 kvState = ENDSOURCEDEST;
1087
1088 // Ignoring any comments that might be here...
1089 }
1090 else if(c == ',')
1091 {
1092 stripTrailing(commType);
1093 infile.get(); // Throw away ,
1094 kvState = GETPROCMETHOD;
1095 }
1096 else
1097 {
1098 commType += infile.get();
1099 }
1100
1101 break;
1102
1103 }
1104 /* remedius */
1105 case GETPROCMETHOD:
1106 {
1107 int c = infile.peek();
1108
1109 if(c == EOF || isEOL(c))
1110 {
1111 setError("901", "Partial processing mathod is found. No terminating ']'.");
1112 kvState = KVERROR;
1113 }
1114 else if(d_commentchar != 0 && c == d_commentchar)
1115 {
1116 // discard '#'
1117 //
1118 infile.get();
1119
1120 kvState = SDCOMMENT;
1121 }
1122 else if(c == ' ' || c == '\t')
1123 {
1124 // discard whitespace
1125 //
1126 infile.get();
1127
1128 // LOOP
1129 }
1130 else if(c == ']')
1131 {
1132 stripTrailing(commType);
1133 infile.get(); // Throw away ]
1134 kvState = ENDSOURCEDEST;
1135
1136 // Ignoring any comments that might be here...
1137 }
1138 else if(c != ',')
1139 {
1140 procMethod += infile.get();
1141 }
1142 else
1143 {
1144 setError("904", "Unexpected symbol.");
1145 kvState = KVERROR;
1146 }
1147
1148 break;
1149
1150 }
1151 case SDCOMMENT:
1152 {
1153 //std::cout << "SDCOMMENT\n";
1154
1155 int c = infile.peek();
1156
1157 if(c == EOF || isEOL(c))
1158 {
1159 stripTrailing(comment);
1160 kvState = ENDSOURCEDEST;
1161 }
1162 else
1163 {
1164 // Append to comment
1165 //
1166 comment += infile.get();
1167
1168 // LOOP
1169 }
1170 break;
1171 }
1172 case ENDSOURCEDEST:
1173 {
1174 //std::cout << "ENDSOURCEDEST\n";
1175
1176 chompEOL(infile);
1177
1178 stripTrailing(srcApp);
1179 stripTrailing(srcObj);
1180 stripTrailing(destApp);
1181 stripTrailing(destObj);
1182 stripTrailing(width);
1183 /* remedius */
1184 stripTrailing(commType);
1185 /* remedius */
1186 stripTrailing(procMethod);
1187 /* remedius */
1188 organiser.foundSourceDest(srcApp.c_str(), srcObj.c_str(), destApp.c_str(), destObj.c_str(), width.c_str(), commType.c_str(), procMethod.c_str(), comment.c_str());
1189
1190 kvState = ENDKEYVALUE;
1191 break;
1192 }
1193
1194
1195 } // end switch
1196 } // end while
1197 }
1198 }
1199 return true;
1200 }
1201
1202 }} // end namespaces
1203
1204
1205
1206