Changeset 1241 for toilet/trunk/src/main.c
- Timestamp:
- Oct 26, 2006, 3:07:58 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
toilet/trunk/src/main.c
r1240 r1241 28 28 #endif 29 29 #include <stdio.h> 30 #include <string.h>31 30 #include <stdlib.h> 32 31 #include <cucul.h> … … 34 33 #include "toilet.h" 35 34 #include "render.h" 36 #include "figlet.h"37 35 #include "filter.h" 38 36 … … 46 44 context_t struct_cx; 47 45 context_t *cx = &struct_cx; 48 49 cucul_buffer_t *buffer;50 51 int i, j, ret;52 46 53 47 int infocode = -1; … … 184 178 } 185 179 186 if(!strcasecmp(cx->font, "mono9")) 187 ret = init_big(cx); 188 else if(!strcasecmp(cx->font, "term")) 189 ret = init_tiny(cx); 180 if(render_init(cx) < 0) 181 return -1; 182 183 if(optind >= argc) 184 render_stdin(cx); 190 185 else 191 ret = init_figlet(cx); 192 193 if(ret) 194 return -1; 195 196 if(optind >= argc) 197 { 198 char buf[10]; 199 unsigned int len; 200 uint32_t ch; 201 202 i = 0; 203 204 /* Read from stdin */ 205 while(!feof(stdin)) 206 { 207 buf[i++] = getchar(); 208 buf[i] = '\0'; 209 210 ch = cucul_utf8_to_utf32(buf, &len); 211 212 if(!len) 213 continue; 214 215 cx->feed(cx, ch); 216 i = 0; 217 } 218 } 219 else for(i = optind; i < argc; i++) 220 { 221 /* Read from commandline */ 222 unsigned int len; 223 224 if(i != optind) 225 cx->feed(cx, ' '); 226 227 for(j = 0; argv[i][j];) 228 { 229 cx->feed(cx, cucul_utf8_to_utf32(argv[i] + j, &len)); 230 j += len; 231 } 232 } 233 234 cx->end(cx); 235 236 /* Apply optional effects to our string */ 237 filter_do(cx); 238 239 /* Output char */ 240 buffer = cucul_export_canvas(cx->cv, cx->export); 241 fwrite(cucul_get_buffer_data(buffer), 242 cucul_get_buffer_size(buffer), 1, stdout); 243 cucul_free_buffer(buffer); 244 245 cucul_free_canvas(cx->cv); 186 render_list(cx, argc - optind, argv + optind); 187 188 render_end(cx); 189 filter_end(cx); 246 190 247 191 return 0;
Note: See TracChangeset
for help on using the changeset viewer.