SqlBool LikeSmartWild(const SqlVal& exp, const String& text) { const char *s = text; if(*s == 0) return SqlBool::True(); if((*s == '.' && s[1] != 0 && *++s != '.') || HasNlsLetters(WString(s))) { SqlBool e = Like(Upper(exp), Wild(ToUpper(s))); if(ToUpper((byte)*s) == 'C' && s[1] == 0) e &= NotLike(Upper(exp), "CH%"); // CH patch return e; } else return LikeUpperAscii(exp, Wild(s)); }
/* =========================================================================== * If not in exclude mode, expand the pattern based on the contents * of the file system. * This function is used while gathering filenames to be added or updated *w :: Path/pattern to match. Possible return values: ZEN_MISS, ZEN_OK, ZEN_ABORT, ZEN_MEM or ZEN_PARMS. */ int Wild( char *w, struct Globals *pG ) { zDIR *d; /* Stream for reading directory */ char *e; /* File or directory name found. */ char *n; /* Constructed name from directory */ int WError; /* Result of Wild() */ char *p, *a; /* path originale and fixed. */ char *q; /* Filename / pattern. */ int r; /* Result / temp var. */ char v[5]; /* space for device current directory.*/ bool StopRecurs = false; /* No recursion if filespec is file. */ // sprintf( pG->ewemsg, "in Wild of win32zip.c, pattern=%s recurse=%d", w, pG->recurse ); // diag( pG->ewemsg, pG ); // "zip -$ foo a:" can be used to force a drive name once. // v1.6017 if ( pG->volume_label == 1 ) { pG->volume_label = 2; pG->label = getVolumeLabel( pG, (w != NULL && w[ 1 ] == ':') ? to_up( w[ 0 ] ) : '\0', &pG->label_time, &pG->label_mode, &pG->label_utim ); if ( pG->label != NULL ) (void)newname( pG->label, 0, pG ); if ( w == NULL || (w[1] == ':' && w[2] == '\0') ) return ZEN_OK; } /* Allocate and copy pattern */ if ( (p = a = MALLOC( lstrlen( w ) + 1) ) == NULL ) return ZEN_MEM19; lstrcpy( p, w ); /* Separate path and name into p and q */ // We have '\' or '\name' or 'path1\path2\name2' or 'C:\path\name' but NOT 'C:\name' if ( (q = strrchr( p, '\\' )) != NULL && (q == p || q[-1] != ':') ) { // SLASH *q++ = '\0'; if ( *p == '\0' ) p = lstrcpy( v, "\\." ); /* if path is just '\' SLASH */ } else if ( (q = strrchr( p, ':' )) != NULL ) { /* We have 'C:' or 'C:\' or 'C:\name' */ *q++ = '\0'; p = lstrcat( lstrcpy( v, p ), ":" ); /* copy device as path eg. 'C:' */ if ( *q == '\\' ) { /* -> device:/., name eg. 'C:\.' SLASH */ lstrcat( p, "\\" ); // SLASH q++; /* name or nothing. */ } lstrcat( p, "." ); /* eg. 'C:.' or 'C:\.' */ } else if ( pG->recurse && (!strcmp( p, "." ) || !strcmp( p, ".." )) ) { /* current or parent directory */ /* Get "zip -r foo ." to work. Allow the dubious "zip -r foo .." but * reject "zip -r -m foo ..". "dispose" means wipe out source path. */ if ( pG->dispose && !strcmp( p, ".." ) ) ziperr( ZEN_PARMS15, pG ); q = (char *)pG->wild_match_all; } else { /* no path or device */ q = p; p = lstrcpy( v, "." ); } if ( pG->recurse && *q == '\0' ) q = (char *)pG->wild_match_all; /* take out a possibly redundant dir name of "." */ if ( (r = lstrlen( p )) > 1 && (strcmp( p + r - 2, ":." ) == 0 || strcmp( p + r - 2, "\\." ) == 0) ) // SLASH *(p + r - 1) = '\0'; /* Only filename (not the path) can have special matching characters */ if ( IsShExp( p ) ) { diag( "path has illegal chars", pG ); FREE( a ); return ZEN_PARMS16; } // sprintf( ewemsg, "at break up place in Wild: path=%s name=%s", p, q ); // diag( ewemsg ); if ( !IsShExp( q ) ) { // Speed up checking if file exits in case there are no wildcards struct stat s; // and no recursion and no archiving v1.6016 if ( !pG->recurse && !pG->ArchiveFiles ) { if ( !LSSTAT( GetFullPath( pG, w ), &s ) ) /* file exists ? */ return procname( w, false, pG ); return ZEN_MISS02; /* woops, no wildcards where is the file! */ } if ( pG->norecursefiles ) StopRecurs = true; } /* Now that we have a dir spec, along with an fspec, we'll step * in the dir specified to see if there's any matches against the fspec. */ WError = ZEN_MISS02; if ( (d = Opendir( p, pG )) != NULL ) { while ( (e = readd( d, pG )) != NULL ) { if ( pG->global_abort_sw ) { WError = ZEN_ABORT; break; } // sprintf( ewemsg, "Found %s: %s", d->d_attr & FILE_ATTRIBUTE_DIRECTORY ? "directory" : "file", e ); // diag( ewemsg ); /* if e is NOT '.' or '..', and is a dir or match fspec. */ if ( strcmp( e, "." ) && strcmp( e, ".." ) && (d->d_attr & FILE_ATTRIBUTE_DIRECTORY || dosmatch( q, e, pG )) ) { // diag( "Matched" ); /* we matched fspec or it's a dir and entry is not '.' or '..' */ if ( d->d_attr & FILE_ATTRIBUTE_DIRECTORY ) { // We do not save dirs or go into dirs if norecursefiles==1 and we a file without * or ? specs. if ( !StopRecurs && (pG->dirnames || pG->recurse) ) { if ( (n = MALLOC( lstrlen( p ) + lstrlen( e ) + lstrlen( q ) + 3 )) == NULL ) { WError = ZEN_MEM20; break; } *n = '\0'; if ( *p != '.' ) AddSlash( lstrcpy( n, p ) ); // No ./ as first dir. lstrcat( n, e ); if ( pG->dirnames ) { // Save directory names also. r = procname( n, false, pG ); if ( (int)(char)(r & 0xFF) > ZEN_OK || !pG->recurse ) FREE( n ); if ( (int)(char)(r & 0xFF) > (int)(char)(WError & 0xFF) ) WError = r; if ( (int)(char)(r & 0xFF) > ZEN_OK ) break; } if ( pG->recurse ) { // Recursively go into dir and check for other pattern matches. r = Wild( lstrcat( AddSlash( n ), q ), pG ); // Add the original pattern. FREE( n ); // We keep a ZEN_OK even when ZEN_MISS occurs. if ( (int)(char)(r & 0xFF) > (int)(char)(WError & 0xFF) ) WError = r; if ( (int)(char)(r & 0xFF) > ZEN_OK ) break; // An error, stop processing. } } } else { if ( (n = MALLOC( lstrlen( p ) + lstrlen( e ) + 2 )) == NULL ) { WError = ZEN_MEM21; break; } if ( !strcmp( p, "." ) ) r = procname( e, false, pG ); else r = procname( lstrcat( AddSlash( lstrcpy( n, p ) ), e ), false, pG ); FREE( n ); if ( (int)(char)(r & 0xFF) > (int)(char)(WError & 0xFF) ) WError = r; if ( (int)(char)(r & 0xFF) > ZEN_OK ) break; } } /* end "if (strcmp..." */ } /* end while */ Closedir( d ); } else diag( "can't open dir", pG ); FREE( a ); // sprintf( ewemsg, "Wild returned: %d", WError ); // diag( ewemsg ); return WError; }
{ unsigned char u = (unsigned char) c; g_CharToLetterEx[u] = AX_GAP; g_LetterExToChar[AX_GAP] = u; g_AlignChar[u] = u; g_UnalignChar[u] = u; } static void SetAlphaDNA() { Res('A', NX_A) Res('C', NX_C) Res('G', NX_G) Res('T', NX_T) Wild('M', NX_M) Wild('R', NX_R) Wild('W', NX_W) Wild('S', NX_S) Wild('Y', NX_Y) Wild('K', NX_K) Wild('V', NX_V) Wild('H', NX_H) Wild('D', NX_D) Wild('B', NX_B) Wild('X', NX_X) Wild('N', NX_N) } static void SetAlphaRNA() {
/* =========================================================================== select files to be processed */ int ZipSelect(struct Globals *pG, const ZCL2 *C) { int i; // arg counter, root directory flag int k; // next argument type, marked counter, const char *p; // steps through option arguments int r; // temporary variable long g_before; // 1.74 global 'before' int argno, arg1; if ((p = getenv("TZ")) == NULL || *p == '\0') pG->extra_fields = 0; // disable storing "Unix" time stamps SetExclFilters(pG); // Process arguments diag("ready to read zip file", pG); // the read will be done in file: zipfile.c if ((r = readzipfile(pG)) != ZEN_OK) { diag("err returned from \"readzipfile\"", pG); return (ziperr(r, pG)); } if (pG->action == UPDATE || pG->action == FRESHEN) pG->doall = 1; r = 0; arg1 = - 1; g_before = pG->before; for (argno = 0; !r && argno < C->fTotFileSpecs; argno++) { char *fspec; FileData *fileArg = &C->fFDS[argno]; if (!fileArg) continue; fspec = fileArg->fFileSpec; if (!fspec || *fspec == '>') continue; pG->FileArg = fileArg; pG->key = 0; //pG->user_key; // set globals pG->recurse = fileArg->fRecurse; r = C->fLevel; r = r < 0 ? 0 : (r > 9 ? 9 : r); if (r != pG->level) { pG->level = r; pG->method = r ? DEFLATE : STORE; if (pG->verbose) Inform(pG, 0, IDIAG, "setting compression level to %d", r); } // Set the new RootDir if needed; DLL v1.608, Component v1.60L if (fileArg->fRootDir) { // We can't use SetCurrentDirectory() because there is only one cd // in each process // when a user uses threads it went wrong. FREE(pG->OrigCurrentDir); // DLL v1.6017 pG->OCDlength = lstrlen(fileArg->fRootDir); if ((pG->OrigCurrentDir = (char*)MALLOC(pG->OCDlength + 2)) == NULL) { // RP allow space for '\' Inform(pG, ZEN_MEM36, 0, "CurrentDir allocation error"); return ziperr(ZEN_MEM36, pG); } lstrcpy(pG->OrigCurrentDir, fileArg->fRootDir); if (pG->verbose) Inform(pG, 0, IERROR, "Root dir now %s", pG->OrigCurrentDir); } if (C->fVersion > 178) { if (fileArg->fLevel) { r = fileArg->fLevel; r = r < 0 ? 0 : (r > 9 ? 9 : r); if (r != pG->level) { pG->level = r; pG->method = r ? DEFLATE : STORE; if (pG->verbose) Inform(pG, 0, IDIAG, "setting compression level to %d", r); } } if (fileArg->fFromDate) pG->before = fileArg->fFromDate == (unsigned) - 1 ? 0 : fileArg ->fFromDate; else pG->before = g_before; } #ifdef USE_STRM_INPUT if (arg1 < 0) { arg1 = argno; if (pG->UseInStream) { // Here we fill in the FoundList from the input stream data // newname (fileio.c) adds to found list. If error m!=0 on return if ((r = newname(fspec, pG->InStreamSize, pG)) != ZEN_OK) { if (pG->verbose) Inform(pG, 0, IDIAG, "Stream filename could not be added in newname call"); if (pG->zcount) FREE(pG->zsort); return r; } break; } } #endif #ifdef CRYPT if (fileArg->fEncrypt) { pG->key = fileArg->fPassword; if (!pG->key || !*(pG->key)) { // use global if ((r = GetUserPW(pG)) != ZEN_OK) break; pG->key = pG->user_key; } // pG->doesEncrypt = 1; // 1.73 } #endif pG->doall = 0; // do selected if ((pG->action == ADD) || (pG->action == UPDATE)) { if (pG->verbose) Inform(pG, 0, IDIAG, "collecting %s %s", fspec, pG->recurse ? "recurse" : " "); r = Wild(fspec, pG); } else // Freshen or Delete - must be internal file { if (pG->verbose) Inform(pG, 0, IDIAG, "collecting %s %s", fspec, pG->recurse ? "recurse" : " "); r = procname(fspec, pG->recurse, pG); } if (r != ZEN_OK) { if ((int)(char)(r &0xFF) == ZEN_MISS) { /* this occurs if new file wasn't found */ Inform(pG, r, IERROR, "File specification \"%s\" skipped", fspec); r = 0; } } if (r) return ziperr(r, pG); } return 0; }