inline void add(const BiIntv& suff, const BiIntv& pref) { bvs_[0].set(begins(suff)); bvs_[1].set(ends(suff)); ++perm_[0][begins(pref)]; ++perm_[1][ends(pref)]; }
/* based on the name of a symbol determine whether it is an imported symbol */ static int is_import (unsigned char *name) { if (begins (name, "__imp_")) /* don't reimport symbols */ return 0; else if (begins (name, "__IMPORT_DESCRIPTOR_")) return 0; else if (strcmp (name, "__NULL_IMPORT_DESCRIPTOR") == 0) return 0; else if (*name == 0x7f) /* thunk */ return 0; return 1; }
void buy(char* input) { debug("init buy cmd"); if (begins(input, "snack ")) { debug("exec buy snack"); buySnacks(input + 5); } else if (begins(input, "mate")) { debug("exec buy mate"); execBuyWithName(MATE); } else { debug("no match in buy"); printf("Don't know what you want...\n"); } }
void find(char* input) { if (begins(input, "snack ")) { debug("exec find snack cmd"); findSnack(input + 6); } else if (begins(input, "user ")) { debug("exec find user cmd"); findUser(input + 5); } else { debug("no match found in find"); debug("try snack"); findSnack(input); } }
int main() { assert(begins("abc", "a")); assert(begins("abc", "ab")); assert(begins("abc", "abc")); assert(begins("abcd", "abc")); assert(!begins("abc", "b")); assert(!begins("abc", "bc")); assert(!begins("abc", "bcd")); assert(!begins("abc", "abcd")); assert(ibegins("Abc", "a")); assert(ibegins("aBc", "ab")); assert(ibegins("abC", "abc")); assert(ibegins("abcD", "abc")); assert(!ibegins("abc", "b")); assert(!ibegins("abc", "bc")); assert(!ibegins("abc", "bcd")); assert(!ibegins("abc", "abcd")); assert(ends("abc", "c")); assert(ends("abc", "bc")); assert(ends("abc", "abc")); assert(ends("abcd", "abcd")); assert(!ends("abc", "b")); assert(!ends("abc", "ab")); assert(!ends("abc", "bcd")); assert(!ends("abc", "abcd")); assert(iends("Abc", "c")); assert(iends("aBc", "bc")); assert(iends("abC", "abc")); assert(iends("abcD", "abcd")); assert(!iends("abc", "b")); assert(!iends("abc", "ab")); assert(!iends("abc", "bcd")); assert(!iends("abc", "abcd")); return 0; }
/** * shell function */ int shell() { debug("shell init"); checkLogin(); char input[MAXLENGTH]; for (;;) { printf("%s>", getUser()); read_line(input); if (sequals(input, "exit")) { debug("shut down"); shellExit(); } else if (begins(input, "set ")) { debug("exec set cmd"); parseSet(input + 4); } else if (begins(input, "list ")) { debug("exec list cmd"); parseList(input + 5); } else if (begins(input, "search ")) { debug("exec find cmd from search"); find(input + 7); } else if (begins(input, "find ")) { debug("exec find cmd"); find(input + 5); } else if (begins(input, "buy ")) { debug("exec buy cmd"); buy(input + 4); } else if (begins(input, "help")) { debug("exec help cmd"); printInternHelp(); } else if (begins(input, "balance")) { debug("exec balance cmd"); balanceUser(); } else { debug("no match found in shell"); printf("Don't know what you mean...\n"); } } return 0; }
bool auth_require(x0::HttpRequest *r, const x0::FlowParams& args) { AuthBasic* auth = r->customData<AuthBasic>(this); if (!auth || !auth->backend) { r->log(x0::Severity::error, "auth.require used without specifying a backend"); r->status = x0::HttpStatus::InternalServerError; r->finish(); return true; } auto authorization = r->requestHeader("Authorization"); if (!authorization) return sendAuthenticateRequest(r, auth->realm); if (authorization.begins("Basic ")) { x0::BufferRef authcode = authorization.ref(6); x0::Buffer plain = x0::Base64::decode(authcode); const char* user = plain.c_str(); char* pass = strchr(const_cast<char*>(plain.c_str()), ':'); if (!pass) return sendAuthenticateRequest(r, auth->realm); *pass++ = '\0'; r->username = user; r->log(x0::Severity::debug, "auth.require: '%s' -> '%s'", authcode.str().c_str(), plain.c_str()); if (auth->verify(user, pass)) { // authentification succeed, so do not intercept request processing return false; } } // authentification failed, one way or the other return sendAuthenticateRequest(r, auth->realm); }
/** * parse the set command */ void parseSet(char* input) { printf("%s\n", input); if (begins(input, "user ")) { debug("set user"); setUser(input + 5); return; } else if (begins(input, "pass ")) { if (strlen(input + 5) < 1) { debug("ask for password"); askPassword(); return; } debug("set password"); setPassword(input + 5); return; } else if (begins(input, "debug ")) { if (begins(input + 6, "true") || begins(input + 6, "on")) { setDebug(true); } else if (begins(input + 6, "false") || begins(input + 6, "off")) { setDebug(false); } } else if (begins(input, "pgpass ")) { if (begins(input + 7, "true") || begins(input + 7, "on")) { setPGPass(true); } else if (begins(input + 7, "false") || begins(input + 7, "off")) { setPGPass(false); } } debug("no match in set"); printf("Don't know what you want...\n"); }
typename super::const_iterator end() const { return { f, tuple::map(advances_by(size()), tuple::map(begins(), os)) }; }
typename super::const_iterator begin() const { return { f, tuple::map(begins(), os) }; }
typename super::iterator begin() { return { f, tuple::map(begins(), os) }; }