// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> void MNcursesPlugin::readUserInput() { while ( true ) { int ch = getch(); if ( ch == '<' ) { int idx = findTag(_activeTag); if ( idx >= 0 ) { if ( --idx < 0 ) idx = _tagOrder.size() - 1; _activeTag = _tagOrder[idx]; printTable(_clientTableCache); } } else if ( ch == '>' ) { int idx = findTag(_activeTag); if ( idx >= 0 ) { idx = (idx + 1) % _tagOrder.size(); _activeTag = _tagOrder[idx]; printTable(_clientTableCache); } } else if ( ch == 'r' ) { _reverseSortOrder = !_reverseSortOrder; printTable(_clientTableCache); } } }
int main(int argc, const char** argv){ if(argc != 2){ printf("得到html文件的各个节点(请加上html文件名作为执行参数)"); exit(1); } const char* filename = argv[1]; // FILE *fp; if(!(fp = fopen(filename, "r"))){ printf("file open error!"); exit(1); } // char* input; int length; readFile(fp, &input, &length); // GumboOutput* output = gumbo_parse_with_options( &kGumboDefaultOptions, input, length); findTag(output->root, 0); // gumbo_destroy_output(&kGumboDefaultOptions, output); fclose(fp); free(input); }
/** Reads XML tags from an input file. */ void Parser::parse() { Tag tag; // Read and process tags tags.clear(); skipWhitespace(); try { while (file) { if (character != '<') { throw BasicException("[Parser] Tags must start with '<'."); } else if (match("<!--")) { skip("-->"); } else { tag = create(findTag()); tag.setFilename(filename); tag.setLine(lineNumber); tags.push_back(tag); } skipWhitespace(); } file.close(); } catch (BasicException e) { file.close(); BasicException ex; ex << Tag::toLocation(filename, lineNumber) << e.what(); throw ex; } }
void printLineID(HumdrumFile& infile, int index, Array<Array<char> >& primaryids, Array<Array<char> >& idtags) { Array<Array<int> > spines; spines.setSize(primaryids.getSize()); int i; for (i=0; i<spines.getSize(); i++) { spines[i].setSize(32); spines[i].setSize(0); } int mapping; for (i=0; i<idtags.getSize(); i++) { mapping = findTag(primaryids, idtags[i]); spines[mapping].append(i); } int j; for (i=0; i<spines.getSize(); i++) { if (spines[i].getSize() == 0) { cout << "X"; } else { for (j=0; j<spines[i].getSize(); j++) { cout << "Y"; } } cout << "\t"; } }
static void findVerilogTags (void) { vString *const name = vStringNew (); volatile bool newStatement = true; volatile int c = '\0'; exception_t exception = (exception_t) setjmp (Exception); if (exception == ExceptionNone) while (c != EOF) { c = vGetc (); switch (c) { case ';': case '\n': newStatement = true; break; case ' ': case '\t': break; default: if (newStatement && readIdentifier (name, c)) findTag (name); newStatement = false; break; } } vStringDelete (name); }
void SieveArgumentList::tagError( const char * tag, const EString & error ) { SieveArgument * t = argumentFollowingTag( tag ); if ( !t ) t = findTag( tag ); if ( t ) t->setError( error ); else setError( error ); }
int Ifd::erase(uint16 tag) { int idx = 0; iterator pos = findTag(tag); if (pos != end()) { idx = pos->idx(); erase(pos); } return idx; }
static void findVerilogTags (void) { tokenInfo *const token = newToken (); int c = '\0'; currentContext = newToken (); while (c != EOF) { c = vGetc (); c = skipWhite (c); switch (c) { /* Store current block name whenever a : is found * This is used later by any tag type that requires this information * */ case ':': vStringCopy (currentContext->blockName, token->name); break; /* Skip interface modport port declarations */ case '(': if (currentContext && currentContext->lastKind == K_MODPORT) { skipPastMatch ("()"); } break; /* Drop context on prototypes because they don't have an end * statement */ case ';': if (currentContext->scope && currentContext->scope->prototype) { verbose ("Dropping context %s\n", vStringValue (currentContext->name)); currentContext = popToken (currentContext); currentContext->prototype = FALSE; } /* Prototypes end at the end of statement */ if (currentContext->prototype) { currentContext->prototype = FALSE; } break; default : if (isIdentifierCharacter (c)) { readIdentifier (token, c); updateKind (token); findTag (token); } } } deleteToken (token); pruneTokens (currentContext); currentContext = NULL; }
int Ifd::readSubIfd( Ifd& dest, const char* buf, ByteOrder byteOrder, uint16 tag ) const { int rc = 0; const_iterator pos = findTag(tag); if (pos != entries_.end()) { uint32 offset = getULong(pos->data(), byteOrder); rc = dest.read(buf + offset, byteOrder, offset); } return rc; } // Ifd::readSubIfd
long cmmGetProfileElementSize(LPLCMSICCPROFILE hProfile, icTagSignature sig) { int idx = findTag(hProfile, sig); if(idx < 0) return -1; else return hProfile->TagSizes[idx]; }
void XmlReader::parseDHT() { std::string entries = findTag("dht"); if(entries.length() > 0) { std::vector<std::string> lines = Tools::explode(";", entries); for(int l=0; l<lines.size(); l++) { if(lines[l].length() > 0) { std::vector<std::string> words = Tools::explode(":", lines[l]); Dht d; for(int w=0; w<words.size(); w++) { if(typeid(words.at(0))==typeid(std::string)) d.setName(words[0]); if(typeid(words.at(1))==typeid(std::string)) d.setType(words[1]); if(typeid(words.at(2))==typeid(std::string)) d.setGpio(words[2]); } dht.push_back(d); } } } }
void XmlReader::parseGpios() { std::string entries = findTag("gpios"); if(entries.length() > 0) { std::vector<std::string> lines = Tools::explode(";", entries); for(int l=0; l<lines.size(); l++) { if(lines[l].length() > 0) { std::vector<std::string> words = Tools::explode(":", lines[l]); Gpio g; for(int w=0; w<words.size(); w++) { if(typeid(words.at(0))==typeid(std::string)) g.setName(words[0]); if(typeid(words.at(1))==typeid(std::string)) g.setGpio(atoi(words[1].c_str())); } gpios.push_back(g); } } } }
void XmlReader::parseSockets() { std::string entries = findTag("sockets"); if(entries.length() > 0) { std::vector<std::string> lines = Tools::explode(";", entries); for(int l=0; l<lines.size(); l++) { if(lines[l].length() > 0) { std::vector<std::string> words = Tools::explode(":", lines[l]); WSocket s; for(int w=0; w<words.size(); w++) { if(typeid(words.at(0))==typeid(std::string)) s.setName(words[0]); if(typeid(words.at(1))==typeid(std::string)) s.setCode(words[1]); } sockets.push_back(s); } } } }
LCMSBOOL cmmGetProfileElement( LPLCMSICCPROFILE hProfile, icTagSignature sig, LPBYTE data, size_t *dataSize ) { int idx = findTag(hProfile, sig); if(idx < 0) { cmsSignalError(LCMS_ERRC_ABORTED, "Tagged profile element not found"); return FALSE; } *dataSize = MIN(*dataSize, hProfile->TagSizes[idx]); if(hProfile->TagPtrs[idx]) { CopyMemory(data, hProfile->TagPtrs[idx], *dataSize); } else { seekMemBuffer(hProfile->stream, hProfile->TagOffsets[idx]); readMemBuffer(data, 1, *dataSize, hProfile->stream); } return TRUE; }
static const void findTag(const GumboNode* root, int layer){ //layer代表层数 //用于递归结束条件 if(root->type != GUMBO_NODE_ELEMENT){ return; } //while的功能是缩进格式 int indent = layer; while(indent--){ printf(" "); } //获取标签名 const char* tag_name = gumbo_normalized_tagname(root->v.element.tag); printf("%d--------%s\n", layer, tag_name); // const GumboVector* rchildren = &root->v.element.children; for(unsigned int i = 0; i < rchildren->length; ++i){ GumboNode* child = rchildren->data[i]; findTag(child, layer+1); } }
void updateCriticalTags(LPLCMSICCPROFILE Icc) { LPVOID savedData = NULL; int idx; cmsCIEXYZ* dummy; MemBuffer *memBuffer = (MemBuffer*) Icc->stream; if(!memBuffer->needsUpdateCriticalTags) // Nothing to do return; idx = findTag(Icc, icSigMediaWhitePointTag); dummy = cmsD50_XYZ(); if(idx >= 0) { // There is media white point already cmsAddTag(Icc, icSigMediaWhitePointTag, dummy); // Force LCMS to read critical tags free(Icc->TagPtrs[idx]); // Get rid of dummy media white point Icc->TagPtrs[idx] = NULL; } else { cmsAddTag(Icc, icSigMediaWhitePointTag, dummy); // Force LCMS to read critical tags // Get rid of dummy media white point free(Icc->TagPtrs[Icc->TagCount-1]); Icc->TagPtrs[Icc->TagCount-1] = NULL; Icc->TagNames[Icc->TagCount-1] = 0; Icc->TagSizes[Icc->TagCount-1] = 0; Icc->TagOffsets[Icc->TagCount-1] = 0; Icc->TagCount--; } memBuffer->needsUpdateCriticalTags = FALSE; }
XMLElement *XMLElement::findTag (std::string tagToFind, XMLElement *inElement) { XMLElement *xmlSearch = inElement; if (xmlSearch == 0) xmlSearch = this; if (xmlSearch->tag == tagToFind) return (xmlSearch); else { for (unsigned int iIdx = 0; iIdx < xmlSearch->children->size (); iIdx++) { XMLElement *xmlTemp = findTag (tagToFind, xmlSearch->children->at (iIdx)); if (xmlTemp != 0) return (xmlTemp); } } return (0); }
static void findVhdlTags (void) { volatile boolean newStatement = TRUE; volatile int c = '\0'; exception_t exception = (exception_t) setjmp (Exception); Name = vStringNew (); Lastname = vStringNew (); Keyword = vStringNew (); TagName = vStringNew (); if (exception == ExceptionNone) while (c != EOF) { c = vGetc (); switch (c) { case ';': case '\n': newStatement = TRUE; break; case ' ': case '\t': break; default: if (newStatement && readIdentifier (Name, c)) { findTag (Name); } newStatement = FALSE; break; } } vStringDelete (Name); vStringDelete (Lastname); vStringDelete (Keyword); vStringDelete (TagName); }
void XmlReader::parseSchedules() { std::string entries = findTag("schedules"); if(entries.length() > 0) { std::vector<std::string> lines = Tools::explode(";", entries); for(int l=0; l<lines.size(); l++) { if(lines[l].length() > 0) { std::vector<std::string> words = Tools::explode(":", lines[l]); Schedule s; for(int w=0; w<words.size(); w++) { if(typeid(words.at(0))==typeid(std::string)) s.setName(words[0]); if(typeid(words.at(1))==typeid(std::string)) s.setSocket(words[1]); if(typeid(words.at(2))==typeid(std::string)) s.setGpio(words[2]); if(typeid(words.at(3))==typeid(std::string)) s.setHour(atoi(words[3].c_str())); if(typeid(words.at(4))==typeid(std::string)) s.setMinute(atoi(words[4].c_str())); if(typeid(words.at(5))==typeid(std::string)) s.setOnoff(atoi(words[5].c_str())); if(typeid(words.at(6))==typeid(std::string)) s.setStatus(atoi(words[6].c_str())); } schedules.push_back(s); } } } }
LCMSBOOL cmmSetProfileElement(LPLCMSICCPROFILE hProfile, icTagSignature sig, LPVOID data, size_t size) { MemBuffer *memBuffer; int idx = findTag(hProfile, sig); if(idx < 0) { idx = hProfile->TagCount; hProfile->TagCount++; if (hProfile->TagCount >= MAX_TABLE_TAG) { cmsSignalError(LCMS_ERRC_ABORTED, "Too many tags (%d)", MAX_TABLE_TAG); hProfile->TagCount = MAX_TABLE_TAG-1; } } memBuffer = (MemBuffer*) hProfile->stream; if( sig == icSigMediaWhitePointTag || sig == icSigMediaBlackPointTag || sig == icSigChromaticAdaptationTag ) memBuffer->needsUpdateCriticalTags = TRUE; memBuffer->needsUpdate = TRUE; // Always needs update if(size == 0) { if(hProfile->TagPtrs[idx]) free(hProfile->TagPtrs[idx]); hProfile->TagPtrs[idx] = NULL; hProfile->TagNames[idx] = 0; hProfile->TagOffsets[idx] = 0; hProfile->TagSizes[idx] = 0; } else { if(hProfile->TagPtrs[idx]) hProfile->TagPtrs[idx] = realloc(hProfile->TagPtrs[idx], size); else hProfile->TagPtrs[idx] = malloc(size); hProfile->TagSizes[idx] = size; hProfile->TagOffsets[idx] = 0; hProfile->TagNames[idx] = sig; CopyMemory(hProfile->TagPtrs[idx], data, size); } return TRUE; }
/********************************************************************** *%FUNCTION: relayHandlePADS *%ARGUMENTS: * iface -- interface on which packet was received * packet -- the PADS packet *%RETURNS: * Nothing *%DESCRIPTION: * Receives and processes a PADS packet. ***********************************************************************/ void relayHandlePADS(PPPoEInterface const *iface, PPPoEPacket *packet, int size) { PPPoETag tag; unsigned char *loc; int ifIndex; int acIndex; PPPoESession *ses = NULL; SessionHash *sh; /* Can a server legally be behind this interface? */ if (!iface->acOK) { syslog(LOG_ERR, "PADS packet from %02x:%02x:%02x:%02x:%02x:%02x on interface %s not permitted", packet->ethHdr.h_source[0], packet->ethHdr.h_source[1], packet->ethHdr.h_source[2], packet->ethHdr.h_source[3], packet->ethHdr.h_source[4], packet->ethHdr.h_source[5], iface->name); return; } acIndex = iface - Interfaces; /* Source address must be unicast */ if (NOT_UNICAST(packet->ethHdr.h_source)) { syslog(LOG_ERR, "PADS packet from %02x:%02x:%02x:%02x:%02x:%02x on interface %s not from a unicast address", packet->ethHdr.h_source[0], packet->ethHdr.h_source[1], packet->ethHdr.h_source[2], packet->ethHdr.h_source[3], packet->ethHdr.h_source[4], packet->ethHdr.h_source[5], iface->name); return; } /* Destination address must be interface's MAC address */ if (memcmp(packet->ethHdr.h_dest, iface->mac, ETH_ALEN)) { return; } /* Find relay tag */ loc = findTag(packet, TAG_RELAY_SESSION_ID, &tag); if (!loc) { syslog(LOG_ERR, "PADS packet from %02x:%02x:%02x:%02x:%02x:%02x on interface %s does not have Relay-Session-Id tag", packet->ethHdr.h_source[0], packet->ethHdr.h_source[1], packet->ethHdr.h_source[2], packet->ethHdr.h_source[3], packet->ethHdr.h_source[4], packet->ethHdr.h_source[5], iface->name); return; } /* If it's the wrong length, ignore it */ if (ntohs(tag.length) != MY_RELAY_TAG_LEN) { syslog(LOG_ERR, "PADS packet from %02x:%02x:%02x:%02x:%02x:%02x on interface %s does not have correct length Relay-Session-Id tag", packet->ethHdr.h_source[0], packet->ethHdr.h_source[1], packet->ethHdr.h_source[2], packet->ethHdr.h_source[3], packet->ethHdr.h_source[4], packet->ethHdr.h_source[5], iface->name); return; } /* Extract interface index */ memcpy(&ifIndex, tag.payload, sizeof(ifIndex)); if (ifIndex < 0 || ifIndex >= NumInterfaces || !Interfaces[ifIndex].clientOK || iface == &Interfaces[ifIndex]) { syslog(LOG_ERR, "PADS packet from %02x:%02x:%02x:%02x:%02x:%02x on interface %s has invalid interface in Relay-Session-Id tag", packet->ethHdr.h_source[0], packet->ethHdr.h_source[1], packet->ethHdr.h_source[2], packet->ethHdr.h_source[3], packet->ethHdr.h_source[4], packet->ethHdr.h_source[5], iface->name); return; } /* If session ID is zero, it's the AC respoding with an error. Just relay it; do not create a session */ if (packet->session != htons(0)) { /* Check for existing session */ sh = findSession(packet->ethHdr.h_source, packet->session); if (sh) ses = sh->ses; /* If already an existing session, assume it's a duplicate PADS. Send the frame, but do not create a new session. Is this the right thing to do? Arguably, should send an error to the client and a PADT to the server, because this could happen due to a server crash and reboot. */ if (!ses) { /* Create a new session */ ses = createSession(iface, &Interfaces[ifIndex], packet->ethHdr.h_source, loc + TAG_HDR_SIZE + sizeof(ifIndex), packet->session); if (!ses) { /* Can't allocate session -- send error PADS to client and PADT to server */ PPPoETag hostUniq, *hu; if (findTag(packet, TAG_HOST_UNIQ, &hostUniq)) { hu = &hostUniq; } else { hu = NULL; } relaySendError(CODE_PADS, htons(0), &Interfaces[ifIndex], loc + TAG_HDR_SIZE + sizeof(ifIndex), hu, "RP-PPPoE: Relay: Unable to allocate session"); relaySendError(CODE_PADT, packet->session, iface, packet->ethHdr.h_source, NULL, "RP-PPPoE: Relay: Unable to allocate session"); return; } } /* Replace session number */ packet->session = ses->sesNum; } /* Remove relay-ID tag */ removeBytes(packet, loc, MY_RELAY_TAG_LEN + TAG_HDR_SIZE); size -= (MY_RELAY_TAG_LEN + TAG_HDR_SIZE); /* Set destination address to MAC address in relay ID */ memcpy(packet->ethHdr.h_dest, tag.payload + sizeof(ifIndex), ETH_ALEN); /* Set source address to MAC address of interface */ memcpy(packet->ethHdr.h_source, Interfaces[ifIndex].mac, ETH_ALEN); /* Send the PADS to the proper client */ sendPacket(NULL, Interfaces[ifIndex].discoverySock, packet, size); }
extern int main (int argc, char **argv) { int options = 0; int actionSupplied = 0; int i; int ignore_prefix = 0; ProgramName = argv [0]; if (argc == 1) printUsage(stderr, 1); for (i = 1 ; i < argc ; ++i) { const char *const arg = argv [i]; if (ignore_prefix || arg [0] != '-') { findTag (arg, options); actionSupplied = 1; } else if (arg [0] == '-' && arg [1] == '\0') ignore_prefix = 1; else { size_t j; for (j = 1 ; arg [j] != '\0' ; ++j) { switch (arg [j]) { case 'd': debugMode++; break; case 'h': printUsage (stdout, 0); break; case 'e': extensionFields = 1; break; case 'i': options |= TAG_IGNORECASE; break; case 'p': options |= TAG_PARTIALMATCH; break; case 'l': listTags (); actionSupplied = 1; break; case 'n': allowPrintLineNumber = 1; break; case 't': if (arg [j+1] != '\0') { TagFileName = arg + j + 1; j += strlen (TagFileName); } else if (i + 1 < argc) TagFileName = argv [++i]; else printUsage(stderr, 1); break; case 's': SortOverride = 1; ++j; if (arg [j] == '\0') SortMethod = TAG_SORTED; else if (strchr ("012", arg[j]) != NULL) SortMethod = (sortType) (arg[j] - '0'); else printUsage(stderr, 1); break; #ifdef QUALIFIER case 'Q': if (i + 1 == argc) printUsage(stderr, 1); Qualifier = convertToQualifier (argv[++i]); break; #endif default: fprintf (stderr, "%s: unknown option: %c\n", ProgramName, arg[j]); exit (1); break; } } } } if (! actionSupplied) { fprintf (stderr, "%s: no action specified: specify tag name(s) or -l option\n", ProgramName); exit (1); } return 0; }
int XmlReader::getDatagpio() { std::string datagpio_str = findTag("datagpio"); return atoi(datagpio_str.c_str()); }
void fixReplaces(string& req_hdrs, bool is_invite) { string replaces; string refer_to; AmUriParser refer_target; vector<string> hdrs; // headers from Refer-To URI vector<string>::iterator replaces_hdr_it; // Replaces header from Refer-To URI DBG("Replaces handler: fixing %s request\n", is_invite?"INVITE":"REFER"); if (is_invite) { replaces = getHeader(req_hdrs, SIP_HDR_REPLACES, true); if (replaces.empty()) { DBG("Replaces handler: no Replaces in INVITE, ignoring\n"); return; } } else { refer_to = getHeader(req_hdrs, SIP_HDR_REFER_TO, SIP_HDR_REFER_TO_COMPACT, true); if (refer_to.empty()) { DBG("Replaces handler: empty Refer-To header, ignoring\n"); return; } size_t pos=0; size_t end=0; if (!refer_target.parse_contact(refer_to, pos, end)) { DBG("Replaces handler: unable to parse Refer-To name-addr, ignoring\n"); return; } if (refer_target.uri_headers.empty()) { DBG("Replaces handler: no headers in Refer-To target, ignoring\n"); return; } hdrs = explode(refer_target.uri_headers, ";"); for (replaces_hdr_it=hdrs.begin(); replaces_hdr_it != hdrs.end(); replaces_hdr_it++) { string s = URL_decode(*replaces_hdr_it); const char* Replaces_str = "Replaces"; if ((s.length() >= 8) && !strncmp(Replaces_str, s.c_str(), 8)) { size_t pos = 8; while (s.length()>pos && (s[pos] == ' ' || s[pos] == '\t')) pos++; if (s[pos] != '=') continue; pos++; while (s.length()>pos && (s[pos] == ' ' || s[pos] == '\t')) pos++; replaces = s.substr(pos); break; } } if (replaces_hdr_it == hdrs.end()) { DBG("Replaces handler: no Replaces headers in Refer-To target, ignoring\n"); return; } } DBG("Replaces found: '%s'\n", replaces.c_str()); size_t ftag_begin; size_t ftag_len; size_t ttag_begin; size_t ttag_len; size_t cid_len=0; // todo: parse full replaces header and reconstruct including unknown params if (!findTag(replaces, "from-tag=", ftag_begin, ftag_len)) { WARN("Replaces missing 'from-tag', ignoring\n"); return; } if (!findTag(replaces, "to-tag=", ttag_begin, ttag_len)) { WARN("Replaces missing 'to-tag', ignoring\n"); return; } while (cid_len < replaces.size() && replaces[cid_len] != ';') cid_len++; string ftag = replaces.substr(ftag_begin, ftag_len); string ttag = replaces.substr(ttag_begin, ttag_len); string callid = replaces.substr(0, cid_len); bool early_only = replaces.find("early-only") != string::npos; DBG("Replaces handler: found callid='%s', ftag='%s', ttag='%s'\n", callid.c_str(), ftag.c_str(), ttag.c_str()); SBCCallRegistryEntry other_dlg; if (SBCCallRegistry::lookupCall(ttag, other_dlg)) { replaces = other_dlg.callid+ ";from-tag="+other_dlg.ltag+";to-tag="+other_dlg.rtag; if (early_only) replaces += ";early_only"; DBG("Replaces handler: mapped Replaces to: '%s'\n", replaces.c_str()); if (is_invite) { removeHeader(req_hdrs, SIP_HDR_REPLACES); req_hdrs+=SIP_HDR_COLSP(SIP_HDR_REPLACES)+replaces+CRLF; } else { string replaces_enc = SIP_HDR_REPLACES "="+URL_encode(replaces); string new_hdrs; for (vector<string>::iterator it = hdrs.begin(); it != hdrs.end(); it++) { if (it != hdrs.begin()) new_hdrs+=";"; if (it != replaces_hdr_it) { // different hdr, just add it new_hdrs+=*it; } else { //reconstructed replaces hdr new_hdrs+=replaces_enc; } } refer_target.uri_headers=new_hdrs; removeHeader(req_hdrs, SIP_HDR_REFER_TO); removeHeader(req_hdrs, SIP_HDR_REFER_TO_COMPACT); req_hdrs+=SIP_HDR_COLSP(SIP_HDR_REFER_TO)+refer_target.nameaddr_str()+CRLF; } } else { DBG("Replaces handler: call with tag '%s' not found\n", ttag.c_str()); } }
extern int main (int argc, char **argv) { int options = 0; int actionSupplied = 0; int i; ProgramName = argv [0]; if (argc == 1) { fprintf (stderr, Usage, ProgramName); exit (1); } for (i = 1 ; i < argc ; ++i) { const char *const arg = argv [i]; if (arg [0] != '-') { findTag (arg, options); actionSupplied = 1; } else { size_t j; for (j = 1 ; arg [j] != '\0' ; ++j) { switch (arg [j]) { case 'e': extensionFields = 1; break; case 'i': options |= TAG_IGNORECASE; break; case 'p': options |= TAG_PARTIALMATCH; break; case 'l': listTags (); actionSupplied = 1; break; case 't': if (arg [j+1] != '\0') { TagFileName = arg + j + 1; j += strlen (TagFileName); } else if (i + 1 < argc) TagFileName = argv [++i]; else { fprintf (stderr, Usage, ProgramName); exit (1); } break; case 's': SortOverride = 1; ++j; if (arg [j] == '\0') SortMethod = TAG_SORTED; else if (strchr ("012", arg[j]) != NULL) SortMethod = (sortType) (arg[j] - '0'); else { fprintf (stderr, Usage, ProgramName); exit (1); } break; default: fprintf (stderr, "%s: unknown option: %c\n", ProgramName, arg[j]); exit (1); break; } } } } if (! actionSupplied) { fprintf (stderr, "%s: no action specified: specify tag name(s) or -l option\n", ProgramName); exit (1); } return 0; }
//adds a tag to the tag_list if it isn't already in there //tag_list is used to filter incoming subscription messages for data of interest void ReefServer::addTag(std::string tag){ std::string sys_msg = "SYS_newMember"; if (!findTag(tag)&&tag!=sys_msg){ tag_list.push_back(tag); } }
/********************************************************************** *%FUNCTION: relayHandlePADR *%ARGUMENTS: * iface -- interface on which packet was received * packet -- the PADR packet *%RETURNS: * Nothing *%DESCRIPTION: * Receives and processes a PADR packet. ***********************************************************************/ void relayHandlePADR(PPPoEInterface const *iface, PPPoEPacket *packet, int size) { PPPoETag tag; unsigned char *loc; int ifIndex; int cliIndex; /* Can a client legally be behind this interface? */ if (!iface->clientOK) { syslog(LOG_ERR, "PADR packet from %02x:%02x:%02x:%02x:%02x:%02x on interface %s not permitted", packet->ethHdr.h_source[0], packet->ethHdr.h_source[1], packet->ethHdr.h_source[2], packet->ethHdr.h_source[3], packet->ethHdr.h_source[4], packet->ethHdr.h_source[5], iface->name); return; } cliIndex = iface - Interfaces; /* Source address must be unicast */ if (NOT_UNICAST(packet->ethHdr.h_source)) { syslog(LOG_ERR, "PADR packet from %02x:%02x:%02x:%02x:%02x:%02x on interface %s not from a unicast address", packet->ethHdr.h_source[0], packet->ethHdr.h_source[1], packet->ethHdr.h_source[2], packet->ethHdr.h_source[3], packet->ethHdr.h_source[4], packet->ethHdr.h_source[5], iface->name); return; } /* Destination address must be interface's MAC address */ if (memcmp(packet->ethHdr.h_dest, iface->mac, ETH_ALEN)) { return; } /* Find relay tag */ loc = findTag(packet, TAG_RELAY_SESSION_ID, &tag); if (!loc) { syslog(LOG_ERR, "PADR packet from %02x:%02x:%02x:%02x:%02x:%02x on interface %s does not have Relay-Session-Id tag", packet->ethHdr.h_source[0], packet->ethHdr.h_source[1], packet->ethHdr.h_source[2], packet->ethHdr.h_source[3], packet->ethHdr.h_source[4], packet->ethHdr.h_source[5], iface->name); return; } /* If it's the wrong length, ignore it */ if (ntohs(tag.length) != MY_RELAY_TAG_LEN) { syslog(LOG_ERR, "PADR packet from %02x:%02x:%02x:%02x:%02x:%02x on interface %s does not have correct length Relay-Session-Id tag", packet->ethHdr.h_source[0], packet->ethHdr.h_source[1], packet->ethHdr.h_source[2], packet->ethHdr.h_source[3], packet->ethHdr.h_source[4], packet->ethHdr.h_source[5], iface->name); return; } /* Extract interface index */ memcpy(&ifIndex, tag.payload, sizeof(ifIndex)); if (ifIndex < 0 || ifIndex >= NumInterfaces || !Interfaces[ifIndex].acOK || iface == &Interfaces[ifIndex]) { syslog(LOG_ERR, "PADR packet from %02x:%02x:%02x:%02x:%02x:%02x on interface %s has invalid interface in Relay-Session-Id tag", packet->ethHdr.h_source[0], packet->ethHdr.h_source[1], packet->ethHdr.h_source[2], packet->ethHdr.h_source[3], packet->ethHdr.h_source[4], packet->ethHdr.h_source[5], iface->name); return; } /* Replace Relay-ID tag with opposite-direction tag */ memcpy(loc+TAG_HDR_SIZE, &cliIndex, sizeof(cliIndex)); memcpy(loc+TAG_HDR_SIZE+sizeof(ifIndex), packet->ethHdr.h_source, ETH_ALEN); /* Set destination address to MAC address in relay ID */ memcpy(packet->ethHdr.h_dest, tag.payload + sizeof(ifIndex), ETH_ALEN); /* Set source address to MAC address of interface */ memcpy(packet->ethHdr.h_source, Interfaces[ifIndex].mac, ETH_ALEN); /* Send the PADR to the proper access concentrator */ sendPacket(NULL, Interfaces[ifIndex].discoverySock, packet, size); }
/** * マクロから呼び出されるエントリポイント。 * @param [in] text 検索文字列 * @return 戻り値に意味はない */ EXPORT int search(const char *text) { if (!IsHidemaruMail()) { #ifndef _DEBUG MessageBox(NULL, "このマクロは秀丸からは起動できません。", NULL, MB_OK); return 0; #endif } HWND hwnd = reinterpret_cast<HWND>(MainWnd()); if (hwnd == NULL) { MessageBox(NULL, "秀丸メール本体が起動してなければなりません。", NULL, MB_OK); return 0; } if (strlen(text) != 0) { std::string oneLine = text; size_t pos; if ((pos = oneLine.find("\r\n")) != std::string.npos) { oneLine[pos] = '\0'; } if (oneLine.find(' ') != std::string.npos) { selectedText = "\""; selectedText += YenEncode(oneLine.c_str()); selectedText += "\""; } else { selectedText = YenEncode(oneLine.c_str()); } } // SetQuietMode を使用すると、検索結果ウィンドウが手前に来ない // SetQuietMode(1); int rc = (int)DialogBox(hInst, (LPCTSTR)IDD_HIDEMARUMAILSEARCH_DIALOG, hwnd, (DLGPROC)DialogProc); // SetQuietMode(0); if (rc == IDOK) { const char *account = NULL; const char *folder = NULL; switch (selectedRadioButton) { case IDC_RADIO1: case IDC_RADIO2: account = (const char *)ExecAtMain("CurrentAccount"); if (IsHidemaruMailMain() || IsHidemaruMailGrep()) { folder = CurrentFolder(); } else { folder = (const char *)ExecAtMain("CurrentFolder"); } break; case IDC_RADIO3: account = (const char *)ExecAtMain("CurrentAccount"); if (selectedCheckBox) { folder = ""; } else { folder = "受信+送信済み+ユーザー"; } break; case IDC_RADIO4: account = ""; if (selectedCheckBox) { folder = ""; } else { folder = "受信+送信済み+ユーザー"; } break; } #ifdef _DEBUG switch (selectedRadioButton) { case IDC_RADIO1: case IDC_RADIO2: case IDC_RADIO3: if (account == NULL || strlen(account) == 0) { MessageBox(NULL, "秀丸メールにアカウントが見つかりませんでした。\nこのエラーが頻発するようなら作者に連絡してください。", "HidemaruMailSearch", MB_OK); } break; } #endif std::string inputText = history[0].c_str(); std::string query; trim(inputText); // お気に入りの保存と読み込み if (inputText.find("fav:") == 0) { size_t pos = inputText.find(' '); if (pos != std::string::npos) { size_t len = strlen("fav:"); if (pos != len) { std::string favname = inputText.substr(len, pos - len); std::string favval = inputText.substr(pos + 1); if (favval == "\"\"") { iniFile->write("Favorite", favname.c_str(), NULL); return 0; } else { iniFile->write("Favorite", favname.c_str(), favval.c_str()); return 0; } } } else { char *favval = iniFile->read("Favorite", inputText.substr(strlen("fav:")).c_str()); if (favval != NULL) { inputText = favval; free(favval); } } } if (inputText.compare("help:") == 0) { if (helpCmd == "") { char *temp; char *work = NULL; DWORD type; if ((temp = (char *)get_reg_value(hideinstloc, &type)) == NULL) { // 秀丸がインストールされていないなら、メモ帳 helpCmd = "notepad.exe "; work = (char *)get_reg_value(turukamedir, &type); helpCmd += "\""; helpCmd += work; helpCmd += "\\HidemaruMailSearch.txt\""; } else { helpCmd = "\""; helpCmd += temp; helpCmd += "\\Hidemaru.exe\" \""; helpCmd += "/j"; helpCmd += HELPFILE_LINE; helpCmd += " "; if ((work = (char *)get_reg_value(macropath, &type)) == NULL) { // マクロパスが存在しなければ秀丸の InstallLocation がホーム helpCmd += temp; } else { helpCmd += work; } helpCmd += "\\HidemaruMailSearch.txt\""; } if (temp != NULL) { free(temp); } if (work != NULL) { free(work); } } PROCESS_INFORMATION pi; STARTUPINFO si; memset(&si, 0, sizeof(STARTUPINFO)); si.cb = sizeof(STARTUPINFO); CreateProcess(NULL, (LPSTR)helpCmd.c_str(), NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi); return 0; } else if (inputText.find("debug:") == 0) { query = inputText.substr(strlen("debug:")); } else { std::string flag; trim(inputText); while (inputText.size() != 0) { int tagKind = findTag(inputText); if (tagKind == TARGET_SMALLHEADERBODY && inputText.find(colon_targets[TARGET_SMALLHEADERBODY]) != 0) { inputText = colon_targets[TARGET_SMALLHEADERBODY] + inputText; } rc = makeQuery(tagKind, inputText, query, flag); trim(inputText); } if (flag.size() != 0) { if (query.size() != 0) { query += ","; } query += flag; } // サブフォルダを検索対称にするかどうか if (selectedRadioButton == IDC_RADIO2) { query += ",subfolder=1"; } else { query += ",subfolder=0"; } // 常にハイライト query += ",hilight=1"; } #ifdef _DEBUG println("■アカウント"); println(account); println("■フォルダ"); println(folder); println("■検索式"); println(query); println("■入力"); println(history[0]); #endif if (IsHidemaruMailMain() || IsHidemaruMailGrep()) { SetFindPack(query.c_str()); StartDoGrep(account, folder); PushFindPack(); } else { ExecAtMain("SetFindPack", query.c_str()); ExecAtMain("StartDoGrep", account, folder); ExecAtMain("PushFindPack"); } } return 0; }
/********************************************************************** *%FUNCTION: relayHandlePADI *%ARGUMENTS: * iface -- interface on which packet was received * packet -- the PADI packet *%RETURNS: * Nothing *%DESCRIPTION: * Receives and processes a PADI packet. ***********************************************************************/ void relayHandlePADI(PPPoEInterface const *iface, PPPoEPacket *packet, int size) { PPPoETag tag; unsigned char *loc; int i, r; int ifIndex; /* Can a client legally be behind this interface? */ if (!iface->clientOK) { syslog(LOG_ERR, "PADI packet from %02x:%02x:%02x:%02x:%02x:%02x on interface %s not permitted", packet->ethHdr.h_source[0], packet->ethHdr.h_source[1], packet->ethHdr.h_source[2], packet->ethHdr.h_source[3], packet->ethHdr.h_source[4], packet->ethHdr.h_source[5], iface->name); return; } /* Source address must be unicast */ if (NOT_UNICAST(packet->ethHdr.h_source)) { syslog(LOG_ERR, "PADI packet from %02x:%02x:%02x:%02x:%02x:%02x on interface %s not from a unicast address", packet->ethHdr.h_source[0], packet->ethHdr.h_source[1], packet->ethHdr.h_source[2], packet->ethHdr.h_source[3], packet->ethHdr.h_source[4], packet->ethHdr.h_source[5], iface->name); return; } /* Destination address must be broadcast */ if (NOT_BROADCAST(packet->ethHdr.h_dest)) { syslog(LOG_ERR, "PADI packet from %02x:%02x:%02x:%02x:%02x:%02x on interface %s not to a broadcast address", packet->ethHdr.h_source[0], packet->ethHdr.h_source[1], packet->ethHdr.h_source[2], packet->ethHdr.h_source[3], packet->ethHdr.h_source[4], packet->ethHdr.h_source[5], iface->name); return; } /* Get array index of interface */ ifIndex = iface - Interfaces; loc = findTag(packet, TAG_RELAY_SESSION_ID, &tag); if (!loc) { tag.type = htons(TAG_RELAY_SESSION_ID); tag.length = htons(MY_RELAY_TAG_LEN); memcpy(tag.payload, &ifIndex, sizeof(ifIndex)); memcpy(tag.payload+sizeof(ifIndex), packet->ethHdr.h_source, ETH_ALEN); /* Add a relay tag if there's room */ r = addTag(packet, &tag); if (r < 0) return; size += r; } else { /* We do not re-use relay-id tags. Drop the frame. The RFC says the relay agent SHOULD return a Generic-Error tag, but this does not make sense for PADI packets. */ return; } /* Broadcast the PADI on all AC-capable interfaces except the interface on which it came */ for (i=0; i < NumInterfaces; i++) { if (iface == &Interfaces[i]) continue; if (!Interfaces[i].acOK) continue; memcpy(packet->ethHdr.h_source, Interfaces[i].mac, ETH_ALEN); sendPacket(NULL, Interfaces[i].discoverySock, packet, size); } }
bool hasTag(const TurnLaneType::Mask tag, const LaneDataVector &data) { return findTag(tag, data) != data.cend(); }