void LoadHSet(qCtx *ctx) { //core CStr tmpName; tmpName = getenv("SMXHOME"); if (tmpName.IsEmpty()) { #ifdef WIN32 tmpName = getenv("TEMP"); if (tmpName.IsEmpty()) { tmpName = getenv("HOMEDRIVE"); if (!tmpName.IsEmpty()) { tmpName += getenv("HOMEPATH"); tmpName.RTrim('/'); tmpName.RTrim('\\'); } else { tmpName = "."; } } tmpName = tmpName + "\\.smx"; CreateDirectory(tmpName,NULL); tmpName = tmpName + "\\hset.db"; #else tmpName = getenv("HOME"); if (tmpName.IsEmpty()) tmpName = "/tmp"; mkdir(tmpName,0750); tmpName = tmpName + "/.smx"; mkdir(tmpName,0750); tmpName = tmpName + "/hset.db"; #endif } else { #ifdef WIN32 tmpName = tmpName + "\\hset.db"; #else tmpName = tmpName + "/hset.db"; #endif } #ifdef WIN32 remove(tmpName); #endif qObjHCtx *hCtx = new qObjHCtx(ctx); hCtx->SetPath(tmpName, true); ctx->MapObj(hCtx, EvalHSet, "hset"); ctx->MapObj(hCtx, EvalHSet, "hdel"); ctx->MapObj(hCtx, EvalHGet, "hget"); ctx->MapObj(hCtx, EvalHExists, "hexists"); ctx->MapObj(hCtx, EvalHFile, "hdbfile"); ctx->MapObj(hCtx, EvalHEnumValues, "henumvalues"); ctx->MapObj(hCtx, EvalHEnumKeys, "henumkeys"); ctx->MapObj(hCtx, EvalHEnumTree, "henumtree"); ctx->MapObj(hCtx, "<hctx>"); }
void EvalRTrim(const void *data, qCtx *ctx, qStr *out, qArgAry *args) { VALID_ARGC("ltrim", 1, 2); if (args->Count() > 1) { CStr str = (*args)[0]; if (str.IsEmpty()) return; CStr toks = (*args)[1]; if (toks.Length() == 0) out->PutS(str); else if (toks.Length() == 1) out->PutS(str.RTrim(*toks)); else { const char *p, *b = str; p = b + str.Length() - 1; while(p >= b && strchr((const char *)toks, *p)) --p; ++p; out->PutS(b, p - b); } } else out->PutS((*args)[0].RTrim()); }