/* * adds a keyword to the compiler */ keyword_t *keywords_add (const char *str, const int tagval, const unsigned int langtag, origin_t *origin) { keyword_t *kw = keywords_lookup (str, strlen (str), 0); #if 0 fhandle_printf (FHAN_STDERR, "keywords_add(): adding [%s]\n", str); #endif if (kw) { /* already got one */ if ((kw->langtag & LANGTAG_LANGMASK) == (langtag & LANGTAG_LANGMASK)) { nocc_warning ("already got keyword [%s]", str); return kw; } /* merge in this one */ if ((kw->langtag & LANGTAG_IMASK) & (langtag & LANGTAG_IMASK)) { nocc_serious ("clobbering implementation-specific flags in keyword [%s]", str); } kw->langtag |= langtag; return kw; } kw = (keyword_t *)smalloc (sizeof (keyword_t)); kw->name = string_dup ((char *)str); kw->tagval = tagval; kw->langtag = langtag; kw->origin = origin; stringhash_insert (extrakeywords, kw, kw->name); return kw; }
int extract_alias_residue_define(stringhash *h, const char *altres, const char *realres) { if ( ! h || ! altres || ! realres || stringhash_insert(h,altres,realres) == STRINGHASH_FAIL ) { return EXTRACT_ALIAS_FAIL; } return 0; }
int extract_alias_atom_define(stringhash *h, const char *resname, const char *altatom, const char *realatom) { char resatom[24]; const char *resname2; if ( ! h || ! resname || ! altatom || ! realatom ) return EXTRACT_ALIAS_FAIL; if ( strlen(resname) + strlen(altatom) > 20 ) return EXTRACT_ALIAS_FAIL; sprintf(resatom,"%s %s",resname,altatom); if ( stringhash_insert(h,resatom,realatom) == STRINGHASH_FAIL ) { return EXTRACT_ALIAS_FAIL; } resname2 = extract_alias_residue_check(h,resname); if ( resname == resname2 ) return 0; resname = resname2; if ( strlen(resname) + strlen(altatom) > 20 ) return EXTRACT_ALIAS_FAIL; sprintf(resatom,"%s %s",resname,altatom); if ( stringhash_insert(h,resatom,realatom) == STRINGHASH_FAIL ) { return EXTRACT_ALIAS_FAIL; } return 0; }