/** * @short One block read from in, prepare the output. * * Depending on the mode of the block it calls the appropiate handler: variable, tag or just write text. */ void write_block(parser_status *st, onion_block *b){ int mode=st->last_wmode; //ONION_DEBUG("Write mode %d, code %s", mode, b->data); switch(mode){ case TEXT: { int oldl; if ( (oldl=onion_block_size(b)) ){ char *safe=onion_c_quote_new(onion_block_data(b)); function_add_code(st, " onion_response_write(res, %s, %d);\n", safe, oldl); free(safe); } } break; case VARIABLE: variable_write(st, b); break; case TAG: tag_write(st, b); break; default: ONION_ERROR("Unknown final mode %d", mode); } onion_block_clear(st->rawblock); }
void taglist_write(TagList_t *tlist) { GList *p; for (p = tlist->list; p; p = p->next) tag_write((Tag_t*) p->data); }
/** * @short One block read from in, prepare the output. * * Depending on the mode of the block it calls the appropiate handler: variable, tag or just write text. */ void write_block(parser_status *st, onion_block *b){ int mode=st->last_wmode; //ONION_DEBUG("Write mode %d, code %s", mode, b->data); switch(mode){ case TEXT: { int oldl; if ( (oldl=onion_block_size(b)) ){ if (oldl>0){ // Not Just \0 int use_orig_line_numbers_bak=use_orig_line_numbers; use_orig_line_numbers=0; char *safe=onion_c_quote_new(onion_block_data(b)); function_add_code(st, " onion_response_write(res, "); int pos=0; int size=strlen(safe); char *s=safe; //ONION_DEBUG("------- pos %d, size %d",pos,size); while (pos<size){ //ONION_DEBUG("pos %d, size %d",pos,size); char *e=strstr(s, "\n"); if (!e) break; *e='\0'; if (pos==0) function_add_code(st, "%s\n", s); else function_add_code(st, " %s\n", s); pos+=(e-s)+1; s=e+1; } if (pos==0) function_add_code(st, "%s, %d);\n", s, oldl); else function_add_code(st, " %s, %d);\n", s, oldl); use_orig_line_numbers=use_orig_line_numbers_bak; free(safe); } } } break; case VARIABLE: variable_write(st, b); break; case TAG: tag_write(st, b); break; default: ONION_ERROR("Unknown final mode %d", mode); } onion_block_clear(st->rawblock); }
/* * Remove the annotation pointed to by 'last'.next * last_type is 0 for contig, 1 for reading or 2 for annotation. * Returns the new next annotation for 'last'. */ int delete_tag(GapIO *io, int last, int curr, int last_type) { GAnnotations a; tag_read(io, curr, a); delete_tag_rec(io, curr); switch(last_type) { case 0: {/* contig */ GContigs c; contig_read(io, last, c); c.annotations = a.next; contig_write(io, last, c); break; } case 1: {/* reading */ GReadings r; gel_read(io, last, r); r.annotations = a.next; gel_write(io, last, r); break; } case 2: {/* cannotation */ GAnnotations t; tag_read(io, last, t); t.next = a.next; tag_write(io, last, t); break; } } return a.next; }