size_t sd_autolink__www( size_t *rewind_p, struct buf *link, uint8_t *data, size_t max_rewind, size_t size, unsigned int flags) { size_t link_end; if (max_rewind > 0 && !ispunct(data[-1]) && !isspace(data[-1])) return 0; if (size < 4 || memcmp(data, "www.", strlen("www.")) != 0) return 0; link_end = check_domain(data, size, 0); if (link_end == 0) return 0; while (link_end < size && !isspace(data[link_end])) link_end++; link_end = autolink_delim(data, link_end, max_rewind, size); if (link_end == 0) return 0; bufput(link, data, link_end); *rewind_p = 0; return (int)link_end; }
size_t sd_autolink__url(size_t *rewind_p, struct buf *link, uint8_t *data, size_t offset, size_t size) { size_t link_end, rewind = 0, domain_len; if (size < 4 || data[1] != '/' || data[2] != '/') return 0; while (rewind < offset && isalpha(data[-rewind - 1])) rewind++; if (!sd_autolink_issafe(data - rewind, size + rewind)) return 0; link_end = strlen("://"); domain_len = check_domain(data + link_end, size - link_end); if (domain_len == 0) return 0; link_end += domain_len; while (link_end < size && !isspace(data[link_end])) link_end++; link_end = autolink_delim(data, link_end, offset, size); if (link_end == 0) return 0; bufput(link, data - rewind, link_end + rewind); *rewind_p = rewind; return link_end; }
static cmark_node *www_match(cmark_parser *parser, cmark_node *parent, cmark_inline_parser *inline_parser) { cmark_chunk *chunk = cmark_inline_parser_get_chunk(inline_parser); size_t max_rewind = cmark_inline_parser_get_offset(inline_parser); uint8_t *data = chunk->data + max_rewind; size_t size = chunk->len - max_rewind; int start = cmark_inline_parser_get_column(inline_parser); size_t link_end; if (max_rewind > 0 && strchr("*_~(", data[-1]) == NULL && !cmark_isspace(data[-1])) return 0; if (size < 4 || memcmp(data, "www.", strlen("www.")) != 0) return 0; link_end = check_domain(data, size, 0); if (link_end == 0) return NULL; while (link_end < size && !cmark_isspace(data[link_end])) link_end++; link_end = autolink_delim(data, link_end); if (link_end == 0) return NULL; cmark_inline_parser_set_offset(inline_parser, (int)(max_rewind + link_end)); cmark_node *node = cmark_node_new_with_mem(CMARK_NODE_LINK, parser->mem); cmark_strbuf buf; cmark_strbuf_init(parser->mem, &buf, 10); cmark_strbuf_puts(&buf, "http://"); cmark_strbuf_put(&buf, data, (bufsize_t)link_end); node->as.link.url = cmark_chunk_buf_detach(&buf); cmark_node *text = cmark_node_new_with_mem(CMARK_NODE_TEXT, parser->mem); text->as.literal = cmark_chunk_dup(chunk, (bufsize_t)max_rewind, (bufsize_t)link_end); cmark_node_append_child(node, text); node->start_line = text->start_line = node->end_line = text->end_line = cmark_inline_parser_get_line(inline_parser); node->start_column = text->start_column = start - 1; node->end_column = text->end_column = cmark_inline_parser_get_column(inline_parser) - 1; return node; }
void read_list(void *readMole,kdomain *root,char *bl_filename,int type){ FILE *fp; char line[80]; if((fp = fopen(bl_filename,"r")) != NULL){ while(fgets(line,sizeof(line),fp) != NULL){ if(isalpha(line[0]) || isdigit(line[0])){ line[strlen(line)-1] = '\0'; check_domain(readMole,line,root,type,0); } } } fclose(fp); }
static cmark_node *url_match(cmark_parser *parser, cmark_node *parent, cmark_inline_parser *inline_parser) { size_t link_end, domain_len; int rewind = 0; cmark_chunk *chunk = cmark_inline_parser_get_chunk(inline_parser); int max_rewind = cmark_inline_parser_get_offset(inline_parser); uint8_t *data = chunk->data + max_rewind; size_t size = chunk->len - max_rewind; if (size < 4 || data[1] != '/' || data[2] != '/') return 0; while (rewind < max_rewind && cmark_isalpha(data[-rewind - 1])) rewind++; if (!sd_autolink_issafe(data - rewind, size + rewind)) return 0; link_end = strlen("://"); domain_len = check_domain(data + link_end, size - link_end, 1); if (domain_len == 0) return 0; link_end += domain_len; while (link_end < size && !cmark_isspace(data[link_end])) link_end++; link_end = autolink_delim(data, link_end); if (link_end == 0) return NULL; cmark_inline_parser_set_offset(inline_parser, (int)(max_rewind + link_end)); cmark_node_unput(parent, rewind); cmark_node *node = cmark_node_new_with_mem(CMARK_NODE_LINK, parser->mem); cmark_chunk url = cmark_chunk_dup(chunk, max_rewind - rewind, (bufsize_t)(link_end + rewind)); node->as.link.url = url; cmark_node *text = cmark_node_new_with_mem(CMARK_NODE_TEXT, parser->mem); text->as.literal = url; cmark_node_append_child(node, text); return node; }
char * search_email (char *data) { char *tmp; char *name; char *domain; int ret,count; struct email_info one_email; tmp = data; for ( ; *tmp !='\0';tmp++ ) { if (*tmp == '@') break; } if (tmp == data) return NULL; name = search_name(tmp,data); if (name == NULL) return NULL; count = tmp - name ; if (count > 32) return NULL; strncpy(one_email.name,name,count); one_email.name[count] = 0; ret = check_name(one_email.name,1); if (!ret) return NULL; domain = search_domain(tmp); if (domain == NULL) return NULL; count = domain - tmp - 1; if (count > 64) return NULL; tmp ++; strncpy(one_email.domain ,tmp,count); one_email.domain[count] = 0; ret = check_domain(one_email.domain,1); if (!ret) return NULL; printf("name: %s@%s\n",one_email.name,one_email.domain); }
static void ns_blist_add(IRC_User *s, IRC_User *u) { char *target = strtok(NULL, " "); if(target == NULL) send_lang(u, s, NS_BLIST_ADD_SYNTAX); else if(check_domain(target) == 0) send_lang(u, s, NS_BLIST_INPUT_NOT_CORRECT, target); else if(sql_singlequery("SELECT data FROM ns_blist WHERE data='%s'", target) !=0) send_lang(u, s, NS_BLIST_X_ALREADY_ON_LIST, target); else { sql_execute("INSERT INTO ns_blist VALUES ('%s')", target); send_lang(u, s, NS_BLIST_X_ADD_TO_LIST, target); } }
/** * see http://sourceforge.net/apps/mediawiki/sumo/index.php?title=TraCI/Mobility-related_commands * * Calls \c abort() in case of problems after sending a message to \c stderr. * * \param[in] node node to set max speed for * \param[in] max_speed max speed to set (negative -> original value) */ void TraCIClient::command_set_maximum_speed( const Node& node, double max_speed ) { // Node ID TraCIID ti; try { ti = find_traci_id_by_node( node ); } catch ( std::logic_error &e ) { std::cerr << "Error in method TraCIClient::command_set_maximum_speed: " << e.what() << std::endl; abort(); } check_domain( DomainVehicle, ti, true, "command_set_maximum_speed" ); command_set_value( id::CmdChangeVehicleState, id::VarVehicleSetMaxSpeed, ti.id(), FloatTypeWithTypeId(max_speed) ); }
size_t sd_autolink__url( size_t *rewind_p, struct buf *link, uint8_t *data, size_t max_rewind, size_t size, unsigned int flags) { size_t link_end, rewind = 0, domain_len; if (size < 4 || data[1] != '/' || data[2] != '/') return 0; while (rewind < max_rewind && isalpha(data[-rewind - 1])) rewind++; if (!sd_autolink_issafe(data - rewind, size + rewind)) return 0; link_end = strlen("://"); domain_len = check_domain( data + link_end, size - link_end, flags & SD_AUTOLINK_SHORT_DOMAINS); if (domain_len == 0) return 0; link_end += domain_len; while (link_end < size && !isspace(data[link_end])) link_end++; link_end = autolink_delim(data, link_end, max_rewind, size); if (link_end == 0) return 0; bufput(link, data - rewind, link_end + rewind); *rewind_p = rewind; return link_end; }
/** * see http://sourceforge.net/apps/mediawiki/sumo/index.php?title=TraCI/Mobility-related_commands * * Calls \c abort() in case of problems after sending a message to \c stderr. * * \param[in] node node (vehicle) to set lane constraint for * \param[in] lane lane to get vehicle to change to (0 for rightmost) * \param[in] time duration of lane constraint */ void TraCIClient::command_change_lane( const Node& node, char lane, float time ) { TraCIID ti; try { ti = find_traci_id_by_node( node ); } catch ( std::logic_error &e ) { std::cerr << "Error in method TraCIClient::command_change_lane: " << e.what() << std::endl; abort(); } check_domain( DomainVehicle, ti, true, "command_change_lane" ); VehicleChangeLaneType changeLane; changeLane.laneNum = lane; changeLane.duration = timeShawnToSumo(time); command_set_value(id::CmdChangeVehicleState, id::VarVehicleSetLane, ti.id(), changeLane); }
/** * see http://sourceforge.net/apps/mediawiki/sumo/index.php?title=TraCI/Mobility-related_commands * * Calls \c abort() in case of problems after sending a message to \c stderr. * * \param[in] node node to set stop position for * \param[in] x \c x of 2DPosition * \param[in] y \c y of 2DPosition * \param[in] radius \c Radius of stop node command * \param[in] wait_time \c WaitTime of stop node command */ void TraCIClient::command_stop( const Node& node, double x, double y, double radius, double wait_time ) { TraCIID ti; try { //out.writeInt(find_traci_id_by_node(node).id()); ti = find_traci_id_by_node( node ); } catch ( std::logic_error &e ) { std::cerr << "Error in method TraCIClient::command_stop: " << e.what() << std::endl; abort(); } check_domain( DomainVehicle, ti, true, "command_stop" ); // convert x/y to roadmap position ConstDynamicTraciType<> out; Position2DTypeWithTypeId stopPosXy; stopPosXy.x = x; stopPosXy.y = y; out.push_back(&stopPosXy); // result RoadMapPositionTypeWithTypeId stopPosRoadmap; const UbyteType resultType(stopPosRoadmap.getTraciTypeId()); out.push_back(&resultType); send_command(id::CmdPositionconversion, out, stopPosRoadmap); // send stop command VehicleStopType stop; stop.edgeId = stopPosRoadmap.road; stop.offset = stopPosRoadmap.pos; stop.laneNum = stopPosRoadmap.lane; stop.duration = timeShawnToSumo(wait_time); command_set_value(id::CmdChangeVehicleState, id::VarVehicleSetStop, ti.id(), stop); }
int main(int argc, char** argv) { int opt; xc_interface *xch; struct xs_handle *xsh; char buf[16]; int rv, fd; while ( (opt = getopt_long(argc, argv, "", options, NULL)) != -1 ) { switch ( opt ) { case 'k': kernel = optarg; break; case 'm': memory = strtol(optarg, NULL, 10); break; case 'f': flask = optarg; break; case 'r': ramdisk = optarg; break; case 'p': param = optarg; break; case 'n': name = optarg; break; default: usage(); return 2; } } if ( optind != argc || !kernel || !memory ) { usage(); return 2; } xch = xc_interface_open(NULL, NULL, 0); if ( !xch ) { fprintf(stderr, "xc_interface_open() failed\n"); return 1; } rv = check_domain(xch); if ( !rv ) rv = build(xch); else if ( rv > 0 ) fprintf(stderr, "xenstore domain already present.\n"); xc_interface_close(xch); if ( rv ) return 1; rv = gen_stub_json_config(domid); if ( rv ) return 3; xsh = xs_open(0); if ( !xsh ) { fprintf(stderr, "xs_open() failed.\n"); return 3; } snprintf(buf, 16, "%d", domid); do_xs_write(xsh, "/tool/xenstored/domid", buf); do_xs_write_dom(xsh, "domid", buf); do_xs_write_dom(xsh, "name", name); snprintf(buf, 16, "%d", memory * 1024); do_xs_write_dom(xsh, "memory/target", buf); do_xs_write_dom(xsh, "memory/static-max", buf); xs_close(xsh); fd = creat("/var/run/xenstored.pid", 0666); if ( fd < 0 ) { fprintf(stderr, "Creating /var/run/xenstored.pid failed\n"); return 3; } rv = snprintf(buf, 16, "domid:%d\n", domid); rv = write(fd, buf, rv); close(fd); if ( rv < 0 ) { fprintf(stderr, "Writing domid to /var/run/xenstored.pid failed\n"); return 3; } return 0; }
int analysis_connect_info() { char *pStart=NULL,Domain[50]; char tmp=85; int i; memset(Server_IP,NULL,sizeof(Server_IP)); memset(Proxy_IP,NULL,sizeof(Proxy_IP)); memset(Proxy_Username,NULL,sizeof(Proxy_Username)); memset(Proxy_Password,NULL,sizeof(Proxy_Password)); memset(RC4_KEY,NULL,sizeof(RC4_KEY)); memset(S_box,NULL,sizeof(S_box)); for(pStart=_RC4_KEY,i=0; i<256; pStart++,i++) *pStart^=tmp; pStart=strchr(_RC4_KEY,':'); pStart++; memcpy(RC4_KEY,pStart,248); for(pStart=SERVER_IP,i=0; i<50; pStart++,i++) *pStart^=tmp; pStart=strchr(SERVER_IP,':'); pStart++; memset(Domain,NULL,sizeof(Domain)); memcpy(Domain,pStart,16); if(check_domain(Domain)) { //服务端地址是域名 if(DNSQuery(Domain,Server_IP)!=0) //解析域名 exit(-1); } else memcpy(Server_IP,Domain,16); for(pStart=SERVER_PORT,i=0; i<50; pStart++,i++) *pStart^=tmp; pStart=strchr(SERVER_PORT,':'); pStart++; Server_Port=atoi(pStart); for(pStart=PROXY_IP,i=0; i<50; pStart++,i++) *pStart^=tmp; pStart=strchr(PROXY_IP,':'); pStart++; memset(Domain,NULL,sizeof(Domain)); memcpy(Domain,pStart,16); if(check_domain(Domain)) { //服务端地址是域名 if(DNSQuery(Domain,Proxy_IP)!=0) //解析域名 exit(-1); } else memcpy(Proxy_IP,Domain,16); for(pStart=PROXY_PORT,i=0; i<50; pStart++,i++) *pStart^=tmp; pStart=strchr(PROXY_PORT,':'); pStart++; Proxy_Port=atoi(pStart); for(pStart=PROXY_USERNAME,i=0; i<50; pStart++,i++) *pStart^=tmp; pStart=strchr(PROXY_USERNAME,':'); pStart++; memcpy(Proxy_Username,pStart,19); for(pStart=PROXY_PASSWORD,i=0; i<50; pStart++,i++) *pStart^=tmp; pStart=strchr(PROXY_PASSWORD,':'); pStart++; memcpy(Proxy_Password,pStart,19); return 0; }