Stay in GETCOORDS if there are more coord prompts.
[geda-gaf/berndj.git] / utils / src / sarlacc_schem.c
bloba6c376fc10267e5aab9da1870439e8d11e1b6a26
1 /* Orcad.c v 0.92
2 * Copyright 1999 Matthew Ettus
3 * For more info email matt@ettus.com
4 * Ths code is released under the terms of the GNU GPL
5 * See www.fsf.org for a copy of the license
7 * Changes 0.94 by <egil@kvaleberg.no>, october 5th 2002
8 * Scaling defaults to 200%
9 * Bus implemented - but still no bus entries!
10 * Check for stack overwrite and other horrors
11 * Changed orcad_xsize/orcad_ysize to sarlacc_dim
12 * Port improved
13 * Command line options
15 * Todo:
16 * Hierarchy
17 * Bus entries
18 * Many details - see BAD
21 /* This program will convert an ORCAD SDT IV file to geda format */
23 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <ctype.h>
30 #include <sys/types.h>
31 #include <sys/stat.h>
32 #include <fcntl.h>
33 #include <unistd.h>
34 #include <string.h>
35 #ifdef HAVE_GETOPT_H
36 #include <getopt.h>
37 #endif
39 #include <libgeda/colors.h>
41 #ifdef HAVE_LIBDMALLOC
42 #include <dmalloc.h>
43 #endif
46 * command line options
48 #define SARVERSION "0.94"
49 #define GEDAVERSION "20020825"
51 #define DEFAULT_SCALE 200 /* was 100 */
53 char *symbol_dir = 0;
54 int scale = DEFAULT_SCALE;
56 #define TEXTSIZE ((scale <= 100) ? 6 : 10)
59 * orcad
61 #define GET_TAG(VAL) (VAL & 0x0F)
63 int CONV16(char *base,int offset)
65 int retval;
66 retval = ((base[offset+1] & 255) <<8) | (base[offset] & 255);
67 if(base[offset+1]&128)
68 retval = retval | (65535U << 16);
69 return retval;
72 #define CONV32(VAR,POS) (VAR[POS]+VAR[POS+1]*256+VAR[POS+2]*65536+VAR[POS+3]*256*16777216)
74 #define CONV(X) ( (scale/10)*X )
75 #define CONVX(X) CONV(X)
76 #define CONVY(Y) ( 32700 - ((scale/10)*Y) )
78 #define HDR_LEN 0x20
79 #define BYTECOUNT 0x16
80 #define DATE 0x05
81 #define PATH 0x3B
82 #define REV 0x60
83 #define TITLE 0x64
84 #define ORG 0x91
85 #define ADDR1 0xBE
86 #define ADDR2 0xEB
87 #define ADDR3 0x118
88 #define ADDR4 0x145
90 /* change return type from int to void AVH */
91 void remove_spaces(char *src)
93 char *ptr=src;
94 while (*ptr != 0)
96 if(*ptr == ' ')
97 *ptr = '_';
98 ptr++;
103 * read block from Orcad file
104 * return size
106 unsigned read_block(int fd, char *block, int block_min_size,int block_max_size)
108 char sizebuf[2];
109 unsigned size;
111 read(fd,sizebuf,2);
112 size = CONV16(sizebuf,0);
113 if (size < block_min_size) {
114 fprintf(stderr,"Segment too small; size %d, min is %d\n",
115 size, block_min_size);
116 exit(1);
118 if (size > block_max_size) {
119 fprintf(stderr,"Segment too large; size %d, max is %d\n",
120 size, block_max_size);
121 exit(1);
123 if (read(fd,block,size) != size) {
124 fprintf(stderr,"File truncated\n");
125 exit(1);
127 return size;
130 unsigned read_string(char *dest, int dest_size, char *src)
132 unsigned size = ((unsigned char *)src)[0];
134 if (size+1 > dest_size) {
135 fprintf(stderr,"Text too large; size %d, max is %d\n",
136 size, dest_size-1);
137 exit(1);
139 strncpy(dest,src+1,size);
140 dest[size] = '\0';
141 return size;
144 /* change return type from int to void AVH */
145 void read_string_file(int fd,char *dest, int dest_size)
147 unsigned char len;
149 if (read(fd,&len,1) != 1) {
150 fprintf(stderr,"File truncated\n");
151 exit(1);
153 if (len+1 > dest_size) {
154 fprintf(stderr,"Text too large; size %d, max is %d\n",
155 len, dest_size-1);
156 exit(1);
158 if (len > 0) {
159 if (read(fd,dest,len) != len) {
160 fprintf(stderr,"File truncated\n");
161 exit(1);
164 dest[len] = '\0';
170 void parse_header(int fd1,int fd2)
172 unsigned char localbuf[32];
173 int length;
175 read(fd1,localbuf,32);
176 if( strncmp(localbuf,"Schematic FILE",14) )
178 fprintf(stderr,"\nFile is not an ORCAD 16 Bit Schematic\n");
179 exit(1);
182 length=CONV32(localbuf,BYTECOUNT);
183 fprintf(stderr,"length: %d\n",length);
185 lseek(fd2,length+HDR_LEN,SEEK_SET);
188 /* BAD more titleblock stuff */
189 void parse_titleblock(int fd)
191 int size,sheet,total,ypos;
192 char localbuf[1000];
193 char data[100];
194 char pagesize;
196 size = read_block(fd,localbuf,5,sizeof(localbuf));
197 // fprintf(stderr,"\nTitleblock %d bytes\n",size);
199 sheet=CONV16(localbuf,0x00);
200 total=CONV16(localbuf,0x02);
201 fprintf(stderr,"Sheet #%d of %d\n",sheet,total);
202 read_string(data,sizeof(data),localbuf+DATE);
203 fprintf(stderr,"%s\n",data);
205 switch(localbuf[4] && 0x0F)
207 case 0: pagesize = 'A'; ypos = 8*scale+scale/2; break;
208 case 1: pagesize = 'B'; ypos = 11*scale; break;
209 case 2: pagesize = 'C'; ypos = 17*scale; break;
210 case 3: pagesize = 'D'; ypos = 22*scale; break;
211 case 4: pagesize = 'E'; ypos = 34*scale; break;
212 default: fprintf(stderr,"Unknown Page Size\n");exit(-1);
214 if (scale==100) {
215 fprintf(stdout,"C %d %d 0 0 0 title-%c.sym\n",CONVX(0),CONVY(ypos),pagesize);
219 /* BAD Rotation and mirroring origin issues */
220 /* Other component label issues */
221 void parse_component(int fd1,int fd2)
223 char localbuf[1000];
224 char partname[256];
225 char filename[512];
226 char full_filename[1024];
227 int size;
228 int x,y;
229 int xpos = 0,ypos = 0,xpossav,ypossav;
230 int xgeda,ygeda;
231 int angle,mirror;
232 int i = 0;
233 int sarlacc_xsize = 0, sarlacc_ysize = 0;
234 int sarlacc_xoffset = 0, sarlacc_yoffset = 0;
235 int attribcnt;
237 int refx,refy,ref_vis;
238 char refdes[32];
239 int valx,valy,val_vis;
240 char value[64];
241 char attrib[64];
242 char attribsav[64];
244 char flags;
245 char vis;
247 int pointer;
248 FILE *cfp;
249 char buff[128];
251 size = read_block(fd1,localbuf,29,sizeof(localbuf));
253 x=CONV16(localbuf,0);
254 y=CONV16(localbuf,2);
256 refx = CONVX(x + CONV16(localbuf,4));
257 refy = CONVY(y + CONV16(localbuf,6));
259 valx = CONVX(x + CONV16(localbuf,8));
260 valy = CONVY(y + CONV16(localbuf,10));
262 xgeda = CONVX(x);
263 ygeda = CONVY(y);
265 if(localbuf[12] & 0x80) mirror=1;
266 else mirror=0;
268 angle=0;
269 if (localbuf[12] & 0x20) angle=90;
270 if (localbuf[12] & 0x40) angle+=180;
271 /* BAD decode and use device number, fix rotation offset */
273 ref_vis=val_vis=1;
275 flags = localbuf[13];
276 if (flags & 2) ref_vis=0;
277 if (flags & 4) val_vis=0;
278 /* BAD decode more flags */
280 vis = localbuf[14];
282 /* 14-27 */
284 pointer = 28 + read_string(refdes,sizeof(refdes),localbuf+28) +1;
285 pointer = pointer + 1 +read_string(value,sizeof(value),localbuf+pointer);
287 read_string_file(fd2,partname,sizeof(partname));
288 remove_spaces(partname);
289 // fprintf(stderr,"Component %s: %s\n",refdes,partname);
290 snprintf(filename,sizeof(filename),"%s-1.sym", partname);
291 if (symbol_dir) {
292 snprintf(full_filename,sizeof(full_filename),"%s/%s",
293 symbol_dir, filename);
294 } else {
295 snprintf(full_filename,sizeof(full_filename),"%s", filename);
298 cfp = fopen(full_filename, "r");
299 if (cfp != NULL) {
300 /* "sarlacc_dim=" set by sarlacc_sym */
301 while (!feof(cfp)) {
302 fgets(buff, 128, cfp);
303 if (!strncmp(buff, "sarlacc_dim=", 12)) {
304 sscanf(buff+12, "%d,%d,%d,%d",
305 &sarlacc_xoffset,&sarlacc_yoffset,&sarlacc_xsize,&sarlacc_ysize);
308 fclose(cfp);
310 fprintf(stderr,"ref: %s dim = %d %d %d %d angle = %d mirror = %d\n",
311 refdes,
312 sarlacc_xoffset, sarlacc_yoffset,
313 sarlacc_xsize, sarlacc_ysize, angle, mirror);
315 switch (angle) {
316 default: /* 0 */
317 if (mirror) {
318 xgeda = xgeda + sarlacc_xsize + sarlacc_xoffset;
319 } else {
320 xgeda = xgeda - sarlacc_xoffset;
322 ygeda = ygeda - (sarlacc_ysize + sarlacc_yoffset);
323 break;
324 case 90:
325 xgeda = xgeda + sarlacc_ysize + sarlacc_yoffset;
326 if (mirror) {
327 /* BAD untested */
328 ygeda = ygeda + sarlacc_xoffset;
329 } else {
330 ygeda = ygeda - (sarlacc_xsize + sarlacc_xoffset);
332 break;
333 case 180:
334 if (mirror) {
335 xgeda = xgeda - sarlacc_xoffset;
336 } else {
337 xgeda = xgeda + sarlacc_xsize + sarlacc_xoffset;
339 ygeda = ygeda + sarlacc_yoffset;
340 break;
341 case 270:
342 xgeda = xgeda - sarlacc_yoffset;
343 if (mirror) {
344 /* BAD untested */
345 ygeda = ygeda - (sarlacc_xsize + sarlacc_xoffset);
346 } else {
347 ygeda = ygeda + sarlacc_xoffset;
349 break;
351 } else {
352 fprintf(stderr,"Couldn't find symbol %s in file: %s\n"
353 "Position on sheet will be uncertain\n", partname, full_filename);
356 fprintf(stdout,"C %d %d 1 %d %d %s\n",
357 xgeda,ygeda,angle,mirror,filename);
358 fprintf(stdout,"{\n");
360 #if 0
361 /* For sarlacc debugging purposes, it's useful to see
362 if a component is mirrored and how much it's rotated */
363 fprintf(stdout,"T %d %d %d %d %d 1 0 0\nmirror=%d\n",
364 refx,refy,GRAPHIC_COLOR,TEXTSIZE,0,mirror);
365 fprintf(stdout,"T %d %d %d %d %d 1 0 0\nrotation=%d\n",
366 refx,refy,GRAPHIC_COLOR,TEXTSIZE,0,angle);
367 #endif
368 if (refdes[0] != 0) {
369 if (value[0] && refx==valx && refy==valy) {
370 /* prevent text overlap */
371 refy += scale;
373 fprintf(stdout,"T %d %d %d %d %d 1 0 0\nrefdes=%s\n",
374 refx,refy,ATTRIBUTE_COLOR,TEXTSIZE,ref_vis,refdes);
377 if (value[0] != 0) {
378 fprintf(stdout,"T %d %d %d %d %d 1 0 0\nvalue=%s\n",
379 valx,valy,ATTRIBUTE_COLOR,TEXTSIZE,val_vis,value);
382 attribcnt = 0;
383 if(flags & 0x40) {
384 for(i=0;i<8;i++) {
385 /* This assumes that the last attribute is the footprint */
386 xpos = CONVX(x + CONV16(localbuf,pointer));
387 ypos = CONVY(y + CONV16(localbuf,pointer+2));
388 pointer += 4;
389 size = read_string(attrib,sizeof(attrib),localbuf+pointer);
390 pointer += size + 1;
391 if (size > 0) {
392 attribcnt++;
393 fprintf(stdout,"T %d %d %d %d %d 1 0 0\npattern=%s\n",
394 xpos,ypos,ATTRIBUTE_COLOR,TEXTSIZE,
395 ( (flags & (1<<i))?1:0 ),attrib);
396 xpossav = xpos;
397 ypossav = ypos;
398 strcpy(attribsav, attrib);
402 if (attribcnt > 0 && attrib[0]) {
403 fprintf(stdout,"T %d %d %d %d %d 1 0 0\n"
404 "footprint=%s\n",
405 xpos,ypos,ATTRIBUTE_COLOR,TEXTSIZE,
406 ( (flags & (1<<i))?1:0 ),attrib);
408 fprintf(stdout,"}\n");
411 /* BAD Sheets need work */
412 void parse_sheet (int fd)
414 char localbuf[1000];
415 char filename[1000];
416 char filetext[1000];
417 int size;
418 int index;
419 int n;
420 int x1,y1,x2,y2;
422 size = read_block(fd,localbuf,15,sizeof(localbuf));
423 // fprintf(stderr,"Sheet %d bytes\n",size);
425 x1=CONVX(CONV16(localbuf,0));
426 y1=CONVY(CONV16(localbuf,2));
428 x2=CONV(CONV16(localbuf,4));
429 y2=CONV(CONV16(localbuf,6));
430 index = 8;
432 /* BAD 5 bytes - dunno? */
433 index += 5;
435 n = 1+read_string(filename,sizeof(filename),localbuf+index);
436 index += n;
437 n = 1+read_string(filetext,sizeof(filetext),localbuf+index);
438 index += n;
440 /* BAD Implement Hierarchy properly! */
441 fprintf(stderr,"Hierarchy\n");
442 fprintf(stderr,"xy = %d %d %d %d\n",x1,y1,x2,y2);
443 for (n=8; n<13; ++n) fprintf(stderr,"%02x ",localbuf[n] & 0xff);
444 fprintf(stderr,"\nfile = %s\n",filename);
445 fprintf(stderr,"text = %s\n",filetext);
447 /* BAD not the way to do it... */
448 fprintf(stdout,"C %d %d 0 0 0 include-1.sym\n",x1,y1-y2);
449 fprintf(stdout,"{\n");
450 fprintf(stdout,"B %d %d %d %d %d 0 0 0 -1 -1 0 -1 -1 -1 -1 -1\n",
451 x1,y1-y2,x2,y2,GRAPHIC_COLOR);
452 fprintf(stdout,"T %d %d %d %d 0 1 0 0\n"
453 "source=%s\n",x1,y1-y2,ATTRIBUTE_COLOR,TEXTSIZE,filename);
454 fprintf(stdout,"T %d %d %d %d 1 1 0 0\n"
455 "%s\n",x1,(y1-y2)-scale,ATTRIBUTE_COLOR,TEXTSIZE,filetext);
456 fprintf(stdout,"}\n");
459 static int pending_netlabel=0;
460 static char netlabel[256];
461 static int netlabel_x, netlabel_y, netlabel_angle;
463 /* BAD Set wire color properly */
464 static void wire_or_bus(int fd, char kind, int color)
466 char localbuf[32];
467 int size;
468 int x1,y1,x2,y2;
470 size = read_block(fd,localbuf,8,sizeof(localbuf));
472 x1=CONVX(CONV16(localbuf,0));
473 y1=CONVY(CONV16(localbuf,2));
475 x2=CONVX(CONV16(localbuf,4));
476 y2=CONVY(CONV16(localbuf,6));
477 fprintf(stdout,"%c %d %d %d %d %d 0 0 0 -1 -1\n",kind,x1,y1,x2,y2,color);
478 if (pending_netlabel) {
479 fprintf(stdout,"{\n");
480 fprintf(stdout,"T %d %d %d %d 1 1 %d 0\n", netlabel_x, netlabel_y,
481 ATTRIBUTE_COLOR, TEXTSIZE, netlabel_angle);
482 fprintf(stdout,"label=%s\n", netlabel); /* BAD netname= */
483 fprintf(stdout,"}\n");
484 pending_netlabel = 0;
488 void parse_wire (int fd)
490 wire_or_bus(fd, 'N', NET_COLOR);
493 /* BAD Haven't implemented GEDA buses */
494 /* but guessing that Orcad busses are parsed just like wires... */
495 void parse_bus (int fd)
497 wire_or_bus(fd, 'U', BUS_COLOR);
500 /* BAD How do we handle junctions in GEDA? */
501 /* 19990726 I think we don't need to worry
502 * ORCAD splits wires at junction points
505 void parse_junction (int fd)
507 char localbuf[32];
508 int size;
510 size = read_block(fd,localbuf,4,sizeof(localbuf));
513 x=CONVX(CONV16(localbuf,0));
514 y=CONVY(CONV16(localbuf,2));
515 fprintf(stderr,"Junctions %d %d\n",x,y);
520 /* BAD Fix handling of ports */
522 void parse_port (int fd)
524 char localbuf[1024];
525 char textbuf[1024];
526 int size;
527 int x,y;
528 int w;
529 int m;
530 int mirror = 0;
532 size = read_block(fd,localbuf,7,sizeof(localbuf));
534 x = CONVX(CONV16(localbuf,0));
535 y = CONVY(CONV16(localbuf,2));
536 w = localbuf[4] & 0xff;
537 m = localbuf[5] & 0xff;
538 read_string(textbuf,sizeof(textbuf),localbuf+6);
540 // fprintf(stderr,"PORT %s %d %d %d 0x%x\n",textbuf,x,y,w,m);
542 switch (m & 0x60) {
543 case 0x40: /* 0101 */
544 case 0x20: /* 1010 */
545 x += scale + w * (scale/10);
546 break;
547 case 0x00: /* 0000 */
548 /* 1001 */
549 case 0x60: /* 1111 */
550 mirror = 1;
551 break;
553 fprintf(stdout,"C %d %d 1 0 %d input-orcad-1.sym\n",x,y,mirror);
554 fprintf(stdout,"{\n"
555 "T %d %d %d 8 1 1 0 0\nvalue=%s\n"
556 "}\n",x,y,GRAPHIC_COLOR,
557 textbuf);
560 /* BAD Fix Labels attach to wire. Multiline issues?*/
561 /* Fix text sizing */
562 void parse_label (int fd)
564 char localbuf[1000];
565 char textbuf[1000];
566 int size;
567 int x,y;
568 int angle;
569 int textsize;
571 size = read_block(fd,localbuf,5,sizeof(localbuf));
573 x=CONVX(CONV16(localbuf,0));
574 y=CONVY(CONV16(localbuf,2));
576 read_string(textbuf,sizeof(textbuf),localbuf+0x06);
578 angle=0;
579 textsize = 5* CONV16(localbuf,4);
580 if (textsize<0)
582 textsize *= -1;
583 angle = 90;
585 /* fprintf(stdout,"T %d %d %d %d 1 1 %d 0\n",x,y,GRAPHIC_COLOR, TEXTSIZE, angle);
586 fprintf(stdout,"net=%s ATTACHME\n",textbuf); */
587 pending_netlabel = 1;
588 strncpy(netlabel, textbuf, 256);
589 netlabel_x = x;
590 netlabel_y = y;
591 netlabel_angle = angle;
594 /* BAD Fix Entries */
596 void parse_entry (int fd)
598 char localbuf[32];
599 int size;
600 int x,y,type;
602 size = read_block(fd,localbuf,5,sizeof(localbuf));
603 // fprintf(stderr,"Entry %d bytes\n",size);
605 x=CONVX(CONV16(localbuf,0));
606 y=CONVY(CONV16(localbuf,2));
607 type=localbuf[4];
608 fprintf(stderr,"Entry %d %d type %d\n",x,y,type);
611 /* BAD Fix Dashed Lines */
613 void parse_dashed (int fd)
615 char localbuf[32];
616 int size;
617 int x,y,type;
619 size = read_block(fd,localbuf,4,sizeof(localbuf));
620 fprintf(stderr,"Dashed %d bytes\n",size);
622 x=CONVX(CONV16(localbuf,0));
623 y=CONVY(CONV16(localbuf,2));
624 type=localbuf[4];
627 /* BAD Fix power */
628 /* How do netlisters handle power connections/nets? */
630 void parse_power (int fd)
632 char localbuf[256];
633 char textbuf[256];
634 char *symbol;
635 int size;
636 int x,y,xtext,ytext;
637 int angle;
638 char type;
640 size = read_block(fd,localbuf,5,sizeof(localbuf));
641 // fprintf(stderr,"POWER %d bytes\n",size);
643 read_string(textbuf,sizeof(textbuf),localbuf+0x05);
645 x=CONVX(CONV16(localbuf,0));
646 y=CONVY(CONV16(localbuf,2));
647 type = localbuf[4];
648 switch(type & 0x0C)
650 case 0x04: angle = 180; xtext = x; ytext = y - 600; break;
651 case 0x08: angle = 90; ytext = y; xtext = x-600; break;
652 case 0x0C: angle = 270;ytext = y; xtext = x+600; break;
653 default: angle = 0; xtext=x;ytext = y+600;
655 switch(type & 0x03)
657 /* BAD GEDA only has bar and circle pix. Also, they
658 * All say VCC or VDD, which they should not */
659 case 0x02:
660 symbol = "vcc-orcad-bar-1.sym";break; /* BAR */
661 case 0x00: /* circle */
662 case 0x01: /* arrow */
663 case 0x03: /* wave */
664 default:
665 symbol = "vcc-orcad-circle-1.sym";break;
667 fprintf(stdout,"C %d %d 1 %d 0 %s\n",x,y,angle,symbol);
668 /* fprintf(stdout,"{\n"
669 "T %d %d %d %d 1 1 %d 0\n"
670 "value=%s\n"
671 "}\n",
672 xtext,ytext,GRAPHIC_COLOR,TEXTSIZE,angle%180,textbuf);*/
673 fprintf(stdout,"{\n"
674 "T %d %d %d %d 1 1 %d 0\n"
675 "net=%s:1\n"
676 "}\n",
677 xtext,ytext,GRAPHIC_COLOR,TEXTSIZE,angle%180,textbuf);
680 /* BAD Fix Text color and check rotation */
681 /* BAD Fix multi-line text */
683 void parse_text (int fd)
685 char localbuf[1024];
686 char textbuf[1024];
687 int size;
688 int x,y,textsize,angle;
690 size = read_block(fd,localbuf,7,sizeof(localbuf));
692 x=CONVX(CONV16(localbuf,0));
693 y=CONVY(CONV16(localbuf,2));
694 read_string(textbuf,sizeof(textbuf),localbuf+6);
696 angle=0;
697 textsize = TEXTSIZE * CONV16(localbuf,4);
698 if (textsize<0)
700 textsize *= -1;
701 angle = 90;
703 fprintf(stdout,"T %d %d %d %d 1 1 %d 0\n",x,y,GRAPHIC_COLOR,textsize,angle);
704 fprintf(stdout,"%s\n",textbuf);
707 /* BAD - Markers are unimplemented in gEDA (yet).
708 * They are the no-connects that you can place on pins to
709 * exempt them from the connectivity checks in DRC/ERC
712 void parse_marker (int fd)
714 char localbuf[1024];
715 int size;
717 size = read_block(fd,localbuf,0,sizeof(localbuf));
719 /* fprintf(stderr,"MARKER %d\n",size); */
723 int parse_block(int fd1,int fd2)
725 char tag;
726 read(fd1,&tag,1);
727 switch(GET_TAG(tag))
729 case 0x00:
730 parse_titleblock(fd1);
731 break;
732 case 0x01:
733 parse_sheet(fd1);
734 break;
735 case 0x02:
736 parse_component(fd1,fd2);
737 break;
738 case 0x03:
739 parse_wire(fd1);
740 break;
741 case 0x04:
742 parse_bus(fd1);
743 break;
744 case 0x05:
745 parse_junction(fd1);
746 break;
747 case 0x06:
748 parse_port(fd1);
749 break;
750 case 0x07:
751 parse_label(fd1);
752 break;
753 case 0x08:
754 parse_entry(fd1);
755 break;
756 case 0x09:
757 parse_dashed(fd1);
758 break;
759 case 0x0a:
760 parse_power(fd1);
761 break;
762 case 0x0b:
763 parse_text(fd1);
764 break;
765 case 0x0c:
766 parse_marker(fd1);
767 break;
768 case 0x0f:
769 return 0;
770 break;
771 default:
772 fprintf(stderr,"\nUnknown Block Tag\n");
773 exit(-1);
774 break;
778 return 1;
782 main(int argc, char **argv)
784 int c;
785 int fd1,fd2;
787 while ((c = getopt(argc, argv, "d:hs:v")) > 0) {
788 switch (c) {
789 case 'd':
790 symbol_dir = optarg;
791 break;
792 case 's':
793 scale = atoi(optarg);
794 break;
795 case 'v':
796 fprintf(stderr,"sarlacc_scheme ver %s\n", SARVERSION);
797 exit(0);
798 break;
799 case 'h':
800 default:
801 fprintf(stderr,"Convert Oracd schematics file (16 bit format) to gEDA\n");
802 usage:
803 fprintf(stderr,"\nUsage: %s [options] infile >outfile\n"
804 "\nOptions:"
805 "\n -d<dir> directory for symbols (from sarlacc_sym)"
806 "\n -h help"
807 "\n -s<n> scale <n>%%, default is %d"
808 "\n -v version"
809 "\n\n",
810 argv[0],DEFAULT_SCALE);
811 exit(1);
812 break;
816 if( optind+1 != argc )
818 goto usage;
821 /* BAD update to latest file format.. */
822 fprintf(stdout,"v %s\n",GEDAVERSION);
824 fd1 = open(argv[optind],O_RDONLY);
825 if( fd1 < 0 )
827 fprintf(stderr,"\nCould not open input file: %s\n",argv[optind]);
828 exit(1);
830 fd2 = open(argv[optind],O_RDONLY);
831 if( fd2 < 0 )
833 fprintf(stderr,"\n Could not open input file part deux\n");
834 exit(-1);
837 parse_header(fd1,fd2);
839 while(parse_block(fd1,fd2));
840 fprintf(stderr,"\n Normal End\n");
842 return(0);