bool HttpRequestMessage::isValid() const{ //regex String _http_url_pattern (L"^(http|https)\\://[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\\-\\._\\?\\,\\'/\\\\+&%\\$#\\=~])*[^\\.\\,\\)\\(\\s]$"); std::wregex _reg( _http_url_pattern ); std::wsregex_iterator _reg_iter ( m_URLString.begin(), m_URLString.end(), _reg ); return _reg_iter != std::wsregex_iterator(); }
RegNodePtr _capture() { if (tryConsume('(')) { RegNodePtr r(new RegNode_Capture(_reg())); consume(')'); return r; } return RegNodePtr(); }
int sock_udp_create(sock_udp_t *sock, const sock_udp_ep_t *local, const sock_udp_ep_t *remote, uint16_t flags) { int res; (void)flags; assert((sock != NULL)); assert((remote == NULL) || (remote->port != 0)); if (sock->sock.input_callback != NULL) { sock_udp_close(sock); } mutex_init(&sock->mutex); mutex_lock(&sock->mutex); mbox_init(&sock->mbox, sock->mbox_queue, SOCK_MBOX_SIZE); atomic_init(&sock->receivers, 0); if ((res = _reg(&sock->sock, sock, _input_callback, local, remote)) < 0) { sock->sock.input_callback = NULL; } mutex_unlock(&sock->mutex); return res; }
int sock_udp_send(sock_udp_t *sock, const void *data, size_t len, const sock_udp_ep_t *remote) { struct udp_socket tmp; _send_cmd_t send_cmd = { .block = MUTEX_INIT, .remote = remote, .data = data, .len = len }; assert((sock != NULL) || (remote != NULL)); assert((len == 0) || (data != NULL)); /* (len != 0) => (data != NULL) */ /* we want the send in the uip thread (which udp_socket_send does not offer) * so we need to do it manually */ if (!send_registered) { if (evproc_regCallback(EVENT_TYPE_SOCK_SEND, _output_callback) != E_SUCCESS) { return -ENOMEM; } else { send_registered = true; } } if ((len > (UIP_BUFSIZE - (UIP_LLH_LEN + UIP_IPUDPH_LEN))) || (len > UINT16_MAX)) { return -ENOMEM; } if (remote != NULL) { if (remote->family != AF_INET6) { return -EAFNOSUPPORT; } if (remote->port == 0) { return -EINVAL; } send_cmd.remote = remote; } else if (sock->sock.udp_conn->rport == 0) { return -ENOTCONN; } /* cppcheck-supress nullPointerRedundantCheck * remote == NULL implies that sock != NULL (see assert at start of * function) * that's why it is okay in the if-statement above to check * sock->... without checking (sock != NULL) first => this check afterwards * isn't redundant */ if (sock == NULL) { int res; if ((res = _reg(&tmp, NULL, NULL, NULL, NULL)) < 0) { return res; } send_cmd.sock = &tmp; } else { send_cmd.sock = &sock->sock; } mutex_lock(&send_cmd.block); /* change to emb6 thread context */ if (evproc_putEvent(E_EVPROC_TAIL, EVENT_TYPE_SOCK_SEND, &send_cmd) == E_SUCCESS) { /* block thread until data was sent */ mutex_lock(&send_cmd.block); } else { /* most likely error: event queue was full */ send_cmd.res = -ENOMEM; } if (send_cmd.sock == &tmp) { udp_socket_close(&tmp); } mutex_unlock(&send_cmd.block); return send_cmd.res; }
RegNodePtr parse(const string& src) { m_src = src, m_curPos = 0; return _reg(); }