void run() { for ( int i = 0; i < 10; ++i ) { BSONObj shortKey = simpleKey( shortToken( i ), 1 ); insert( shortKey ); BSONObj longKey = simpleKey( longToken( i ), 800 ); insert( longKey ); } checkValid( 20 ); }
/*************************************************************** * cliToken: * Get token, as described by CLI flags ***************************************************************/ int cliToken( char **pp /* <m> addr of ptr to char string */ ,struct descriptor *dsc_ret /* <w> return token here */ ,int flags /* <r> cli flags, describing data type */ ) { int k; int sts; int typeflag; char c; char *p,*p2; char util[1024]; static char legalMdsChars[] = "0123456789._-:;*?%\\"; static struct descriptor dscUtil = { sizeof(util)-1,DSC_K_DTYPE_T,DSC_K_CLASS_S,0}; typeflag = flags & 0x0FFF; p = *pp = nonblank(*pp); if (!p) return(0); dscUtil.dscA_pointer = util; /* set addr in dscUtil descrip */ if (!typeflag || typeflag==VAL_M_QUOTED_STRING || typeflag==VAL_M_USER_DEFINED_TYPE) sts = ascToken(&p,&dscUtil,0,legalMdsChars); else if (typeflag == VAL_M_FILE) sts = ascFilename(&p,&dscUtil,0); else if (typeflag == VAL_M_NUMBER) { if (isdigit(*p) || (*p=='-' && isdigit(*(p+1)))) { sts = longToken(&p,&dscUtil,0,0); } else if (*p == '%') { c = toupper(*(p+1)); p2 = p + 2; /* first char of putative number */ if (c == 'X') { for ( ; isxdigit(*p2) ; p2++) ; } else if (c == 'O') { /* octal number ... */ for ( ; isdigit(*p2) && *p2<='7' ; p2++) ; } k = p2 - p; /* number of chars scanned */ if (k == 2) sts = 0; /*..invalid number */ else { if (k > dscUtil.dscW_length) k = dscUtil.dscW_length; strncpy(dscUtil.dscA_pointer,p,k); if (k < dscUtil.dscW_length) dscUtil.dscA_pointer[k] = '\0'; l2un(dscUtil.dscA_pointer,0,k); p = nonblank(p2); sts = CLI_STS_NORMAL; } } } else if (typeflag == VAL_M_DELTATIME) { sts = deltatimeToken(&p,&dscUtil,0,0); } else if (typeflag == VAL_M_REST_OF_LINE) { k = strlen(p); if (k > dscUtil.dscW_length) k = dscUtil.dscW_length; strncpy(dscUtil.dscA_pointer,p,k); if (k < dscUtil.dscW_length) dscUtil.dscA_pointer[k] = '\0'; p = 0; sts = CLI_STS_NORMAL; } else { printf("\n*ERR* cliToken can't handle typeflag %04X\n\n", typeflag); exit(0); } /*================================================ * Return to caller ... *===============================================*/ str_copy_dx(dsc_ret,&dscUtil); if (sts & 1) *pp = nonblank(p); return(sts); }