• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ parseHeader函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中parseHeader函数的典型用法代码示例。如果您正苦于以下问题:C++ parseHeader函数的具体用法?C++ parseHeader怎么用?C++ parseHeader使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了parseHeader函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: send_ERROR

/* Enviar msg erro:	Tipo de Erro
 * 					 Index
 ****************************************
 */ 		
void send_ERROR( unsigned char error, unsigned char index ){
	
	unsigned char *ptr;
	unsigned char t;
	unsigned int len;
	
	ptr = LENGTH_Build_ptr[1]; //LEN PDU
	*(ptr) = MSG_GET_RESPONSE+ASN_CONTEXT+ASN_FORMAT; //GetResponse	
	
	ptr = parseHeader(ptr, &t, &len);
	
	//RID
	ptr = parseHeader(ptr, &t, &len);
	ptr += len;
	
	//ERROR
	ptr = parseHeader(ptr, &t, &len);
	*ptr = error;
	
	//ERROR_INDEX
	ptr += len;
	ptr = parseHeader(ptr, &t, &len);
	*ptr = index;
	
	sendtoUDP_socket(s, RX_ptr, SIZE_SNMP, IP_dest, PORT_dest); // Enviar data (UDP/IP RAW)

}
开发者ID:lbpassos,项目名称:Monitoring-Station,代码行数:31,代码来源:snmp.c


示例2: main

