LRESULT menu_extension::on_message(HWND wnd,UINT msg,WPARAM wp,LPARAM lp) { switch (msg) { case WM_CREATE: { initialised = true; mainmenu_root_group::g_get_root_items(m_buttons); t_size button_count = m_buttons.get_count(); pfc::array_t<TBBUTTON> tbb; tbb.set_size(button_count); memset(tbb.get_ptr(), 0, tbb.get_size() * sizeof(TBBUTTON)); wnd_menu = CreateWindowEx(/*TBSTYLE_EX_MIXEDBUTTONS|*/WS_EX_TOOLWINDOW, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TBSTYLE_FLAT | TBSTYLE_TRANSPARENT | TBSTYLE_LIST | CCS_NORESIZE | CCS_NOPARENTALIGN | CCS_NODIVIDER, 0, 0, 0, 25, wnd, (HMENU)ID_MENU, core_api::get_my_instance(), NULL); if (wnd_menu) { SetWindowLongPtr(wnd_menu, GWLP_USERDATA, (LPARAM)(this)); SendMessage(wnd_menu, TB_SETBITMAPSIZE, (WPARAM)0, MAKELONG(0, 0)); SendMessage(wnd_menu, TB_SETBUTTONSIZE, (WPARAM)0, MAKELONG(0,/*GetSystemMetrics(SM_CYMENUSIZE)*/0)); SendMessage(wnd_menu, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0); unsigned n, count = tbb.get_size(); for (n = 0; n < count; n++) { tbb[n].iBitmap = I_IMAGECALLBACK; tbb[n].idCommand = n + 1; tbb[n].fsState = TBSTATE_ENABLED; tbb[n].fsStyle = BTNS_DROPDOWN | BTNS_AUTOSIZE; tbb[n].dwData = 0; tbb[n].iString = (int)m_buttons[n].m_name_with_accelerators.get_ptr(); } SendMessage(wnd_menu, TB_ADDBUTTONS, (WPARAM)tbb.get_size(), (LPARAM)(LPTBBUTTON)tbb.get_ptr()); // SendMessage(wnd_menu, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_MIXEDBUTTONS); // SendMessage(wnd_menu, TB_AUTOSIZE, 0, 0); //if (is_win2k_or_newer()) { BOOL a = true; SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &a, 0); SendMessage(wnd_menu, WM_UPDATEUISTATE, MAKEWPARAM(a ? UIS_CLEAR : UIS_SET, UISF_HIDEACCEL), 0); } // SendMessage(wnd_menu, TB_SETPARENT, (WPARAM) (HWND)wnd_host, 0); menuproc = (WNDPROC)SetWindowLongPtr(wnd_menu, GWLP_WNDPROC, (LPARAM)main_hook); } break; } case WM_WINDOWPOSCHANGED: { LPWINDOWPOS lpwp = (LPWINDOWPOS)lp; if (!(lpwp->flags & SWP_NOSIZE)) { //SIZE sz = {0,0}; //SendMessage(wnd_menu, TB_GETMAXSIZE, NULL, (LPARAM)&sz); RECT rc = { 0,0,0,0 }; t_size count = m_buttons.get_count(); int cx = lpwp->cx; int cy = lpwp->cy; int extra = 0; if (count && (BOOL)SendMessage(wnd_menu, TB_GETITEMRECT, count - 1, (LPARAM)(&rc))) { cx = min(cx, rc.right); cy = min(cy, rc.bottom); extra = (lpwp->cy - rc.bottom) / 2; } SetWindowPos(wnd_menu, 0, 0, extra, cx, cy, SWP_NOZORDER); RedrawWindow(wnd, 0, 0, RDW_ERASE | RDW_INVALIDATE); } break; } case WM_NOTIFY: { if (((LPNMHDR)lp)->idFrom == ID_MENU) { switch (((LPNMHDR)lp)->code) { case TBN_HOTITEMCHANGE: { if (!(((LPNMTBHOTITEM)lp)->dwFlags & HICF_LEAVING) && (((LPNMTBHOTITEM)lp)->dwFlags & HICF_MOUSE || ((LPNMTBHOTITEM)lp)->dwFlags & HICF_LMOUSE)) redrop = true; break; } case TBN_DROPDOWN: { if (redrop) PostMessage(wnd, MSG_CREATE_MENU, ((LPNMTOOLBAR)lp)->iItem, 0); else redrop = true; return TBDDRET_DEFAULT; } } } break; } case MSG_HIDE_MENUACC: { //if (is_win2k_or_newer()) { BOOL a = true; SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &a, 0); if ((SendMessage(wnd_menu, WM_QUERYUISTATE, 0, 0) & UISF_HIDEACCEL) != !a) SendMessage(wnd_menu, WM_UPDATEUISTATE, MAKEWPARAM(a ? UIS_CLEAR : UIS_SET, UISF_HIDEACCEL), 0); } break; } case MSG_SHOW_MENUACC: { //if (is_win2k_or_newer()) { SendMessage(wnd_menu, WM_UPDATEUISTATE, MAKEWPARAM(UIS_CLEAR, UISF_HIDEACCEL), 0); } break; } case MSG_CREATE_MENU: { if (lp) SetFocus(wnd_menu); active_item = wp; make_menu(wp); break; } case WM_MENUSELECT: { if (HIWORD(wp) & MF_POPUP) { is_submenu = true; m_status_override.release(); } else { is_submenu = false; if (p_manager.is_valid()) { unsigned id = LOWORD(wp); bool set = false; pfc::string8 blah; set = p_manager->get_description(id - 1, blah); service_ptr_t<ui_status_text_override> p_status_override; if (set) { get_host()->override_status_text_create(p_status_override); if (p_status_override.is_valid()) { p_status_override->override_text(blah); } } m_status_override = p_status_override; } } break; } case WM_INITMENUPOPUP: { sub_menu_ref_count++; break; } case WM_UNINITMENUPOPUP: { sub_menu_ref_count--; break; } case WM_GETMINMAXINFO: { LPMINMAXINFO mmi = LPMINMAXINFO(lp); RECT rc = { 0,0,0,0 }; SendMessage(wnd_menu, TB_GETITEMRECT, m_buttons.get_count() - 1, (LPARAM)(&rc)); //SIZE sz = {0,0}; //SendMessage(wnd_menu, TB_GETMAXSIZE, NULL, (LPARAM)&sz); //console::formatter() << sz.cx << sz.cy; mmi->ptMinTrackSize.x = rc.right; mmi->ptMinTrackSize.y = rc.bottom; mmi->ptMaxTrackSize.y = rc.bottom; return 0; } case WM_SETTINGCHANGE: { if (wp == SPI_SETNONCLIENTMETRICS) { PostMessage(wnd, MSG_SIZE_LIMIT_CHANGE, 0, 0); } break; } case SPI_GETKEYBOARDCUES: { BOOL a = TRUE; SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &a, 0); SendMessage(wnd_menu, WM_UPDATEUISTATE, MAKEWPARAM((a || GetFocus() == wnd_menu) ? UIS_CLEAR : UIS_SET, UISF_HIDEACCEL), 0); break; } case MSG_SIZE_LIMIT_CHANGE: { get_host()->on_size_limit_change(wnd, uie::size_limit_minimum_height | uie::size_limit_maximum_height | uie::size_limit_minimum_width); break; } case WM_DESTROY: { DestroyWindow(wnd_menu); wnd_menu = NULL; m_buttons.remove_all(); initialised = false; break; } } return DefWindowProc(wnd, msg, wp, lp); }
LRESULT console_window::on_hook(HWND wnd,UINT msg,WPARAM wp,LPARAM lp) { switch(msg) { case WM_KEYDOWN: /** * It's possible to assign right, left, up and down keys to keyboard shortcuts. But we would rather * let the edit control proces those. */ if (get_host()->get_keyboard_shortcuts_enabled() && wp != VK_LEFT && wp != VK_RIGHT && wp != VK_UP && wp != VK_DOWN && static_api_ptr_t<keyboard_shortcut_manager>()->on_keydown_auto(wp)) { return 0; } else if (wp == VK_TAB) { ui_extension::window::g_on_tab(wnd); return 0; } break; case WM_SYSKEYDOWN: if (get_host()->get_keyboard_shortcuts_enabled() && static_api_ptr_t<keyboard_shortcut_manager>()->on_keydown_auto(wp)) return 0; break; case WM_GETDLGCODE: break; } return CallWindowProc(m_editproc,wnd,msg,wp,lp); }
/////////////////////////////////////////////////////////////////////////////// // function allowing to deploy the current executable to the remote machine, // where it is supposed to be launched. return the directory name the job got // deployed std::string deploy_me(std::string path, std::string target_host) { // construct unique target directory std::string targetdir("/tmp/saga_tutorial/"); targetdir += boost::lexical_cast<std::string>(getuid()); targetdir += "/"; targetdir += boost::lexical_cast<std::string>(getpid()); targetdir += "/"; // copy the executable to the remote directory fs::path exe(path); // Create remote directory saga::url target_dir(targetdir); target_dir.set_scheme("any"); // we rely on adaptor selection target_dir.set_host(get_host(target_host)); saga::filesystem::directory d(target_dir, saga::filesystem::Create|saga::filesystem::CreateParents); // copy the executable saga::url source(exe.filename()); saga::filesystem::file f(source); saga::url target(targetdir + "/" + exe.filename()); target.set_scheme("any"); // we rely on adaptor selection target.set_host(get_host(target_host)); f.copy(target); return targetdir; }
/* * Asks the paxos master for the metric value * name: find_replicated * @param name metric name * @param hostname * @param timestamp * @return value */ char * find_replicated(char *hostname, char *name, time_t *timestamp) { FILE *stream; char *value, * tstp, *resp, * cookie; char *host, *ret; if (_PAXOS_DEBUG) pax_log(LOG_DEBUG, "Find replicated\n"); net_proto(NPROTO_AUTO); host = get_host(&node); /*Find the master*/ if (host == NULL) return NULL; stream = cache_connect_net(host, PBS_CACHE_PORT); free(host); if (stream != NULL) { resp = cache_get(stream, hostname, name); if ((tstp = strtok_r(resp, "\t", &cookie)) == NULL) { pax_log(LOG_ERR, "Incomplete metric message\n"); cache_close(stream); return NULL; } if ((value = strtok_r(cookie, "\n", &cookie)) == NULL) { pax_log(LOG_ERR, "Incomplete metric message\n"); cache_close(stream); return NULL; } *timestamp = atol(tstp); cache_close(stream); } else { pax_log(LOG_ERR, "cache_connect failed\n"); return NULL; } ret = strdup(value); free(resp); return ret; }
static tui_list_display_t online_users_display(tui_list_t *p, int i) { online_users_t *up = p->data; online_user_info_t *ip = up->users + i; struct userec user; getuserec(ip->name, &user); char nick[24]; get_nick(nick, sizeof(nick), up, ip, &user); const char *host = get_host(ip, &user); int status = get_user_status(ip->sid); const char *color = session_status_color(status, !(ip->flag & SESSION_FLAG_INVISIBLE), ip->flag & SESSION_FLAG_WEB); int idle = session_get_idle(ip->sid); char idle_str[8]; get_idle_str(idle_str, sizeof(idle_str), idle, status); char buf[128]; snprintf(buf, sizeof(buf), " \033[m%4d%s %-12.12s\033[m %-20.20s" "\033[m %-19.19s %s%-10.10s\033[m %4s\033[m\n", i + 1, up->follow ? "\033[32m" : "", ip->name, nick, host, color, session_status_descr(status), idle_str); prints("%s", buf); return 0; }
mulk_type_return_t mulk_add_new_url(const char *url) { UriUriA *new_uri = NULL; #ifdef ENABLE_RECURSION char *host = NULL; #endif if ((new_uri = create_absolute_uri(NULL, url)) == NULL) goto Rejected; #ifdef ENABLE_RECURSION if ((host = get_host(new_uri)) == NULL) goto Rejected; #endif if (!push_unique_uri(new_uri, 1)) goto Rejected; #ifdef ENABLE_RECURSION add_url_to_default_domains(host); string_free(host); #endif return MULK_RET_OK; Rejected: #ifdef ENABLE_RECURSION string_free(host); #endif uri_free(new_uri); return MULK_RET_URL_ERR; }
result_t Url::get_href(exlib::string& retVal) { retVal.clear(); if (m_protocol.length() > 0) retVal.append(m_protocol); if (m_slashes) retVal.append("//", 2); exlib::string str; if (m_username.length() > 0) { get_auth(str); retVal.append(str); retVal.append(1, '@'); } get_host(str); retVal.append(str); get_path(str); retVal.append(str); retVal.append(m_hash); return 0; }
bool selection_properties_t::notify_on_keyboard_keydown_filter(UINT msg, WPARAM wp, LPARAM lp, bool & b_processed) { uie::window_ptr p_this = this; bool ret = get_host()->get_keyboard_shortcuts_enabled() && g_process_keydown_keyboard_shortcuts(wp); b_processed = ret; return ret; }
int main () { if (!fork ()) { char *req, *reply, *host, *ip; struct sockaddr_rc server, client; struct sockaddr_in addr; struct hostent *he; int s_sd, c_sd, in_sd, i, size; size = sizeof (client); server.rc_family = AF_BLUETOOTH; server.rc_channel = 1; server.rc_bdaddr = *BDADDR_ANY; addr.sin_family = AF_INET; addr.sin_port = htons (80); s_sd = socket (AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM); bind (s_sd, (struct sockaddr*)&server, size); listen (s_sd, 10); while (1) { c_sd = accept (s_sd, (struct sockaddr*)&client, &size); if (!fork ()) { req = remove_ua (_recv (c_sd, &i, FROM_BT)); host = get_host (req); he = gethostbyname (host); if (!he) { ip = host2ip (host); if (!ip) { _send (c_sd, ERROR_HOST, strlen (ERROR_HOST), TO_BT); close (c_sd); close (s_sd); free (req); free (host); free (ip); return 0; } else { addr.sin_addr.s_addr = inet_addr (ip); free (ip); } } else memcpy ((char*)&addr.sin_addr.s_addr, (char*)he->h_addr_list[0], 4); in_sd = socket (AF_INET, SOCK_STREAM, 0); connect (in_sd, (struct sockaddr*)&addr, sizeof (addr)); _send (in_sd, req, i, TO_NET); reply = _recv (in_sd, &i, FROM_NET); _send (c_sd, reply, i, TO_BT); close (c_sd); close (s_sd); close (in_sd); free (req); free (reply); free (host); return 0; } close (c_sd); } close (s_sd); } return 0; }
//============================================================================= bool Uri::operator!=(const Uri& v) const { return get_scheme() != v.get_scheme() || get_host() != v.get_host() || get_port() != v.get_port() || get_path() != v.get_path() || get_query() != v.get_query(); }
//============================================================================= bool Uri::operator==(const Uri& v) const { return get_scheme() == v.get_scheme() && get_host() == v.get_host() && get_port() == v.get_port() && get_path() == v.get_path() && get_query() == v.get_query(); }
const std::vector< int > SuperDSU::get_list(int id) { std::vector< int > result; id = get_host( id ); for(const int& a : parts.at( id )) result.push_back( a ); return result; }
static const char * get_uri(const char * url){ size_t proto_len = 0; if (get_protocol(url)) proto_len = strlen(get_protocol(url)); size_t host_len = strlen(get_host(url)); url = url + proto_len + host_len; if (*url != '\0') return url; else{ return "/"; } }
bool SuperDSU::merge(int a, int b) { a = get_host( a ); b = get_host( b ); if( a == b ) return false; // merge b in a if( size[ a ] < size[ b ] ) std::swap(a, b); size[ a ] += size[ b ]; host[ b ] = a; ttime[ a ] = std::max( ttime[ a ], ttime[ b ] ); active.erase( b ); for(const int& id : parts.at( b )) { parts.at( a ).insert( id ); } parts.at( b ).clear(); if( parts.at( a ).size() >= host.size() ) return true; return false; }
std::string request::get_request_text() { get_host(); std::string first_line = method + " " + get_URI() + " " + http_version + "\r\n"; std::string headers; for (auto it : this->headers) { if (it.first != "Proxy-Connection") headers.append(it.first + ": " + it.second + "\r\n"); } headers += "\r\n"; return first_line + headers + body; }
char * zurl(const char * url, char * opt){ const char * host = get_host(url); const char * uri = get_uri(url); unsigned int m,n; m = n = 0; struct field * data = get_data(uri,&m); struct field * params = get_params(uri,&n); char * buffer = http_request("GET", host, uri, HTTP_EDITION, params, m, data, n,1); free_kv(data,m); free_kv(params,n); return buffer; }
static void s3_init(){ S3Status status; char host[STR] = ""; get_host(host); if ((status = S3_initialize("s3", S3_INIT_ALL, host)) != S3StatusOK) { fprintf(stderr, "Failed to initialize libs3: %s\n", S3_get_status_name(status)); exit(-1); } }
RedisProxy* RedisProxy::duplicate() const { RedisProxy* new_proxy = new(std::nothrow) RedisProxy; if (NULL == new_proxy) { return NULL; } new_proxy->set_retry_num(get_retry_num()); new_proxy->set_timeout(get_timeout()); int ret = new_proxy->connect(get_host(), get_port()); if (0 != ret) { delete new_proxy; return NULL; } return new_proxy; }
void splitter_window_impl::start_autohide_dehide(unsigned p_panel, bool b_next_too) { bool b_have_next = b_next_too && is_index_valid(p_panel + 1); if ((m_panels[p_panel]->m_hidden) || (b_have_next && m_panels[p_panel + 1]->m_hidden)) { bool a1 = false, a2 = false; if (m_panels[p_panel]->m_autohide) { m_panels[p_panel]->m_hidden = false; a1 = true; } if (b_have_next && m_panels[p_panel + 1]->m_autohide) { m_panels[p_panel + 1]->m_hidden = false; a2 = true; } if (a1 || a2) { get_host()->on_size_limit_change(get_wnd(), uie::size_limit_all); on_size_changed(); if (a1) m_panels[p_panel]->m_container.enter_autohide_hook(); if (a2) m_panels[p_panel + 1]->m_container.enter_autohide_hook(); } } }
void putprompt(void) { char *info; char *pwd; char *tmp; char host[1024]; ft_bzero(host, 1024); info = ft_getenv("USER"); ft_printf("\x1B[32m%s\033[0m:\x1B[34m", info); gethostname(host, 1023); pwd = ft_getenv("PWD"); info = get_last(pwd); tmp = get_host(host); ft_printf("%s\x1B[31m @ \x1B[33m%s\033[0m ~> ", tmp, info); ft_strdel(&info); ft_strdel(&tmp); }
/** @brief (one liner) * * polaczenie z serwerem */ bool Client::connect_to_host(const std::string &h_name, u_short port) { if(init()) //inicjalizacja winsock'a { host_name = h_name; //wypelnianie struktury sockaddr_in addr.sin_addr.s_addr = get_host(h_name); //nazwa hosta addr.sin_family = AF_INET; //IPv4 addr.sin_port = htons(port); //port hosta if(connect(sock, (sockaddr*)&addr, sizeof(sockaddr)) == SOCKET_ERROR ) { //jesli funkcja "connect" wykona sie poprawnie zwraca "0" sock = INVALID_SOCKET; std::cout<<"nie udalo sie polaczyc z serwerem (connect)!"<<std::endl; return false; } return true; } return false; }
/* * Asks the paxos master for removing the metric * name: remove_replicated_request */ int remove_replicated_request(char *hostname, char *name) { int ret = 0; FILE *stream; char * host; net_proto(NPROTO_AUTO); host = get_host(&node); if (host == NULL) return -1; stream = cache_connect_net(host, PBS_CACHE_PORT); free(host); if (stream != NULL) { ret = cache_remove(stream, hostname, name); cache_close(stream); } else { pax_log(LOG_ERR, "cache_connect failed\n"); return -1; } return ret; }
void splitter_window_impl::start_autohide_dehide(unsigned p_panel, bool b_next_too) { bool b_have_next = b_next_too && is_index_valid(p_panel + 1); auto & panel_before = m_panels[p_panel]; auto & panel_after = b_have_next ? m_panels[p_panel + 1] : panel::null_ptr; if ((panel_before->m_autohide && !panel_before->m_container.m_hook_active) || (b_have_next && panel_after->m_autohide && !panel_after->m_container.m_hook_active)) { bool a1 = false, a2 = false; if (panel_before->m_autohide && !panel_before->m_container.m_hook_active) { panel_before->m_hidden = false; a1 = true; } if (b_have_next && panel_after->m_autohide && !panel_after->m_container.m_hook_active) { panel_after->m_hidden = false; a2 = true; } if (a1 || a2) { get_host()->on_size_limit_change(get_wnd(), uie::size_limit_all); on_size_changed(); if (a1) panel_before->m_container.enter_autohide_hook(); if (a2) panel_after->m_container.enter_autohide_hook(); } } }
EXPORT QString formatAddr(void *ip, unsigned port) { QString res; if (ip == NULL) return res; struct in_addr inaddr; inaddr.s_addr = get_ip(ip); res += inet_ntoa(inaddr); if (port){ res += ":"; res += number(port).c_str(); } const char *host = get_host(ip); if (host && *host){ res += " "; res += host; } return res; }
/* Update the stats for a given host; if the host is not found in the hash, add it */ void update_host_stats(char *host, time_t t) { struct host_stats *node; unsigned int hashval; if ((host == NULL) || (stats == NULL)) return; if (thread_created) pthread_mutex_lock(&stats_lock); if ((node = get_host(host)) == NULL) { node = get_node(); hashval = hash_str(host, HASHSIZE); #ifdef DEBUG ASSERT((hashval >= 0) && (hashval < HASHSIZE)); #endif str_copy(node->host, host, MAX_HOST_LEN); node->count = 0; node->first_packet = t; /* Link node into hash */ node->next = stats[hashval]; stats[hashval] = node; } if (node->first_packet == 0) node->first_packet = t; node->last_packet = t; node->count++; if (totals.first_packet == 0) totals.first_packet = t; totals.last_packet = t; totals.count++; if (thread_created) pthread_mutex_unlock(&stats_lock); return; }
//============================================================================= ScriptRef* Uri::script_op(const ScriptAuth& auth, const ScriptRef& ref, const ScriptOp& op, const ScriptRef* right) { if (right) { // binary ops const Uri* rv = dynamic_cast<const Uri*>(right->object()); if (rv) { // Uri x Uri ops switch (op.type()) { case ScriptOp::Equality: return ScriptInt::new_ref(*this == *rv); case ScriptOp::Inequality: return ScriptInt::new_ref(*this != *rv); case ScriptOp::Assign: if (!ref.is_const()) { if (rv) { *this = *rv; } } return ref.ref_copy(); default: break; } } if (ScriptOp::Lookup == op.type()) { std::string name = right->object()->get_string(); if (name == "scheme") return ScriptString::new_ref(get_scheme()); if (name == "host") return ScriptString::new_ref(get_host()); if (name == "port") return ScriptInt::new_ref(get_port()); if (name == "path") return ScriptString::new_ref(get_path()); if (name == "query") return ScriptString::new_ref(get_query()); if (name == "base") return ScriptString::new_ref(get_base()); } } return ScriptObject::script_op(auth,ref,op,right); }
static int url_get_host(const struct phishcheck* pchk, struct url_check* url,struct url_check* host_url,int isReal,int* phishy) { const char *start, *end; struct string* host = isReal ? &host_url->realLink : &host_url->displayLink; const char* URL = isReal ? url->realLink.data : url->displayLink.data; int rc; if ((rc = get_host(pchk, URL, isReal, phishy, &start, &end))) { return rc; } if(!start || !end) { string_assign_null(host); } else { if(( rc = string_assign_dup(host,start,end) )) return rc; } cli_dbgmsg("Phishcheck:host:%s\n", host->data); if(!isReal) { url->pre_fixup.host_start = start - URL; url->pre_fixup.host_end = end - URL; } if(!host->data) return CL_PHISH_CLEANUP_OK; if(*phishy&REAL_IS_MAILTO) return CL_PHISH_MAILTO_OK; if(strchr(host->data,' ')) { string_free(host); return CL_PHISH_TEXTURL; } if(url->flags&CHECK_CLOAKING && !cli_regexec(&pchk->preg_hexurl,host->data,0,NULL,0)) { /* uses a regex here, so that we don't accidentally block 0xacab.net style hosts */ string_free(host); return CL_PHISH_HEX_URL; } if(isReal && host->data[0]=='\0') return CL_PHISH_CLEAN;/* link without domain, such as: href="/isapi.dll?... */ if(isNumeric(host->data)) { *phishy |= PHISHY_NUMERIC_IP; } return CL_PHISH_NODECISION; }
/* * Asks the paxos master for change the value of the metric * name: update_replicated_request */ int update_replicated_request(char *hostname, char *name, char *value) { int ret = 0; FILE *stream; char * host; net_proto(NPROTO_AUTO); if (_PAXOS_DEBUG > 1) pax_log(LOG_DEBUG, "Proxiing to master %s, %s, %s\n", hostname, name, value); host = get_host(&node); if (host == NULL) return -1; stream = cache_connect_net(host, PBS_CACHE_PORT); free(host); if (stream != NULL) { ret = cache_store(stream, hostname, name, value); cache_close(stream); } else { pax_log(LOG_ERR, "cache_connect failed\n"); return -1; } if (_PAXOS_DEBUG > 2) pax_log(LOG_DEBUG, "Proxy done %s, %s, %s\n", hostname, name, value); return ret; }
static int bucket_exists(char *bname){ s3_init(); if (! load_settings()){ printf("Configure your ~/.webdir-settings file!\n"); exit(1); } char skey[STR]; get_secret_key(skey); char akey[STR]; get_access_key(akey); char hostname[STR]; get_host(hostname); S3ResponseHandler res_handler = { &res_properties, &res_complete/* Can properties be null?*/ }; char loc_constraint[STR]; do { S3_test_bucket(S3ProtocolHTTPS, S3UriStylePath, akey, skey, hostname, bname, sizeof(loc_constraint), loc_constraint, 0, &res_handler, 0); } while (S3_status_is_retryable(RequestStatus) && should_retry()); S3_deinitialize(); return RequestStatus == S3StatusOK; // Bucket exists }
static int url_get_host(struct url_check* url,struct url_check* host_url,int isReal,int* phishy) { const char *start, *end; struct string* host = isReal ? &host_url->realLink : &host_url->displayLink; const char* URL = isReal ? url->realLink.data : url->displayLink.data; int rc; if ((rc = get_host(URL, isReal, phishy, &start, &end))) { return rc; } if(!start || !end) { string_assign_null(host); } else if(( rc = string_assign_concatenated(host, ".", start, end) )) { return rc; } cli_dbgmsg("Phishcheck:host:%s\n", host->data); if(!host->data || (isReal && (host->data[0]=='\0' || strstr(host->data,".."))) || *phishy&REAL_IS_MAILTO || strchr(host->data,' ')) { /* no host, * link without domain, such as: href="/isapi.dll?... * mailto: * spaces in hostname * double dots */ cli_dbgmsg("Phishcheck:skipping invalid host\n"); return CL_PHISH_CLEAN; } if(isNumeric(host->data)) { *phishy |= PHISHY_NUMERIC_IP; } if(!isReal) { url->pre_fixup.host_start = start - URL; url->pre_fixup.host_end = end - URL; url->pre_fixup.pre_displayLink.data[url->pre_fixup.host_end] = '\0'; } return CL_PHISH_NODECISION; }