UINT32 AcpiUtToUpper ( UINT32 c) { return (IS_LOWER(c) ? ((c)-0x20) : (c)); }
static void DoThesis (PubdescPtr pdp, Pointer userdata) { CitBookPtr cbp; Char ch; ScanDataPtr sdp; CharPtr title, tmp; ValNodePtr ttl, vnp; if (pdp == NULL) return; for (vnp = pdp->pub; vnp != NULL; vnp = vnp->next) { if (vnp->choice == PUB_Man) { cbp = (CitBookPtr) vnp->data.ptrvalue; if (cbp != NULL) { ttl = cbp->title; if (ttl != NULL) { title = (CharPtr) ttl->data.ptrvalue; if (! StringHasNoText (title)) { if (StringLen (title) > 3) { ch = *title; if (IS_LOWER (ch)) { tmp = title; ch = *tmp; while (ch != '\0' && (! (IS_WHITESP (ch)))) { tmp++; ch = *tmp; } *tmp = '\0'; sdp = (ScanDataPtr) userdata; RecordThesis (sdp, title); } } } } } } } }
/***************************************************************************** * * void AsnSetTags(atp) * automatically assign CONTEXT tags to named elements * if (tagnumer == -1) then not explicitly assigned in spec * if (>= 0) then tag is assumed already assigned and not reassigned * *****************************************************************************/ NLM_EXTERN void AsnSetTags (AsnTypePtr atp) { int ctr = 0; Int2 isa; AsnTypePtr orig; if (atp == NULL) return; /* find highest set tag */ for (orig = atp; atp != NULL; atp = atp->next) { if (atp->name != NULL) { if (IS_LOWER(*atp->name)) /* identifier, not Type */ { if ((atp->tagclass == TAG_NONE) || /* context tag set? */ (atp->tagclass == TAG_CONTEXT)) { atp->tagclass = TAG_CONTEXT; if (atp->tagnumber > ctr) /* set default higher */ ctr = (int)(atp->tagnumber + 1); } } } } atp = orig; while (atp != NULL) { if (atp->type != NULL) { isa = atp->type->isa; switch (isa) { case SEQOF_TYPE: case SETOF_TYPE: /* check subtypes */ case SEQ_TYPE: case SET_TYPE: case CHOICE_TYPE: AsnSetTags((AsnTypePtr) atp->branch); break; default: break; } } if (atp->name != NULL) { if (IS_LOWER(*atp->name)) /* identifier, not Type */ { if (atp->tagclass == TAG_CONTEXT) /* assign it */ { if (atp->tagnumber < 0) /* not assigned */ { atp->tagnumber = ctr; ctr++; } } } } atp = atp->next; } return; }
/***************************************************************************** * * Int2 AsnLexTWord(aip) * reads words, punctuation, and asn keywords with 2 parts * returns tokens defined at top * *****************************************************************************/ NLM_EXTERN Int2 AsnLexTWord (AsnIoPtr aip) { register CharPtr pos; register int len; Int1 state; Int2 token, asntype, linepos; int done; Boolean first = FALSE, hitnewline = FALSE; CharPtr commentptr; if (! aip->bytes) /* no data loaded */ { hitnewline = TRUE; first = TRUE; AsnIoGets(aip); } linepos = aip->linepos; pos = aip->linebuf + linepos; state = aip->state; len = 0; token = -1; while (*pos == '\n' || *pos == '\r') /* skip empty lines */ { hitnewline = TRUE; pos = AsnIoGets(aip); if (pos == NULL) return EOF_TOKEN; } if (state == IN_STRING_STATE) { aip->word = pos; if (* pos == '\"') /* end of string */ { token = END_STRING; pos++; state = 0; /* reset state */ } else { token = IN_STRING; while ((* pos != '\"') && (* pos != '\n') && (* pos != '\r')) { pos++; len++; } if ((*pos != '\n') && (*pos != '\r') && (* (pos + 1) == '\"')) /* internal quote */ { len++; /* include in previous string */ pos += 2; /* point to rest of string */ } } } else if (state == IN_BITHEX_STATE) { aip->word = pos; if (*pos == '\'') /* end of binhex */ { state = 0; /* set to normal */ pos++; /* move past quote */ while (IS_WHITESP(*pos)) pos++; if (* pos == 'H') token = OCTETS; else if (* pos == 'B') token = ASNBITS; else { AsnIoErrorMsg(aip, 58, aip->linenumber); token = ERROR_TOKEN; } } else { token = IN_BITHEX; while ((* pos != '\'') && (* pos != '\n') && (* pos != '\r')) { pos++; len++; } } } else /* normal scanning */ { done = 0; while (! done) { while (* pos <= ' ') /* skip leading white space */ { if (*pos == '\n' || *pos == '\r') { hitnewline = TRUE; pos = AsnIoGets(aip); if (pos == NULL) return EOF_TOKEN; } else pos++; } done = 1; while (done && (*pos == '-') && (*(pos+1) == '-')) /* skip comments */ { pos += 2; if (first) /* could be revision */ { first = FALSE; if (StrMatch(asnwords[57], pos, 10)) /* $Revision: */ { token = REVISION_TOKEN; pos += 10; while (IS_WHITESP(*pos)) pos++; aip->word = pos; while (IS_DIGIT(*pos)) /* eg. 1.2 */ { len++; pos++; } if (*pos == '.') /* take after . if present */ { pos++; len++; while (IS_DIGIT(*pos)) { len++; pos++; } } } } commentptr = pos; done = 0; while (! done) /* skip to end of comment */ { if ((*pos == '-') && (*(pos +1) == '-')) { if (token != REVISION_TOKEN) { AsnLexTAddComment(commentptr, pos, aip); if ((! hitnewline) && (aip->token != COMMENT_TOKEN)) token = COMMENT_TOKEN; } pos += 2; done = 1; } else if (*pos == '\n' || *pos == '\r') { if (token != REVISION_TOKEN) { AsnLexTAddComment(commentptr, pos, aip); if ((! hitnewline) && (aip->token != COMMENT_TOKEN)) token = COMMENT_TOKEN; } done = 1; } else pos++; } if ((token == REVISION_TOKEN) || (token == COMMENT_TOKEN)) { aip->linepos = pos - aip->linebuf; aip->state = state; aip->wordlen = len; aip->token = token; return token; } if (*pos <= ' ') done = 0; else done = 1; } } aip->word = pos; if (* pos == '\"') { token = START_STRING; state = IN_STRING_STATE; } else if (* pos == '\'') { token = START_BITHEX; state = IN_BITHEX_STATE; } else if (* pos == ',') token = COMMA; else if (* pos == '{') token = START_STRUCT; else if (* pos == '}') token = END_STRUCT; else if (* pos == '[') token = START_TAG; else if (* pos == ']') token = END_TAG; else if (* pos == '(') token = OPEN_PAREN; else if (* pos == ')') token = CLOSE_PAREN; else if (* pos == ';') token = SEMI_COLON; else if (* pos == ':') { if ((*(pos + 1) == ':') && (*(pos + 2) == '=')) { token = ISDEF; pos += 2; len = 3; } else { AsnIoErrorMsg(aip, 59, *pos, aip->linenumber); token = ERROR_TOKEN; } } else if (IS_UPPER(*pos)) /* a reference or keyword */ { token = REF; while ((IS_ALPHANUM(*pos)) || (*pos == '-')) { pos++; len++; } aip->wordlen = len; asntype = AsnLexTMatchToken(aip); /* check types */ if (asntype) /* did it match ? */ { if ((asntype > 27) && (asntype < 57)) /* not a primitive type */ { token = asntype + 400; /* make a keyword type */ if (asntype == COMPS_TOKEN) /* COMPONENTS OF */ { if ((*(pos + 1) == 'O') && (*(pos + 2) == 'F') && (IS_WHITESP(*(pos+3)))) { pos += 3; /* move past OF */ len += 3; } else AsnIoErrorMsg(aip, 89, aip->linenumber); } } else if (asntype == 57) /* StringStore */ token = STRSTORE_TYPE; else if (asntype == 59) /* BitInt */ token = BIGINT_TYPE; else { switch (asntype) { case 3: /* BIT */ case 4: /* OCTET */ if (! StrMatch(asnwords[11], (pos+1), 6)) AsnIoErrorMsg(aip, 90, aip->linenumber); pos += 7; /* move past STRING */ len += 7; break; case 11: /* SEQUENCE */ case 13: /* SET */ if ((*(pos + 1) == 'O') && (*(pos + 2) == 'F')) { asntype++; /* SET or SEQ OF */ pos += 3; len += 3; if (! IS_WHITESP(*pos)) AsnIoErrorMsg(aip, 91, aip->linenumber); } break; case 6: /* OBJECT */ if ((! StrMatch(asnwords[55], (pos+1), 10))) /* IDENTIFIER */ AsnIoErrorMsg(aip, 92, aip->linenumber); pos += 11; len += 11; break; default: break; } token = asntype + 300; /* change to point at type */ } } pos--; /* move back for increment at end */ len--; } else if (IS_LOWER(*pos)) /* an identifier or valuereference */ { token = IDENT; while ((IS_ALPHANUM(*pos)) || (*pos == '-')) { pos++; len++; } pos--; /* move back for increment at end */ len--; } else if ((IS_DIGIT(*pos)) || ((*pos == '-') && (IS_DIGIT(*(pos+1))))) { token = NUMBER; if (*pos == '-') { pos++; len++; } while (IS_DIGIT(*pos)) { pos++; len++; } pos--; /* move back for increment at end */ len--; } else { AsnIoErrorMsg(aip, 59, *pos, aip->linenumber); token = ERROR_TOKEN; } len++; pos++; /* move over last symbol */ } aip->linepos = pos - aip->linebuf; aip->state = state; aip->wordlen = len; aip->token = token; return token; }
/***************************************************************************** * * void AsnTxtBufWrite(aip, atp, buf, buflen) * *****************************************************************************/ NLM_EXTERN Boolean LIBCALL AsnTxtBufWrite (AsnIoPtr aip, AsnTypePtr atp, CharPtr buf, size_t buflen) { Int2 isa; AsnTypePtr atp2; Boolean firstvalue; if ((! aip->indent_level) && (aip->typestack[0].type == NULL)) firstvalue = TRUE; /* first call to this routine */ else firstvalue = FALSE; atp2 = AsnFindBaseType(atp); isa = atp2->type->isa; if (ISA_STRINGTYPE(isa)) isa = GENERALSTRING_TYPE; switch (isa) { case GENERALSTRING_TYPE: case OCTETS_TYPE: case STRSTORE_TYPE: break; default: AsnIoErrorMsg(aip, 19, AsnErrGetTypeName(atp->name)); return FALSE; } if (! AsnTypeValidateOut(aip, atp, NULL)) return FALSE; if (! aip->first[aip->indent_level]) AsnPrintNewLine(aip); else aip->first[aip->indent_level] = FALSE; atp2 = atp; if (firstvalue) { /* first item, need ::= */ while ((atp2->name == NULL) || (IS_LOWER(*atp2->name))) atp2 = atp2->type; /* find a Type Reference */ } if (atp2->name != NULL) { AsnPrintString(atp2->name, aip); /* put the element name */ if (IS_LOWER(*atp2->name)) AsnPrintChar(' ', aip); else AsnPrintString(" ::= ", aip); } switch (isa) { case GENERALSTRING_TYPE: case STRSTORE_TYPE: AsnPrintChar('\"', aip); AsnPrintBuf(buf, buflen, aip); AsnPrintChar('\"', aip); break; case OCTETS_TYPE: AsnPrintBufOctets(buf, buflen, aip); break; default: AsnIoErrorMsg(aip, 19, AsnErrGetTypeName(atp->name)); return FALSE; } if (aip->type_indent) { /* pop out of choice nests */ if (AsnFindBaseIsa(aip->typestack[aip->type_indent - 1].type) == CHOICE_TYPE) { if (aip->type_indent >= 2) isa = AsnFindBaseIsa(aip->typestack[aip->type_indent - 2].type); else isa = NULL_TYPE; /* just fake it */ AsnPrintIndent(FALSE, aip); AsnTypeSetIndent(FALSE, aip, atp); } } return TRUE; }
static Int2 AsnLexWordEx (AsnIoPtr aip, Uint1 fix_non_print) { register CharPtr pos; Int1 state; Int2 token; register int linepos, len; int done; if (aip->tagsaved) /* had to read ahead */ { aip->tagsaved = FALSE; return aip->token; } if (! aip->bytes) /* no data loaded */ AsnIoGets(aip); linepos = aip->linepos; pos = aip->linebuf + linepos; state = aip->state; len = 0; while (*pos == '\n' || *pos == '\r') /* skip empty lines */ { pos = AsnIoGets(aip); /* get a line */ if (pos == NULL) return EOF_TOKEN; } if (state == IN_STRING_STATE) { aip->word = pos; if ((* pos == '\"') && (*(pos + 1) != '\"')) /* end of string */ { token = END_STRING; pos++; state = 0; /* reset state */ } else { token = IN_STRING; while ((* pos != '\"') && (* pos != '\n') && (* pos != '\r')) { if ((fix_non_print != 2) && ((*pos < ' ') || (*pos > '~'))) { done = (int)(*pos); *pos = '\0'; if ((fix_non_print == 0) || (fix_non_print == 3)) { AsnIoErrorMsg(aip, 106, done, aip->word); } done = 0; *pos = '#'; /* replace with # */ } pos++; len++; } if ((*pos != '\n') && (*pos != '\r') && (* (pos + 1) == '\"')) /* internal quote */ { len++; /* include in previous string */ pos += 2; /* point to rest of string */ } } } else if (state == IN_BITHEX_STATE) { aip->word = pos; if (*pos == '\'') /* end of binhex */ { state = 0; /* set to normal */ pos++; /* move past quote */ while (IS_WHITESP(*pos)) { if (*pos == '\n' || *pos == '\r') /* skip empty lines */ { pos = AsnIoGets(aip); /* get a line */ if (pos == NULL) return EOF_TOKEN; } else pos++; } if (* pos == 'H') token = OCTETS; else if (* pos == 'B') token = ASNBITS; else { AsnIoErrorMsg(aip, 58, aip->linenumber); token = ERROR_TOKEN; } pos++; /* move past H or B */ } else { token = IN_BITHEX; while ((* pos != '\'') && (* pos != '\n') && (* pos != '\r')) { pos++; len++; } } } else /* normal scanning */ { while ((* pos <= ' ') || ((*pos == '-') && (*(pos+1) == '-'))) /* skip leading white space */ { if (*pos == '\n' || *pos == '\r') { pos = AsnIoGets(aip); if (pos == NULL) return EOF_TOKEN; } else if ((*pos == '-') && (*(pos+1) == '-')) /* skip comments */ { pos += 2; done = 0; while (! done) { if ((*pos == '-') && (*(pos +1) == '-')) { pos += 2; done = 1; } else if (*pos == '\n' || *pos == '\r') done = 1; else pos++; } } else pos++; } aip->word = pos; if (* pos == '\"') { token = START_STRING; state = IN_STRING_STATE; } else if (* pos == '\'') { token = START_BITHEX; state = IN_BITHEX_STATE; } else if (* pos == ',') token = COMMA; else if (* pos == '{') token = START_STRUCT; else if (* pos == '}') token = END_STRUCT; else if (* pos == '[') token = START_TAG; else if (* pos == ']') token = END_TAG; else if (* pos == '(') token = OPEN_PAREN; else if (* pos == ')') token = CLOSE_PAREN; else if (* pos == ';') token = SEMI_COLON; else if (* pos == ':') { if ((*(pos + 1) == ':') && (*(pos + 2) == '=')) { token = ISDEF; pos += 2; len = 3; } else { AsnIoErrorMsg(aip, 59, *pos, aip->linenumber); token = ERROR_TOKEN; } } else if (IS_UPPER(*pos)) /* a reference or keyword */ { token = REF; while ((IS_ALPHANUM(*pos)) || (*pos == '-')) { pos++; len++; } pos--; /* move back for increment at end */ len--; } else if (IS_LOWER(*pos)) /* an identifier or valuereference */ { token = IDENT; while ((IS_ALPHANUM(*pos)) || (*pos == '-')) { pos++; len++; } pos--; /* move back for increment at end */ len--; } else if ((IS_DIGIT(*pos)) || ((*pos == '-') && (IS_DIGIT(*(pos+1))))) { token = NUMBER; if (*pos == '-') { pos++; len++; } while (IS_DIGIT(*pos)) { pos++; len++; } pos--; /* move back for increment at end */ len--; } else { AsnIoErrorMsg(aip, 59, *pos, aip->linenumber); token = ERROR_TOKEN; } len++; pos++; /* move over last symbol */ } aip->linepos = pos - aip->linebuf; /******************** check on MSWIN linepos = 0; while (pos != linebuf) { linepos++; pos++; } aip->linepos = linepos; **********************/ aip->state = state; aip->wordlen = len; aip->token = token; return token; }