00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <data_struct/static_memory_gremlin.h>
00027
00028 #include <stdio.h>
00029 #include <stdlib.h>
00030 #include <string.h>
00031
00032 HOOPLE_STARTUP_CODE;
00033
00034 #define LENGTH 150
00035
00036 int uuread(FILE *infile)
00037 {
00038 char *s2, *s1, *s0, *tmp_s;
00039 int length;
00040 static char s[3 * (LENGTH + 1)];
00041 static int echo_on = false, started = false, just_finished = false;
00042 static int line_length = 0, lines_to_go = 0;
00043
00044 s0 = s;
00045 s1 = s0 + (LENGTH + 1);
00046 s2 = s1 + (LENGTH + 1);
00047
00048 s0[0] = s1[0] = s2[0] = '\0';
00049
00050 while (fgets(s0, LENGTH, infile) != NULL)
00051 {
00052 s0[LENGTH] = '\0';
00053
00054 if (just_finished)
00055 {
00056 if (strncmp(s0, "size ", 5) == 0)
00057 {
00058 fputs(s0, stdout);
00059 s0[0] = '\0';
00060 }
00061 just_finished = false;
00062 }
00063
00064 if (!started)
00065 {
00066 if (strncmp(s0, "begin ", 6) == 0)
00067 {
00068 started = echo_on = true;
00069 line_length = 0;
00070 lines_to_go = 0;
00071 }
00072 }
00073 else
00074 {
00075 length = int(strlen(s0));
00076 if (line_length == 0)
00077 line_length = length;
00078
00079 if (echo_on)
00080 {
00081 lines_to_go = 0;
00082 if (s0[0] != 'M' || length != line_length)
00083 {
00084 echo_on = false;
00085 lines_to_go = 2;
00086 if (s0[0] == ' ' || s0[0] == '`')
00087 lines_to_go = 1;
00088 }
00089 }
00090 else
00091 {
00092 if (s0[0] == 'M' && length == line_length)
00093 echo_on = true;
00094 else if (lines_to_go > 0)
00095 {
00096 if (lines_to_go == 2)
00097 {
00098 if (s0[0] == ' ' || s0[0] == '`')
00099 lines_to_go = 1;
00100 else
00101 lines_to_go = 0;
00102 }
00103 else if (lines_to_go == 1)
00104 {
00105 if (strcmp(s0, "end\n") == 0)
00106 {
00107 fputs(s2, stdout);
00108 fputs(s1, stdout);
00109 fputs(s0, stdout);
00110 lines_to_go = 0;
00111 just_finished = true;
00112 started = false;
00113 }
00114 else
00115 lines_to_go = 0;
00116 }
00117 }
00118 }
00119 }
00120
00121 if (echo_on)
00122 {
00123 fputs(s0, stdout);
00124 s0[0] = '\0';
00125 }
00126
00127 tmp_s = s2;
00128 s2 = s1;
00129 s1 = s0;
00130 s0 = tmp_s;
00131 }
00132 return 0;
00133 }
00134
00135 int main(int argc, char *argv[])
00136 {
00137 int error, argno;
00138 FILE *infile;
00139
00140 if (argc < 2)
00141 return uuread(stdin);
00142 else
00143 {
00144 error = false;
00145 for (argno = 1; !error && argno < argc; argno++)
00146 {
00147 if ((infile = fopen(argv[argno], "r")) == NULL)
00148 {
00149 error = true;
00150 fprintf(stderr, "uucat: Can't open '%s' for input.\n", argv[argno]);
00151 }
00152 else
00153 {
00154 return uuread(infile);
00155 fclose(infile);
00156 }
00157 }
00158 }
00159
00160 return 0;
00161 }
00162
00163 #ifdef __BUILD_STATIC_APPLICATION__
00164
00165 #include <basis/array.cpp>
00166 #include <basis/byte_array.cpp>
00167 #include <basis/callstack_tracker.cpp>
00168 #include <basis/chaos.cpp>
00169 #include <basis/convert_utf.cpp>
00170 #include <basis/definitions.cpp>
00171 #include <basis/earth_time.cpp>
00172 #include <basis/guards.cpp>
00173 #include <basis/istring.cpp>
00174 #include <basis/log_base.cpp>
00175 #include <basis/memory_checker.cpp>
00176 #include <basis/mutex.cpp>
00177 #include <basis/object_base.cpp>
00178 #include <basis/outcome.cpp>
00179 #include <basis/packable.cpp>
00180 #include <basis/portable.cpp>
00181 #include <basis/sequence.cpp>
00182 #include <basis/set.cpp>
00183 #include <basis/utility.cpp>
00184 #include <basis/version_record.cpp>
00185 #include <data_struct/amorph.cpp>
00186 #include <data_struct/bit_vector.cpp>
00187 #include <data_struct/byte_hasher.cpp>
00188 #include <data_struct/configurator.cpp>
00189 #include <data_struct/hash_table.cpp>
00190 #include <data_struct/pointer_hash.cpp>
00191 #include <data_struct/stack.cpp>
00192 #include <data_struct/static_memory_gremlin.cpp>
00193 #include <data_struct/string_hash.cpp>
00194 #include <data_struct/string_hasher.cpp>
00195 #include <data_struct/string_table.cpp>
00196 #include <data_struct/symbol_table.cpp>
00197 #include <data_struct/table_configurator.cpp>
00198 #include <loggers/console_logger.cpp>
00199 #include <loggers/file_logger.cpp>
00200 #include <loggers/locked_logger.cpp>
00201 #include <loggers/null_logger.cpp>
00202 #include <loggers/program_wide_logger.cpp>
00203 #include <opsystem/byte_filer.cpp>
00204 #include <opsystem/command_line.cpp>
00205 #include <opsystem/critical_events.cpp>
00206 #include <opsystem/directory.cpp>
00207 #include <opsystem/filename.cpp>
00208 #include <opsystem/ini_config.cpp>
00209 #include <opsystem/ini_parser.cpp>
00210 #include <opsystem/path_configuration.cpp>
00211 #include <opsystem/rendezvous.cpp>
00212 #include <textual/byte_format.cpp>
00213 #include <textual/parser_bits.cpp>
00214 #include <textual/string_manipulation.cpp>
00215 #include <textual/tokenizer.cpp>
00216 #endif // __BUILD_STATIC_APPLICATION__
00217