int main(int argc, char *argv[])
{
    struct sockaddr_in si_me, si_other;
     
    int s, i, slen = sizeof(si_other) , numbytes;
    char buf[BUFLEN];
    char *message;
     
    if (argc != 2){
        fprintf(stderr,"usage: %s <port>\n", argv[0]);
        exit(1);
    }

    //create a UDP socket
    if ((s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1){
        die("socket");
    }
     
    // zero out the structure
    memset((char *) &si_me, 0, sizeof(si_me));
     
    si_me.sin_family = AF_INET;
    si_me.sin_port = htons(atoi(argv[1]));
    si_me.sin_addr.s_addr = htonl(INADDR_ANY);
     
    //bind socket to port
    if( bind(s , (struct sockaddr*)&si_me, sizeof(si_me) ) == -1)
        die("bind");
     
    //receive data
    if ((numbytes = recvfrom(s, buf, BUFLEN, 0, (struct sockaddr *) &si_other, &slen)) == -1) 
        die("recvfrom()");
    parseHeader(buf);

    //packet #2
    if (strcmp(SYN_BIT, "1") == 0){
        addHeader(0,1,"1","1", 100);
        strcpy(buf, header);
        if (sendto(s, buf, strlen(buf), 0, (struct sockaddr*) &si_other, slen) == -1) 
            die("sendto()");
    }

    if ((numbytes = recvfrom(s, buf, BUFLEN, 0, (struct sockaddr *) &si_other, &slen)) == -1) 
        die("recvfrom()");

    if ((numbytes = recvfrom(s, buf, BUFLEN, 0, (struct sockaddr *) &si_other, &slen)) == -1) 
        die("recvfrom()");
    message = parseHeader(buf);
    printf("server: received\n%s\n", message);

    //packet #5
    addHeader(0,1,"1","1", 100);
    strcpy(buf, header);
    strcat(buf, "Okay! Sending you test.txt...");
    if (sendto(s, buf, strlen(buf), 0, (struct sockaddr*) &si_other, slen) == -1) 
        die("sendto()");
 
    close(s);
    return 0;
}
开发者ID:MCOlivera,项目名称:TCP-UDP-Simulation,代码行数:60,代码来源:server.c


示例3: main1

int main1(int argc, char * argv[]) {
	
	//test header parse
	char headerStr1[]    = "Content-Length: 348";
	char headerStr2[]    = "Date: Tue, 15 Nov 1994 08:12:31 GMT";
	Header * header1;
	Header * header2;
	header1 = (Header*) malloc(sizeof(Header));
	header2 = (Header*) malloc(sizeof(Header));
	if (header1 != NULL) {
		parseHeader(headerStr1, strlen(headerStr1), header1);
		printf("header1 name is %s\n header1 value is %s\n", header1->name, header1->value);
	}
	if (header2 != NULL) {
		parseHeader(headerStr2, strlen(headerStr2), header2);
		printf("header2 name is %s\n header2 value is %s\n", header2->name, header2->value);
	}
	free(header1);
	free(header2);

	//test request line parse
	char requestLine1[]  = "GET http://www.w3.org/pub/WWW/TheProject.html HTTP/1.1";
	char requestLine2[]  = "GET /pub/WWW/TheProject.html HTTP/1.1";
	RequestLine * line1;
	RequestLine * line2;
	line1 = (RequestLine*) malloc(sizeof(RequestLine));
	line2 = (RequestLine*) malloc(sizeof(RequestLine));
	if (line1) {
		parseHttpRequestLine(requestLine1, strlen(requestLine1), line1);
		printf("request line1's method is %s\n path is %s\n version is %s\n'", line1->method, line1->path, line1->version);
	}
	if (line2) {
		parseHttpRequestLine(requestLine2, strlen(requestLine2), line2);
		printf("request line2's method is %s\n path is %s\n version is %s\n'", line2->method, line2->path, line2->version);
	}
	free(line1);
	free(line2);
	
	//test formHeader
	Header *header;
	char headStr[1024];
	header = (Header*) malloc(sizeof(Header));
	strcpy(header->name,"Content-length");
	strcpy(header->value,"123456");
	formHeader(header,headStr,sizeof(headStr));
	printf("headerStr is %s", headStr);

	return 0;
}
开发者ID:mixianghang,项目名称:tcpudp,代码行数:49,代码来源:httputil.c


示例4: parseHeaders

static inline void parseHeaders(const String& headers, ResourceResponse& response)
{
    int startPos = 0;
    int endPos;
    while ((endPos = headers.find('\n', startPos)) != -1) {
        ASSERT(startPos != endPos);

        parseHeader(headers.characters() + startPos, endPos - startPos, response);
        
        startPos = endPos + 1;
    }
    
    if (startPos != static_cast<int>(headers.length()))
        parseHeader(headers.characters(), headers.length(), response);
}
开发者ID:Gin-Rye,项目名称:duibrowser,代码行数:15,代码来源:ApplicationCacheStorage.cpp


示例5: parseHeader

HttpParser::status_t
HttpParser::addBytes( const char* bytes, unsigned len )
{
    if ( _status != Incomplete ) {
        return _status;
    }

    // append the bytes to data.
    _data.append( bytes, len );

    if ( _state < p_content ) {
        parseHeader();
    }

    if ( _state == p_error ) {
        _status = Error;
    } else if ( _state == p_content ) {
        if ( _contentLength == 0 || _data.length() - _contentStart >= _contentLength ) {
            if ( parseRequestLine() ) {
                _status = Done;
            } else {
                _status = Error;
            }
        }
    }

    return _status;
}
开发者ID:Hooksdena36,项目名称:xbmc,代码行数:28,代码来源:HttpParser.cpp


示例6: demuxer

TheoraVideoStream::TheoraVideoStream(love::filesystem::File *file)
	: demuxer(file)
	, headerParsed(false)
	, decoder(nullptr)
	, frameReady(false)
	, lastFrame(0)
	, nextFrame(0)
{
	if (demuxer.findStream() != OggDemuxer::TYPE_THEORA)
		throw love::Exception("Invalid video file, video is not theora");

	th_info_init(&videoInfo);

	frontBuffer = new Frame();
	backBuffer = new Frame();

	try
	{
		parseHeader();
	}
	catch (love::Exception &ex)
	{
		delete backBuffer;
		delete frontBuffer;
		th_info_clear(&videoInfo);
		throw ex;
	}

	frameSync.set(new DeltaSync(), Acquire::NORETAIN);
}
开发者ID:MikuAuahDark,项目名称:livesim4,代码行数:30,代码来源:TheoraVideoStream.cpp


示例7: reset

void VcfFile::openForRead(const char* filename, int nbuf) {
  reset();
  
  iFile = ifopen(filename,"rb");
  if ( iFile == NULL ) {
    throw VcfFileException("Failed opening file %s - %s",filename, strerror(errno));
  }
  nBuffers = nbuf;
  nNumMarkers = 0;
  nHead = 0;
  if ( nBuffers == 0 ) { // infinite buffer size
    // do not set size of markers
  }
  else {
    vpVcfMarkers.resize( nBuffers );
    for(int i=0; i < nBuffers; ++i) {
      VcfMarker* p = new VcfMarker;
      vpVcfMarkers[i] = p;
    }
  }
  parseMeta();
  parseHeader();

  if ( bUpgrade ) {
    upgradeMetaLines();
  }
}
开发者ID:amarawi,项目名称:gotcloud,代码行数:27,代码来源:VcfFile.cpp


示例8: parseHeader

bool
WAVAudioFile::open()
{
    // if already open
    if (m_inFile && (*m_inFile))
        return true;

    m_inFile = new std::ifstream(m_fileName.toLocal8Bit(),
                                 std::ios::in | std::ios::binary);

    if (!(*m_inFile)) {
        m_type = UNKNOWN;
        return false;
    }

    // Get the file size and store it for comparison later
    m_fileSize = m_fileInfo->size();

    try {
        parseHeader();
    } catch (BadSoundFileException e) {
        RG_WARNING << "ERROR: WAVAudioFile::open(): parseHeader: " << e.getMessage();
        return false;
    }

    return true;
}
开发者ID:tedfelix,项目名称:rosegarden,代码行数:27,代码来源:WAVAudioFile.cpp


示例9: myfile

void EpwData::loadData(const openstudio::path &fn)
{
  // Array was fully initialized in constructor
  std::ifstream myfile(openstudio::toString(fn).c_str());
  if (myfile.is_open())
  {
    size_t i = 0;
    size_t row = 0;
    while ( myfile.good() && row < 8760)
    {
      i++;
      std::string line;
      getline(myfile,line);
      if(i==1)
      {
        parseHeader(line);
      }
      else if(i > 8)
      {
        parseData(line,row++);
      }
    }
    myfile.close();
  } else {
    throw std::runtime_error("Unable to open weather file: " + openstudio::toString(fn));
  }
}
开发者ID:NREL,项目名称:OpenStudio,代码行数:27,代码来源:EpwData.cpp


示例10: main

int main(int argc, const char* argv[])
{
	char fileExt[64];
	BGFunction* functions;

	if (argc != 3)
	{
		printf("usage: <input file> <output file>\nExample: bind_generator foo.h out.cs");
		return 0;
	}

	functions = parseHeader(argv[1]);

	if (!getExt(fileExt, argv[2]))
	{
		printf("Unable to find file extension for %s", argv[2]);
		return -1;
	}

	// This is a bit hacky but like this because of extra params handling in tundra. Hopefully
	// this can be fixed by sending is some proper commandline args instead

	if (!strcmp(fileExt, ".c"))
	{
		if (!generate_exp(argv[2], functions))
			return -1;
	}
	else if (!strcmp(fileExt, ".cs"))
	{
		generate_cs(argv[2], functions);
	}

	return 0;
}
开发者ID:emoon,项目名称:Arika,代码行数:34,代码来源:bind_parser.c


示例11: m_datafile

Loader::Loader(fs::DataFile& datafile, const string& filename)
    : m_datafile(datafile)
{
    // Load configuration file
    std::vector<conftree::Node> nodes = conftree::parseMultiDocYAML(datafile, filename);

    // Sanity checks
    if(nodes.empty())
        throw ResourceException(datafile.name(), filename, "Not a YAML file!");

    if(nodes.size() > 2)
        throw ResourceException(datafile.name(), filename, "Resource file should contain at most two documents!");

    if(nodes[0].type() != conftree::Node::MAP)
        throw ResourceException(datafile.name(), filename, "Resource file should contain a Map!");

    if(nodes.size() > 1) {
        // Header present
        m_node = nodes[1];
        parseHeader(datafile, nodes[0]);
    } else {
        // No header
        m_node = nodes[0];
    }
}
开发者ID:mivihe,项目名称:luola2,代码行数:25,代码来源:loader.cpp


示例12: parseRequestLine

/**
 * @brief Parse socket data.
 * @param [in] s The socket from which to retrieve data.
 */
void HttpParser::parse(Socket s) {
	std::string line;
	line = s.readToDelim(lineTerminator);
	parseRequestLine(line);
	line = s.readToDelim(lineTerminator);
	while(!line.empty()) {
		m_headers.insert(parseHeader(line));
		line = s.readToDelim(lineTerminator);
	}
	// Only PUT and POST requests have a body
	if (getMethod() != "POST" && getMethod() != "PUT") {
		return;
	}

	// We have now parsed up to and including the separator ... we are now at the point where we
	// want to read the body.  There are two stories here.  The first is that we know the exact length
	// of the body or we read until we can't read anymore.
	if (hasHeader(HttpRequest::HTTP_HEADER_CONTENT_LENGTH)) {
		std::string val = getHeader(HttpRequest::HTTP_HEADER_CONTENT_LENGTH);
		int length = std::atoi(val.c_str());
		uint8_t data[length];
		s.receive_cpp(data, length, true);
		m_body = std::string((char *)data, length);
	} else {
		uint8_t data[512];
		int rc = s.receive_cpp(data, sizeof(data));
		m_body = std::string((char *)data, rc);
	}
	ESP_LOGD(LOG_TAG, "Size of body: %d", m_body.length());
} // parse
开发者ID:EdWeller,项目名称:esp32-snippets,代码行数:34,代码来源:HttpParser.cpp


示例13: gettimeofday

MistarParser::MistarParser(string file,string indexForFile,string chrName,int start,int end){
    //for rand() ins SingleAllele
    timeval time;
    gettimeofday(&time, NULL);
    srand(  long((time.tv_sec * 1000) + (time.tv_usec / 1000)) );

    // cout<<file<<endl;
    // cout<<indexForFile<<endl;
    // cout<<chrName<<endl;
    // cout<<start<<endl;
    // cout<<end<<endl;

    rt =new ReadTabix (file,indexForFile,chrName,start,end);
    string headertemp=rt->getHeader();

    istringstream is(headertemp);
  
    //reading the header
    numberPopulations=0;
    populationNames=new vector<string>();

    parseHeader(is);

    if(defline.empty()){
	cerr << "Error: MistarParser cannot get definition line"  <<endl;
	exit(1);
    }

    numberOfTimesHasDataWasCalled=-1;
    tabixMode  = true;
    textMode   = false;
    stringMode = false;
}
开发者ID:mnievesc,项目名称:dice,代码行数:33,代码来源:MistarParser.cpp


示例14: parseHeader

int AppMessageParser::parse( uint8_t octet )
{
    int r = 0;
    AppMessage *msg = 0;

    // Is there room in the header buffer?
    if ( m_header_buffer.canPut() )
    {
        // yes, try parse the header
        msg = parseHeader( octet );
    }
    else
    {
        // is there octets we are expecting for the payload?
        if ( m_octets_left_in_payload )
        {
            // yes, parse the payload
            msg = parsePayload( octet );
        }
    }

    if ( msg )
    {
        dispatchMsg( *msg );
        r = 0;
    }

    if ( m_error_count > 0 )
    {
        r = -1;
    }

    return r;
}
开发者ID:AVB-YJ,项目名称:jdksavdecc-mcu,代码行数:34,代码来源:AppMessageParser.cpp


示例15: parseHeader

bool
BWFAudioFile::open()
{
    // if already open
    if (m_inFile && (*m_inFile))
        return true;

    m_inFile = new std::ifstream(m_fileName.toLocal8Bit(),
                                 std::ios::in | std::ios::binary);

    if (!(*m_inFile)) {
        m_type = UNKNOWN;
        return false;
    }

    // Get the file size and store it for comparison later
    //
    m_fileSize = m_fileInfo->size();

    try {
        parseHeader();
    } catch (BadSoundFileException s) {
        //throw(s);
        return false;
    }

    return true;
}
开发者ID:EQ4,项目名称:RosegardenW,代码行数:28,代码来源:BWFAudioFile.cpp


示例16: decode

bool CGarminTyp::decode(QDataStream& in, QMap<quint32, polygon_property>& polygons, QMap<quint32, polyline_property>& polylines, QList<quint32>& drawOrder, QMap<quint32, point_property>& points)
{

    if(!parseHeader(in))
    {
        return false;
    }

    if(!parseDrawOrder(in, drawOrder))
    {
        return false;
    }

    if(!parsePolygon(in, polygons))
    {
        return false;
    }

    if(!parsePolyline(in, polylines))
    {
        return false;
    }

    if(!parsePoint(in, points))
    {
        return false;
    }

    return true;
}
开发者ID:Nikoli,项目名称:qlandkartegt,代码行数:30,代码来源:CGarminTyp.cpp


示例17: parseHeader

void
Lane::setHeaders(header_map headers)
{
  _headers = std::move(headers);
  for (auto &h : _headers)
    parseHeader(h.first, h.second.first);
}
开发者ID:Peppar,项目名称:mist-conn,代码行数:7,代码来源:lane.cpp


示例18: parseHeader

void
cgicc::Cgicc::parseMIME(const std::string& data)
{
  // Find the header
  std::string end = "\r\n\r\n";
  std::string::size_type headLimit = data.find(end, 0);
  
  // Detect error
  if(std::string::npos == headLimit)
    throw std::runtime_error("Malformed input");

  // Extract the value - there is still a trailing CR/LF to be subtracted off
  std::string::size_type valueStart = headLimit + end.length();
  std::string value = data.substr(valueStart, data.length() - valueStart - 2);

  // Parse the header - pass trailing CR/LF x 2 to parseHeader
  MultipartHeader head = parseHeader(data.substr(0, valueStart));

  if(head.getFilename().empty())
    fFormData.push_back(FormEntry(head.getName(), value));
  else
    fFormFiles.push_back(FormFile(head.getName(), 
				  head.getFilename(), 
				  head.getContentType(), 
				  value));
}
开发者ID:Hooligan-0,项目名称:cgicc-ng,代码行数:26,代码来源:Cgicc.cpp


示例19: removeUselessBlanks

void SUROpener::Parser::parseLine(QString line)
{
    removeUselessBlanks(line);
    if (line.size() == 0) return;
    if (header(line)) parseHeader(line);
    else dispatch(line);
}
开发者ID:matiasjrossi,项目名称:Dimension,代码行数:7,代码来源:suropener.cpp


示例20: if

XmlElement* XmlDocument::parseDocumentElement (String::CharPointerType textToParse,
                                               const bool onlyReadOuterDocumentElement)
{
    input = textToParse;
    errorOccurred = false;
    outOfData = false;
    needToLoadDTD = true;

    if (textToParse.isEmpty())
    {
        lastError = "not enough input";
    }
    else if (! parseHeader())
    {
        lastError = "malformed header";
    }
    else if (! parseDTD())
    {
        lastError = "malformed DTD";
    }
    else
    {
        lastError.clear();

        ScopedPointer<XmlElement> result (readNextElement (! onlyReadOuterDocumentElement));

        if (! errorOccurred)
            return result.release();
    }

    return nullptr;
}
开发者ID:Neknail,项目名称:JUCE,代码行数:32,代码来源:juce_XmlDocument.cpp



注:本文中的parseHeader函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ parseIdentifier函数代码示例发布时间:2022-05-30
下一篇:
C++ parseFloat函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap