示例#1
0
void startDialog::on_ExportExcel_clicked()
{
    ClearLog();

    if (false == expExcel()) {
        WriteLog("Export excel error");
        return;
    }
    WriteLog("==========excel export success==========\n");

    const char *packaged_cmd = _getFromIocfg("packeaged_rum_cmd");
    if (packaged_cmd && *packaged_cmd)	{
		char cmdbuf[1024];
		const char *p = packaged_cmd;
		while (p && *p) {
			cmdbuf[0] = 0;
			p = ndstr_nstr_end(p, cmdbuf, ';', sizeof(cmdbuf));
			if (p && *p == ';')	{
				++p;
			}

			if (cmdbuf[0])	{
				int ret = system(cmdbuf);
				if (0 != ret)	{
                    nd_logerror("Run command by system %s %d\n", cmdbuf, ret);
					break;
				}
			}
		}
    }
}
示例#2
0
int NDHttpRequest::_parseHeader()
{
	
	int datasize = _getDataSize () ;
	char *p_start = _getCurParseAddr() ;
	char buf[1024] ;
	
	if (!p_start) {
		return 0 ;
	}
	char *p = p_start ;
	
	p = parser_valid(p, datasize) ;
	if (!p) {
		return  0 ;
	}
	
	p = (char*) ndstr_nstr_end(p,buf,':', datasize -(int) (p-p_start) ) ;
	if(*p != ':') {
		return  0 ;
	}
	std::string hdrName = buf ;
	
	++p ;
	p =  parser_valid(p, datasize -(int) (p-p_start));
	char *_st = p ;
	if(parser_check_end(p, &p, datasize -(int) (p-p_start)) ) {
		int len =(int)( p-_st );
		memcpy(buf,_st, len-2) ;
		buf[len-2] = 0 ;
		
		std::string hdrVal = buf ;
		
		httpHeaderNode node1 = {hdrName, hdrVal} ;
		m_header.push_back(node1) ;
		
		len = (int)( p- p_start );
		ndlbuf_sub_data(&m_recvBuf, len) ;
		
		if (*p=='\r' && *(p+1)=='\n') {
			ndlbuf_sub_data(&m_recvBuf, 2) ;
			m_parseStat = 2 ;
			//_dumRequestHeader() ;
			if (_findBodySize()==0) {
				m_parseProgress = 3 ;//without body

			}
		}
		
		return len ;
	}
	
	return 0;
	

}
示例#3
0
int set_xml_value(char *file, char *node_name_list, char *attr_name, char*attr_val, char *node_val)
{
    int ret;
    ndxml_root xmlfile;
    
    ndxml *xnode = 0 ;
    
    char *p = node_name_list;
    char name[128] ;
    
    ret = ndxml_load(file, &xmlfile) ;
    if(0!=ret) {
        fprintf(stderr,"load xml from %s\n", file) ;
        return -1;
    }
    
    p = (char*)ndstr_nstr_end(p, name, '.', sizeof(name)) ;
    
    if (IS_NUMERALS(name[0])) {
		xnode = ndxml_getnodei(&xmlfile, ndstr_atoi_hex(name));
    }
    else {
        xnode = ndxml_getnode(&xmlfile, name) ;
    }
    if (!xnode) {
        fprintf(stderr,"read xml-node %s error \n", name) ;
    }
    
    bool success = true ;
    while (p && *p) {
        
        if (*p == '.') {
            ++p ;
            if (!*p) {
                break ;
            }
        }
        
        p = (char*) ndstr_nstr_end(p, name, '.', sizeof(name)) ;
        
        if (IS_NUMERALS(name[0])) {
			xnode = ndxml_refsubi(xnode, ndstr_atoi_hex(name));
        }
        else {
            xnode = ndxml_refsub(xnode, name) ;
        }
        if (!xnode) {
            fprintf(stderr,"read xml-node %s error \n", name) ;
            success = false ;
            break ;
        }
        
        
    }
    if (success) {
        success = false;
        if (attr_name && attr_name[0] && attr_val && attr_val[0]) {
            ndxml_setattrval(xnode,attr_name, attr_val ) ;
            success = true ;
        }
        if (node_val && node_val[0]) {
            ndxml_setval(xnode, node_val) ;
            success = true ;
        }
        if (success) {
            ndxml_save(&xmlfile,file) ;
        }
    }
    
    ndxml_destroy(&xmlfile);
    return success ? 0: -1 ;
}