1 /* ###--------------------------------------------------------------### */
2 /* */
3 /* file : mvl_util.c */
4 /* date : Jan 06 1993 */
5 /* author : P. BAZARGAN-SABET */
6 /* update : VUONG H.N. */
7 /* */
8 /* description : This file contains some utility functions : */
9 /* mvl_addtab , mvl_chktab , mvl_fretab , mvl_error , */
10 /* mvl_addent , mvl_addrcd , yy_b_error , mvl_y_error , */
11 /* yy_v_error , yy_b_wrap , mvl_y_wrap , yy_v_wrap , */
12 /* mvl_toolbug, mvl_message, mvl_reverse, mvl_warning, */
13 /* mvl_initab , mvl_deltab, */
14 /* */
15 /* ###--------------------------------------------------------------### */
16 #ident "$Id: mvl_util.c,v 1.2 2009/06/14 13:51:56 ludo Exp $"
17 #include <stdio.h>
18 #include <string.h>
19 #include <stdlib.h>
20 #include <mut.h>
21 #include <mlo.h>
22 #include "mvl_utype.h"
23 #include "mvl_util.h"
24 #include "mvl_utdef.h"
25
26 /* ###--------------------------------------------------------------### */
27 /* function : mvl_deltab */
28 /* ###--------------------------------------------------------------### */
29
mvl_deltab(head,key_str,ctx_str)30 void mvl_deltab (head,key_str,ctx_str)
31
32 struct dct_entry **head;
33 char *key_str;
34 char *ctx_str;
35
36 {
37 long found = 0;
38 long index;
39 struct dct_entry *entry_pnt;
40 struct dct_entry *last_entry = NULL;
41 struct dct_recrd *recrd_pnt;
42 struct dct_recrd *last_recrd = NULL;
43
44 index = (unsigned long)key_str % MVL_HSZDFN;
45 entry_pnt = head [index];
46
47 while (entry_pnt != NULL)
48 {
49 if (entry_pnt->key == key_str)
50 {
51 found = 1;
52 break;
53 }
54 last_entry = entry_pnt;
55 entry_pnt = entry_pnt->next;
56 }
57
58 if (found == 1)
59 {
60 found = 0;
61 recrd_pnt = entry_pnt->data;
62 while (recrd_pnt != NULL)
63 {
64 if (recrd_pnt->key == ctx_str)
65 {
66 found = 1;
67 break;
68 }
69 last_recrd = recrd_pnt;
70 recrd_pnt = recrd_pnt->next;
71 }
72
73 if (found == 1)
74 {
75 if (last_recrd == NULL)
76 entry_pnt->data = recrd_pnt->next;
77 else
78 last_recrd->next = recrd_pnt->next;
79
80 recrd_pnt->next = MVL_DCRHED;
81 MVL_DCRHED = recrd_pnt;
82
83 if (entry_pnt->data == NULL)
84 {
85 if (last_entry == NULL)
86 head[index] = entry_pnt->next;
87 else
88 last_entry->next = entry_pnt->next;
89
90 entry_pnt->next = MVL_DCEHED;
91 MVL_DCEHED = entry_pnt;
92 }
93 }
94 }
95 }
96
97 /* ###--------------------------------------------------------------### */
98 /* function : mvl_initab */
99 /* ###--------------------------------------------------------------### */
mvl_initab()100 struct dct_entry **mvl_initab ()
101
102 {
103 struct dct_entry **head;
104 long i;
105
106 head = (struct dct_entry **)
107 mbkalloc (sizeof(struct dct_entry *) * MVL_HSZDFN);
108
109 for (i=0 ; i<MVL_HSZDFN ; i++)
110 head[i] = NULL;
111
112 return (head);
113 }
114
115 /* ###--------------------------------------------------------------### */
116 /* function : mvl_warning */
117 /* content : print out warning messages on the standard error output */
118 /* ###--------------------------------------------------------------### */
mvl_warning(code,str1)119 void mvl_warning (code,str1)
120 long code;
121 char *str1;
122 {
123 static char first_time = 0;
124
125 switch(code)
126 {
127 case 2:
128 if (first_time != 1)
129 {
130 (void)fprintf (stderr,"Warning %ld : ",code);
131 (void)fprintf(stderr,"consistency checks will be disabled\n");
132 first_time = 1;
133 }
134 break;
135
136 case 42:
137 (void) fprintf (stderr,"Warning : connection missing on port `%s`\n",
138 str1);
139 break;
140
141 default:
142 {
143 (void)fprintf(stderr,"Warning %ld : ",code);
144 (void)fprintf(stderr,"unknown Warning code\n");
145 }
146 }
147 }
148
149 /* ###--------------------------------------------------------------### */
150 /* function : mvl_toolbug */
151 /* content : print out bugs messages on the standard error output */
152 /* ###--------------------------------------------------------------### */
mvl_toolbug(code,str1,str2,nbr1)153 void mvl_toolbug (code,str1,str2,nbr1)
154
155 long code;
156 char *str1;
157 char *str2;
158 long nbr1;
159
160 {
161 (void) fprintf (stderr,"Fatal error %ld executing `%s`: ", code,str1);
162 switch (code)
163 {
164 case 10:
165 (void) fprintf (stderr,"decompiler called on empty lofig\n");
166 break;
167 }
168 exit (1);
169 }
170
171
172 /* ###--------------------------------------------------------------### */
173 /* function : mvl_message */
174 /* content : print out messages on the standard error output */
175 /* ###--------------------------------------------------------------### */
mvl_message(code,str1,nmb1)176 void mvl_message (code,str1,nmb1)
177
178 long code;
179 char *str1;
180 long nmb1;
181
182 {
183 switch (code)
184 {
185 default:
186 (void) fprintf (stderr,"mvl_message : code %ld unknown.\n",code);
187 }
188 }
189
190 /* ###--------------------------------------------------------------### */
191 /* function : mvl_addtab */
192 /* ###--------------------------------------------------------------### */
mvl_addtab(head,key_str,ctx_str,field,valu)193 void mvl_addtab (head,key_str,ctx_str,field,valu)
194
195 struct dct_entry **head;
196 char *key_str;
197 char *ctx_str;
198 long field;
199 long valu;
200
201 {
202 long found = 0;
203 long index;
204 struct dct_entry *entry_pnt;
205 struct dct_recrd *recrd_pnt;
206
207 index = (unsigned long) key_str % MVL_HSZDFN;
208 entry_pnt = head[index];
209
210 while (entry_pnt != NULL)
211 {
212 if (entry_pnt->key == key_str)
213 {
214 found = 1;
215 break;
216 }
217 entry_pnt = entry_pnt->next;
218 }
219
220 if (found == 0)
221 {
222 head[index] = mvl_addent (head[index],key_str);
223 entry_pnt = head[index];
224 }
225
226 found = 0;
227 recrd_pnt = entry_pnt->data;
228 while (recrd_pnt != NULL)
229 {
230 if (recrd_pnt->key == ctx_str)
231 {
232 found = 1;
233 break;
234 }
235 recrd_pnt = recrd_pnt->next;
236 }
237
238 if (found == 0)
239 {
240 entry_pnt->data = mvl_addrcd (entry_pnt->data,ctx_str);
241 recrd_pnt = entry_pnt->data ;
242 }
243
244 switch (field)
245 {
246 case 0 :
247 recrd_pnt->fd0_val = valu;
248 break;
249 case 1 :
250 recrd_pnt->fd1_val = valu;
251 break;
252 case 2 :
253 recrd_pnt->fd2_val = valu;
254 break;
255 case 3 :
256 recrd_pnt->fd3_val = valu;
257 break;
258 case 4 :
259 recrd_pnt->fd4_val = valu;
260 break;
261 case 5 :
262 recrd_pnt->fd5_val = valu;
263 break;
264 case 6 :
265 recrd_pnt->fd6_val = valu;
266 break;
267 case 7 :
268 recrd_pnt->pnt_val = valu;
269 break;
270 }
271
272 }
273
274 /* ###--------------------------------------------------------------### */
275 /* function : mvl_chktab */
276 /* ###--------------------------------------------------------------### */
mvl_chktab(head,key_str,ctx_str,field)277 long mvl_chktab (head,key_str,ctx_str,field)
278
279 struct dct_entry **head;
280 char *key_str;
281 char *ctx_str;
282 long field;
283
284 {
285 long found = 0;
286 long valu = 0;
287 struct dct_entry *entry_pnt;
288 struct dct_recrd *recrd_pnt;
289
290 entry_pnt = head [(unsigned long)key_str % MVL_HSZDFN];
291
292 while (entry_pnt != NULL)
293 {
294 if (entry_pnt->key == key_str)
295 {
296 found = 1;
297 break;
298 }
299 entry_pnt = entry_pnt->next;
300 }
301
302 if (found == 1)
303 {
304 found = 0;
305 recrd_pnt = entry_pnt->data;
306 while (recrd_pnt != NULL)
307 {
308 if (recrd_pnt->key == ctx_str)
309 {
310 found = 1;
311 break;
312 }
313 recrd_pnt = recrd_pnt->next;
314 }
315 if (found == 1)
316 {
317 switch (field)
318 {
319 case 0 :
320 valu = recrd_pnt->fd0_val;
321 break;
322 case 1 :
323 valu = recrd_pnt->fd1_val;
324 break;
325 case 2 :
326 valu = recrd_pnt->fd2_val;
327 break;
328 case 3 :
329 valu = recrd_pnt->fd3_val;
330 break;
331 case 4 :
332 valu = recrd_pnt->fd4_val;
333 break;
334 case 5 :
335 valu = recrd_pnt->fd5_val;
336 break;
337 case 6 :
338 valu = recrd_pnt->fd6_val;
339 break;
340 case 7 :
341 valu = recrd_pnt->pnt_val;
342 break;
343 }
344 }
345 }
346
347 return (valu);
348 }
349
350 /* ###--------------------------------------------------------------### */
351 /* function : mvl_fretab */
352 /* ###--------------------------------------------------------------### */
mvl_fretab(pt_hash)353 void mvl_fretab (pt_hash)
354
355 struct dct_entry **pt_hash;
356 {
357 struct dct_entry *pt_entry;
358 struct dct_entry *pt_nxtentry;
359 struct dct_recrd *pt_record;
360 long i;
361
362 if (pt_hash != NULL)
363 {
364 for (i=0 ; i<MVL_HSZDFN ; i++)
365 {
366 if ((pt_entry = pt_hash[i]) != NULL)
367 {
368 while (pt_entry != NULL)
369 {
370 pt_record = pt_entry->data;
371
372 while (pt_record->next != NULL)
373 pt_record = pt_record->next;
374
375 pt_record->next = MVL_DCRHED;
376 MVL_DCRHED = pt_entry->data;
377
378 pt_nxtentry = pt_entry->next;
379 pt_entry->next = MVL_DCEHED;
380 MVL_DCEHED = pt_entry;
381 pt_entry = pt_nxtentry;
382 }
383 }
384 }
385 free (pt_hash);
386 }
387 }
388
389 /* ###--------------------------------------------------------------### */
390 /* function : mvl_error */
391 /* ###--------------------------------------------------------------### */
mvl_error(code,str1)392 void mvl_error (code,str1)
393
394 long code;
395 char *str1;
396
397 {
398 MVL_ERRFLG++;
399 if (code < 100)
400 (void)fprintf (stderr,"`%s` Error %ld line %d :",MVL_CURFIL,code,MVL_LINNUM);
401 else
402 {
403 if (code < 200)
404 (void)fprintf (stderr,"Error %ld :",code);
405 }
406
407 switch (code)
408 {
409 case 1:
410 (void) fprintf (stderr,"`%s` is incompatible with the entity name\n",str1);
411 break;
412 case 2:
413 (void) fprintf (stderr,"bad entity declaration\n");
414 break;
415 case 3:
416 (void) fprintf (stderr,"bad port clause declaration\n");
417 break;
418 case 4:
419 (void) fprintf (stderr,"port `%s` already declared\n",str1);
420 break;
421 case 5:
422 (void) fprintf (stderr,"illegal port declaration `%s` (mode, type, guard mark)\n",str1);
423 break;
424 case 6:
425 (void) fprintf (stderr,"bad port declaration\n");
426 break;
427 case 7:
428 (void) fprintf (stderr,"`%s` is incompatible with the architecture name\n",str1);
429 break;
430 case 8:
431 (void) fprintf (stderr,"bad architecture declaration\n");
432 break;
433 case 9:
434 (void) fprintf (stderr,"illegal declaration\n");
435 break;
436 case 10:
437 (void) fprintf (stderr,"signal `%s` already declared\n",str1);
438 break;
439 case 11:
440 (void) fprintf (stderr,"illegal signal declaration `%s` (type, guard mark)\n",str1);
441 break;
442 case 12:
443 (void) fprintf (stderr,"component `%s` already declared\n",str1);
444 break;
445 case 13:
446 (void) fprintf (stderr,"instance `%s` already declared\n",str1);
447 break;
448 case 14:
449 (void) fprintf (stderr,"`%s` unknown component\n",str1);
450 break;
451 case 15:
452 (void) fprintf (stderr,"illegal usage of implicit port map description\n");
453 break;
454 case 16:
455 (void) fprintf (stderr,"`%s` unknown local port\n",str1);
456 break;
457 case 17:
458 (void) fprintf (stderr,"`%s` unknown port or signal\n",str1);
459 break;
460 case 18:
461 (void) fprintf (stderr,"illegal concurrent statement\n");
462 break;
463 case 31:
464 (void) fprintf (stderr,"bad signal association\n");
465 break;
466 case 32:
467 (void) fprintf (stderr,"null array not supported\n");
468 break;
469 case 33:
470 (void) fprintf (stderr,"illegal constraint in declaration of type\n");
471 break;
472 case 36:
473 (void) fprintf (stderr,"signal `%s` used out of declared range\n",str1);
474 break;
475 case 38:
476 (void) fprintf (stderr,"width or/and type mismatch\n");
477 break;
478 case 41:
479 (void) fprintf (stderr,"port `%s` connected to more than one signal\n",str1);
480 break;
481 case 76:
482 (void) fprintf (stderr,"instance %s mismatch with the model\n",str1);
483 break;
484 case 107:
485 (void) fprintf (stderr,"Cannot open result file\n");
486 break;
487 case 200:
488 (void) fprintf (stderr,"\n cannot continue further more.\n");
489 (void) fprintf (stderr,"\n Have a nice day...\n");
490 break;
491
492 default:
493 (void) fprintf (stderr,"syntax error\n");
494 break;
495 }
496
497 if (MVL_ERRFLG > MVL_MXRDFN)
498 {
499 (void) fprintf (stderr,"Too many errors. Cannot continue further more\n");
500 (void) fprintf (stderr,"\n Have a nice day...\n");
501 exit (1);
502 }
503
504 }
505
506 /* ###--------------------------------------------------------------### */
507 /* function : mvl_addent */
508 /* ###--------------------------------------------------------------### */
mvl_addent(head,key)509 static struct dct_entry *mvl_addent (head , key)
510
511 struct dct_entry *head;
512 char *key;
513
514 {
515 struct dct_entry *entry;
516 long i;
517
518 if (MVL_DCEHED == NULL)
519 {
520 MVL_DCEHED = (struct dct_entry *)
521 mbkalloc (sizeof(struct dct_entry) * MVL_ALODFN);
522
523 entry = MVL_DCEHED;
524 for (i=1 ; i<MVL_ALODFN ; i++)
525 {
526 entry->next = entry + 1;
527 entry++;
528 }
529 entry->next = NULL;
530 }
531
532 entry = MVL_DCEHED;
533 MVL_DCEHED = MVL_DCEHED->next;
534
535 entry->next = head;
536 entry->data = NULL;
537 entry->key = key;
538
539 return (entry);
540 }
541
542 /* ###--------------------------------------------------------------### */
543 /* function : mvl_addrcd */
544 /* ###--------------------------------------------------------------### */
mvl_addrcd(head,key)545 static struct dct_recrd *mvl_addrcd (head , key)
546
547 struct dct_recrd *head;
548 char *key;
549
550 {
551 struct dct_recrd *recrd;
552 long i;
553
554 if (MVL_DCRHED == NULL)
555 {
556 MVL_DCRHED = (struct dct_recrd *)
557 mbkalloc (sizeof(struct dct_recrd) * MVL_ALODFN);
558
559 recrd = MVL_DCRHED;
560 for (i=1 ; i<MVL_ALODFN ; i++)
561 {
562 recrd->next = recrd + 1;
563 recrd++;
564 }
565 recrd->next = NULL;
566 }
567
568 recrd = MVL_DCRHED;
569 MVL_DCRHED = MVL_DCRHED->next;
570
571 recrd->next = head;
572 recrd->fd0_val = 0;
573 recrd->fd1_val = 0;
574 recrd->fd2_val = 0;
575 recrd->fd3_val = 0;
576 recrd->fd4_val = 0;
577 recrd->fd5_val = 0;
578 recrd->fd6_val = 0;
579 recrd->pnt_val = 0;
580 recrd->key = key;
581
582 return (recrd);
583 }
584
585 /* ###--------------------------------------------------------------### */
586 /* function : mvl__y_error */
587 /* ###--------------------------------------------------------------### */
mvl_y_error(str)588 void mvl_y_error (str)
589
590 char *str;
591 {
592 MVL_ERRFLG++;
593 (void)fprintf (stderr,"`%s` Error line %d : %s\n",MVL_CURFIL,MVL_LINNUM,str);
594 }
595
596 /* ###--------------------------------------------------------------### */
597 /* function : mvl_y_wrap */
598 /* ###--------------------------------------------------------------### */
mvl_y_wrap()599 int mvl_y_wrap ()
600 {
601 return (1);
602 }
603
604 /* ###--------------------------------------------------------------### */
605 /* function : mvl_avers */
606 /* ###--------------------------------------------------------------### */
mvl_avers()607 char *mvl_avers ()
608 {
609 return ("-- V 1.3 --");
610 }
611
612 /* ###--------------------------------------------------------------### */
613 /* function : mvl_vhdlname */
614 /* ###--------------------------------------------------------------### */
mvl_vhdlname(name)615 char *mvl_vhdlname (name)
616
617 char *name;
618
619 {
620 char *new_name;
621 char *prv_name;
622 char *tmp_name;
623 char buffer[200];
624 long i,j,flag,number;
625 static struct dct_entry **namtab=NULL;
626
627 if (namtab == NULL)
628 namtab = mvl_initab ();
629
630 tmp_name = namealloc (name);
631 new_name = (char *) mvl_chktab (namtab,tmp_name,NULL,MVL_PNTDFN);
632
633 if (mvl_chktab (namtab,tmp_name,NULL,MVL_NAMDFN) == 0)
634 {
635 i = 0;
636 j = 0;
637 number = 0;
638 flag = 1;
639 while (tmp_name[i] != '\0')
640 {
641 buffer[j] = tmp_name[i];
642 if ( ((tmp_name[i] >= 'a') && (tmp_name[i] <= 'z')) ||
643 ((tmp_name[i] >= 'A') && (tmp_name[i] <= 'Z')) ||
644 ((tmp_name[i] >= '0') && (tmp_name[i] <= '9') && (i != 0)) ||
645 ((tmp_name[i] == '(') || (tmp_name[i] == ')')) )
646 flag = 0;
647 else
648 {
649 if (flag == 1)
650 buffer[j++] = 'v';
651 buffer[j] = '_';
652 flag = 1;
653 }
654 i++;
655 j++;
656 }
657 if (buffer[j-1] == '_')
658 buffer[j++] = '0';
659 buffer[j] = '\0';
660 new_name = namealloc (buffer);
661
662 prv_name = new_name;
663 while (mvl_chktab (namtab,new_name,NULL,MVL_NEWDFN) != 0)
664 {
665 new_name = prv_name;
666 sprintf (buffer,"%s_%ld",new_name,number++);
667 prv_name = new_name;
668 new_name = namealloc (buffer);
669 }
670 mvl_addtab (namtab,new_name,NULL,MVL_NEWDFN,1);
671 mvl_addtab (namtab,tmp_name,NULL,MVL_PNTDFN,(long)new_name);
672 mvl_addtab (namtab,tmp_name,NULL,MVL_NAMDFN,1);
673 }
674
675 return (new_name);
676 }
677
678
679 /* ###--------------------------------------------------------------### */
680 /* function : mvl_name */
681 /* ###--------------------------------------------------------------### */
mvl_name(name,new_name)682 void mvl_name (name,new_name)
683
684 char *name;
685 char *new_name;
686
687 {
688 char *blank_space;
689
690 /* Transformation des blancs en parentheses */
691 strcpy(new_name,name);
692 blank_space = strchr(new_name,' ');
693 if(blank_space != NULL)
694 {
695 *blank_space = '(';
696 blank_space = strchr(new_name,'\0');
697 /* Transformation du dernier caractere en ) */
698 if(blank_space != NULL)
699 {
700 *blank_space = ')';
701 blank_space++;
702 *blank_space = '\0';
703 }
704 }
705 strcpy(new_name,mvl_vhdlname(new_name));
706 }
707
708 /* ###--------------------------------------------------------------### */
709 /* function : mvl_vectnam */
710 /* ###--------------------------------------------------------------### */
mvl_vectnam(pt_list,left,right,name,type)711 void *mvl_vectnam(pt_list,left,right,name,type)
712
713 void *pt_list;
714 long *left, *right;
715 char **name;
716 char type;
717
718 {
719 char *blank_space;
720 char *sig_name;
721 char name_tmp[200];
722 char number[200];
723 losig_list *ptsig;
724 locon_list *ptcon;
725 char END = 0;
726
727 /* Case losig_list */
728 if(type==0)
729 {
730 ptsig = (losig_list *)pt_list;
731 if (ptsig->TYPE == 'I')
732 {
733 *left = *right = -1;
734 sig_name = getsigname(ptsig);
735 *name = (char*)mbkalloc(strlen(sig_name) + 1);
736 strcpy(*name,sig_name);
737 blank_space = strchr(*name,' ');
738 if (blank_space != NULL)
739 {
740 strcpy(number,blank_space);
741 *right = atoi(number);
742 *left = *right;
743 *blank_space = '\0';
744 }
745
746 while(!END)
747 {
748 if(ptsig->NEXT != NULL)
749 {
750 strcpy(name_tmp,getsigname(ptsig->NEXT));
751 blank_space = strchr(name_tmp,' ');
752 if(blank_space!=NULL)
753 {
754 strcpy(number,blank_space);
755 *blank_space = '\0';
756 if(!strcmp(*name,name_tmp))
757 {
758 *left = atoi(number);
759 ptsig = ptsig->NEXT;
760 }
761 else
762 END = 1;
763 }
764 else
765 END = 1;
766 }
767 else
768 END = 1;
769 }
770 return(ptsig);
771 }
772 else
773 {
774 *name = NULL;
775 return(ptsig);
776 }
777 }
778
779 /*case locon_list */
780 if(type==1)
781 {
782 ptcon = (locon_list *)pt_list;
783 /* Extract the name and number of an element */
784 *left = *right = -1;
785 sig_name = ptcon->NAME;
786 *name = (char *)mbkalloc(strlen(sig_name) + 1);
787 strcpy(*name,sig_name);
788 blank_space = strchr(*name,' ');
789 if (blank_space != NULL)
790 {
791 strcpy(number,blank_space);
792 *right = atoi(number);
793 *left = *right;
794 *blank_space = '\0';
795 }
796
797 while(END != 1)
798 {
799 if(ptcon->NEXT != NULL)
800 {
801 strcpy(name_tmp,ptcon->NEXT->NAME);
802 blank_space = strchr(name_tmp,' ');
803 if(blank_space!=NULL)
804 {
805 strcpy(number,blank_space);
806 *blank_space = '\0';
807 if(!strcmp(*name,name_tmp))
808 {
809 *right = atoi(number);
810 ptcon = ptcon->NEXT;
811 }
812 else
813 END = 1;
814 }
815 else
816 END = 1;
817 }
818 else
819 END = 1;
820 }
821 return(ptcon);
822 }
823 /* To avoid Warning from GCC */
824 return(NULL);
825 }
826
827
828 /* ###--------------------------------------------------------------### */
829 /* function : mvl_reverse */
830 /* ###--------------------------------------------------------------### */
mvl_reverse(head)831 struct chain *mvl_reverse (head)
832
833 struct chain *head;
834
835 {
836 struct chain *last_pnt = NULL;
837 struct chain *curr_pnt = NULL;
838 struct chain *next_pnt = NULL;
839
840 if (head != NULL)
841 {
842 last_pnt = head;
843 curr_pnt = head->NEXT;
844 last_pnt->NEXT = NULL;
845
846 if (curr_pnt != NULL)
847 {
848 next_pnt = curr_pnt->NEXT;
849
850 while (next_pnt != NULL)
851 {
852 curr_pnt->NEXT = last_pnt;
853
854 /* ###------------------------------------------------------### */
855 /* Now shift the window to the next structure */
856 /* ###------------------------------------------------------### */
857
858 last_pnt = curr_pnt;
859 curr_pnt = next_pnt;
860 next_pnt = next_pnt->NEXT;
861 }
862
863 curr_pnt->NEXT = last_pnt;
864 }
865 else
866 curr_pnt = head;
867 }
868
869 return (curr_pnt);
870 }
871
872 /* ###--------------------------------------------------------------### */
873 /* function : mvl_fill */
874 /* content : Fill a lofig of mode 'P' with another lofig of mode 'A' */
875 /* ###--------------------------------------------------------------### */
mvl_fill(lofig_P,lofig_A)876 struct lofig *mvl_fill (lofig_P, lofig_A)
877
878 struct lofig *lofig_P;
879 struct lofig *lofig_A;
880
881 {
882 struct locon *ptlocon_P, *ptlocon_A;
883 struct chain *ptchain;
884 struct lofig *ptlofig;
885 struct losig *ptlosig;
886
887 /* MODELCHAIN */
888 ptchain = lofig_P->MODELCHAIN;
889 lofig_P->MODELCHAIN = lofig_A->MODELCHAIN;
890
891 /* LOCON */
892 ptlocon_P = lofig_P->LOCON;
893 ptlocon_A = lofig_A->LOCON;
894
895 while(ptlocon_A != NULL)
896 {
897 if(ptlocon_A->NAME == ptlocon_P->NAME)
898 {
899 ptlocon_P->SIG = ptlocon_A->SIG;
900 }
901 else
902 {
903 (void)fprintf(stderr,"\n*** mbk error *** bad consistency in figure %s,\n external interface are different\n", lofig_P->NAME);
904 }
905 ptlocon_A = ptlocon_A->NEXT;
906 ptlocon_P = ptlocon_P->NEXT;
907 }
908
909 /* LOSIG */
910 ptlosig = lofig_P->LOSIG;
911 lofig_P->LOSIG = lofig_A->LOSIG;
912
913 /* LOINS */
914 lofig_P->LOINS = lofig_A->LOINS;
915
916 /* LOTRS */
917 lofig_P->LOTRS = lofig_A->LOTRS;
918
919 /* USER */
920 lofig_P->USER = lofig_A->USER;
921
922 /* MODE */
923 lofig_P->MODE = 'A';
924
925 /* Freeing the memory zone unusable */
926
927 freechain(ptchain);
928
929 while (lofig_A->LOCON != NULL)
930 {
931 (void)dellocon(lofig_A, lofig_A->LOCON->NAME);
932 }
933
934 ptlofig = addlofig(" bidon");
935 ptlofig->LOSIG = ptlosig;
936 (void)dellofig(ptlofig->NAME);
937
938
939
940 return(lofig_P);
941 }
942