static Nlm_CharPtr Nlm_FindSubString (const char FAR *str, const char FAR *sub, Nlm_Boolean caseCounts) { int ch; int d [256]; int i; int j; int k; size_t strLen; size_t subLen; if (sub != NULL && sub [0] != '\0' && str != NULL && str [0] != '\0') { strLen = Nlm_StringLen (str); subLen = Nlm_StringLen (sub); if (subLen <= strLen) { for (ch = 0; ch < 256; ch++) { d [ch] = subLen; } for (j = 0; j < (int)(subLen - 1); j++) { ch = (int) (caseCounts ? sub [j] : TO_UPPER (sub [j])); if (ch >= 0 && ch <= 255) { d [ch] = subLen - j - 1; } } i = subLen; do { j = subLen; k = i; do { k--; j--; } while (j >= 0 && (caseCounts ? sub [j] : TO_UPPER (sub [j])) == (caseCounts ? str [k] : TO_UPPER (str [k]))); if (j >= 0) { ch = (int) (caseCounts ? str [i - 1] : TO_UPPER (str [i - 1])); if (ch >= 0 && ch <= 255) { i += d [ch]; } else { i++; } } } while (j >= 0 && i <= (int) strLen); if (j < 0) { i -= subLen; return (Nlm_CharPtr) (str + i); } } } return NULL; }
NLM_EXTERN Nlm_CharPtr Nlm_SearchSubString ( const char FAR *str, Nlm_SubStringData PNTR data ) { Nlm_Boolean caseCounts; int ch; int i; int j; int k; size_t strLen; size_t subLen; const char FAR *sub; if (str == NULL || str [0] == '\0') return NULL; if (data == NULL || ! data->initialized) return NULL; strLen = Nlm_StringLen (str); subLen = data->subLen; if (strLen < subLen) return NULL; caseCounts = data->caseCounts; sub = data->sub; if (sub == NULL || sub [0] == '\0') return NULL; i = subLen; do { j = subLen; k = i; do { k--; j--; } while (j >= 0 && (caseCounts ? sub [j] : TO_UPPER (sub [j])) == (caseCounts ? str [k] : TO_UPPER (str [k]))); if (j >= 0) { ch = (int) (caseCounts ? str [i - 1] : TO_UPPER (str [i - 1])); if (ch >= 0 && ch <= 255) { i += data->d [ch]; } else { i++; } } } while (j >= 0 && i <= (int) strLen); if (j < 0) { i -= subLen; return (Nlm_CharPtr) (str + i); } return NULL; }
int caracteresIguais(const char *palavra, const char *str) { int i = 0, quantidadeDeCaracteresIguais = 0; while (palavra[i] != '\0' && str[i] != '\0') { if (TO_UPPER(palavra[i]) == TO_UPPER(str[i])) { quantidadeDeCaracteresIguais++; } i++; } return quantidadeDeCaracteresIguais; }
static CharPtr get_token(CharPtr str, CharPtr token) { int i; token[2]= '\0'; while(IS_WHITESP(*str)) { if(*str == '\0') return NULL; ++str; } if(*str == '\0') return NULL; for(i= 1; i < 250; i++) { if(IS_WHITESP(*str)) { token[i]= ' '; token[i+1]= '\0'; return str; } if(*str == '\0') { token[i]= ' '; token[i+1]= '\0'; return NULL; } token[i]= TO_UPPER(*str); str++; } token[i]= ' '; token[i+1]= '*'; token[i+2]= '\0'; return str; }
NLM_EXTERN Nlm_Boolean Nlm_SetupSubString ( const char FAR *sub, Nlm_Boolean caseCounts, Nlm_SubStringData PNTR data ) { int ch; int j; size_t subLen; if (data == NULL) return FALSE; MemSet ((Nlm_VoidPtr) data, 0, sizeof (Nlm_SubStringData)); if (sub == NULL || sub [0] == '\0') return FALSE; subLen = Nlm_StringLen (sub); for (ch = 0; ch < 256; ch++) { data->d [ch] = subLen; } for (j = 0; j < (int)(subLen - 1); j++) { ch = (int) (caseCounts ? sub [j] : TO_UPPER (sub [j])); if (ch >= 0 && ch <= 255) { data->d [ch] = subLen - j - 1; } } data->subLen = subLen; data->caseCounts = caseCounts; data->initialized = TRUE; data->sub = sub; return TRUE; }
int main(void) { FILE *in, *out; char inName[64], outName[64]; int character; printf ("Enter name of file to be copied: "); scanf ("%63s", inName); printf ("Enter name of output file: "); scanf ("%63s", outName); if((in = fopen(inName, "r")) == NULL) { fprintf(stderr,"Cannot open %s for reading.\n",inName); return 1; } if((out = fopen(outName, "w")) == NULL) { fprintf(stderr,"Cannot open %s for writing.\n",outName); return 2; } while((character = getc(in)) != EOF) { putc(TO_UPPER(character),out); } printf("File has been copied.\n"); return 0; }
NLM_EXTERN int LIBCALL Nlm_StrNIPCmp (const char FAR *a, const char FAR *b, size_t max) { int diff, done; if (a == b) return 0; while (*a && !isalnum(*a)) a++; while (*b && !isalnum(*b)) b++; done = 0; while (! done) { if (!isalnum(*a) && !isalnum(*b)) { while (*a && !isalnum(*a)) { a++; max--; if (!max) { done = 1; break; } } while (*b && !isalnum(*b)) b++; } diff = TO_UPPER(*a) - TO_UPPER(*b); if (diff) return (Nlm_Int2) diff; if (*a == '\0') done = 1; else { a++; b++; max--; if (! max) done = 1; } } return 0; }
/** Performs a case-insensitive comparison of two Null-terminated strings. @param This Protocol instance pointer. @param Str1 A pointer to a Null-terminated string. @param Str2 A pointer to a Null-terminated string. @retval 0 Str1 is equivalent to Str2 @retval > 0 Str1 is lexically greater than Str2 @retval < 0 Str1 is lexically less than Str2 **/ INTN EFIAPI EngStriColl ( IN EFI_UNICODE_COLLATION_PROTOCOL *This, IN CHAR16 *Str1, IN CHAR16 *Str2 ) { while (*Str1 != 0) { if (TO_UPPER (*Str1) != TO_UPPER (*Str2)) { break; } Str1 += 1; Str2 += 1; } return TO_UPPER (*Str1) - TO_UPPER (*Str2); }
NLM_EXTERN int LIBCALL Nlm_StrICmp (const char FAR *a, const char FAR *b) { int diff, done; if (a == b) return 0; done = 0; while (! done) { diff = TO_UPPER(*a) - TO_UPPER(*b); if (diff) return (Nlm_Int2) diff; if (*a == '\0') done = 1; else { a++; b++; } } return 0; }
const char * stristr(const char * str1, const char * str2) { if (!*str2) return str1; for (const char * cp = str1; *cp; cp++) { const char * s2 = str2; for (const char * s1 = cp; *s1 && *s2 && (IS_ALPHA(*s1) && IS_ALPHA(*s2)) ? !(TO_UPPER(*s1) - TO_UPPER(*s2)) : !(*s1 - *s2); s1++) ++s2; if (!*s2) return cp; } return nullptr; }
/** Converts all the characters in a Null-terminated string to upper case characters. @param This Protocol instance pointer. @param Str A pointer to a Null-terminated string. **/ VOID EFIAPI EngStrUpr ( IN EFI_UNICODE_COLLATION_PROTOCOL *This, IN OUT CHAR16 *Str ) { while (*Str != 0) { *Str = TO_UPPER (*Str); Str += 1; } }
int main (void) { if (isEven(17) == YES) printf ("yes "); else printf ("no "); if(isEven(20) == YES) printf ("yes\n"); else printf ("no\n"); printf ("%c\n", TO_UPPER('b')); debugPrintf("x" "y" "z%i\n", 10) return 0; }
/***************************************************************************** * * Int4 AsnTypeStringToHex(from, len, to, left) * converts an octet string to binary * returns number of hex digits created if all ok * *left is chars left at the end of the buffer including first letter of * a remaining digit (from does not have an even number of letters) * since this could include white space, could be more than 1 * returns a negative number on an error * skips over internal or trailing white space * left can be NULL in which case it is ignored * *****************************************************************************/ NLM_EXTERN Int4 LIBCALL AsnTypeStringToHex (Pointer from, Int4 len, Pointer to, Int4Ptr left) { BytePtr f, t; Byte octet = 0, value; int i; Int4 added = 0; f = (BytePtr) from; t = (BytePtr) to; if (left != NULL) *left = 0; i = 16; while (len) { if (! IS_WHITESP(*f)) /* skip spaces */ { if (i == 16) /* first letter of pair */ { octet = 0; if (left != NULL) *left = len; /* point at it in case one letter left */ } value = TO_UPPER(*f); if ((value >= 'A') && (value <= 'F')) octet += (((value - 'A') + 10) * i); else if ((value >= '0') && (value <= '9')) octet += ((value - '0') * i); else return (Int4)(-1); if (i == 16) /* first letter of pair */ i = 1; /* goto second letter */ else /* letter pair was read */ { i = 16; /* reset for first letter */ if (left != NULL) *left = 0; /* nothing left so far */ *t = octet; /* record the hex digit */ t++; added++; } } len--; f++; } return added; }
int SerialCommands::buildCommand(char nextChar) { if ((nextChar == '\n') || (nextChar == '\t') || (nextChar == '\r')) return false; if (nextChar == ';') { gCommandBuffer[it_cmd] = '\0'; gParamBuffer[it_param] = '\0'; it_cmd = 0; it_param = 0; state = COMMAND; return true; } if (nextChar == ',') { state = PARAM; return false; } if (state == COMMAND) { gCommandBuffer[it_cmd] = TO_UPPER(nextChar); it_cmd++; if (it_cmd > MAX_COMMAND_LEN) { it_cmd = 0; return true; } } if (state == PARAM) { if(it_param == 0 && (nextChar == ' ')) return false; gParamBuffer[it_param] = nextChar; it_param++; if (it_param > MAX_PARAMETER_LEN) { it_param = 0; return true; } } return false; }
extern Nlm_Boolean Nlm_StrToDouble (Nlm_CharPtr str, Nlm_FloatHiPtr doubleval) { Nlm_Char ch; Nlm_Int2 i; Nlm_Int2 len; Nlm_Char local [64]; Nlm_Boolean nodigits; Nlm_Boolean rsult; double val; rsult = FALSE; if (doubleval != NULL) { *doubleval = (Nlm_FloatHi) 0; } len = (Nlm_Int2) Nlm_StringLen (str); if (len != 0) { rsult = TRUE; nodigits = TRUE; for (i = 0; i < len; i++) { ch = str [i]; if (ch == '+' || ch == '-' || ch == '.' || ch == 'E' || ch == 'e') { } else if (ch < '0' || ch > '9') { rsult = FALSE; } else { nodigits = FALSE; } } if (nodigits) { rsult = FALSE; } if (rsult && doubleval != NULL) { Nlm_StringNCpy_0 (local, str, sizeof (local)); for (i = 0; i < len; i++) { local [i] = TO_UPPER (local [i]); } if (sscanf (local, "%lf", &val) == 1) { *doubleval = val; } } } return rsult; }
static void Get_Sequence (FILE *f, SeqRecPtr seqrp) { Char ch; CharPtr chptr; Boolean goOn; IdRecPtr last; Int4 len; Char str [256]; IdRecPtr this; Int4 total; if (f != NULL && seqrp != NULL) { if (seqrp->rawSeq == NULL) { seqrp->rawSeq = BSNew (1000); } if (seqrp->segLens == NULL) { seqrp->segLens = BSNew (10); } len = 0; total = 0; goOn = TRUE; while (goOn && ReadNextLine (f, str, sizeof (str))) { if (str [0] == '&') { goOn = FALSE; } else if (str [0] == '!') { goOn = FALSE; } else if (str [0] == '>') { if (len > 0) { if (seqrp->lookForStop) { BSPutByte (seqrp->rawSeq, (Int2) '*'); len++; } BSWrite (seqrp->segLens, &len, sizeof (Int4)); total += len; len = 0; } chptr = StringChr (str, ' '); if (chptr != NULL) { *chptr = '\0'; } if (seqrp->ids != NULL) { last = seqrp->ids; while (last->next != NULL) { last = last->next; } this = MemNew (sizeof (IdRec)); if (this != NULL) { this->id.accn = StringSave (str + 1); } last->next = this; } else { last = MemNew (sizeof (IdRec)); if (last != NULL) { last->id.accn = StringSave (str + 1); } seqrp->ids = last; } } else if (str [0] != '\0') { chptr = str; while (*chptr != '\0') { ch = TO_UPPER (*chptr); if (ch >= 'A' && ch <= 'Z') { if (seqrp->nuc) { if (ch == 'U') { ch = 'T'; } if (StringChr ("BDEFHIJKLMOPQRSUVWXYZ", ch) == NULL) { BSPutByte (seqrp->rawSeq, (Int2) ch); len++; } } else { if (StringChr ("JOU", ch) == NULL) { BSPutByte (seqrp->rawSeq, (Int2) ch); len++; } } } chptr++; } } } if (seqrp->nuc) { BSPutByte (seqrp->rawSeq, (Int2) 'N'); BSPutByte (seqrp->rawSeq, (Int2) 'N'); BSPutByte (seqrp->rawSeq, (Int2) 'N'); len += 3; } if (len > 0) { if (seqrp->lookForStop) { BSPutByte (seqrp->rawSeq, (Int2) '*'); len++; } BSWrite (seqrp->segLens, &len, sizeof (Int4)); total += len; len = 0; } if (total > 0) { seqrp->sequence = BSMerge (seqrp->rawSeq, NULL); seqrp->length = total; } else { seqrp->sequence = NULL; seqrp->length = 0; } } }
// // Open filename specified and return the size. // ULONG FSOpenFile(char* pFileName) { USHORT i = 0; USHORT j = 0; ULONG DirLBA = 1; CHAR* Sector = (CHAR*)READ_BUFFER_START; CHAR FileName[30] = { 0 }; BOOL bFound = FALSE; // Check caller's parameters. if (pFileName == NULL) return(0); memset( &g_FileInfo, 0, sizeof(FILEINFO) ); // Convert the filename to the form stored on disk. for (i = 0 ; i < 15 && *(pFileName + i) ; i++) FileName[i*2] = TO_UPPER(*(pFileName + i)); // Look for the filename in directory list. for( bFound = FALSE, DirLBA = g_FATParms.RootDirLBA ; !bFound && DirLBA ; DirLBA = NextSector( DirLBA ) ) { // Read a sector from the root directory. if (!ReadSectors(pBPB->DriveID, DirLBA, 1, Sector)) { ERRMSG(MSG_CANNOT_READ_ROOT_DIR, ("Couldn't read root directory sector (LBA=0x%x)\n", DirLBA)); return(0); } // Try to find the specified file in the root directory... for (j = 0 ; (j < (1 << (pBPB->BytesPerSector - 5))) && !bFound; j++) { BYTE* pCurrent = Sector + (j << 5); // // We've found a stream entry, record this in case it's our file. // if( ((pCurrent[0] & 0x7F) == 64) && (pCurrent[0] & 0x80) ) { EXFAT_STREAM_RECORD* pEntry; pEntry = (EXFAT_STREAM_RECORD*)(pCurrent); g_FileInfo.Flags = pEntry->Flags; g_FileInfo.FileSize = (ULONG)pEntry->FileSize; g_FileInfo.FirstCluster = pEntry->FirstCluster; g_FileInfo.CurCluster = g_FileInfo.FirstCluster; g_FileInfo.pCurReadBuffAddr = g_pReadBuffStart; } else if( ((pCurrent[0] & 0x7F) == 65) && (pCurrent[0] & 0x80) ) { BYTE Current = 0; bFound = TRUE; for (i = 0 ; i < 30 ; i++) { Current = TO_UPPER( (pCurrent)[2 + i] ); if( FileName[i] != Current ) { bFound = FALSE; } } } } } if (!bFound) { WARNMSG(MSG_FILE_NOT_FOUND, ("File '%s' not found\n", pFileName)); return(0); } else { INFOMSG(MSG_FILE_FOUND, ("Found file '%s' (start=0x%x size=0x%x)\n", pFileName, g_FileInfo.FirstCluster, g_FileInfo.FileSize)); } return(g_FileInfo.FileSize); }
/** Performs a case-insensitive comparison of a Null-terminated pattern string and a Null-terminated string. @param This Protocol instance pointer. @param String A pointer to a Null-terminated string. @param Pattern A pointer to a Null-terminated pattern string. @retval TRUE Pattern was found in String. @retval FALSE Pattern was not found in String. **/ BOOLEAN EFIAPI EngMetaiMatch ( IN EFI_UNICODE_COLLATION_PROTOCOL *This, IN CHAR16 *String, IN CHAR16 *Pattern ) { CHAR16 CharC; CHAR16 CharP; CHAR16 Index3; for (;;) { CharP = *Pattern; Pattern += 1; switch (CharP) { case 0: // // End of pattern. If end of string, TRUE match // if (*String != 0) { return FALSE; } else { return TRUE; } case '*': // // Match zero or more chars // while (*String != 0) { if (EngMetaiMatch (This, String, Pattern)) { return TRUE; } String += 1; } return EngMetaiMatch (This, String, Pattern); case '?': // // Match any one char // if (*String == 0) { return FALSE; } String += 1; break; case '[': // // Match char set // CharC = *String; if (CharC == 0) { // // syntax problem // return FALSE; } Index3 = 0; CharP = *Pattern++; while (CharP != 0) { if (CharP == ']') { return FALSE; } if (CharP == '-') { // // if range of chars, get high range // CharP = *Pattern; if (CharP == 0 || CharP == ']') { // // syntax problem // return FALSE; } if (TO_UPPER (CharC) >= TO_UPPER (Index3) && TO_UPPER (CharC) <= TO_UPPER (CharP)) { // // if in range, it's a match // break; } } Index3 = CharP; if (TO_UPPER (CharC) == TO_UPPER (CharP)) { // // if char matches // break; } CharP = *Pattern++; } // // skip to end of match char set // while ((CharP != 0) && (CharP != ']')) { CharP = *Pattern; Pattern += 1; } String += 1; break; default: CharC = *String; if (TO_UPPER (CharC) != TO_UPPER (CharP)) { return FALSE; } String += 1; break; } } }
Int2 Main (void) { Int2 m_argModuleIn=0, f_arg_moduleOut=1, X_argDTDModuleOut=2, T_argTreeDumpOut=3, v_argPrintFileIn = 4, p_argPrintFileOut = 5, x_argXMLDataOut=6, d_argBinaryFileIn = 7 , t_argAsnTypeName = 8, e_argBinaryFileOut = 9 , o_argHeadFile = 10, l_argLoadFile = 11 , b_argBufferSize = 12, w_argTokenMax = 13 /*--- args below here are capitilized and for code generation, only--*/ /*-- Except for the 'M' arg, which will also affect normal use ---*/ , G_argGenerateCode = 14, M_argMoreModuleFiles = 15 , B_argCodeFileName = 16, D_argCodeGenDebugLevel = 17 , S_argDebugFileName = 18, I_argExtraIncludeName = 19 , Z_argBitTwiddle = 20, K_argLoadName = 21 , J_objMgrEntry = 22, L_objMgrLabel = 23, P_argXMLmodulePrefix = 24 , V_argChoiceStruct = 25; AsnIoPtr aip = NULL, aipout = NULL, xaipout = NULL, aipencode = NULL; FILE * fp; AsnModulePtr amp = NULL, currentmod = NULL, nextmod, thisamp; AsnTypePtr atp; Boolean print_each_module = FALSE; AsnCodeInfoPtr acip = (AsnCodeInfoPtr)MemNew(sizeof(AsnCodeInfo)); CharPtr filename = NULL, p, last_comma, objmgrentry = NULL; int len; /* never abort on error, but show it */ ErrSetFatalLevel(SEV_MAX); ErrSetMessageLevel(SEV_MIN); asnargs[P_argXMLmodulePrefix].defaultvalue = (const char *)AsnGetXMLmodulePrefix(); if (! GetArgs("AsnTool 4", NUMARGS, asnargs)) return 1; ErrClear(); AsnSetXMLmodulePrefix((CharPtr)(asnargs[P_argXMLmodulePrefix].strvalue)); /* if (! GetArgs("AsnTool 4", NUMARGS, asnargs)) return 1; ErrClear(); */ if (! AsnIoSetBufsize(NULL, (Int2)asnargs[b_argBufferSize].intvalue)) return 1; if ((aip = AsnIoOpen(asnargs[m_argModuleIn].strvalue, "r")) == NULL) { ErrShow(); return 1; } acip -> loadname = asnargs[m_argModuleIn].strvalue; if (asnargs[K_argLoadName].strvalue != NULL) { acip -> loadname = asnargs[K_argLoadName].strvalue; /* overrides m_argModuleIn, if set */ } if (asnargs[e_argBinaryFileOut].strvalue != NULL) /* output a binary value file */ if ((aipencode = AsnIoOpen(asnargs[e_argBinaryFileOut].strvalue, "wb")) == NULL) { ErrShow(); return 1; } /** parse the module(s) ***/ if (asnargs[f_arg_moduleOut].strvalue != NULL) { if ((aipout = AsnIoOpen(asnargs[f_arg_moduleOut].strvalue, "w")) == NULL) { ErrShow(); return 1; } } thisamp = NULL; while ((nextmod = AsnLexTReadModule(aip)) != NULL ) { if (thisamp == NULL) thisamp = nextmod; if (amp == NULL) amp = nextmod; else currentmod->next = nextmod; currentmod = nextmod; } acip -> last_amp = currentmod; /* last module of main file */ AsnStoreTree(acip->loadname, thisamp); /* store and link tree */ /*--- read additional module files that will be used for everything but code generation. ---*/ if (asnargs[M_argMoreModuleFiles].strvalue != NULL) for (p = asnargs[M_argMoreModuleFiles].strvalue; *p; p = last_comma + 1) { /*--- extract next filename for reading ASN.1 definitions ---*/ for (last_comma = p; *last_comma; last_comma++) { if (*last_comma == ',') break; } len = last_comma - p; filename = (char *)MemFree (filename); filename = (char *)MemNew (len + 1); StringNCpy (filename, p, len); filename[len] = '\0'; #ifdef WIN_DUMB printf ("Loading %s \n", filename); #endif if ((aip = AsnIoOpen(filename, "r")) == NULL) { ErrShow(); return 1; } /*--- read the modules in this current file ---*/ thisamp = NULL; while ((nextmod = AsnLexTReadModule(aip)) != NULL ) { if (thisamp == NULL) thisamp = nextmod; if (amp == NULL) amp = nextmod; else currentmod->next = nextmod; currentmod = nextmod; } AsnStoreTree(filename, thisamp); /* store and link tree */ if (!*last_comma) break; aip = AsnIoClose(aip); } aip = AsnIoClose(aip); if (amp == NULL) { ErrPostEx(SEV_FATAL,0,0, "Unable to continue due to bad ASN.1 module"); ErrShow(); return 1; } if (asnargs[f_arg_moduleOut].strvalue != NULL) { if ((aipout = AsnIoOpen(asnargs[f_arg_moduleOut].strvalue, "w")) == NULL) { ErrShow(); return 1; } currentmod = amp; do { AsnPrintModule(currentmod, aipout); if (currentmod == acip->last_amp) /* last main module */ currentmod = NULL; else currentmod = currentmod->next; } while (currentmod != NULL); aipout = AsnIoClose(aipout); } if (asnargs[X_argDTDModuleOut].strvalue != NULL) { Char tbuf[250]; CharPtr ptr; if (! StringCmp(asnargs[X_argDTDModuleOut].strvalue, "m")) { print_each_module = TRUE; } else { if ((aipout = AsnIoOpen(asnargs[X_argDTDModuleOut].strvalue, "wx")) == NULL) { ErrShow(); return 1; } } currentmod = amp; do { if (print_each_module) { StringMove(tbuf, currentmod->modulename); for (ptr = tbuf; *ptr != '\0'; ptr++) { if (*ptr == '-') *ptr = '_'; } StringMove(ptr, ".dtd"); AsnPrintModuleXMLInc(currentmod, tbuf); StringMove(ptr, ".mod"); aipout = AsnIoOpen(tbuf, "wx"); } AsnPrintModuleXML(currentmod, aipout); if (print_each_module) aipout = AsnIoClose(aipout); if (currentmod == acip->last_amp) /* last main module */ currentmod = NULL; else currentmod = currentmod->next; } while (currentmod != NULL); if (! print_each_module) aipout = AsnIoClose(aipout); } if (asnargs[T_argTreeDumpOut].strvalue != NULL) { if ((fp = FileOpen(asnargs[T_argTreeDumpOut].strvalue, "w")) == NULL) { ErrShow(); return 1; } currentmod = amp; do { AsnPrintTreeModule(currentmod, fp); if (currentmod == acip->last_amp) /* last main module */ currentmod = NULL; else currentmod = currentmod->next; } while (currentmod != NULL); FileClose(fp); } acip -> amp = amp; /* print a value file */ if (asnargs[p_argPrintFileOut].strvalue != NULL) { if ((aipout = AsnIoOpen(asnargs[p_argPrintFileOut].strvalue, "w")) == NULL) { ErrShow(); return 1; } } /* print an XML file */ if (asnargs[x_argXMLDataOut].strvalue != NULL) { if ((xaipout = AsnIoOpen(asnargs[x_argXMLDataOut].strvalue, "wx")) == NULL) { ErrShow(); return 1; } } if (asnargs[v_argPrintFileIn].strvalue != NULL) /* read a printvalue file */ { if ((aip = AsnIoOpen(asnargs[v_argPrintFileIn].strvalue, "r")) == NULL) { ErrShow(); return 1; } AsnTxtReadValFile(amp, aip, aipout, aipencode, xaipout); ErrShow(); } aip = AsnIoClose(aip); if (asnargs[d_argBinaryFileIn].strvalue != NULL) /* read a ber file */ { if ((asnargs[t_argAsnTypeName].strvalue == NULL) || (! TO_UPPER(*asnargs[t_argAsnTypeName].strvalue))) { ErrPostEx(SEV_FATAL,0,0, "Must use -t Type to define contents of decode file"); ErrShow(); return 1; } atp = AsnTypeFind(amp, asnargs[t_argAsnTypeName].strvalue); if (atp == NULL) { #ifdef WIN_MSWIN ErrPostEx(SEV_FATAL,0,0, "Couldn't find Type %Fs", asnargs[t_argAsnTypeName].strvalue); #else ErrPostEx(SEV_FATAL,0,0, "Couldn't find Type %s", asnargs[t_argAsnTypeName].strvalue); #endif ErrShow(); return 1; } if ((aip = AsnIoOpen(asnargs[d_argBinaryFileIn].strvalue, "rb")) == NULL) { ErrShow(); return 1; } AsnBinReadValFile(atp, aip, aipout, aipencode, xaipout); ErrShow(); } AsnIoClose(xaipout); AsnIoClose(aipout); AsnIoClose(aip); AsnIoClose(aipencode); if (asnargs[o_argHeadFile].strvalue != NULL) /* produce header file */ AsnOutput(asnargs[o_argHeadFile].strvalue, amp, FALSE, (Int2)asnargs[w_argTokenMax].intvalue); if (asnargs[l_argLoadFile].strvalue != NULL) /* produce loader file */ AsnOutput(asnargs[l_argLoadFile].strvalue, amp, TRUE, (Int2)asnargs[w_argTokenMax].intvalue); if (asnargs[G_argGenerateCode ].intvalue != 0) { acip -> filename = asnargs[B_argCodeFileName].strvalue; acip -> do_bit_twiddle = asnargs[Z_argBitTwiddle].intvalue; acip -> force_choice_struct = asnargs[V_argChoiceStruct].intvalue; acip -> include_filename = asnargs[I_argExtraIncludeName].strvalue; acip -> maxDefineLength = asnargs[w_argTokenMax].intvalue; acip -> debug_level = asnargs[D_argCodeGenDebugLevel ].intvalue; acip -> object_manager_entry = asnargs[J_objMgrEntry].strvalue; acip -> object_label = asnargs[L_objMgrLabel].strvalue; if (asnargs[S_argDebugFileName].strvalue != NULL) { (acip -> bug_fp) = FileOpen (asnargs[S_argDebugFileName].strvalue, "w"); } else { (acip -> bug_fp) = FileOpen ("stderr", "w"); } AsnCode(acip); } MemFree(acip); MemFree(filename); return 0; }