static void write_chunk (stream_t output, chunk label_c) { char label_s[label_c.len * 2 + 6]; chunk2string (label_c, sizeof label_s, label_s); DSwriteLN (output, label_s); }
static void output_types(FILE *tbl_file) { int type_count = lts_type_get_type_count(ltstype); for (int i = 0; i < type_count; i++) { Warning(info, "dumping type %s", lts_type_get_type(ltstype, i)); fprintf(tbl_file, "begin sort "); fprint_ltsmin_ident(tbl_file, lts_type_get_type(ltstype, i)); fprintf(tbl_file, "\n"); int values = pins_chunk_count (model,i); for (int j = 0; j < values; j++) { chunk c = pins_chunk_get (model, i, j); size_t len = c.len * 2 + 6; char str[len]; chunk2string(c, len, str); fprintf(tbl_file, "%s\n", str); } fprintf(tbl_file,"end sort\n"); } }
static void aut_write_edge(lts_file_t file,int src_seg,void* src_state, int dst_seg,void*dst_state,void* labels){ (void)src_seg;(void)dst_seg; uint32_t src=*((uint32_t*)src_state); uint32_t dst=*((uint32_t*)dst_state); uint32_t lbl=*((uint32_t*)labels); if (src>=file->states) file->states=src+1; if (dst>=file->states) file->states=dst+1; file->trans++; value_table_t table=lts_file_get_table(file,file->type_no); if (table==NULL) { fprintf(file->f,"(%llu,%llu,%llu)\n", (long long unsigned int)src, (long long unsigned int)lbl, (long long unsigned int)dst); } else { chunk label_c=VTgetChunk(table,lbl); char label_s[label_c.len*2+6]; chunk2string(label_c,sizeof label_s,label_s); fprintf(file->f,"(%llu,%s,%llu)\n", (long long unsigned int)src, label_s, (long long unsigned int)dst); } }
void CAESAR_PRINT_STATE(CAESAR_TYPE_FILE f,CAESAR_TYPE_STATE s) { int i; chunk c; int labels[state_labels]; if (state_format==0) { fprintf(f, "state ["); for(i=0; i < N; i++) { if (i>0) fprintf(f, ","); fprintf(f, "%d", s->state[i]); } fprintf(f, "]\n"); } else if (state_format==1) { GBgetStateLabelsAll(model,s->state,labels); fprintf(f, "state <"); for(i=0; i < state_labels; i++) { if (i>0) fprintf(f, ";"); c=GBchunkGet(model,lts_type_get_state_label_typeno(ltstype,i),labels[i]); char str[c.len*2+6]; chunk2string(c,sizeof str,str); fprintf(f, "%s", str); } fprintf(f, ">"); } }
void CAESAR_DELTA_STATE(CAESAR_TYPE_FILE f,CAESAR_TYPE_STATE s1,CAESAR_TYPE_STATE s2) { int i; chunk c; int labels1[state_labels]; int labels2[state_labels]; if (state_format==0) { fprintf(f, "state ["); for(i=0; i < N; i++) { if (i>0) fprintf(f, ","); if (s1->state[i] == s2->state[i]) fprintf(f, "-"); else fprintf(f, "%d:=%d", s1->state[i], s2->state[i]); } fprintf(f, "]\n"); } else if (state_format==1) { GBgetStateLabelsAll(model,s1->state,labels1); GBgetStateLabelsAll(model,s2->state,labels2); fprintf(f, "state <"); for(i=0; i < state_labels; i++) { if (i>0) fprintf(f, ";"); if (s1->state[i] == s2->state[i]) fprintf(f, "-"); else { c=GBchunkGet(model,lts_type_get_state_label_typeno(ltstype,i),labels1[i]); { char str[c.len*2+6]; chunk2string(c,sizeof str,str); fprintf(f, "%s", str); } fprintf(f, ":="); c=GBchunkGet(model,lts_type_get_state_label_typeno(ltstype,i),labels2[i]); { char str[c.len*2+6]; chunk2string(c,sizeof str,str); fprintf(f, "%s", str); } } } fprintf(f, ">"); } }
CAESAR_TYPE_STRING CAESAR_STRING_LABEL(CAESAR_TYPE_LABEL l) { static char *s = NULL; /* start of string */ static char *b = NULL; /*beyond*/ static char *tau = "i"; char *p = NULL; /* current insertion point */ int u, n; /* used, needed */ int i; chunk c; size_t clen; p = s; n = 5; if (b-p < n) { u = p-s; s = RTrealloc(s, u+n);/* TODO: check s!=0 */ p = s+u; b = s + u+n; } if (edge_labels > 0 && l->label[0]<0){ n = 6; if (b-p < n) { u = p-s; s = RTrealloc(s, u+n); /* TODO: check s!=0 */ p = s+u; b = s + u+n; } sprintf(p, "delta"); p+=strlen(p); } else { if (edge_labels > 1 || edge_encode) { sprintf(p, "|"); p += strlen(p); } for(i=0; i < edge_labels; i++) { char *name=lts_type_get_edge_label_name(ltstype,i); c=GBchunkGet(model,lts_type_get_edge_label_typeno(ltstype,i),l->label[i]); if (c.len==3 && strncmp(c.data, LTSMIN_EDGE_VALUE_TAU, c.len)==0) clen=strlen(tau); else clen=c.len*2+6; n = strlen(name)+ 1 + clen+1+1+1; /* for name , '=' , c, ';', '>', '\0' */ if (b-p < n) { u = p-s; s = RTrealloc(s, u+n); /* TODO: check s!=0 */ p = s+u; b = s + u+n; } if (i>0) { sprintf(p, "|"); p += strlen(p); } if (edge_labels > 1 || edge_encode ) { sprintf(p, "%s=",name); p += strlen(p); } if (c.len==3 && strncmp(c.data, LTSMIN_EDGE_VALUE_TAU, c.len)==0) sprintf(p, "%s", tau); else chunk2string(c,b-p,p); p += strlen(p); } } if (edge_labels > 1 || edge_encode ) { sprintf(p, "|"); p += strlen(p); } if (edge_encode){ int ofs=edge_labels; /* for(i=0;i<N;i++){ char*name=lts_type_get_state_name(ltstype,i); c=GBchunkGet(model,lts_type_get_state_typeno(ltstype,i),l->label[ofs+i]); n=strlen(name)+c.len*2+7; if (b-p < n) { u = p-s; s = realloc(s, u+n); // TODO: check s!=0 p = s+u; b = s + u+n; } sprintf(p, "%s=",name); p+=strlen(p); chunk2string(c,b-p,p); p+=strlen(p); sprintf(p, "|"); p +=strlen(p); } */ ofs+=N; for(i=0;i<state_labels;i++){ char*name=lts_type_get_state_label_name(ltstype,i); c=GBchunkGet(model,lts_type_get_state_label_typeno(ltstype,i),l->label[ofs+i]); n=strlen(name)+c.len*2+7; if (b-p < n) { u = p-s; s = RTrealloc(s, u+n); /* TODO: check s!=0 */ p = s+u; b = s + u+n; } sprintf(p, "%s=",name); p+=strlen(p); chunk2string(c,b-p,p); p+=strlen(p); sprintf(p, "|"); p +=strlen(p); } } return s; }