1 /* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */
2 /* From input file "cht-1.7.pp" */
3
4
5 #ifdef HAVE_CONFIG_H
6 #include <config.h>
7 #endif
8
9 #ifndef P2C_H
10 #define P2C_H
11
12
13 /* Header file for code generated by "p2c", the Pascal-to-C translator */
14
15 /* "p2c" Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation.
16 * By Dave Gillespie, daveg@synaptics.com. Version 1.21alpha-07.Dec.93.
17 * This file may be copied, modified, etc. in any way. It is not restricted
18 * by the licence agreement accompanying p2c itself.
19 */
20
21
22 #include <stdio.h>
23 #include <unistd.h>
24 #define DOUBLE double
25
26
27
28 /* If the following heuristic fails, compile -DBSD=0 for non-BSD systems,
29 or -DBSD=1 for BSD systems. */
30
31 #ifdef M_XENIX
32 # define BSD 0
33 #endif
34
35 #ifdef vms
36 # define BSD 0
37 # ifndef __STDC__
38 # define __STDC__ 1
39 # endif
40 #endif
41
42 #ifdef __TURBOC__
43 # define MSDOS 1
44 #endif
45
46 #ifdef MSDOS
47 # define BSD 0
48 #endif
49
50 #ifdef FILE /* a #define in BSD, a typedef in SYSV (hp-ux, at least) */
51 # ifndef BSD /* (a convenient, but horrible kludge!) */
52 # define BSD 1
53 # endif
54 #endif
55
56 #ifdef BSD
57 # if !BSD
58 # undef BSD
59 # endif
60 #endif
61
62
63 #if (defined(__STDC__) && !defined(M_XENIX)) || defined(__TURBOC__)
64 # include <stdlib.h>
65 # include <stddef.h>
66 # define HAS_STDLIB
67 # if defined(vms) || defined(__TURBOC__)
68 # define NON_ANSI_CAT
69 # endif
70 #else
71 # ifndef BSD
72 # ifndef __TURBOC__
73 # include <memory.h>
74 # endif
75 # endif
76 # ifdef hpux
77 # ifdef _INCLUDE__STDC__
78 # include <stddef.h>
79 # include <stdlib.h>
80 # define HAS_STDLIB
81 # endif
82 # endif
83 # include <sys/types.h>
84 # if !defined(MSDOS) || defined(__TURBOC__)
85 # define NON_ANSI_CAT
86 # endif
87 #endif
88
89 #if defined(NON_ANSI_CAT) && !defined(ANSI_CAT)
90 # ifdef NON_ANSI_CAT_ALTERNATE
91 # define __CAT__(a,b)a/**/b
92 # else
93 # define __ID__(a)a
94 # define __CAT__(a,b)__ID__(a)b
95 # endif
96 #else
97 # define __CAT__(a,b)a##b
98 #endif
99
100
101 #ifdef BSD
102 # include <strings.h>
103 # define strchr(s,c) index(s,c)
104 # define strrchr(s,c) rindex(s,c)
105 #else
106 # include <string.h>
107 #endif
108
109 #include <ctype.h>
110 #include <math.h>
111 #include <setjmp.h>
112 #include <assert.h>
113
114
115 #ifndef NO_LACK
116 #ifdef vms
117
118 #define LACK_LABS
119 #define LACK_MEMMOVE
120 #define LACK_MEMCPY
121
122 #else
123
124 #define LACK_LABS /* Undefine these if your library has these */
125 #define LACK_MEMMOVE
126
127 #endif
128 #endif
129
130
131 typedef struct __p2c_jmp_buf {
132 struct __p2c_jmp_buf *next;
133 jmp_buf jbuf;
134 } __p2c_jmp_buf;
135
136
137 /* Warning: The following will not work if setjmp is used simultaneously.
138 This also violates the ANSI restriction about using vars after longjmp,
139 but a typical implementation of longjmp will get it right anyway. */
140
141 #ifndef FAKE_TRY
142 # define TRY(x) do { __p2c_jmp_buf __try_jb; \
143 __try_jb.next = __top_jb; \
144 if (!setjmp((__top_jb = &__try_jb)->jbuf)) {
145 # define RECOVER(x) __top_jb = __try_jb.next; } else {
146 # define RECOVER2(x,L) __top_jb = __try_jb.next; } else { \
147 if (0) { L: __top_jb = __try_jb.next; }
148 # define ENDTRY(x) } } while (0)
149 #else
150 # define TRY(x) if (1) {
151 # define RECOVER(x) } else do {
152 # define RECOVER2(x,L) } else do { L: ;
153 # define ENDTRY(x) } while (0)
154 #endif
155
156
157
158 #ifdef M_XENIX /* avoid compiler bug */
159 # define SHORT_MAX (32767)
160 # define SHORT_MIN (-32768)
161 #endif
162
163
164 /* The following definitions work only on twos-complement machines */
165 #ifndef SHORT_MAX
166 # define SHORT_MAX ((short)(((unsigned short) -1) >> 1))
167 # define SHORT_MIN (~SHORT_MAX)
168 #endif
169
170 #ifndef INT_MAX
171 # define INT_MAX ((int)(((unsigned int) -1) >> 1))
172 # define INT_MIN (~INT_MAX)
173 #endif
174
175 #ifndef LONG_MAX
176 # define LONG_MAX ((long)(((unsigned long) -1) >> 1))
177 # define LONG_MIN (~LONG_MAX)
178 #endif
179
180 #ifndef SEEK_SET
181 # define SEEK_SET 0
182 # define SEEK_CUR 1
183 # define SEEK_END 2
184 #endif
185
186 #ifndef EXIT_SUCCESS
187 # ifdef vms
188 # define EXIT_SUCCESS 1
189 # define EXIT_FAILURE (02000000000L)
190 # else
191 # define EXIT_SUCCESS 0
192 # define EXIT_FAILURE 1
193 # endif
194 #endif
195
196
197 #define SETBITS 32
198
199
200 #if defined(__STDC__) || defined(__TURBOC__)
201 # if !defined(vms) && !defined(M_LINT)
202 # define Signed signed
203 # else
204 # define Signed
205 # endif
206 # define Void void /* Void f() = procedure */
207 # ifndef Const
208 # define Const const
209 # endif
210 # ifndef Volatile
211 # define Volatile volatile
212 # endif
213 # ifdef M_LINT
214 # define PP(x) ()
215 # define PV() ()
216 typedef char *Anyptr;
217 # else
218 # define PP(x) x /* function prototype */
219 # define PV() (void) /* null function prototype */
220 typedef void *Anyptr;
221 # endif
222 #else
223 # define Signed
224 # define Void void
225 # ifndef Const
226 # define Const
227 # endif
228 # ifndef Volatile
229 # define Volatile
230 # endif
231 # define PP(x) ()
232 # define PV() ()
233 typedef char *Anyptr;
234 #endif
235
236 #ifdef __GNUC__
237 # define Inline inline
238 #else
239 # define Inline
240 #endif
241
242 #define Register register /* Register variables */
243 #define Char char /* Characters (not bytes) */
244
245 #ifndef Static
246 # define Static static /* Private global funcs and vars */
247 #endif
248
249 #ifndef Local
250 # define Local static /* Nested functions */
251 #endif
252
253 typedef Signed char schar;
254 typedef unsigned char uchar;
255 typedef unsigned char boolean;
256
257 #ifndef NO_DECLARE_ALFA
258 typedef Char alfa[10];
259 #endif
260
261 #ifndef true
262 # define true 1
263 # define false 0
264 #endif
265
266 #ifndef TRUE
267 # define TRUE 1
268 # define FALSE 0
269 #endif
270
271
272 typedef struct {
273 Anyptr proc, link;
274 } _PROCEDURE;
275
276 #ifndef _FNSIZE
277 # define _FNSIZE 120
278 #endif
279
280
281 extern Void PASCAL_MAIN PP( (int, Char **) );
282 extern Char **P_argv;
283 extern int P_argc;
284 extern short P_escapecode;
285 extern int P_ioresult;
286 extern __p2c_jmp_buf *__top_jb;
287
288
289 #ifdef P2C_H_PROTO /* if you have Ansi C but non-prototyped header files */
290 extern Char *strcat PP( (Char *, Const Char *) );
291 extern Char *strchr PP( (Const Char *, int) );
292 extern int strcmp PP( (Const Char *, Const Char *) );
293 extern Char *strcpy PP( (Char *, Const Char *) );
294 extern size_t strlen PP( (Const Char *) );
295 extern Char *strncat PP( (Char *, Const Char *, size_t) );
296 extern int strncmp PP( (Const Char *, Const Char *, size_t) );
297 extern Char *strncpy PP( (Char *, Const Char *, size_t) );
298 extern Char *strrchr PP( (Const Char *, int) );
299
300
301 extern int atoi PP( (Const Char *) );
302 extern double atof PP( (Const Char *) );
303 extern long atol PP( (Const Char *) );
304 extern double strtod PP( (Const Char *, Char **) );
305 extern long strtol PP( (Const Char *, Char **, int) );
306 #endif /*P2C_H_PROTO*/
307
308 #ifndef HAS_STDLIB
309 #ifndef NO_DECLARE_MALLOC
310 extern Anyptr malloc PP( (size_t) );
311 extern Void free PP( (Anyptr) );
312 #endif
313 #endif
314
315 extern int _OutMem PV();
316 extern int _CaseCheck PV();
317 extern int _NilCheck PV();
318 extern int _Escape PP( (int) );
319 extern int _EscIO PP( (int) );
320 extern int _EscIO2 PP( (int, Char *) );
321
322 extern long ipow PP( (long, long) );
323 extern long P_imax PP( (long, long) );
324 extern long P_imin PP( (long, long) );
325 extern double P_rmax PP( (double, double) );
326 extern double P_rmin PP( (double, double) );
327 extern Char *strsub PP( (Char *, Char *, int, int) );
328 extern Char *strltrim PP( (Char *) );
329 extern Char *strrtrim PP( (Char *) );
330 extern Char *strrpt PP( (Char *, Char *, int) );
331 extern Char *strpad PP( (Char *, Char *, int, int) );
332 extern int strpos2 PP( (Char *, Char *, int) );
333 extern long memavail PV();
334 extern int P_peek PP( (FILE *) );
335 extern int P_eof PP( (FILE *) );
336 extern int P_eoln PP( (FILE *) );
337 extern Void P_readpaoc PP( (FILE *, Char *, int) );
338 extern Void P_readlnpaoc PP( (FILE *, Char *, int) );
339 extern long P_maxpos PP( (FILE *) );
340 extern Char *P_trimname PP( (Char *, int) );
341 extern long *P_setunion PP( (long *, long *, long *) );
342 extern long *P_setint PP( (long *, long *, long *) );
343 extern long *P_setdiff PP( (long *, long *, long *) );
344 extern long *P_setxor PP( (long *, long *, long *) );
345 extern int P_inset PP( (unsigned, long *) );
346 extern int P_setequal PP( (long *, long *) );
347 extern int P_subset PP( (long *, long *) );
348 extern long *P_addset PP( (long *, unsigned) );
349 extern long *P_addsetr PP( (long *, unsigned, unsigned) );
350 extern long *P_remset PP( (long *, unsigned) );
351 extern long *P_expset PP( (long *, long) );
352 extern long P_packset PP( (long *) );
353 extern FILE *_skipspaces PP( (FILE *) );
354 extern FILE *_skipnlspaces PP( (FILE *) );
355
356
357 /* I/O error handling */
358 #define _CHKIO(cond,ior,val,def) ((cond) ? P_ioresult=0,(val) \
359 : P_ioresult=(ior),(def))
360 #define _SETIO(cond,ior) (P_ioresult = (cond) ? 0 : (ior))
361
362 /* Following defines are suitable for the HP Pascal operating system */
363 #define FileNotFound 10
364 #define FileNotOpen 13
365 #define FileWriteError 38
366 #define BadInputFormat 14
367 #define EndOfFile 30
368
369 #define FILENOTFOUND 10
370 #define FILENOTOPEN 13
371 #define FILEWRITEERROR 38
372 #define BADINPUTFORMAT 14
373 #define ENDOFFILE 30
374
375 /* Creating temporary files */
376 #if (defined(BSD) || defined(NO_TMPFILE)) && !defined(HAVE_TMPFILE)
377 # define tmpfile() (fopen(tmpnam(NULL), "w+"))
378 #endif
379
380 /* File buffers */
381 #define FILEBUF(f,sc,type) sc int __CAT__(f,_BFLAGS); \
382 sc type __CAT__(f,_BUFFER)
383 #define FILEBUFNC(f,type) int __CAT__(f,_BFLAGS); \
384 type __CAT__(f,_BUFFER)
385
386 #define RESETBUF(f,type) (__CAT__(f,_BFLAGS) = 1)
387 #define SETUPBUF(f,type) (__CAT__(f,_BFLAGS) = 0)
388
389 #define GETFBUF(f,type) (*((__CAT__(f,_BFLAGS) == 1 && \
390 ((__CAT__(f,_BFLAGS) = 2), \
391 fread(&__CAT__(f,_BUFFER), \
392 sizeof(type),1,(f)))),\
393 &__CAT__(f,_BUFFER)))
394 #define AGETFBUF(f,type) ((__CAT__(f,_BFLAGS) == 1 && \
395 ((__CAT__(f,_BFLAGS) = 2), \
396 fread(__CAT__(f,_BUFFER), \
397 sizeof(type),1,(f)))),\
398 __CAT__(f,_BUFFER))
399
400 #define PUTFBUF(f,type,v) (GETFBUF(f,type) = (v))
401 #define CPUTFBUF(f,v) (PUTFBUF(f,char,v))
402
403 #define GET(f,type) (__CAT__(f,_BFLAGS) == 1 ? \
404 fread(&__CAT__(f,_BUFFER),sizeof(type),1,(f)) : \
405 (__CAT__(f,_BFLAGS) = 1))
406
407 #define PUT(f,type) (fwrite(&__CAT__(f,_BUFFER),sizeof(type),1,(f)), \
408 (__CAT__(f,_BFLAGS) = 0))
409 #define CPUT(f) (PUT(f,char))
410
411 #define BUFEOF(f) (__CAT__(f,_BFLAGS) != 2 && P_eof(f))
412 #define BUFFPOS(f) (ftell(f) - (__CAT__(f,_BFLAGS) == 2))
413
414 typedef struct {
415 FILE *f;
416 int f_BFLAGS; /* FILEBUFNC(f,Char); */
417 Char f_BUFFER;
418 Char name[_FNSIZE];
419 } _TEXT;
420
421 /* Memory allocation */
422 #ifdef __GCC__
423 # define Malloc(n) (malloc(n) ?: (Anyptr)_OutMem())
424 #else
425 extern Anyptr __MallocTemp__;
426 # define Malloc(n) ((__MallocTemp__ = malloc(n)) ? __MallocTemp__ : (Anyptr)_OutMem())
427 #endif
428 #define FreeR(p) (free((Anyptr)(p))) /* used if arg is an rvalue */
429 #define Free(p) (free((Anyptr)(p)), (p)=NULL)
430
431 /* sign extension */
432 #define SEXT(x,n) ((x) | -(((x) & (1L<<((n)-1))) << 1))
433
434 /* packed arrays */ /* BEWARE: these are untested! */
435 #define P_getbits_UB(a,i,n,L) ((int)((a)[(i)>>(L)-(n)] >> \
436 (((~(i))&((1<<(L)-(n))-1)) << (n)) & \
437 (1<<(1<<(n)))-1))
438
439 #define P_getbits_SB(a,i,n,L) ((int)((a)[(i)>>(L)-(n)] << \
440 (16 - ((((~(i))&((1<<(L)-(n))-1))+1) <<\
441 (n)) >> (16-(1<<(n))))))
442
443 #define P_putbits_UB(a,i,x,n,L) ((a)[(i)>>(L)-(n)] |= \
444 (x) << (((~(i))&((1<<(L)-(n))-1)) << (n)))
445
446 #define P_putbits_SB(a,i,x,n,L) ((a)[(i)>>(L)-(n)] |= \
447 ((x) & (1<<(1<<(n)))-1) << \
448 (((~(i))&((1<<(L)-(n))-1)) << (n)))
449
450 #define P_clrbits_B(a,i,n,L) ((a)[(i)>>(L)-(n)] &= \
451 ~( ((1<<(1<<(n)))-1) << \
452 (((~(i))&((1<<(L)-(n))-1)) << (n))) )
453
454 /* small packed arrays */
455 #define P_getbits_US(v,i,n) ((int)((v) >> ((i)<<(n)) & (1<<(1<<(n)))-1))
456 #define P_getbits_SS(v,i,n) ((int)((long)(v) << (SETBITS - (((i)+1) << (n))) >> (SETBITS-(1<<(n)))))
457 #define P_putbits_US(v,i,x,n) ((v) |= (x) << ((i) << (n)))
458 #define P_putbits_SS(v,i,x,n) ((v) |= ((x) & (1<<(1<<(n)))-1) << ((i)<<(n)))
459 #define P_clrbits_S(v,i,n) ((v) &= ~( ((1<<(1<<(n)))-1) << ((i)<<(n)) ))
460
461 #define P_max(a,b) ((a) > (b) ? (a) : (b))
462 #define P_min(a,b) ((a) < (b) ? (a) : (b))
463
464
465 /* Fix ANSI-isms */
466
467 #ifdef LACK_LABS
468 # ifndef labs
469 # define labs my_labs
470 extern long my_labs PP( (long) );
471 # endif
472 #endif
473
474
475 /* Fix toupper/tolower on Suns and other stupid BSD systems */
476 #ifdef toupper
477 # undef toupper
478 # undef tolower
479 # define toupper(c) my_toupper(c)
480 # define tolower(c) my_tolower(c)
481 #endif
482
483 #ifndef _toupper
484 # if 'A' == 65 && 'a' == 97
485 # define _toupper(c) ((c)-'a'+'A')
486 # define _tolower(c) ((c)-'A'+'a')
487 # else
488 # ifdef toupper
489 # undef toupper /* hope these are shadowing real functions, */
490 # undef tolower /* because my_toupper calls _toupper! */
491 # endif
492 # define _toupper(c) toupper(c)
493 # define _tolower(c) tolower(c)
494 # endif
495 #endif
496
497
498 #endif /* P2C_H */
499
500
501
502 /* End. */
503
504
505
506
507 /* Run-time library for use with "p2c", the Pascal to C translator */
508
509 /* "p2c" Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation.
510 * By Dave Gillespie, daveg@synaptics.com. Version --VERSION--.
511 * This file may be copied, modified, etc. in any way. It is not restricted
512 * by the licence agreement accompanying p2c itself.
513 */
514
515
516
517
518
519 #ifndef NO_TIME
520 # include <time.h>
521 #endif
522
523
524 #define Isspace(c) isspace(c) /* or "((c) == ' ')" if preferred */
525
526
527
528
529 int P_argc;
530 char **P_argv;
531
532 short P_escapecode;
533 int P_ioresult;
534
535 long EXCP_LINE; /* Used by Pascal workstation system */
536
537 Anyptr __MallocTemp__;
538
539 __p2c_jmp_buf *__top_jb;
540
541
542
543
PASCAL_MAIN(argc,argv)544 void PASCAL_MAIN(argc, argv)
545 int argc;
546 char **argv;
547 {
548 P_argc = argc;
549 P_argv = argv;
550 __top_jb = NULL;
551
552 #ifdef LOCAL_INIT
553 LOCAL_INIT();
554 #endif
555 }
556
557
558
559
560
561 /* In case your system lacks these... */
562
my_labs(x)563 long my_labs(x)
564 long x;
565 {
566 return((x > 0) ? x : -x);
567 }
568
569
570
571
572
573
574
575
my_toupper(c)576 int my_toupper(c)
577 int c;
578 {
579 if (islower(c))
580 return _toupper(c);
581 else
582 return c;
583 }
584
585
my_tolower(c)586 int my_tolower(c)
587 int c;
588 {
589 if (isupper(c))
590 return _tolower(c);
591 else
592 return c;
593 }
594
595
596
597
ipow(a,b)598 long ipow(a, b)
599 long a, b;
600 {
601 long v;
602
603 if (a == 0 || a == 1)
604 return a;
605 if (a == -1)
606 return (b & 1) ? -1 : 1;
607 if (b < 0)
608 return 0;
609 if (a == 2)
610 return 1L << b;
611 v = (b & 1) ? a : 1;
612 while ((b >>= 1) > 0) {
613 a *= a;
614 if (b & 1)
615 v *= a;
616 }
617 return v;
618 }
619
620
P_imax(a,b)621 long P_imax(a, b)
622 long a, b;
623 {
624 if (a > b)
625 return a;
626 else
627 return b;
628 }
629
P_imin(a,b)630 long P_imin(a, b)
631 long a, b;
632 {
633 if (a < b)
634 return a;
635 else
636 return b;
637 }
638
639
P_rmax(a,b)640 double P_rmax(a, b)
641 double a, b;
642 {
643 if (a > b)
644 return a;
645 else
646 return b;
647 }
648
P_rmin(a,b)649 double P_rmin(a, b)
650 double a, b;
651 {
652 if (a < b)
653 return a;
654 else
655 return b;
656 }
657
658
659
660
661 /* Common string functions: */
662
663 /* Store in "ret" the substring of length "len" starting from "pos" (1-based).
664 Store a shorter or null string if out-of-range. Return "ret". */
665
strsub(ret,s,pos,len)666 char *strsub(ret, s, pos, len)
667 register char *ret, *s;
668 register int pos, len;
669 {
670 register char *s2;
671
672 if (--pos < 0 || len <= 0) {
673 *ret = 0;
674 return ret;
675 }
676 while (pos > 0) {
677 if (!*s++) {
678 *ret = 0;
679 return ret;
680 }
681 pos--;
682 }
683 s2 = ret;
684 while (--len >= 0) {
685 if (!(*s2++ = *s++))
686 return ret;
687 }
688 *s2 = 0;
689 return ret;
690 }
691
692
693 /* Return the index of the first occurrence of "pat" as a substring of "s",
694 starting at index "pos" (1-based). Result is 1-based, 0 if not found. */
695
strpos2(s,pat,pos)696 int strpos2(s, pat, pos)
697 char *s;
698 register char *pat;
699 register int pos;
700 {
701 register char *cp, ch;
702 register int slen;
703
704 if (--pos < 0)
705 return 0;
706 slen = (int)strlen(s) - pos;
707 cp = s + pos;
708 if (!(ch = *pat++))
709 return 0;
710 pos = (int)strlen(pat);
711 slen -= pos;
712 while (--slen >= 0) {
713 if (*cp++ == ch && !strncmp(cp, pat, (size_t)pos))
714 return cp - s;
715 }
716 return 0;
717 }
718
719
720 /* Case-insensitive version of strcmp. */
721
strcicmp(s1,s2)722 int strcicmp(s1, s2)
723 register char *s1, *s2;
724 {
725 register unsigned char c1, c2;
726
727 while (*s1) {
728 if (*s1++ != *s2++) {
729 if (!s2[-1])
730 return 1;
731 c1 = (unsigned char)toupper(s1[-1]);
732 c2 = (unsigned char)toupper(s2[-1]);
733 if (c1 != c2)
734 return c1 - c2;
735 }
736 }
737 if (*s2)
738 return -1;
739 return 0;
740 }
741
742
743
744
745 /* HP and Turbo Pascal string functions: */
746
747 /* Trim blanks at left end of string. */
748
strltrim(s)749 char *strltrim(s)
750 register char *s;
751 {
752 while (Isspace(*s++)) ;
753 return s - 1;
754 }
755
756
757 /* Trim blanks at right end of string. */
758
strrtrim(s)759 char *strrtrim(s)
760 register char *s;
761 {
762 register char *s2 = s;
763
764 if (!*s)
765 return s;
766 while (*++s2) ;
767 while (s2 > s && Isspace(*--s2))
768 *s2 = 0;
769 return s;
770 }
771
772
773 /* Store in "ret" "num" copies of string "s". Return "ret". */
774
strrpt(ret,s,num)775 char *strrpt(ret, s, num)
776 char *ret;
777 register char *s;
778 register int num;
779 {
780 register char *s2 = ret;
781 register char *s1;
782
783 while (--num >= 0) {
784 s1 = s;
785 while ((*s2++ = *s1++)) ;
786 s2--;
787 }
788 return ret;
789 }
790
791
792 /* Store in "ret" string "s" with enough pad chars added to reach "size". */
793
strpad(ret,s,padchar,num)794 char *strpad(ret, s, padchar, num)
795 char *ret;
796 register char *s;
797 register int padchar, num;
798 {
799 register char *d = ret;
800
801 if (s == d) {
802 while (*d++) ;
803 } else {
804 while ((*d++ = *s++)) ;
805 }
806 num -= (--d - ret);
807 while (--num >= 0)
808 *d++ = padchar;
809 *d = 0;
810 return ret;
811 }
812
813
814 /* Copy the substring of length "len" from index "spos" of "s" (1-based)
815 to index "dpos" of "d", lengthening "d" if necessary. Length and
816 indices must be in-range. */
817
strmove(len,s,spos,d,dpos)818 void strmove(len, s, spos, d, dpos)
819 register char *s, *d;
820 register int len, spos, dpos;
821 {
822 s += spos - 1;
823 d += dpos - 1;
824 while (*d && --len >= 0)
825 *d++ = *s++;
826 if (len > 0) {
827 while (--len >= 0)
828 *d++ = *s++;
829 *d = 0;
830 }
831 }
832
833
834 /* Delete the substring of length "len" at index "pos" from "s".
835 Delete less if out-of-range. */
836
strdelete(s,pos,len)837 void strdelete(s, pos, len)
838 register char *s;
839 register int pos, len;
840 {
841 register int slen;
842
843 if (--pos < 0)
844 return;
845 slen = (int)strlen(s) - pos;
846 if (slen <= 0)
847 return;
848 s += pos;
849 if (slen <= len) {
850 *s = 0;
851 return;
852 }
853 while ((*s = s[len])) s++;
854 }
855
856
857 /* Insert string "src" at index "pos" of "dst". */
858
strinsert(src,dst,pos)859 void strinsert(src, dst, pos)
860 register char *src, *dst;
861 register int pos;
862 {
863 register int slen, dlen;
864
865 if (--pos < 0)
866 return;
867 dlen = (int)strlen(dst);
868 dst += dlen;
869 dlen -= pos;
870 if (dlen <= 0) {
871 strcpy(dst, src);
872 return;
873 }
874 slen = (int)strlen(src);
875 do {
876 dst[slen] = *dst;
877 --dst;
878 } while (--dlen >= 0);
879 dst++;
880 while (--slen >= 0)
881 *dst++ = *src++;
882 }
883
884
885
886
887 /* File functions */
888
889 /* Peek at next character of input stream; return EOF at end-of-file. */
890
P_peek(f)891 int P_peek(f)
892 FILE *f;
893 {
894 int ch;
895
896 ch = getc(f);
897 if (ch == EOF)
898 return EOF;
899 ungetc(ch, f);
900 return (ch == '\n') ? ' ' : ch;
901 }
902
903
904 /* Check if at end of file, using Pascal "eof" semantics. End-of-file for
905 stdin is broken; remove the special case for it to be broken in a
906 different way. */
907
P_eof(f)908 int P_eof(f)
909 FILE *f;
910 {
911 register int ch;
912
913 if (feof(f))
914 return 1;
915 #ifdef HAVE_ISATTY
916 if (isatty(fileno(f)))
917 #else
918 if (f == stdin)
919 #endif
920 return 0; /* not safe to look-ahead on the keyboard! */
921 ch = getc(f);
922 if (ch == EOF)
923 return 1;
924 ungetc(ch, f);
925 return 0;
926 }
927
928
929 /* Check if at end of line (or end of entire file). */
930
P_eoln(f)931 int P_eoln(f)
932 FILE *f;
933 {
934 register int ch;
935
936 ch = getc(f);
937 if (ch == EOF)
938 return 1;
939 ungetc(ch, f);
940 return (ch == '\n');
941 }
942
943
944 /* Skip whitespace (including newlines) in a file. */
945
_skipnlspaces(f)946 FILE *_skipnlspaces(f)
947 FILE *f;
948 {
949 register int ch;
950
951 do {
952 ch = getc(f);
953 } while (ch == ' ' || ch == '\t' || ch == '\n');
954 if (ch != EOF)
955 ungetc(ch, f);
956 return f;
957 }
958
959
960 /* Skip whitespace (not including newlines) in a file. */
961
_skipspaces(f)962 FILE *_skipspaces(f)
963 FILE *f;
964 {
965 register int ch;
966
967 do {
968 ch = getc(f);
969 } while (ch == ' ' || ch == '\t');
970 if (ch != EOF)
971 ungetc(ch, f);
972 return f;
973 }
974
975
976 /* Read a packed array of characters from a file. */
977
P_readpaoc(f,s,len)978 Void P_readpaoc(f, s, len)
979 FILE *f;
980 char *s;
981 int len;
982 {
983 int ch;
984
985 for (;;) {
986 if (len <= 0)
987 return;
988 ch = getc(f);
989 if (ch == EOF || ch == '\n')
990 break;
991 *s++ = ch;
992 --len;
993 }
994 while (--len >= 0)
995 *s++ = ' ';
996 if (ch != EOF)
997 ungetc(ch, f);
998 }
999
P_readlnpaoc(f,s,len)1000 Void P_readlnpaoc(f, s, len)
1001 FILE *f;
1002 char *s;
1003 int len;
1004 {
1005 int ch;
1006
1007 for (;;) {
1008 ch = getc(f);
1009 if (ch == EOF || ch == '\n')
1010 break;
1011 if (len > 0) {
1012 *s++ = ch;
1013 --len;
1014 }
1015 }
1016 while (--len >= 0)
1017 *s++ = ' ';
1018 }
1019
1020
1021 /* Compute maximum legal "seek" index in file (0-based). */
1022
P_maxpos(f)1023 long P_maxpos(f)
1024 FILE *f;
1025 {
1026 long savepos = ftell(f);
1027 long val;
1028
1029 if (fseek(f, 0L, SEEK_END))
1030 return -1;
1031 val = ftell(f);
1032 if (fseek(f, savepos, SEEK_SET))
1033 return -1;
1034 return val;
1035 }
1036
1037
1038 /* Use packed array of char for a file name. */
1039
P_trimname(fn,len)1040 Char *P_trimname(fn, len)
1041 register Char *fn;
1042 register int len;
1043 {
1044 static Char fnbuf[256];
1045 register Char *cp = fnbuf;
1046
1047 while (--len >= 0 && *fn && !isspace(*fn))
1048 *cp++ = *fn++;
1049 *cp = 0;
1050 return fnbuf;
1051 }
1052
1053
1054
1055
1056 /* Pascal's "memavail" doesn't make much sense in Unix with virtual memory.
1057 We fix memory size as 10Meg as a reasonable compromise. */
1058
memavail()1059 long memavail()
1060 {
1061 return 10000000; /* worry about this later! */
1062 }
1063
maxavail()1064 long maxavail()
1065 {
1066 return memavail();
1067 }
1068
1069
1070
1071
1072 /* Sets are stored as an array of longs. S[0] is the size of the set;
1073 S[N] is the N'th 32-bit chunk of the set. S[0] equals the maximum
1074 I such that S[I] is nonzero. S[0] is zero for an empty set. Within
1075 each long, bits are packed from lsb to msb. The first bit of the
1076 set is the element with ordinal value 0. (Thus, for a "set of 5..99",
1077 the lowest five bits of the first long are unused and always zero.) */
1078
1079 /* (Sets with 32 or fewer elements are normally stored as plain longs.) */
1080
P_setunion(d,s1,s2)1081 long *P_setunion(d, s1, s2) /* d := s1 + s2 */
1082 register long *d, *s1, *s2;
1083 {
1084 long *dbase = d++;
1085 register int sz1 = *s1++, sz2 = *s2++;
1086 while (sz1 > 0 && sz2 > 0) {
1087 *d++ = *s1++ | *s2++;
1088 sz1--, sz2--;
1089 }
1090 while (--sz1 >= 0)
1091 *d++ = *s1++;
1092 while (--sz2 >= 0)
1093 *d++ = *s2++;
1094 *dbase = d - dbase - 1;
1095 return dbase;
1096 }
1097
1098
P_setint(d,s1,s2)1099 long *P_setint(d, s1, s2) /* d := s1 * s2 */
1100 register long *d, *s1, *s2;
1101 {
1102 long *dbase = d++;
1103 register int sz1 = *s1++, sz2 = *s2++;
1104 while (--sz1 >= 0 && --sz2 >= 0)
1105 *d++ = *s1++ & *s2++;
1106 while (--d > dbase && !*d) ;
1107 *dbase = d - dbase;
1108 return dbase;
1109 }
1110
1111
P_setdiff(d,s1,s2)1112 long *P_setdiff(d, s1, s2) /* d := s1 - s2 */
1113 register long *d, *s1, *s2;
1114 {
1115 long *dbase = d++;
1116 register int sz1 = *s1++, sz2 = *s2++;
1117 while (--sz1 >= 0 && --sz2 >= 0)
1118 *d++ = *s1++ & ~*s2++;
1119 if (sz1 >= 0) {
1120 while (sz1-- >= 0)
1121 *d++ = *s1++;
1122 }
1123 while (--d > dbase && !*d) ;
1124 *dbase = d - dbase;
1125 return dbase;
1126 }
1127
1128
P_setxor(d,s1,s2)1129 long *P_setxor(d, s1, s2) /* d := s1 / s2 */
1130 register long *d, *s1, *s2;
1131 {
1132 long *dbase = d++;
1133 register int sz1 = *s1++, sz2 = *s2++;
1134 while (sz1 > 0 && sz2 > 0) {
1135 *d++ = *s1++ ^ *s2++;
1136 sz1--, sz2--;
1137 }
1138 while (--sz1 >= 0)
1139 *d++ = *s1++;
1140 while (--sz2 >= 0)
1141 *d++ = *s2++;
1142 while (--d > dbase && !*d) ;
1143 *dbase = d - dbase;
1144 return dbase;
1145 }
1146
1147
P_inset(val,s)1148 int P_inset(val, s) /* val IN s */
1149 register unsigned val;
1150 register long *s;
1151 {
1152 register int bit;
1153 bit = (int) (val % SETBITS);
1154 val /= SETBITS;
1155 if ((long)val < *s++ && ((1L<<bit) & s[val]))
1156 return 1;
1157 return 0;
1158 }
1159
1160
P_addset(s,val)1161 long *P_addset(s, val) /* s := s + [val] */
1162 register long *s;
1163 register unsigned val;
1164 {
1165 register long *sbase = s;
1166 register int bit, size;
1167 bit = (int) (val % SETBITS);
1168 val /= SETBITS;
1169 size = (int)*s;
1170 if (++val >(unsigned) size) {
1171 s += size;
1172 while (val > (unsigned)size)
1173 *++s = 0, size++;
1174 *sbase = size;
1175 } else
1176 s += val;
1177 *s |= 1L<<bit;
1178 return sbase;
1179 }
1180
1181
P_addsetr(s,v1,v2)1182 long *P_addsetr(s, v1, v2) /* s := s + [v1..v2] */
1183 register long *s;
1184 register unsigned v1, v2;
1185 {
1186 register long *sbase = s;
1187 register int b1, b2, size;
1188 if ((int)v1 > (int)v2)
1189 return sbase;
1190 b1 = (int) (v1 % SETBITS);
1191 v1 /= SETBITS;
1192 b2 = (int) (v2 % SETBITS);
1193 v2 /= SETBITS;
1194 size = *s;
1195 v1++;
1196 if (++v2 > (unsigned)size) {
1197 while (v2 > (unsigned)size)
1198 s[++size] = 0;
1199 s[v2] = 0;
1200 *s = (long)v2;
1201 }
1202 s += v1;
1203 if (v1 == v2) {
1204 *s |= (~((-2L)<<(b2-b1))) << b1;
1205 } else {
1206 *s++ |= (-1L) << b1;
1207 while (++v1 < v2)
1208 *s++ = -1;
1209 *s |= ~((-2L) << b2);
1210 }
1211 return sbase;
1212 }
1213
1214
P_remset(s,val)1215 long *P_remset(s, val) /* s := s - [val] */
1216 register long *s;
1217 register unsigned val;
1218 {
1219 register int bit;
1220 bit = (int) (val % SETBITS);
1221 val /= SETBITS;
1222 if ((long)++val <= *s) {
1223 if (!(s[val] &= ~(1L<<bit)))
1224 while (*s && !s[*s])
1225 (*s)--;
1226 }
1227 return s;
1228 }
1229
1230
P_setequal(s1,s2)1231 int P_setequal(s1, s2) /* s1 = s2 */
1232 register long *s1, *s2;
1233 {
1234 register int size = *s1++;
1235 if (*s2++ != size)
1236 return 0;
1237 while (--size >= 0) {
1238 if (*s1++ != *s2++)
1239 return 0;
1240 }
1241 return 1;
1242 }
1243
1244
P_subset(s1,s2)1245 int P_subset(s1, s2) /* s1 <= s2 */
1246 register long *s1, *s2;
1247 {
1248 register int sz1 = *s1++, sz2 = *s2++;
1249 if (sz1 > sz2)
1250 return 0;
1251 while (--sz1 >= 0) {
1252 if (*s1++ & ~*s2++)
1253 return 0;
1254 }
1255 return 1;
1256 }
1257
1258
1259
1260 /* s is a "smallset", i.e., a 32-bit or less set stored
1261 directly in a long. */
1262
P_expset(d,s)1263 long *P_expset(d, s) /* d := s */
1264 register long *d;
1265 register long s;
1266 {
1267 if (s) {
1268 d[1] = s;
1269 *d = 1;
1270 } else
1271 *d = 0;
1272 return d;
1273 }
1274
1275
P_packset(s)1276 long P_packset(s) /* convert s to a small-set */
1277 register long *s;
1278 {
1279 if (*s++)
1280 return *s;
1281 else
1282 return 0;
1283 }
1284
1285
1286
1287
1288
1289
1290
_OutMem()1291 int _OutMem()
1292 {
1293 return _Escape(-2);
1294 }
1295
_CaseCheck()1296 int _CaseCheck()
1297 {
1298 return _Escape(-9);
1299 }
1300
_NilCheck()1301 int _NilCheck()
1302 {
1303 return _Escape(-3);
1304 }
1305
1306
1307
1308
1309
1310 /* The following is suitable for the HP Pascal operating system.
1311 It might want to be revised when emulating another system. */
1312
_ShowEscape(buf,code,ior,prefix)1313 char *_ShowEscape(buf, code, ior, prefix)
1314 char *buf, *prefix;
1315 int code, ior;
1316 {
1317 char *bufp;
1318
1319 if (prefix && *prefix) {
1320 strcpy(buf, prefix);
1321 strcat(buf, ": ");
1322 bufp = buf + strlen(buf);
1323 } else {
1324 bufp = buf;
1325 }
1326 if (code == -10) {
1327 snprintf(bufp,80, "Pascal system I/O error %d", ior);
1328 switch (ior) {
1329 case 3:
1330 strcat(buf, " (illegal I/O request)");
1331 break;
1332 case 7:
1333 strcat(buf, " (bad file name)");
1334 break;
1335 case FileNotFound: /*10*/
1336 strcat(buf, " (file not found)");
1337 break;
1338 case FileNotOpen: /*13*/
1339 strcat(buf, " (file not open)");
1340 break;
1341 case BadInputFormat: /*14*/
1342 strcat(buf, " (bad input format)");
1343 break;
1344 case 24:
1345 strcat(buf, " (not open for reading)");
1346 break;
1347 case 25:
1348 strcat(buf, " (not open for writing)");
1349 break;
1350 case 26:
1351 strcat(buf, " (not open for direct access)");
1352 break;
1353 case 28:
1354 strcat(buf, " (string subscript out of range)");
1355 break;
1356 case EndOfFile: /*30*/
1357 strcat(buf, " (end-of-file)");
1358 break;
1359 case FileWriteError: /*38*/
1360 strcat(buf, " (file write error)");
1361 break;
1362 }
1363 } else {
1364 snprintf(bufp,80, "Pascal system error %d", code);
1365 switch (code) {
1366 case -2:
1367 strcat(buf, " (out of memory)");
1368 break;
1369 case -3:
1370 strcat(buf, " (reference to NIL pointer)");
1371 break;
1372 case -4:
1373 strcat(buf, " (integer overflow)");
1374 break;
1375 case -5:
1376 strcat(buf, " (divide by zero)");
1377 break;
1378 case -6:
1379 strcat(buf, " (real math overflow)");
1380 break;
1381 case -8:
1382 strcat(buf, " (value range error)");
1383 break;
1384 case -9:
1385 strcat(buf, " (CASE value range error)");
1386 break;
1387 case -12:
1388 strcat(buf, " (bus error)");
1389 break;
1390 case -20:
1391 strcat(buf, " (stopped by user)");
1392 break;
1393 }
1394 }
1395 return buf;
1396 }
1397
1398
_Escape(code)1399 int _Escape(code)
1400 int code;
1401 {
1402 char buf[100];
1403
1404 P_escapecode = code;
1405 if (__top_jb) {
1406 __p2c_jmp_buf *jb = __top_jb;
1407 __top_jb = jb->next;
1408 longjmp(jb->jbuf, 1);
1409 }
1410 if (code == 0)
1411 exit(EXIT_SUCCESS);
1412 if (code == -1)
1413 exit(EXIT_FAILURE);
1414 fprintf(stderr, "%s\n", _ShowEscape(buf, P_escapecode, P_ioresult, ""));
1415 exit(EXIT_FAILURE);
1416 }
1417
_EscIO(code)1418 int _EscIO(code)
1419 int code;
1420 {
1421 P_ioresult = code;
1422 return _Escape(-10);
1423 }
1424
_EscIO2(code,name)1425 int _EscIO2(code, name)
1426 int code;
1427 char *name;
1428 {
1429 P_ioresult = code;
1430 if (!__top_jb && name && *name) {
1431 char buf[100];
1432 fprintf(stderr, "%s: %s\n",
1433 name, _ShowEscape(buf, P_escapecode, P_ioresult, ""));
1434 exit(EXIT_FAILURE);
1435 }
1436 return _Escape(-10);
1437 }
1438
1439 /* End. */
1440
1441
1442 typedef struct TPoint {
1443 long X, Y, C, H, N, O, P, S, Si, B, Br, Cl, F, I, Al, Ag, As,Au, Ba, Be, Bi, Ca, Cd,
1444 Co, Cr, Cs, Cu, Fe, Ga, Ge, Hf, Hg, In, Ir, Li, Lu, Mg, Mn, Mo, Na, Nb, Ni, Os, K, Pb, Pd, Pt, Rb,
1445 Re, Rh, Ru, Sb, Sc, Se, Sn, Sr, Ta, Te, Ti, Tl, V, W, Ytt, Zn, Zr, RecCount;
1446 struct TPoint *Last;
1447 } TPoint;
1448
1449 typedef struct TBond {
1450 long X1, Y1, X2, Y2, RecCount;
1451 struct TBond *Last;
1452 } TBond;
1453
1454
1455 Static long C, H, N, O, P, S, Si, B, Br, Cl, F, I, Al, Ag, As, Au, Ba, Be, Bi, Ca, Cd,
1456 Co, Cr, Cs, Cu, Fe, Ga, Ge, Hf, Hg, In, Ir, Li, Lu, Mg, Mn, Mo, Na, Nb, Ni, Os, K, Pb,
1457 Pd, Pt, Rb, Re, Rh, Ru, Sb, Sc, Se, Sn, Sr, Ta, Te, Ti, Tl, V, W, Ytt, Zn, Zr, X1, X2, Y1, Y2, T, D;
1458 Static FILE *IFile;
1459 Static TPoint *Point, *Last, *Current;
1460 Static TBond *Bond, *LastB, *CurrentB;
1461 Static Char sss[256], A[256], subs[256], Alert[256];
1462 Static Char sssb[7];
1463 Static double M, Me;
1464 Static Char separator;
1465 Static long Count, code, atoms, rep, range, bonds;
1466 Static boolean Abandon, debug, verbose, fa, nobonds;
1467 Static long Sensi = 5; /*bonds and labels joint precision sensitivity*/
1468 Static Char IFile_NAME[_FNSIZE];
1469
1470
doBonds()1471 Static Void doBonds()
1472 {
1473 do {
1474 if (!fgets(sss,256,IFile)) return;
1475 sscanf(sss, "%ld%ld%ld%ld%ld%ld%*[^\n]", &X1, &Y1, &X2, &Y2, &T, &D);
1476 /*getc(IFile);*/
1477 bonds--;
1478 if (debug)
1479 printf("%ld; %ld; %ld; %ld; %ld; %ld\n", X1, Y1, X2, Y2, T, D);
1480 if (D == 1 || T == 8){
1481 if (debug) printf("skipped\n");
1482 continue;
1483 }
1484 if (debug) printf("parsed\n");
1485 if (T == 11)
1486 range = ((X1 - X2) * (X1 - X2) + (Y1 - Y2) * (Y1 - Y2)) * 4;
1487
1488 LastB = Bond;
1489 Bond = (TBond *)malloc(sizeof(TBond));
1490 if (Bond == NULL) {
1491 fprintf(stderr,"Could not allocate memory\n");
1492 exit(1);
1493 }
1494 Bond->X1 = X1;
1495 Bond->X2 = X2;
1496 Bond->Y1 = Y1;
1497 Bond->Y2 = Y2;
1498 Bond->Last = LastB;
1499 CurrentB = Bond;
1500 Bond = Bond->Last;
1501 while (Bond->Last != NULL) {
1502 if ((labs(Bond->X1 - X1) < Sensi && labs(Bond->Y1 - Y1) < Sensi &&
1503 labs(Bond->X2 - X2) < Sensi && labs(Bond->Y2 - Y2) < Sensi) ||
1504 (labs(Bond->X2 - X1) < Sensi && labs(Bond->Y2 - Y1) < Sensi &&
1505 labs(Bond->X1 - X2) < Sensi && labs(Bond->Y1 - Y2) < Sensi)) {
1506 if (debug)
1507 printf(" ! Bond overlap\n");
1508 strcat(Alert, "!");
1509 }
1510 Bond = Bond->Last;
1511 }
1512 Bond = CurrentB;
1513
1514 Abandon = false;
1515 Current = Point;
1516 while (Point->Last != NULL) {
1517 if (T == 11) {
1518 Abandon = true;
1519 if ((Point->X - X1) * (Point->X - X1) +
1520 (Point->Y - Y1) * (Point->Y - Y1) < range) {
1521 if (Point->H > 0)
1522 Point->H--;
1523 if (debug)
1524 printf("Ring --> stripped one H from %ld %ld\n",
1525 Point->X, Point->Y);
1526 }
1527 } else {
1528 if (labs(Point->X - X1) < Sensi && labs(Point->Y - Y1) < Sensi) {
1529 if (debug)
1530 printf(" %ld --> Joined at %ld %ld\n", Point->RecCount, X1, Y1);
1531 if (T == 0 || T == 5 || T == 6 || T == 7 || T == 10 || T == 12 ||
1532 T == 13)
1533 Point->H--;
1534 if (T == 1 || T == 2 || T == 4 || T == 14 || T == 15 )
1535 Point->H -= 2;
1536 if (T == 3)
1537 Point->H -= 3;
1538 if (Point->H < 0) {
1539 if (debug) printf("Point^.X=%ld, Point^.Y=%ld has H count <0 !\n",Point->X,Point->Y);
1540 Point->H = 0;
1541 }
1542 Abandon = true;
1543 }
1544 }
1545 Point = Point->Last;
1546 }
1547 Point = Current;
1548
1549 if (!Abandon) {
1550 Count++;
1551 Last = Point;
1552 Point = (TPoint *)malloc(sizeof(TPoint));
1553 if (Point == NULL) {
1554 fprintf(stderr,"Could not allocate memory\n");
1555 exit(1);
1556 }
1557 Point->X = X1;
1558 if (debug)
1559 printf(" Point^.X=%ld", Point->X);
1560 Point->Y = Y1;
1561 if (debug)
1562 printf(" Point^.Y=%ld", Point->Y);
1563 if (T != 11 && T != 9)
1564 Point->C = 1;
1565 else
1566 Point->C = 0;
1567 if (debug)
1568 printf(" Point^.C=%ld", Point->C);
1569 if (T == 0 || T == 5 || T == 6 || T == 7 || T == 10 || T == 12 ||
1570 T == 13)
1571 Point->H = 3;
1572 if (T == 1 || T == 2 || T == 4 || T == 14 || T == 15)
1573 Point->H = 2;
1574 if (T == 3)
1575 Point->H = 1;
1576 if (debug)
1577 printf(" Point^.H=%ld", Point->H);
1578 Point->N = 0;
1579 Point->O = 0;
1580 Point->P = 0;
1581 Point->S = 0;
1582 Point->Si = 0;
1583 Point->B = 0;
1584 Point->Br = 0;
1585 Point->Cl = 0;
1586 Point->F = 0;
1587 Point->I = 0;
1588 Point->Al = 0;
1589 Point->Ag = 0;
1590 Point->As = 0;
1591 Point->Au = 0;
1592 Point->Ba = 0;
1593 Point->Be = 0;
1594 Point->Bi = 0;
1595 Point->Ca = 0;
1596 Point->Cd = 0;
1597 Point->Co = 0;
1598 Point->Cr = 0;
1599 Point->Cs = 0;
1600 Point->Cu = 0;
1601 Point->Fe = 0;
1602 Point->Ga = 0;
1603 Point->Ge = 0;
1604 Point->Hf = 0;
1605 Point->Hg = 0;
1606 Point->In = 0;
1607 Point->Ir = 0;
1608 Point->Li = 0;
1609 Point->Lu = 0;
1610 Point->Na = 0;
1611 Point->Nb = 0;
1612 Point->Ni = 0;
1613 Point->Os = 0;
1614 Point->Mg = 0;
1615 Point->Mn = 0;
1616 Point->Mo = 0;
1617 Point->K = 0;
1618 Point->Pb = 0;
1619 Point->Pd = 0;
1620 Point->Pt = 0;
1621 Point->Rb = 0;
1622 Point->Re = 0;
1623 Point->Rh = 0;
1624 Point->Ru = 0;
1625 Point->Sb = 0;
1626 Point->Sc = 0;
1627 Point->Se = 0;
1628 Point->Sn = 0;
1629 Point->Sr = 0;
1630 Point->Ta = 0;
1631 Point->Te = 0;
1632 Point->Ti = 0;
1633 Point->Tl = 0;
1634 Point->V = 0;
1635 Point->W = 0;
1636 Point->Ytt = 0;
1637 Point->Zn = 0;
1638 Point->Zr = 0;
1639 Point->RecCount = Count;
1640 if (debug)
1641 printf(" Point^.RecCount=%ld\n", Point->RecCount);
1642 Point->Last = Last;
1643 }
1644
1645 if (T != 11) {
1646 Abandon = false;
1647 Current = Point;
1648 while (Point->Last != NULL) {
1649 if (labs(Point->X - X2) < Sensi && labs(Point->Y - Y2) < Sensi) {
1650 if (debug)
1651 printf(" %ld --> Joined at %ld %ld\n", Point->RecCount, X2, Y2);
1652 if (T == 0 || T == 5 || T == 6 || T == 7 || T == 10 || T == 12 ||
1653 T == 13)
1654 Point->H--;
1655 if (T == 1 || T == 2 || T == 4 || T == 14 || T == 15)
1656 Point->H -= 2;
1657 if (T == 3)
1658 Point->H -= 3;
1659 if (Point->H < 0) {
1660 if (debug) printf("Point^.X=%ld, Point^.Y=%ld has H count <0 !\n",Point->X,Point->Y);
1661 Point->H = 0;
1662 }
1663 Abandon = true;
1664 }
1665 Point = Point->Last;
1666 }
1667 Point = Current;
1668
1669 if (!Abandon) {
1670 Count++;
1671 Last = Point;
1672 Point = (TPoint *)malloc(sizeof(TPoint));
1673 if (Point == NULL) {
1674 fprintf(stderr,"Could not allocate memory\n");
1675 exit(1);
1676 }
1677 Point->X = X2;
1678 if (debug)
1679 printf(" Point^.X=%ld", Point->X);
1680 Point->Y = Y2;
1681 if (debug)
1682 printf(" Point^.Y=%ld", Point->Y);
1683 if (T != 11 && T != 9)
1684 Point->C = 1;
1685 else
1686 Point->C = 0;
1687 if (debug)
1688 printf(" Point^.C=%ld", Point->C);
1689 if (T == 0 || T == 5 || T == 6 || T == 7 || T == 10 || T == 12 ||
1690 T == 13)
1691 Point->H = 3;
1692 if (T == 1 || T == 2 || T == 4 || T == 14 || T == 15 )
1693 Point->H = 2;
1694 if (T == 3)
1695 Point->H = 1;
1696 if (debug)
1697 printf(" Point^.H=%ld", Point->H);
1698 Point->N = 0;
1699 Point->O = 0;
1700 Point->P = 0;
1701 Point->S = 0;
1702 Point->Si = 0;
1703 Point->B = 0;
1704 Point->Br = 0;
1705 Point->Cl = 0;
1706 Point->F = 0;
1707 Point->I = 0;
1708 Point->Al = 0;
1709 Point->Ag = 0;
1710 Point->As = 0;
1711 Point->Au = 0;
1712 Point->Ba = 0;
1713 Point->Be = 0;
1714 Point->Bi = 0;
1715 Point->Ca = 0;
1716 Point->Cd = 0;
1717 Point->Co = 0;
1718 Point->Cr = 0;
1719 Point->Cs = 0;
1720 Point->Cu = 0;
1721 Point->Fe = 0;
1722 Point->Ga = 0;
1723 Point->Ge = 0;
1724 Point->Hf = 0;
1725 Point->Hg = 0;
1726 Point->In = 0;
1727 Point->Ir = 0;
1728 Point->Li = 0;
1729 Point->Lu = 0;
1730 Point->Mg = 0;
1731 Point->Mn = 0;
1732 Point->Mo = 0;
1733 Point->Na = 0;
1734 Point->Nb = 0;
1735 Point->Ni = 0;
1736 Point->Os = 0;
1737 Point->K = 0;
1738 Point->Pb = 0;
1739 Point->Pd = 0;
1740 Point->Pt = 0;
1741 Point->Rb = 0;
1742 Point->Re = 0;
1743 Point->Rh = 0;
1744 Point->Ru = 0;
1745 Point->Sb = 0;
1746 Point->Sc = 0;
1747 Point->Se = 0;
1748 Point->Sn = 0;
1749 Point->Sr = 0;
1750 Point->Ta = 0;
1751 Point->Te = 0;
1752 Point->Ti = 0;
1753 Point->Tl = 0;
1754 Point->V = 0;
1755 Point->W = 0;
1756 Point->Ytt = 0;
1757 Point->Zn = 0;
1758 Point->Zr = 0;
1759 Point->RecCount = Count;
1760 if (debug)
1761 printf(" Point^.RecCount=%ld\n", Point->RecCount);
1762 Point->Last = Last;
1763 }
1764 }
1765 } while (bonds != 0);
1766 }
1767
1768
doLabels()1769 Static Void doLabels()
1770 {
1771 long mul, gmul, gmpos, ggmul, ggmpos;
1772 boolean stripped;
1773 Char STR2[256];
1774 long FORLIM;
1775 Char *TEMP;
1776
1777 if (debug)
1778 printf("---- and now parse the labels ---------\n");
1779 if (verbose)
1780 printf("HeteroAtoms: %ld\n", atoms);
1781 FORLIM = atoms;
1782 for (rep = 1; rep <= FORLIM; rep++) {
1783 if (fscanf(IFile, "%ld%ld%c", &X1, &Y1, &separator)<2) return;
1784 if (!fgets(sss, 256, IFile))return;
1785 TEMP = strchr(sss, '\n');
1786 if (TEMP != NULL)
1787 *TEMP = 0;
1788 snprintf(A,256, "%.*s", strpos2(sss, "\t", 1) - 1, sss);
1789
1790 if (debug)
1791 printf("Atom %s X=%ld Y=%ld sss: %s\n", A, X1, Y1, sss);
1792 if (nobonds)
1793 { /*initialize the Point structure if no bonds, only labels, defined*/
1794 Count++;
1795 Last = Point;
1796 Point = (TPoint *)malloc(sizeof(TPoint));
1797 if (Point == NULL) {
1798 fprintf(stderr,"Could not allocate memory\n");
1799 exit(1);
1800 }
1801 Point->X = X1;
1802 Point->Y = Y1;
1803 Point->C = 0;
1804 Point->H = 0;
1805 Point->N = 0;
1806 Point->O = 0;
1807 Point->P = 0;
1808 Point->S = 0;
1809 Point->Si = 0;
1810 Point->B = 0;
1811 Point->Br = 0;
1812 Point->Cl = 0;
1813 Point->F = 0;
1814 Point->I = 0;
1815 Point->Al = 0;
1816 Point->Ag = 0;
1817 Point->As = 0;
1818 Point->Au = 0;
1819 Point->Ba = 0;
1820 Point->Be = 0;
1821 Point->Bi = 0;
1822 Point->Ca = 0;
1823 Point->Cd = 0;
1824 Point->Co = 0;
1825 Point->Cr = 0;
1826 Point->Cs = 0;
1827 Point->Cu = 0;
1828 Point->Fe = 0;
1829 Point->Ga = 0;
1830 Point->Ge = 0;
1831 Point->Hf = 0;
1832 Point->Hg = 0;
1833 Point->In = 0;
1834 Point->Ir = 0;
1835 Point->Li = 0;
1836 Point->Lu = 0;
1837 Point->Mg = 0;
1838 Point->Mn = 0;
1839 Point->Mo = 0;
1840 Point->Na = 0;
1841 Point->Nb = 0;
1842 Point->Ni = 0;
1843 Point->Os = 0;
1844 Point->K = 0;
1845 Point->Pb = 0;
1846 Point->Pd = 0;
1847 Point->Pt = 0;
1848 Point->Rb = 0;
1849 Point->Re = 0;
1850 Point->Rh = 0;
1851 Point->Ru = 0;
1852 Point->Sb = 0;
1853 Point->Sc = 0;
1854 Point->Se = 0;
1855 Point->Sn = 0;
1856 Point->Sr = 0;
1857 Point->Ta = 0;
1858 Point->Te = 0;
1859 Point->Ti = 0;
1860 Point->Tl = 0;
1861 Point->V = 0;
1862 Point->W = 0;
1863 Point->Ytt = 0;
1864 Point->Zn = 0;
1865 Point->Zr = 0;
1866 Point->RecCount = Count;
1867 Point->Last = Last;
1868 }
1869 Current = Point;
1870 while (Point->Last != NULL) {
1871 if (labs(Point->X - X1) < Sensi && labs(Point->Y - Y1) < Sensi) {
1872 if (debug)
1873 printf(" [%ld]\n", Point->RecCount);
1874 Point->C = 0; /*we substitute -CH_x(-) by -R(-)*/
1875 Point->H = 0;
1876 Point->N = 0;
1877 Point->O = 0;
1878 Point->P = 0;
1879 Point->S = 0;
1880 Point->Si = 0;
1881 Point->B = 0;
1882 Point->Br = 0;
1883 Point->Cl = 0;
1884 Point->F = 0;
1885 Point->I = 0;
1886 Point->Al = 0;
1887 Point->Ag = 0;
1888 Point->As = 0;
1889 Point->Au = 0;
1890 Point->Ba = 0;
1891 Point->Be = 0;
1892 Point->Bi = 0;
1893 Point->Ca = 0;
1894 Point->Cd = 0;
1895 Point->Co = 0;
1896 Point->Cr = 0;
1897 Point->Cs = 0;
1898 Point->Cu = 0;
1899 Point->Fe = 0;
1900 Point->Ga = 0;
1901 Point->Ge = 0;
1902 Point->Hf = 0;
1903 Point->Hg = 0;
1904 Point->In = 0;
1905 Point->Ir = 0;
1906 Point->Li = 0;
1907 Point->Lu = 0;
1908 Point->Mg = 0;
1909 Point->Mn = 0;
1910 Point->Mo = 0;
1911 Point->Na = 0;
1912 Point->Nb = 0;
1913 Point->Ni = 0;
1914 Point->Os = 0;
1915 Point->K = 0;
1916 Point->Pb = 0;
1917 Point->Pd = 0;
1918 Point->Pt = 0;
1919 Point->Rb = 0;
1920 Point->Re = 0;
1921 Point->Rh = 0;
1922 Point->Ru = 0;
1923 Point->Sb = 0;
1924 Point->Sc = 0;
1925 Point->Se = 0;
1926 Point->Sn = 0;
1927 Point->Sr = 0;
1928 Point->Ta = 0;
1929 Point->Te = 0;
1930 Point->Ti = 0;
1931 Point->Tl = 0;
1932 Point->V = 0;
1933 Point->W = 0;
1934 Point->Ytt = 0;
1935 Point->Zn = 0;
1936 Point->Zr = 0;
1937 mul = 1;
1938 gmul = 1;
1939 ggmul = 1;
1940 while (*A != '\0') {
1941 stripped = false;
1942 if ((int)strlen(A) >= 5) {
1943 snprintf(subs,256, "%.5s", A);
1944 if ((int)strlen(A) > 6) {
1945 if (A[5] == '_') {
1946 if (A[6]!= '{') {
1947 snprintf(STR2,256, "%c", A[6]);
1948 if (A[7]=='_') snprintf(STR2,256, "%c%c", A[6],A[8]);
1949 code = (sscanf(STR2, "%ld", &mul) == 0);
1950 }else{
1951 mul=7;
1952 while(A[mul]!='}'){STR2[mul-7]=A[mul]; mul++ ; }
1953 STR2[mul-6]='\0';
1954 code = (sscanf(STR2, "%ld", &mul) == 0);
1955 }
1956 } else
1957 mul = 1;
1958 }
1959 mul *= gmul * ggmul;
1960 if (!strcmp(subs, "TBDMS")) { /*Tert-butyldimethylsilyl*/
1961 if (debug)
1962 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
1963 Point->C += mul * 6;
1964 Point->H += mul * 15;
1965 Point->Si += mul;
1966 strcpy(A, strsub(STR2, A, 6, (int)(strlen(A) - 5)));
1967 stripped = true;
1968 }
1969 if (!strcmp(subs, "TBDPS")) { /*Tert-butyldiphenylsilyl*/
1970 if (debug)
1971 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
1972 Point->C += mul * 16;
1973 Point->H += mul * 19;
1974 Point->Si += mul;
1975 strcpy(A, strsub(STR2, A, 6, (int)(strlen(A) - 5)));
1976 stripped = true;
1977 }
1978 if (A[0] == '[') {
1979 ggmpos = strpos2(A, "]", 1);
1980 if (ggmpos != 0) {
1981 if (A[ggmpos] == '_') {
1982 if (A[ggmpos+1]!= '{') {
1983 snprintf(STR2,256, "%c", A[ggmpos+1]);
1984 if (A[ggmpos+2]=='_') snprintf(STR2,256, "%c%c", A[ggmpos+1],A[ggmpos+3]);
1985 code = (sscanf(STR2, "%ld", &ggmul) == 0);
1986 }else{
1987 ggmul=ggmpos+2;
1988 while(A[ggmul]!='}'){STR2[ggmul-ggmpos-2]=A[ggmul]; ggmul++ ; }
1989 STR2[ggmul-ggmpos-1]='\0';
1990 code = (sscanf(STR2, "%ld", &ggmul) == 0);
1991 }
1992 } else
1993 ggmul = 1;
1994 }
1995 }
1996 if (A[0] == '(') {
1997 gmpos = strpos2(A, ")", 1);
1998 if (gmpos != 0) {
1999 if (A[gmpos] == '_') {
2000 if (A[gmpos+1]!= '{') {
2001 snprintf(STR2,256, "%c", A[gmpos+1]);
2002 if (A[gmpos+2]=='_') snprintf(STR2,256, "%c%c", A[gmpos+1],A[gmpos+3]);
2003 code = (sscanf(STR2, "%ld", &gmul) == 0);
2004 }else{
2005 gmul=gmpos+2;
2006 while(A[gmul]!='}'){STR2[gmul-gmpos-2]=A[gmul]; gmul++ ; }
2007 STR2[gmul-gmpos-1]='\0';
2008 code = (sscanf(STR2, "%ld", &gmul) == 0);
2009 }
2010 } else
2011 gmul = 1;
2012 }
2013 }
2014 }
2015 if ((int)strlen(A) >= 4 && !stripped) {
2016 snprintf(subs,256, "%.4s", A);
2017 if ((int)strlen(A) > 5) {
2018 if (A[4] == '_') {
2019 if (A[5]!= '{') {
2020 snprintf(STR2,256, "%c", A[5]);
2021 if (A[6]=='_') snprintf(STR2,256, "%c%c", A[5],A[7]);
2022 code = (sscanf(STR2, "%ld", &mul) == 0);
2023 }else{
2024 mul=6;
2025 while(A[mul]!='}'){STR2[mul-6]=A[mul]; mul++ ; }
2026 STR2[mul-5]='\0';
2027 code = (sscanf(STR2, "%ld", &mul) == 0);
2028 }
2029 } else
2030 mul = 1;
2031 }
2032 mul *= gmul * ggmul;
2033 if (!strcmp(subs, "DBAM"))
2034 { /*dibutylaminomethylene; =R, used as the N prot.*/
2035 if (debug)
2036 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2037 Point->C += mul * 9;
2038 Point->H += mul * 19;
2039 Point->N += mul;
2040 strcpy(A, strsub(STR2, A, 5, (int)(strlen(A) - 4)));
2041 stripped = true;
2042 }
2043 if (!strcmp(subs, "DMAM"))
2044 { /*dimethylaminomethylene; =R, used as the N prot.*/
2045 if (debug)
2046 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2047 Point->C += mul * 3;
2048 Point->H += mul * 7;
2049 Point->N += mul;
2050 strcpy(A, strsub(STR2, A, 5, (int)(strlen(A) - 4)));
2051 stripped = true;
2052 }
2053 if (!strcmp(subs, "DMTr")) { /*dimethoxytrityl*/
2054 if (debug)
2055 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2056 Point->C += mul * 21;
2057 Point->H += mul * 19;
2058 Point->O += mul * 2;
2059 strcpy(A, strsub(STR2, A, 5, (int)(strlen(A) - 4)));
2060 stripped = true;
2061 }
2062 if (!strcmp(subs, "MMTr")) { /*monomethoxytrityl*/
2063 if (debug)
2064 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2065 Point->C += mul * 20;
2066 Point->H += mul * 16;
2067 Point->O += mul;
2068 strcpy(A, strsub(STR2, A, 5, (int)(strlen(A) - 4)));
2069 stripped = true;
2070 }
2071 if (!strcmp(subs, "TMTr")) { /*trimethoxytrityl*/
2072 if (debug)
2073 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2074 Point->C += mul * 22;
2075 Point->H += mul * 22;
2076 Point->O += mul * 3;
2077 strcpy(A, strsub(STR2, A, 5, (int)(strlen(A) - 4)));
2078 stripped = true;
2079 }
2080 }
2081 if ((int)strlen(A) >= 3 && !stripped) {
2082 snprintf(subs,256, "%.3s", A);
2083 if ((int)strlen(A) > 4) {
2084 if (A[3] == '_') {
2085 if (A[4]!= '{') {
2086 snprintf(STR2,256, "%c", A[4]);
2087 if (A[5]=='_') snprintf(STR2,256, "%c%c", A[4],A[6]);
2088 code = (sscanf(STR2, "%ld", &mul) == 0);
2089 }else{
2090 mul=5;
2091 while(A[mul]!='}'){STR2[mul-5]=A[mul]; mul++ ; }
2092 STR2[mul-4]='\0';
2093 code = (sscanf(STR2, "%ld", &mul) == 0);
2094 }
2095 } else
2096 mul = 1;
2097 }
2098 mul *= gmul * ggmul;
2099 if (!strcmp(subs, "Ade")) { /*Adeninyl*/
2100 if (debug)
2101 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2102 Point->C += mul * 5;
2103 Point->H += mul * 4;
2104 Point->N += mul * 5;
2105 strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2106 stripped = true;
2107 }
2108 if (!strcmp(subs, "BOC")) { /*Butyloxycarbonyl*/
2109 if (debug)
2110 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2111 Point->C += mul * 5;
2112 Point->H += mul * 9;
2113 Point->O += mul * 2;
2114 strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2115 stripped = true;
2116 }
2117 if (!strcmp(subs, "Cyt")) { /*Cytosinyl*/
2118 if (debug)
2119 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2120 Point->C += mul * 4;
2121 Point->H += mul * 4;
2122 Point->N += mul * 3;
2123 Point->O += mul;
2124 strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2125 stripped = true;
2126 }
2127 if (!strcmp(subs, "Gua")) { /*Guaninyl*/
2128 if (debug)
2129 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2130 Point->C += mul * 5;
2131 Point->H += mul * 4;
2132 Point->N += mul * 5;
2133 Point->O += mul;
2134 strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2135 stripped = true;
2136 }
2137 if (!strcmp(subs, "iBu")) { /*iso-Butyl*/
2138 if (debug)
2139 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2140 Point->C += mul * 4;
2141 Point->H += mul * 9;
2142 strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2143 stripped = true;
2144 }
2145 if (!strcmp(subs, "iPr")) { /*2-Propyl*/
2146 if (debug)
2147 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2148 Point->C += mul * 3;
2149 Point->H += mul * 7;
2150 strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2151 stripped = true;
2152 }
2153 if (!strcmp(subs, "MOC")) { /*Methoxycarbonyl*/
2154 if (debug)
2155 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2156 Point->C += mul * 2;
2157 Point->H += mul * 3;
2158 Point->O += mul * 2;
2159 strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2160 stripped = true;
2161 }
2162 if (!strcmp(subs, "MOM")) { /*Methoxymethyl*/
2163 if (debug)
2164 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2165 Point->C += mul * 2;
2166 Point->H += mul * 5;
2167 Point->O += mul;
2168 strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2169 stripped = true;
2170 }
2171 if (!strcmp(subs, "tBu")) { /*t-Butyl*/
2172 if (debug)
2173 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2174 Point->C += mul * 4;
2175 Point->H += mul * 9;
2176 strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2177 stripped = true;
2178 }
2179 if (!strcmp(subs, "Thy")) { /*Thyminyl*/
2180 if (debug)
2181 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2182 Point->C += mul * 5;
2183 Point->H += mul * 5;
2184 Point->N += mul * 2;
2185 Point->O += mul * 2;
2186 strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2187 stripped = true;
2188 }
2189 if (!strcmp(subs, "TMS")) { /*Trimethylsilyl*/
2190 if (debug)
2191 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2192 Point->C += mul * 3;
2193 Point->H += mul * 9;
2194 Point->Si += mul;
2195 strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2196 stripped = true;
2197 }
2198 if (!strcmp(subs, "Tol")) { /*tolyl*/
2199 if (debug)
2200 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2201 Point->C += mul * 8;
2202 Point->H += mul * 7;
2203 Point->O += mul;
2204 strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2205 stripped = true;
2206 }
2207 if (!strcmp(subs, "Ura")) { /*Uracilyl*/
2208 if (debug)
2209 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2210 Point->C += mul * 4;
2211 Point->H += mul * 3;
2212 Point->N += mul * 2;
2213 Point->O += mul * 2;
2214 strcpy(A, strsub(STR2, A, 4, (int)(strlen(A) - 3)));
2215 stripped = true;
2216 }
2217 }
2218 if ((int)strlen(A) >= 2 && !stripped) {
2219 snprintf(subs,256, "%.2s", A);
2220 if ((int)strlen(A) > 3) {
2221 if (A[2] == '_') {
2222 if (A[3]!= '{') {
2223 snprintf(STR2,256, "%c", A[3]);
2224 if (A[4]=='_') snprintf(STR2,256, "%c%c", A[3],A[5]);
2225 code = (sscanf(STR2, "%ld", &mul) == 0);
2226 }else{
2227 mul=4;
2228 while(A[mul]!='}'){STR2[mul-4]=A[mul]; mul++ ; }
2229 STR2[mul-3]='\0';
2230 code = (sscanf(STR2, "%ld", &mul) == 0);
2231 }
2232 } else
2233 mul = 1;
2234 }
2235 mul *= gmul * ggmul;
2236 if (!strcmp(subs, "Ac")) { /*acetyl*/
2237 if (debug)
2238 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2239 Point->C += mul * 2;
2240 Point->H += mul * 3;
2241 Point->O += mul;
2242 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2243 stripped = true;
2244 }
2245 if (!strcmp(subs, "Al")) { /*alumin(i)um*/
2246 if (debug)
2247 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2248 Point->Al += mul ;
2249 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2250 stripped = true;
2251 }
2252 if (!strcmp(subs, "Ag")) { /*silver*/
2253 if (debug)
2254 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2255 Point->Ag += mul ;
2256 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2257 stripped = true;
2258 }
2259 if (!strcmp(subs, "As")) { /*arsenic*/
2260 if (debug)
2261 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2262 Point->As += mul ;
2263 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2264 stripped = true;
2265 }
2266 if (!strcmp(subs, "Au")) { /*gold*/
2267 if (debug)
2268 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2269 Point->Au += mul ;
2270 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2271 stripped = true;
2272 }
2273 if (!strcmp(subs, "Ba")) { /*barium*/
2274 if (debug)
2275 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2276 Point->Ba += mul ;
2277 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2278 stripped = true;
2279 }
2280 if (!strcmp(subs, "Be")) { /*beryllium*/
2281 if (debug)
2282 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2283 Point->Be += mul ;
2284 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2285 stripped = true;
2286 }
2287 if (!strcmp(subs, "Bi")) { /*bismuth*/
2288 if (debug)
2289 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2290 Point->Bi += mul ;
2291 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2292 stripped = true;
2293 }
2294 if (!strcmp(subs, "Bn")) { /*benzyl*/
2295 if (debug)
2296 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2297 Point->C += mul * 7;
2298 Point->H += mul * 7;
2299 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2300 stripped = true;
2301 }
2302 if (!strcmp(subs, "Br")) { /*bromine*/
2303 if (debug)
2304 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2305 Point->Br += mul;
2306 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2307 stripped = true;
2308 }
2309 if (!strcmp(subs, "Bu")) { /*butyl*/
2310 if (debug)
2311 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2312 Point->C += mul * 4;
2313 Point->H += mul * 9;
2314 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2315 stripped = true;
2316 }
2317 if (!strcmp(subs, "Bz")) { /*benzoyl*/
2318 if (debug)
2319 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2320 Point->C += mul * 7;
2321 Point->H += mul * 5;
2322 Point->O += mul;
2323 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2324 stripped = true;
2325 }
2326 if (!strcmp(subs, "CE")) { /*cyanoethyl*/
2327 if (debug)
2328 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2329 Point->C += mul * 3;
2330 Point->H += mul * 4;
2331 Point->N += mul;
2332 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2333 stripped = true;
2334 }
2335 if (!strcmp(subs, "Cl")) { /*chlorine*/
2336 if (debug)
2337 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2338 Point->Cl += mul;
2339 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2340 stripped = true;
2341 }
2342 if (!strcmp(subs, "Ca")) { /*calcium*/
2343 if (debug)
2344 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2345 Point->Ca += mul;
2346 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2347 stripped = true;
2348 }
2349 if (!strcmp(subs, "Cd")) { /*cadmium*/
2350 if (debug)
2351 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2352 Point->Cd += mul;
2353 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2354 stripped = true;
2355 }
2356 if (!strcmp(subs, "Co")) { /*cobalt*/
2357 if (debug)
2358 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2359 Point->Co += mul;
2360 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2361 stripped = true;
2362 }
2363 if (!strcmp(subs, "Cr")) { /*chromium*/
2364 if (debug)
2365 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2366 Point->Cr += mul;
2367 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2368 stripped = true;
2369 }
2370 if (!strcmp(subs, "Cs")) { /*cesium*/
2371 if (debug)
2372 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2373 Point->Cs += mul;
2374 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2375 stripped = true;
2376 }
2377 if (!strcmp(subs, "Cu")) { /*copper*/
2378 if (debug)
2379 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2380 Point->Cu += mul;
2381 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2382 stripped = true;
2383 }
2384 if (!strcmp(subs, "Et")) { /*ethyl*/
2385 if (debug)
2386 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2387 Point->C += mul * 2;
2388 Point->H += mul * 5;
2389 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2390 stripped = true;
2391 }
2392 if (!strcmp(subs, "Fe")) { /*iron*/
2393 if (debug)
2394 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2395 Point->Fe += mul;
2396 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2397 stripped = true;
2398 }
2399 if (!strcmp(subs, "Ga")) { /*gallium*/
2400 if (debug)
2401 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2402 Point->Ga += mul;
2403 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2404 stripped = true;
2405 }
2406 if (!strcmp(subs, "Ge")) { /*germanium*/
2407 if (debug)
2408 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2409 Point->Ge += mul;
2410 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2411 stripped = true;
2412 }
2413 if (!strcmp(subs, "Hf")) { /*hafnium*/
2414 if (debug)
2415 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2416 Point->Hf += mul;
2417 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2418 stripped = true;
2419 }
2420 if (!strcmp(subs, "Hg")) { /*mercury*/
2421 if (debug)
2422 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2423 Point->Hg += mul;
2424 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2425 stripped = true;
2426 }
2427 if (!strcmp(subs, "In")) { /*indium*/
2428 if (debug)
2429 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2430 Point->In += mul;
2431 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2432 stripped = true;
2433 }
2434 if (!strcmp(subs, "Ir")) { /*iridium*/
2435 if (debug)
2436 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2437 Point->Ir += mul;
2438 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2439 stripped = true;
2440 }
2441 if (!strcmp(subs, "Li")) { /*lithium*/
2442 if (debug)
2443 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2444 Point->Li += mul;
2445 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2446 stripped = true;
2447 }
2448 if (!strcmp(subs, "Lu")) { /*lutetium*/
2449 if (debug)
2450 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2451 Point->Lu += mul;
2452 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2453 stripped = true;
2454 }
2455 if (!strcmp(subs, "Me")) { /*methyl*/
2456 if (debug)
2457 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2458 Point->C += mul;
2459 Point->H += mul * 3;
2460 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2461 stripped = true;
2462 }
2463 if (!strcmp(subs, "Ms")) { /*methanesulfonyl, mesyl*/
2464 if (debug)
2465 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2466 Point->C += mul;
2467 Point->H += mul * 3;
2468 Point->O += mul * 2;
2469 Point->S += mul;
2470 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2471 stripped = true;
2472 }
2473 if (!strcmp(subs, "Mg")) { /*magnesium*/
2474 if (debug)
2475 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2476 Point->Mg += mul;
2477 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2478 stripped = true;
2479 }
2480 if (!strcmp(subs, "Mn")) { /*manganese*/
2481 if (debug)
2482 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2483 Point->Mn += mul;
2484 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2485 stripped = true;
2486 }
2487 if (!strcmp(subs, "Mo")) { /*molybdenum*/
2488 if (debug)
2489 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2490 Point->Mo += mul;
2491 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2492 stripped = true;
2493 }
2494 if (!strcmp(subs, "Na")) { /*sodium*/
2495 if (debug)
2496 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2497 Point->Na += mul;
2498 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2499 stripped = true;
2500 }
2501 if (!strcmp(subs, "Nb")) { /*niobium*/
2502 if (debug)
2503 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2504 Point->Nb += mul;
2505 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2506 stripped = true;
2507 }
2508 if (!strcmp(subs, "Ni")) { /*nickel*/
2509 if (debug)
2510 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2511 Point->Ni += mul;
2512 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2513 stripped = true;
2514 }
2515 if (!strcmp(subs, "Os")) { /*osmium*/
2516 if (debug)
2517 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2518 Point->Os += mul;
2519 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2520 stripped = true;
2521 }
2522 if (!strcmp(subs, "Pb")) { /*lead*/
2523 if (debug)
2524 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2525 Point->Pb += mul;
2526 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2527 stripped = true;
2528 }
2529 if (!strcmp(subs, "Pd")) { /*palladium*/
2530 if (debug)
2531 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2532 Point->Pd += mul;
2533 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2534 stripped = true;
2535 }
2536 if (!strcmp(subs, "Ph")|| !strcmp(subs,"@F")) { /*phenyl*/
2537 if (debug)
2538 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2539 Point->C += mul * 6;
2540 Point->H += mul * 5;
2541 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2542 stripped = true;
2543 }
2544 if (!strcmp(subs, "Pr")) { /*propyl*/
2545 if (debug)
2546 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2547 Point->C += mul * 3;
2548 Point->H += mul * 7;
2549 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2550 stripped = true;
2551 }
2552 if (!strcmp(subs, "Pt")) { /*platinum*/
2553 if (debug)
2554 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2555 Point->Pt += mul;
2556 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2557 stripped = true;
2558 }
2559 if (!strcmp(subs, "Rb")) { /*rubidium*/
2560 if (debug)
2561 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2562 Point->Rb += mul;
2563 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2564 stripped = true;
2565 }
2566 if (!strcmp(subs, "Re")) { /*rhenium*/
2567 if (debug)
2568 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2569 Point->Re += mul;
2570 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2571 stripped = true;
2572 }
2573 if (!strcmp(subs, "Rh")) { /*rhodium*/
2574 if (debug)
2575 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2576 Point->Rh += mul;
2577 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2578 stripped = true;
2579 }
2580 if (!strcmp(subs, "Ru")) { /*ruthenium*/
2581 if (debug)
2582 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2583 Point->Ru += mul;
2584 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2585 stripped = true;
2586 }
2587 if (!strcmp(subs, "Sb")) { /*antimony*/
2588 if (debug)
2589 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2590 Point->Sb += mul;
2591 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2592 stripped = true;
2593 }
2594 if (!strcmp(subs, "Sc")) { /*scandium*/
2595 if (debug)
2596 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2597 Point->Sc += mul;
2598 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2599 stripped = true;
2600 }
2601 if (!strcmp(subs, "Se")) { /*selenium*/
2602 if (debug)
2603 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2604 Point->Se += mul;
2605 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2606 stripped = true;
2607 }
2608 if (!strcmp(subs, "Sn")) { /*tin*/
2609 if (debug)
2610 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2611 Point->Sn += mul;
2612 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2613 stripped = true;
2614 }
2615 if (!strcmp(subs, "Sr")) { /*strontium*/
2616 if (debug)
2617 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2618 Point->Sr += mul;
2619 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2620 stripped = true;
2621 }
2622 if (!strcmp(subs, "Ta")) { /*tantal*/
2623 if (debug)
2624 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2625 Point->Ta += mul;
2626 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2627 stripped = true;
2628 }
2629 if (!strcmp(subs, "Te")) { /*tellurium*/
2630 if (debug)
2631 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2632 Point->Te += mul;
2633 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2634 stripped = true;
2635 }
2636 if (!strcmp(subs, "Ti")) { /*titanium*/
2637 if (debug)
2638 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2639 Point->Ti += mul;
2640 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2641 stripped = true;
2642 }
2643 if (!strcmp(subs, "Tf")) { /*trifluoromethanesulfonyl, triflyl*/
2644 if (debug)
2645 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2646 Point->C += mul;
2647 Point->F += mul * 3;
2648 Point->O += mul * 2;
2649 Point->S += mul;
2650 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2651 stripped = true;
2652 }
2653 if (!strcmp(subs, "Tl")) { /*thallium*/
2654 if (debug)
2655 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2656 Point->Tl += mul;
2657 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2658 stripped = true;
2659 }
2660 if (!strcmp(subs, "Tr")) { /*trityl, triphenylmethyl*/
2661 if (debug)
2662 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2663 Point->C += mul * 19;
2664 Point->H += mul * 15;
2665 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2666 stripped = true;
2667 }
2668 if (!strcmp(subs, "Ts")) { /*toluenesulfonyl, tosyl*/
2669 if (debug)
2670 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2671 Point->C += mul * 7;
2672 Point->H += mul * 7;
2673 Point->O += mul * 2;
2674 Point->S += mul;
2675 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2676 stripped = true;
2677 }
2678 if (!strcmp(subs, "Si")) { /*silicon*/
2679 if (debug)
2680 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2681 Point->Si += mul;
2682 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2683 stripped = true;
2684 }
2685 if (!strcmp(subs, "Zn")) { /*zinc*/
2686 if (debug)
2687 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2688 Point->Zn += mul;
2689 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2690 stripped = true;
2691 }
2692 if (!strcmp(subs, "Zr")) { /*zirconium*/
2693 if (debug)
2694 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2695 Point->Zr += mul;
2696 strcpy(A, strsub(STR2, A, 3, (int)(strlen(A) - 2)));
2697 stripped = true;
2698 }
2699 }
2700 if ((int)strlen(A) < 1 || stripped)
2701 continue;
2702 snprintf(subs,256, "%.1s", A);
2703 if ((int)strlen(A) > 2) {
2704 if (A[1] == '_') {
2705 if (A[2]!= '{') {
2706 snprintf(STR2,256, "%c", A[2]);
2707 if (A[3]=='_') snprintf(STR2,256, "%c%c", A[2],A[4]);
2708 code = (sscanf(STR2, "%ld", &mul) == 0);
2709 }else{
2710 mul=3;
2711 while(A[mul]!='}'){STR2[mul-3]=A[mul]; mul++ ; }
2712 STR2[mul-2]='\0';
2713 code = (sscanf(STR2, "%ld", &mul) == 0);
2714 }
2715 } else
2716 mul = 1;
2717 }
2718 mul *= gmul * ggmul;
2719 if (!strcmp(subs, "B")) { /*boron*/
2720 if (debug)
2721 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2722 Point->B += mul;
2723 }
2724 if (!strcmp(subs, "C")) { /*carbon*/
2725 if (debug)
2726 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2727 Point->C += mul;
2728 }
2729 if (!strcmp(subs, "F")) { /*fluorine*/
2730 if (debug)
2731 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2732 Point->F += mul;
2733 }
2734 if (!strcmp(subs, "H")) { /*hydrogen*/
2735 if (debug)
2736 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2737 Point->H += mul;
2738 }
2739 if (!strcmp(subs, "I")) { /*iodine*/
2740 if (debug)
2741 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2742 Point->I += mul;
2743 }
2744 if (!strcmp(subs, "K")) { /*potassium*/
2745 if (debug)
2746 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2747 Point->K += mul;
2748 }
2749 if (!strcmp(subs, "N")) { /*nitrogen*/
2750 if (debug)
2751 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2752 Point->N += mul;
2753 }
2754 if (!strcmp(subs, "O")) { /*oxygen*/
2755 if (debug)
2756 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2757 Point->O += mul;
2758 }
2759 if (!strcmp(subs, "P")) { /*phosphorus*/
2760 if (debug)
2761 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2762 Point->P += mul;
2763 }
2764 if (!strcmp(subs, "S")) { /*sulfur*/
2765 if (debug)
2766 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2767 Point->S += mul;
2768 }
2769 if (!strcmp(subs, "V")) { /*vanadium*/
2770 if (debug)
2771 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2772 Point->V += mul;
2773 }
2774 if (!strcmp(subs, "W")) { /*tungsten*/
2775 if (debug)
2776 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2777 Point->W += mul;
2778 }
2779 if (!strcmp(subs, "Y")) { /*yttrium*/
2780 if (debug)
2781 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2782 Point->Ytt += mul;
2783 }
2784 if (!strcmp(subs, "Z")) { /*"Z", Benzyloxycarbonyl*/
2785 if (debug)
2786 printf(" %s*%ld (%ld,%ld)\n", subs, mul, gmul, ggmul);
2787 Point->C += mul * 8;
2788 Point->H += mul * 7;
2789 Point->O += mul * 2;
2790 }
2791 if (!strcmp(subs, ")")) /*reset gmul*/
2792 gmul = 1;
2793 if (!strcmp(subs, "]")) { /*reset gmul,ggmul*/
2794 gmul = 1;
2795 ggmul = 1;
2796 }
2797 if (true)
2798 strcpy(A, strsub(STR2, A, 2, (int)(strlen(A) - 1)));
2799 }
2800 }
2801 Point = Point->Last;
2802 }
2803 Point = Current;
2804 }
2805 }
2806
2807
main(argc,argv)2808 int main(argc, argv)
2809 int argc;
2810 Char *argv[];
2811 {
2812 Char STR1[256], STR2[256];
2813 Char *TEMP;
2814 boolean interactive=false;
2815
2816 PASCAL_MAIN(argc, argv);
2817 IFile = NULL;
2818 if (P_argc == 1) {
2819 printf("enter \"cht -h\" for help\n");
2820 _Escape(0);
2821 }
2822 C = 0;
2823 H = 0;
2824 N = 0;
2825 O = 0;
2826 P = 0;
2827 S = 0;
2828 Si = 0;
2829 B = 0;
2830 Br = 0;
2831 I = 0;
2832 Cl = 0;
2833 F = 0;
2834 Al = 0;
2835 Ag = 0;
2836 As = 0;
2837 Au = 0;
2838 Ba = 0;
2839 Be = 0;
2840 Bi = 0;
2841 Ca = 0;
2842 Cd = 0;
2843 Co = 0;
2844 Cr = 0;
2845 Cs = 0;
2846 Cu = 0;
2847 Fe = 0;
2848 Ga = 0;
2849 Ge = 0;
2850 Hf = 0;
2851 Hg = 0;
2852 In = 0;
2853 Ir = 0;
2854 Li = 0;
2855 Lu = 0;
2856 Mg = 0;
2857 Mn = 0;
2858 Mo = 0;
2859 Na = 0;
2860 Nb = 0;
2861 Ni = 0;
2862 Os = 0;
2863 K = 0;
2864 Pb = 0;
2865 Pd = 0;
2866 Pt = 0;
2867 Rb = 0;
2868 Re = 0;
2869 Rh = 0;
2870 Ru = 0;
2871 Sb = 0;
2872 Sc = 0;
2873 Se = 0;
2874 Sn = 0;
2875 Sr = 0;
2876 Ta = 0;
2877 Te = 0;
2878 Ti = 0;
2879 Tl = 0;
2880 V = 0;
2881 W = 0;
2882 Ytt = 0;
2883 Zn = 0;
2884 Zr = 0;
2885 verbose = false;
2886 debug = false;
2887 fa = false; /*no file assigned*/
2888 Count = 0;
2889 *Alert = '\0';
2890 for (rep = 1; rep < P_argc; rep++) {
2891 if (!strcmp(strcpy(STR2, P_argv[rep]), "-v") ||
2892 !strcmp(strcpy(STR1, P_argv[rep]), "--verbose"))
2893 verbose = true;
2894 if (!strcmp(strcpy(STR2, P_argv[rep]), "-d") ||
2895 !strcmp(strcpy(STR1, P_argv[rep]), "--debug"))
2896 debug = true;
2897 if (!strcmp(strcpy(STR2, P_argv[rep]), "-i") ||
2898 !strcmp(strcpy(STR1, P_argv[rep]), "--interpret"))
2899 interactive = true;
2900 if (!strcmp(strcpy(STR2, P_argv[rep]), "-h") ||
2901 !strcmp(strcpy(STR1, P_argv[rep]), "--help")) {
2902 printf("The Chemtool drawings analyzer 1.7\n");
2903 printf("*** Gizmo Head Software ***\n");
2904 printf(" Radek Liboska (c) 2001\n\n");
2905 printf("syntax: cht [-options] <filename.cht>\n\n");
2906 printf("Recognizes C,H,O,N,P,S,Si,B,Br,I,Cl,F,Al,Ag,As,Au,Ba,Be,Bi,Ca,Cd,Co,Cr,Cs,Cu,\nFe,Ga,Ge,Hf,Hg,In,Ir,Li,Lu,Mg,Mn,Mo,Na,Nb,Ni,Os,K,Pb,Pd,Pt,Rb,Re,Rh,Ru,Sb,Sc,Se,Sn,Sr,\nTa,Te,Ti,Tl,V,W,Y,Zn,Zr\n");
2907 printf(
2908 " Ac,Ade,Bn,Bu,Bz,BOC,Cyt,CE,DBAM,DMAM,DMTr,Et,Gua,iBu,iPr,Me,Ms,MOC,\n");
2909 printf(
2910 " MOM,MMTr,Ph,Pr,tBu,Tf,Thy,Tol,Tr,Ts,TBDMS,TBDPS,TMS,TMTr,Ura,Z\n");
2911 printf("Can handle two levels of parentheses; e.g. P[OCH(CH_3)_2]_3\n\n");
2912 printf("options:\n");
2913 printf(" -h or --help : this help\n");
2914 printf(" -v or --verbose : be verbose\n");
2915 printf(" -d or --debug : be more verbose\n\n");
2916 _Escape(0);
2917 }
2918 if (strcpy(STR2, P_argv[rep])[0] != '-') {
2919 strcpy(STR1, P_argv[rep]);
2920 strcpy(IFile_NAME, STR1);
2921 fa = true;
2922 }
2923 }
2924 if (!fa && !interactive) {
2925 printf("No file defined, enter \"cht -h\" for help\n");
2926 _Escape(1);
2927 }
2928 if (!interactive){
2929 if (IFile != NULL)
2930 IFile = freopen(IFile_NAME, "r", IFile);
2931 else
2932 IFile = fopen(IFile_NAME, "r");
2933 if (IFile == NULL)
2934 _EscIO2(FileNotFound, IFile_NAME);
2935 }else {
2936 if (IFile)fclose(IFile);
2937 IFile=tmpfile();
2938 fprintf(IFile,"Chemtool Version 1.0\ngeometry 100 100\n\bonds 0\natoms 1\n0 0 %s 0\n",IFile_NAME);
2939 rewind(IFile);
2940 }
2941 Point = (TPoint *)malloc(sizeof(TPoint));
2942 if (Point == NULL) {
2943 fprintf(stderr,"Could not allocate memory\n");
2944 exit(1);
2945 }
2946 Point->X = 0;
2947 Point->Y = 0;
2948 Point->C = 0;
2949 Point->H = 0;
2950 Point->N = 0;
2951 Point->O = 0;
2952 Point->P = 0;
2953 Point->S = 0;
2954 Point->Si = 0;
2955 Point->B = 0;
2956 Point->Br = 0;
2957 Point->Cl = 0;
2958 Point->F = 0;
2959 Point->I = 0;
2960 Point->Al = 0;
2961 Point->As = 0;
2962 Point->Au = 0;
2963 Point->Ba = 0;
2964 Point->Be = 0;
2965 Point->Bi = 0;
2966 Point->Ca = 0;
2967 Point->Cd = 0;
2968 Point->Co = 0;
2969 Point->Cr = 0;
2970 Point->Cs = 0;
2971 Point->Cu = 0;
2972 Point->Fe = 0;
2973 Point->Ga = 0;
2974 Point->Ge = 0;
2975 Point->Hf = 0;
2976 Point->Hg = 0;
2977 Point->In = 0;
2978 Point->Ir = 0;
2979 Point->Li = 0;
2980 Point->Lu = 0;
2981 Point->Mg = 0;
2982 Point->Mn = 0;
2983 Point->Mo = 0;
2984 Point->Na = 0;
2985 Point->Nb = 0;
2986 Point->Ni = 0;
2987 Point->Os = 0;
2988 Point->K = 0;
2989 Point->Pb = 0;
2990 Point->Pd = 0;
2991 Point->Pt = 0;
2992 Point->Rb = 0;
2993 Point->Re = 0;
2994 Point->Rh = 0;
2995 Point->Ru = 0;
2996 Point->Sb = 0;
2997 Point->Sc = 0;
2998 Point->Se = 0;
2999 Point->Sn = 0;
3000 Point->Sr = 0;
3001 Point->Ta = 0;
3002 Point->Te = 0;
3003 Point->Ti = 0;
3004 Point->Tl = 0;
3005 Point->V = 0;
3006 Point->W = 0;
3007 Point->Ytt = 0;
3008 Point->Zn = 0;
3009 Point->Zr = 0;
3010 Point->RecCount = Count;
3011 Point->Last = NULL;
3012 Bond = (TBond *)malloc(sizeof(TBond));
3013 if (Bond == NULL) {
3014 fprintf(stderr,"Could not allocate memory\n");
3015 exit(1);
3016 }
3017 Bond->X1 = 0;
3018 Bond->Y1 = 0;
3019 Bond->X2 = 0;
3020 Bond->Y2 = 0;
3021 Bond->RecCount = Count;
3022 Bond->Last = NULL;
3023 if (!fgets(sss, 256, IFile))exit(2);
3024 TEMP = strchr(sss, '\n');
3025 if (TEMP != NULL)
3026 *TEMP = 0;
3027 snprintf(sss,256, "%.18s", strcpy(STR1, sss));
3028 if (strcmp(sss, "Chemtool Version 1")) {
3029 printf("Not a chemtool 1.x file, enter \"cht -h\" for help\n");
3030 printf("file starts: %s\n",sss);
3031 _Escape(2);
3032 }
3033 if (fscanf(IFile, "%*[^\n]") == EOF) exit(2);
3034 getc(IFile);
3035 if (!fgets(sssb, 7, IFile))exit(2);
3036 TEMP = strchr(sssb, '\n');
3037 if (TEMP != NULL) {
3038 *TEMP = 0;
3039 ungetc('\n', IFile);
3040 }
3041 if (fscanf(IFile, "%ld%*[^\n]", &bonds) == EOF) bonds = 0;
3042 getc(IFile);
3043 if (bonds == 0)
3044 nobonds = true;
3045 if (!strcmp(sssb, "bonds ")) {
3046 if (bonds > 0)
3047 doBonds();
3048 }
3049 if (!fgets(sssb, 7, IFile))exit(2);
3050 TEMP = strchr(sssb, '\n');
3051 if (TEMP != NULL) {
3052 *TEMP = 0;
3053 ungetc('\n', IFile);
3054 }
3055 if (fscanf(IFile, "%ld%*[^\n]", &atoms) == EOF) atoms = 0;
3056 getc(IFile);
3057 if (!strcmp(sssb, "atoms ")) {
3058 if (atoms > 0)
3059 doLabels();
3060 }
3061 if (IFile != NULL)
3062 fclose(IFile);
3063 IFile = NULL;
3064 if (verbose)
3065 printf("---------------------- Summary -------------------------\n");
3066 while (Point->Last != NULL) {
3067 if (verbose)
3068 printf(
3069 "RecCount: %ld X=%ld Y=%ld C%ld H%ld N%ld O%ld P%ld S%ld Si%ld B%ld\nBr%ld Cl%ld F%ld I%ld Al%ld Ag%ld As%ld Au%ld Ba%ld Be%ld Bi%ld Ca%ld Cd%ld Co%ld\nCr%ld Cs%ld Cu%ld Fe%ld Ga%ld Ge%ld Hf%ld Hg%ld In%ld Ir%ld Li%ld Lu%ld Mg%ld Mn%ld\n Mo%ld Na%ld Nb%ld Ni%ld Os%ld K%ld Pb%ld Pd%ld Pt%ld Rb%ld Re%ld Rh%ld Ru%ld Sb%ld\n Sc%ld Se%ld Sn%ld Sr%ld Ta%ld Te%ld Ti%ld Tl%ld V%ld W%ld Y%ld Zn%ld Zr%ld\n",
3070 Point->RecCount, Point->X, Point->Y, Point->C, Point->H, Point->N,
3071 Point->O, Point->P, Point->S, Point->Si, Point->B, Point->Br,
3072 Point->Cl, Point->F, Point->I, Point->Al, Point->Ag, Point->As, Point->Au, Point->Ba,
3073 Point->Be,Point->Bi, Point->Ca, Point->Cd, Point->Co,
3074 Point->Cr, Point->Cs,Point->Cu,Point->Fe,Point->Ga,Point->Ge,Point->Hf,Point->Hg,
3075 Point->In, Point->Ir, Point->Li,Point->Lu,Point->Mg, Point->Mn, Point->Mo, Point->Na, Point->Nb,Point->Ni,
3076 Point->Os,Point->K,Point->Pb,Point->Pd, Point->Pt, Point->Rb, Point->Re, Point->Rh, Point->Ru,
3077 Point->Sb,Point->Sc,Point->Se,Point->Sn,Point->Sr,Point->Ta,
3078 Point->Te,Point->Ti,Point->Tl,Point->V,Point->W,Point->Ytt,Point->Zn,Point->Zr);
3079 C += Point->C;
3080 H += Point->H;
3081 N += Point->N;
3082 O += Point->O;
3083 P += Point->P;
3084 S += Point->S;
3085 Si += Point->Si;
3086 B += Point->B;
3087 Br += Point->Br;
3088 Cl += Point->Cl;
3089 F += Point->F;
3090 I += Point->I;
3091 Al += Point->Al;
3092 Ag += Point->Ag;
3093 As += Point->As;
3094 Au += Point->Au;
3095 Ba += Point->Ba;
3096 Be += Point->Be;
3097 Bi += Point->Bi;
3098 Ca += Point->Ca;
3099 Cd += Point->Cd;
3100 Co += Point->Co;
3101 Cr += Point->Cr;
3102 Cs += Point->Cs;
3103 Cu += Point->Cu;
3104 Fe += Point->Fe;
3105 Ga += Point->Ga;
3106 Ge += Point->Ge;
3107 Hf += Point->Hf;
3108 Hg += Point->Hg;
3109 In += Point->In;
3110 Ir += Point->Ir;
3111 Li += Point->Li;
3112 Lu += Point->Lu;
3113 Mg += Point->Mg;
3114 Mn += Point->Mn;
3115 Mo += Point->Mo;
3116 Na += Point->Na;
3117 Nb += Point->Nb;
3118 Ni += Point->Ni;
3119 Os += Point->Os;
3120 K += Point->K;
3121 Pb += Point->Pb;
3122 Pd += Point->Pd;
3123 Pt += Point->Pt;
3124 Rb += Point->Rb;
3125 Re += Point->Re;
3126 Rh += Point->Rh;
3127 Ru += Point->Ru;
3128 Sb += Point->Sb;
3129 Sc += Point->Sc;
3130 Se += Point->Se;
3131 Sn += Point->Sn;
3132 Sr += Point->Sr;
3133 Ta += Point->Ta;
3134 Te += Point->Te;
3135 Ti += Point->Ti;
3136 Tl += Point->Tl;
3137 V += Point->V;
3138 W += Point->W;
3139 Ytt += Point->Ytt;
3140 Zn += Point->Zn;
3141 Zr += Point->Zr;
3142 Point = Point->Last;
3143 }
3144
3145 if (H < 0) /*overlapped bonds*/
3146 H = 0;
3147
3148 M = (double)C * 12.011 + (double)H * 1.0079 + (double)N * 14.0067 + (double)O * 15.9994 + (double)P * 30.97376 +
3149 (double)S * 32.064 + (double)Si * 28.086 + (double)B * 10.81 + (double)Br * 79.904 + (double)Cl * 35.453 +
3150 (double)F * 18.9984 + (double)I * 126.9045 + (double)Mg * 24.305 + (double)Na * 22.98977 + (double)K * 39.098 +
3151 (double)Ca * 40.08 + (double)Cd * 112.41 + (double)Co * 58.933 + (double)Cr * 51.996 + (double)Cu * 63.546 +
3152 (double)Fe * 55.847 + (double)Li * 6.941 + (double)Mn * 54.938 + (double)Ni * 58.69 + (double)Al * 26.981539 +
3153 (double)Ba * 137.327 + (double)Cs * 132.90543 + (double)As * 74.92159 + (double)Be *9.012182 +
3154 (double)Ga * 69.723 + (double)Ge * 72.61 + (double)Sb * 121.75 + (double)Sc * 44.95591 + (double)Se * 78.96 +
3155 (double)Sn * 118.710 + (double)Sr * 87.62 + (double)Rb * 85.4678 + (double)Te * 127.60 + (double)Ti * 47.88 +
3156 (double)V * 50.9415 + (double)Zn * 65.39 + (double)In * 114.82 + (double)Bi * 208.98037 + (double)Pb *207.2 +
3157 (double)Tl * 204.3833 + (double)Zr *91.224 + (double)Nb * 92.906 + (double)Mo*95.94 +
3158 (double)Ru * 101.07 + (double)Rh *102.9055 + (double)Re * 186.207 + (double)Pd *106.42 +
3159 (double)Ag *107.868 + (double)Pt *195.078 + (double)Ir * 192.217 + (double)Hg * 200.59 +
3160 (double)Os *190.2 + (double)W * 183.84 + (double)Au * 196.966 + (double)Ta *180.948 +
3161 (double)Hf * 178.49 + (double)Ytt * 88.906 + (double)Lu *174.967;
3162
3163 Me = (double)C * 12. + (double)H * 1.007825037 + (double)N * 14.003074008 + (double)O * 15.99491464 +
3164 (double)P * 30.9737634 + (double)S * 31.9720718 + (double)Si * 27.9769284 + (double)B * 11.0093053 +
3165 (double)Br * 78.9183361 + (double)Cl * 34.968852729 + (double)F * 18.99840325 +
3166 (double)I * 126.904477 + (double)Mg * 23.9850450 + (double)Na * 22.9897697 + (double)K * 38.9637079 +
3167 (double)Ca * 39.9626 + (double)Cd * 113.9034 + (double)Co * 58.9332 + (double)Cr * 51.9405 + (double)Cu * 62.9296 +
3168 (double)Fe * 55.9349 +(double)Li * 7.0160 + (double)Mn * 54.93805 + (double)Ni * 57.9353 + (double)Al * 26.981539 +
3169 (double)Ba * 137.9052 + (double)Cs * 132.90543 + (double)As * 74.92159 + (double)Be * 9.012182 +
3170 (double)Ga * 68.9256 + (double)Ge * 73.9212 + (double)Sb * 120.9038 + (double)Sc * 44.95591 +
3171 (double)Se *79.9165 + (double)Sn * 119.9022 + (double)Sr * 87.9056 + (double)Rb * 84.9118 +
3172 (double)Te * 129.9062 + (double)Ti * 47.9479 + (double)V * 50.9440 + (double)Zn * 63.9291 +
3173 (double)In * 114.9039 + (double)Bi * 208.98037 + (double)Pb * 207.9766 + (double)Tl * 204.9744 +
3174 (double)Zr * 89.9047 + (double)Nb *92.9064 + (double)Mo * 97.9054 + (double)Ru * 101.9043 +
3175 (double)Rh * 102.9055 + (double)Re * 186.9558 + (double)Pd * 105.9035 +(double)Ag * 106.9051 +
3176 (double)Pt * 194.9648 + (double)Ir * 192.9629 + (double)Hg * 201.9706 +(double)Os * 191.9615 +
3177 (double)W * 183.9510 + (double)Au * 196.9666 + (double)Ta * 180.9480 + (double)Hf * 179.9466 +
3178 (double)Ytt * 88.9059 + (double)Lu * 174.9408;
3179
3180 if (Me > 0 && *Alert == '\0') {
3181 if (C > 1)
3182 printf("C%ld", C);
3183 if (C == 1)
3184 putchar('C');
3185 if (H > 1)
3186 printf("H%ld", H);
3187 if (H == 1)
3188 putchar('H');
3189 if (N > 1)
3190 printf("N%ld", N);
3191 if (N == 1)
3192 putchar('N');
3193 if (O > 1)
3194 printf("O%ld", O);
3195 if (O == 1)
3196 putchar('O');
3197 if (P > 1)
3198 printf("P%ld", P);
3199 if (P == 1)
3200 putchar('P');
3201 if (S > 1)
3202 printf("S%ld", S);
3203 if (S == 1)
3204 putchar('S');
3205 if (Si > 1)
3206 printf("Si%ld", Si);
3207 if (Si == 1)
3208 printf("Si");
3209 if (B > 1)
3210 printf("B%ld", B);
3211 if (B == 1)
3212 putchar('B');
3213 if (Br > 1)
3214 printf("Br%ld", Br);
3215 if (Br == 1)
3216 printf("Br");
3217 if (Cl > 1)
3218 printf("Cl%ld", Cl);
3219 if (Cl == 1)
3220 printf("Cl");
3221 if (F > 1)
3222 printf("F%ld", F);
3223 if (F == 1)
3224 putchar('F');
3225 if (I > 1)
3226 printf("I%ld", I);
3227 if (I == 1)
3228 putchar('I');
3229 if (Ag > 1)
3230 printf("Ag%ld", Ag);
3231 if (Ag == 1)
3232 printf("Ag");
3233 if (Al > 1)
3234 printf("Al%ld", Al);
3235 if (Al == 1)
3236 printf("Al");
3237 if (As > 1)
3238 printf("As%ld", As);
3239 if (As == 1)
3240 printf("As");
3241 if (Au > 1)
3242 printf("Au%ld", Au);
3243 if (Au == 1)
3244 printf("Au");
3245 if (Ba > 1)
3246 printf("Ba%ld", Ba);
3247 if (Ba == 1)
3248 printf("Ba");
3249 if (Be > 1)
3250 printf("Be%ld", Be);
3251 if (Be == 1)
3252 printf("Be");
3253 if (Bi > 1)
3254 printf("Bi%ld", Bi);
3255 if (Bi == 1)
3256 printf("Bi");
3257 if (Ca > 1)
3258 printf("Ca%ld", Ca);
3259 if (Ca == 1)
3260 printf("Ca");
3261 if (Cd > 1)
3262 printf("Cd%ld", Cd);
3263 if (Cd == 1)
3264 printf("Cd");
3265 if (Co > 1)
3266 printf("Co%ld", Co);
3267 if (Co == 1)
3268 printf("Co");
3269 if (Cr > 1)
3270 printf("Cr%ld", Cr);
3271 if (Cr == 1)
3272 printf("Cr");
3273 if (Cs > 1)
3274 printf("Cs%ld", Cs);
3275 if (Cs == 1)
3276 printf("Cs");
3277 if (Cu > 1)
3278 printf("Cu%ld", Cu);
3279 if (Cu == 1)
3280 printf("Cu");
3281 if (Fe > 1)
3282 printf("Fe%ld", Fe);
3283 if (Fe == 1)
3284 printf("Fe");
3285 if (Ga > 1)
3286 printf("Ga%ld", Ga);
3287 if (Ga == 1)
3288 printf("Ga");
3289 if (Ge > 1)
3290 printf("Ge%ld", Ge);
3291 if (Ge == 1)
3292 printf("Ge");
3293 if (Hf > 1)
3294 printf("Hf%ld", Hf);
3295 if (Hf == 1)
3296 printf("Hf");
3297 if (Hg > 1)
3298 printf("Hg%ld", Hg);
3299 if (Hg == 1)
3300 printf("Hg");
3301 if (In > 1)
3302 printf("In%ld", In);
3303 if (In == 1)
3304 printf("In");
3305 if (Ir > 1)
3306 printf("Ir%ld", Ir);
3307 if (Ir == 1)
3308 printf("Ir");
3309 if (K > 1)
3310 printf("K%ld", K);
3311 if (K == 1)
3312 putchar('K');
3313 if (Li > 1)
3314 printf("Li%ld", Li);
3315 if (Li == 1)
3316 printf("Li");
3317 if (Lu > 1)
3318 printf("Lu%ld", Lu);
3319 if (Lu == 1)
3320 printf("Lu");
3321 if (Mg > 1)
3322 printf("Mg%ld", Mg);
3323 if (Mg == 1)
3324 printf("Mg");
3325 if (Mn > 1)
3326 printf("Mn%ld", Mn);
3327 if (Mn == 1)
3328 printf("Mn");
3329 if (Mo > 1)
3330 printf("Mo%ld", Mo);
3331 if (Mo == 1)
3332 printf("Mo");
3333 if (Na > 1)
3334 printf("Na%ld", Na);
3335 if (Na == 1)
3336 printf("Na");
3337 if (Nb > 1)
3338 printf("Nb%ld", Nb);
3339 if (Nb == 1)
3340 printf("Nb");
3341 if (Ni > 1)
3342 printf("Ni%ld", Ni);
3343 if (Ni == 1)
3344 printf("Ni");
3345 if (Os > 1)
3346 printf("Os%ld", Os);
3347 if (Os == 1)
3348 printf("Os");
3349 if (Pb > 1)
3350 printf("Pb%ld", Pb);
3351 if (Pb == 1)
3352 printf("Pb");
3353 if (Pd > 1)
3354 printf("Pd%ld", Pd);
3355 if (Pd == 1)
3356 printf("Pd");
3357 if (Pt > 1)
3358 printf("Pt%ld", Pt);
3359 if (Pt == 1)
3360 printf("Pt");
3361 if (Rb > 1)
3362 printf("Rb%ld", Rb);
3363 if (Rb == 1)
3364 printf("Rb");
3365 if (Re > 1)
3366 printf("Re%ld", Re);
3367 if (Re == 1)
3368 printf("Re");
3369 if (Rh > 1)
3370 printf("Rh%ld", Rh);
3371 if (Rh == 1)
3372 printf("Rh");
3373 if (Ru > 1)
3374 printf("Rb%ld", Ru);
3375 if (Ru == 1)
3376 printf("Ru");
3377 if (Sb > 1)
3378 printf("Sb%ld", Sb);
3379 if (Sb == 1)
3380 printf("Sb");
3381 if (Sc > 1)
3382 printf("Sc%ld", Sc);
3383 if (Sc == 1)
3384 printf("Sc");
3385 if (Se > 1)
3386 printf("Se%ld", Se);
3387 if (Se == 1)
3388 printf("Se");
3389 if (Sn > 1)
3390 printf("Sn%ld", Sn);
3391 if (Sn == 1)
3392 printf("Sn");
3393 if (Sr > 1)
3394 printf("Sr%ld", Sr);
3395 if (Sr == 1)
3396 printf("Sr");
3397 if (Ta > 1)
3398 printf("Ta%ld", Ta);
3399 if (Ta == 1)
3400 printf("Ta");
3401 if (Te > 1)
3402 printf("Te%ld", Te);
3403 if (Te == 1)
3404 printf("Te");
3405 if (Ti > 1)
3406 printf("Ti%ld", Ti);
3407 if (Ti == 1)
3408 printf("Ti");
3409 if (Tl > 1)
3410 printf("Tl%ld", Tl);
3411 if (Tl == 1)
3412 printf("Tl");
3413 if (V > 1)
3414 printf("V%ld", V);
3415 if (V == 1)
3416 printf("V");
3417 if (W > 1)
3418 printf("W%ld", W);
3419 if (W == 1)
3420 printf("W");
3421 if (Ytt > 1)
3422 printf("Y%ld", Ytt);
3423 if (Ytt == 1)
3424 printf("Y");
3425 if (Zn > 1)
3426 printf("Zn%ld", Zn);
3427 if (Zn == 1)
3428 printf("Zn");
3429 if (Zr > 1)
3430 printf("Zr%ld", Zr);
3431 if (Zr == 1)
3432 printf("Zr");
3433
3434 printf(" [%2.3f]", M);
3435 printf(" Me=%2.10f ", Me);
3436
3437 if (C > 0)
3438 printf("%4.2f%%C;", (double)C * 12.011 * 100 / M);
3439 if (H > 0)
3440 printf("%4.2f%%H;", (double)H * 1.0079 * 100 / M);
3441 if (B > 0)
3442 printf("%4.2f%%B;", (double)B * 10.81 * 100 / M);
3443 if (N > 0)
3444 printf("%4.2f%%N;", (double)N * 14.0067 * 100 / M);
3445 if (O > 0)
3446 printf("%4.2f%%O;", (double)O * 15.9994 * 100 / M);
3447 if (P > 0)
3448 printf("%4.2f%%P;", (double)P * 30.97376 * 100 / M);
3449 if (S > 0)
3450 printf("%4.2f%%S;", (double)S * 32.0640 * 100 / M);
3451 if (K > 0)
3452 printf("%4.2f%%K;", (double)K * 39.098 * 100 / M);
3453 if (Mg > 0)
3454 printf("%4.2f%%Mg;", (double)Mg * 24.305 * 100 / M);
3455 if (Na > 0)
3456 printf("%4.2f%%Na;", (double)Na * 22.98977 * 100 / M);
3457 if (Si > 0)
3458 printf("%4.2f%%Si;", (double)Si * 28.086 * 100 / M);
3459 if (Br > 0)
3460 printf("%4.2f%%Br;", (double)Br * 79.904 * 100 / M);
3461 if (Cl > 0)
3462 printf("%4.2f%%Cl;", (double)Cl * 35.453 * 100 / M);
3463 if (F > 0)
3464 printf("%4.2f%%F;", (double)F * 18.9984 * 100 / M);
3465 if (I > 0)
3466 printf("%4.2f%%I;", (double)I * 126.9045 * 100 / M);
3467 if (Ag >0)
3468 printf("%4.2f%%Ag;", (double)Ag * 107.868 * 100 / M);
3469 if (Al >0)
3470 printf("%4.2f%%Al;", (double)Al * 26.981539 * 100 / M);
3471 if (As >0)
3472 printf("%4.2f%%As;", (double)As * 74.92159 * 100 / M);
3473 if (Au >0)
3474 printf("%4.2f%%Au;", (double)Au * 196.966 * 100 / M);
3475 if (Ba >0)
3476 printf("%4.2f%%Ba;", (double)Ba * 137.327 * 100 / M);
3477 if (Be >0)
3478 printf("%4.2f%%Be;", (double)Be * 9.012182 * 100 / M);
3479 if (Bi >0)
3480 printf("%4.2f%%Bi;", (double)Bi * 208.98037 * 100 / M);
3481 if (Ca >0)
3482 printf("%4.2f%%Ca;", (double)Ca * 40.08 * 100 / M);
3483 if (Cd >0)
3484 printf("%4.2f%%Cd;", (double)Cd * 112.41 * 100 / M);
3485 if (Co >0)
3486 printf("%4.2f%%Co;", (double)Co * 58.993 * 100 / M);
3487 if (Cr >0)
3488 printf("%4.2f%%Cr;", (double)Cr * 51.996 * 100 / M);
3489 if (Cs >0)
3490 printf("%4.2f%%Cs;", (double)Cs * 132.90543 * 100 / M);
3491 if (Cu >0)
3492 printf("%4.2f%%Cu;", (double)Cu * 63.546 * 100 / M);
3493 if (Fe >0)
3494 printf("%4.2f%%Fe;", (double)Fe * 55.847 * 100 / M);
3495 if (Ga >0)
3496 printf("%4.2f%%Ga;", (double)Ga * 69.723 * 100 / M);
3497 if (Ge >0)
3498 printf("%4.2f%%Ge;", (double)Ge * 72.61 * 100 / M);
3499 if (Hf >0)
3500 printf("%4.2f%%Hf;", (double)Hf * 178.49 * 100 / M);
3501 if (Hg >0)
3502 printf("%4.2f%%Hg;", (double)Hg * 200.59 * 100 / M);
3503 if (In >0)
3504 printf("%4.2f%%In;", (double)In * 114.82 * 100 / M);
3505 if (Ir >0)
3506 printf("%4.2f%%Ir;", (double)Ir * 192.217 * 100 / M);
3507 if (Li >0)
3508 printf("%4.2f%%Li;", (double)Li * 6.941 * 100 / M);
3509 if (Lu >0)
3510 printf("%4.2f%%Lu;", (double)Lu * 174.967 * 100 / M);
3511 if (Mn >0)
3512 printf("%4.2f%%Mn;", (double)Mn * 54.938 * 100 / M);
3513 if (Mo >0)
3514 printf("%4.2f%%Mo;", (double)Mo * 95.94 * 100 / M);
3515 if (Nb >0)
3516 printf("%4.2f%%Nb;", (double)Nb * 92.906 *100 / M);
3517 if (Ni >0)
3518 printf("%4.2f%%Ni;", (double)Ni * 58.69 *100 / M);
3519 if (Os >0)
3520 printf("%4.2f%%Os;", (double)Os * 190.2 *100 / M);
3521 if (Pb >0)
3522 printf("%4.2f%%Pb;", (double)Pb * 207.2 *100 / M);
3523 if (Pd >0)
3524 printf("%4.2f%%Pd;", (double)Pd * 106.42 *100 / M);
3525 if (Pt >0)
3526 printf("%4.2f%%Pt;", (double)Pt * 195.078 *100 / M);
3527 if (Rb >0)
3528 printf("%4.2f%%Rb;", (double)Rb * 85.4678 *100 / M);
3529 if (Re >0)
3530 printf("%4.2f%%Re;", (double)Re * 186.207 *100 / M);
3531 if (Rh >0)
3532 printf("%4.2f%%Rh;", (double)Rh * 102.9055 *100 / M);
3533 if (Ru >0)
3534 printf("%4.2f%%Ru;", (double)Ru * 101.07 *100 / M);
3535 if (Sb >0)
3536 printf("%4.2f%%Sb;", (double)Sb * 121.75 *100 / M);
3537 if (Sc >0)
3538 printf("%4.2f%%Sc;", (double)Sc * 44.95591 *100 / M);
3539 if (Se >0)
3540 printf("%4.2f%%Se;", (double)Se * 78.96 *100 / M);
3541 if (Sn >0)
3542 printf("%4.2f%%Sn;", (double)Sn * 118.71 *100 / M);
3543 if (Sr >0)
3544 printf("%4.2f%%Sr;", (double)Sr * 87.62 *100 / M);
3545 if (Ta >0)
3546 printf("%4.2f%%Ta;", (double)Ta * 180.948 *100 / M);
3547 if (Te >0)
3548 printf("%4.2f%%Te;", (double)Te * 127.60 *100 / M);
3549 if (Ti >0)
3550 printf("%4.2f%%Ti;", (double)Ti * 47.88 *100 / M);
3551 if (Tl >0)
3552 printf("%4.2f%%Tl;", (double)Tl * 204.3833 *100 / M);
3553 if (V >0)
3554 printf("%4.2f%%V;", (double)V * 50.9415 *100 / M);
3555 if (W >0)
3556 printf("%4.2f%%W;", (double)W * 183.84 *100 / M);
3557 if (Ytt >0)
3558 printf("%4.2f%%Y;", (double)Ytt * 88.906 *100 / M);
3559 if (Zn >0)
3560 printf("%4.2f%%Zn;", (double)Zn * 65.39 *100. / M);
3561 if (Zr >0)
3562 printf("%4.2f%%Zr;", (double)Zr * 91.224 *100. / M);
3563 } else {
3564 if (*Alert != '\0')
3565 printf("%s overlapped bonds !", Alert);
3566 else
3567 printf("C0H0 [0.00] Me=0.0000000000 0.00%%C;0.00%%H");
3568 }
3569 putchar('\n');
3570 exit(EXIT_SUCCESS);
3571 }
3572
3573
3574
3575 /* End. */
3576