int Xmacro(int status, char *label, char *mnemo, char *oper) { jmp_buf errjmpsav; char *s1,*s2; struct macroline *startmacro; register struct macroline **where; char mname[LABLEN+1]; struct label *lbl = 0; where = &startmacro; strncpy(mname,label,LABLEN); mname[LABLEN]=0; if ( oper ) error ( "no operand allowed in macro statement" ); if ( macrolevel ) error ( "nested macro definition"); if ( status & 1 ) outputline(); if ( status & 2 ) { lbl = deflabel(mname,0,L_MACRO,0); lbl->ptr = 0; } jmp_buf_copy(errjmpsav,errorjump); do { if (setjmp(errorjump) ) errnumber++; zerobuffer(); linegets(curline,250); if (feof (file) ) { jmp_buf_copy(errorjump,errjmpsav); error("Unexpected End of File"); } if ( !filter(curline,"?_;?",&s1,&s2) ) s1=curline; if (status & 2) { *where= ( struct macroline *) malloc( sizeof( struct macroline ) + strlen( s1 ) ); (*where)->next = NULL; strcpy ( (*where)->line , s1 ); where = & ( (*where)->next ); }; if (status & 1) outputline(); } while ( ! filter(s1,"_?_ENDM_?",&s1,&s2 ) ); jmp_buf_copy(errorjump,errjmpsav); if ( *s1 || *s2 ) error ("illegal ENDM instruction"); if ( lbl ) lbl->ptr = (void*)startmacro; return 0; }
void output_repeat_legend(FILE *fp, int *startpos, int **breaks, int *numsegment, int **colorindex, char **chrname, int num) { int i, j, k, l, m, n; int base[50], point[4][2]; char c, name[100], temp[100]; char **str; double label[3]; str = (char **) ckalloc(10 * sizeof(char *)); for(i = 0; i < 10; i ++) { str[i] = (char *) ckalloc(100 * sizeof(char)); } sprintf(str[0], "Repeat ID"); sprintf(str[1], "Length"); sprintf(str[2], "Chromosome"); sprintf(str[3], "From-to"); sprintf(str[4], "Subrepeats"); sprintf(str[5], "From-to"); base[0] = 50; base[1] = 800; outputline(fp, str, 6, base, 90, 10); base[1] -= 20; for(i = 0; i < num; i ++) { for(j = 0; j < numsegment[i]; j ++) { if(j == 0) { sprintf(str[0], "R%d", i + 1); sprintf(str[1], "%d", breaks[i][numsegment[i]]); sprintf(str[2], "%s", chrname[i]); sprintf(str[3], "%d-%d", startpos[i], startpos[i] + breaks[i][numsegment[i]] - 1); } else { str[0][0] = str[1][0] = str[2][0] = str[3][0] = '\0'; } m = (colorindex[i][j] - 1) % total_color; sprintf(str[4], "s%d", colorindex[i][j]); sprintf(str[5], "%d-%d", startpos[i] + breaks[i][j], startpos[i] + breaks[i][j + 1] - 1); base[0] = 50; base[1] -= 10; outputline(fp, str, 6, base, 90, 8); if(base[1] <= 50) { base[0] = 50; base[1] = 800; showpage(fp); fprintf(fp, "%%%%Page: P%d\n", npages); npages ++; change_scale(fp, scale); } } } for(i = 0; i < 10; i ++) { free((void *) str[i]); } free((void *) str); }
int Xinclude(int modifier, char *label, char *mnemo, char *oper) { FILE *f; register int slevel; if ( !oper) error("no filename"); f=fopen(oper,"r"); if ( f==NULL ) error("can't open include file"); slevel=sourcelevel+1; if ( slevel >= MAXSOURCEDEEP ) fatal ( "too many nested INCLUDEs and MACROs" ); source[slevel].type = S_FILE; source[slevel].filedesc.oldlinnum=linenumber; source[slevel].filedesc.oldprefix=lineprefix; source[slevel].filedesc.oldlist = (asmflags&F_LIST_ON) ? 1 : 0; source[slevel].filedesc.file = f; if ( asmflags & F_LIST_ON ) outputline(); linenumber = 0; sourcelevel=slevel; includelevel++; if ( !(asmflags & F_INCLUDELIST_ON ) ) asmflags &= ~F_LIST_ON; return 0; }
int Xendm(int status, char *label, char *mnemo, char *oper) { if (oper) error ( "no operand allowed in ENDM statement"); if (!macrolevel && (status & 1)) outputline(); return ENDM; }
int macrocall(struct label *labmacro, int status, char *oper) { char replace[9][60]; register int slevel,flag; int numarg,oldsegment,mystatus; jmp_buf errjmpsav; char curlinesav[256]; labmacro->flags |= USED; strcpy(curlinesav,curline); slevel=sourcelevel+1; if ( slevel >= MAXSOURCEDEEP ) fatal ( "too many nested INCLUDEs and MACROs" ); source[slevel].type = S_MACRO; source[slevel].macrodesc.oldlinnum=linenumber; source[slevel].macrodesc.oldprefix=lineprefix; source[slevel].macrodesc.oldlist = (asmflags&F_LIST_ON) ? 1 : 0; numarg=0; oldsegment=segment; while ( oper && *oper ) { char *arg1,*arg2; if ( numarg > 8 ) error ( "Too many arguments in a macro call" ); if ( filter ( oper,"?_,_?",&arg1,&arg2 ) ) { oper = arg2; strncpy(replace[numarg],arg1,59); replace[numarg++][59]=0; } else { strncpy(replace[numarg],oper,59); replace[numarg++][59]=0; oper = NULL; }; }; source[slevel].macrodesc.mlineptr = (struct macroline * ) labmacro->ptr; source[slevel].macrodesc.numarg = numarg; source[slevel].macrodesc.replace = replace; if ( asmflags & F_MACROLIST_ON ) if ( status & 1 ) outputline(); lineprefix = 'M'; sourcelevel=slevel; macrolevel++; segment=++thiscall; mystatus = 2; if ( (asmflags & F_MACROLIST_ON ) ) mystatus |= 1; jmp_buf_copy(errjmpsav,errorjump); do { if (setjmp(errorjump) ) errnumber++; linegets(curline,250); flag=asmline(curline,status & mystatus); } while ( flag == 0 ); macrolevel--; linenumber=source[slevel].filedesc.oldlinnum; lineprefix=source[slevel].filedesc.oldprefix; asmflags &= ~ F_LIST_ON; if ( source[slevel].filedesc.oldlist ) asmflags |= F_LIST_ON; sourcelevel=--slevel; segment=oldsegment; jmp_buf_copy(errorjump,errjmpsav); if ( flag != ENDM && flag != EXITM ) error("ELSE or ENDC illegal here"); if ( !(asmflags & F_MACROLIST_ON ) ) { strcpy(curline,curlinesav); if ( status & 1) outputline(); }; return 0; }
int Xif(int status, char *label, char *mnemo, char *oper) { int flag; int mystatus; int booleanvalue; char oldprefix; jmp_buf errjmpsav; booleanvalue = FALSE; if ( status&2 ) booleanvalue = testtrue(oper); mystatus=0; if ( booleanvalue ) mystatus|=3; if ( asmflags & F_IFLIST_ON ) mystatus|=1; if ( asmflags & F_IFLIST_ON ) if (status & 1) outputline(); oldprefix = lineprefix; if ( status & 2) if ( ! (mystatus & 2) ) lineprefix = 'C'; jmp_buf_copy(errjmpsav,errorjump); do { if (setjmp(errorjump) ) errnumber++; linegets(curline,250); if (feof (file) ) { jmp_buf_copy(errorjump,errjmpsav); error("Unexpected End of File"); } flag=asmline(curline,status & mystatus); if ( !(status & mystatus & 2) ) if ( flag==EXITM ) flag=0; } while ( flag == 0); jmp_buf_copy(errorjump,errjmpsav); lineprefix = oldprefix; if ( flag == ENDM ) error ("ENDM illegal here"); if ( asmflags & F_IFLIST_ON ) if (status & 1) outputline(); if ( flag == ENDC ) return 0; if ( flag == EXITM ) return EXITM; mystatus = 0; if ( !booleanvalue ) mystatus |= 3; if ( asmflags & F_IFLIST_ON ) mystatus |= 1; if ( status & 2) if ( ! (mystatus & 2) ) lineprefix = 'C'; do { if (setjmp(errorjump) ) errnumber++; linegets(curline,250); if (feof (file) ) { jmp_buf_copy(errorjump,errjmpsav); error("Unexpected End of File"); } flag=asmline(curline,status & mystatus); if ( !(status & mystatus & 2) ) if ( flag==EXITM ) flag=0; } while ( flag == 0 ); jmp_buf_copy(errorjump,errjmpsav); lineprefix = oldprefix; if ( flag == ENDM || flag == ELSE) error ("ELSE or ENDM illegal here"); if ( asmflags & F_IFLIST_ON ) if (status & 1) outputline(); if ( flag == ENDC ) return 0; if ( flag == EXITM ) return EXITM; return 0; }
void output_legend(FILE *fp, int *repeat_length, int *multip, int num_repeat, int **repeats) { int i, j, k, l, m, n; int base[50], point[4][2]; char c, name[100], temp[100]; char **str; double label[3]; str = (char **) ckalloc(10 * sizeof(char *)); for(i = 0; i < 10; i ++) { str[i] = (char *) ckalloc(100 * sizeof(char)); } sprintf(str[0], "Subrepeat ID"); sprintf(str[1], "Length"); sprintf(str[2], "Multiplicity"); sprintf(str[3], "Repeats"); sprintf(str[4], "Color coding"); base[0] = 50; base[1] = 680; outputline(fp, str, 5, base, 60, 10); for(i = 0; i < num_repeat; i ++) { if(multip[i] == 0) continue; sprintf(name, "s%d", i + 1); strcpy(str[0], name); sprintf(str[1], "%d", repeat_length[i]); sprintf(str[2], "%d", multip[i]); str[3][0] = '\0'; for(j = 0; j < min(multip[i], MIN_NUM); j ++) { sprintf(temp, "R%d ", repeats[i][j] + 1); strcat(str[3], temp); } base[0] = 50; base[1] -= 10; outputline(fp, str, 4, base, 60, 8); point[0][0] = 370; point[0][1] = base[1]; point[1][0] = 370 + length_intv(repeat_length[i]); point[1][1] = base[1]; point[2][0] = 370 + length_intv(repeat_length[i]); point[2][1] = base[1] + 5; point[3][0] = 370; point[3][1] = base[1] + 5; m = i % total_color; for(j = 0; j < 3; j ++) { label[j] = color_box[m][j]; } prt_box(fp, point, label, 0, 0, 0); base[0] = 370 + length_intv(repeat_length[i]) / 2; base[1] += 2; prt_Text(fp, name, base, 8, 0); if(base[1] <= 50 && i < num_repeat - 1) { base[0] = 50; base[1] = 800; showpage(fp); fprintf(fp, "%%%%Page: P%d\n", npages); npages ++; change_scale(fp, scale); } } for(i = 0; i < 10; i ++) { free((void *) str[i]); } free((void *) str); }
MARC_REC *FormatMARCrec(MARC_REC *rec, DISP_FORMAT *format, int displaynum, int maxlen, void (*output)()) { MARC_FIELD *fld; int print_leader = FALSE; /* special function flags */ int print_directory = FALSE; int print_authority = FALSE; int repeat = FALSE; int list_format = FALSE; int line_length; int field_num = 1; char *line, *format_field(), *tcl_escape(); DISP_FORMAT *f; line_length = maxlen; if (format == tcllistformat) { list_format = 1; line_length = 10000; /* prevent wrapping */ } if (list_format == 1) { /* do some special initialization */ sprintf(linebuffer,"{%d {0 000 {", displaynum); strncat(linebuffer, (char *)rec->leader, sizeof(MARC_LEADER_OVER)); strcat(linebuffer,"}}"); outputline (output, linebuffer, line_length, 0 /* no indenting */,0); } if (format == htmlformat || format == shorthtmlformat || format == reviewhtmlformat) { list_format = 2; line_length = 10000; /* prevent wrapping */ } if (format == dcformat || format == shortdcformat) { list_format = 3; /* duplicate tags */ line_length = 10000; /* prevent wrapping */ } for (f = format; f->newfield >=0 ; f++) { /* get the first field in the format */ fld = GetField(rec, NULL, fieldbuffer, f->tags); /* if no field found, check for number format */ if (fld == NULL && *f->tags == '#') { /* a pound sign means output the supplied */ /* record number -- unless it is negative */ if (displaynum >= 0) { sprintf(linebuffer,"%s%s%d%s", f->label, f->beginpunct,displaynum, f->endpunct); /* assume it won't be longer than maxlen*/ outputline (output, linebuffer, line_length, f->indent,0); } } /* if no field found, check for number format */ if (fld == NULL && *f->tags == '+') { /* a plus sign means output the supplied */ /* label only */ if (displaynum >= 0) { sprintf(linebuffer,"%s", f->label); /* assume it won't be longer than maxlen*/ outputline (output, linebuffer, line_length, f->indent,0); } } repeat = FALSE; while (fld) { if (f->print_all) { codeconvert(fieldbuffer); if (*f->label == '\0') { sprintf(linebuffer,"%s %s%s%s", fld->tag, f->beginpunct,fieldbuffer, f->endpunct); } else { sprintf(linebuffer,"%s %s%s%s", f->label, f->beginpunct,fieldbuffer, f->endpunct); } outputline (output, linebuffer, line_length, f->indent,0); } else {/* more selective printing */ line = format_field(fld,f,linebuffer,repeat,list_format, field_num, fieldbuffer); if (line) { if (list_format == 2) { line = tcl_escape(line); outputline (output, line, line_length, f->indent,0); } else outputline (output, line, line_length, f->indent,0); } } /* more of the same tag set? */ fld = GetField(NULL,fld->next,fieldbuffer,f->tags); if (fld) repeat = TRUE; field_num++; } } if (list_format == 1) { /* do ending brace to terminate the list */ sprintf(linebuffer,"}"); outputline (output, linebuffer, line_length, 0 /* no indenting */,0); } return(rec); }