Beispiel #1
0
void parseSpec(TagsFilters* tagsFilters, const std::string& spec)
{
   if(spec.size() == 0)
   {
      return;
   }
   
   std::string tags;
   std::string rest;
   
   size_t pos = spec.find_first_of('>');
   if(pos == std::string::npos)
   {
      tags = spec;
   }
   else
   {
      tags = spec.substr(0, pos);
      rest = spec.substr(pos+1, spec.size() - pos);
   }   
   
   tagsFilters->addNextFilter(parseFilter(tags));
   
   parseSpec(tagsFilters, rest);
}
Beispiel #2
0
/** \brief parse option from configuration file.
*
* \param[in,out] as Pointer to session handle
* \param[in] opt name of option to set (left of =)
* \param[in] param name of value for option (right of =)
* \param type type for param, currently unused
* \return 0 if parsing was successful, -1 if an error occured.  currently
* always returns 0
*/
PRIVATE int set_option(auto_handle *as, const char *opt, const char *param, option_type type) {
  int32_t numval;
  dbg_printf(P_INFO2, "%s=%s (type: %d)", opt, param, type);

  assert(as != NULL);
  if(!strcmp(opt, "url")) {
    getFeeds(&as->feeds, param);
  } else if(!strcmp(opt, "feed")) {
    parseFeed(&as->feeds, param);
  } else if(!strcmp(opt, "download-folder")) {
    set_path(param, &as->download_folder);
  } else if(!strcmp(opt, "statefile")) {
    set_path(param, &as->statefile);
  } else if(!strcmp(opt, "interval")) {
    numval = parseUInt(param);
    if(numval > 0) {
      as->check_interval = numval;
    } else if(numval != -1) {
      dbg_printf(P_ERROR, "Interval must be 1 minute or more, reverting to default (%dmin)\n\t%s=%s", AM_DEFAULT_INTERVAL, opt, param);
    } else {
      dbg_printf(P_ERROR, "Unknown parameter: %s=%s", opt, param);
    }
  } else if(!strcmp(opt, "patterns")) {
    addPatterns_old(&as->filters, param);
  } else if(!strcmp(opt, "filter")) {
    parseFilter(&as->filters, param);
  } else if(!strcmp(opt, "prowl-apikey")) {
    as->prowl_key = am_strdup(param);
  } else if(!strcmp(opt, "download-done-script")) {
    as->download_done_script = am_strdup(param);
  } else {
    dbg_printf(P_ERROR, "Unknown option: %s", opt);
  }
  return 0;
}
void PublicHubsFrame::updateList()
{
	//CLockRedraw<> l_lock_draw(m_ctrlHubs);
	m_ctrlHubs.DeleteAllItems();
	users = 0;
	visibleHubs = 0;
	
	double size = -1;
	FilterModes mode = NONE;
	
	int sel = ctrlFilterSel.GetCurSel();
	
	bool doSizeCompare = parseFilter(mode, size);
	
	auto cnt = m_ctrlHubs.GetItemCount();
	for (auto i = m_hubs.cbegin(); i != m_hubs.cend(); ++i)
	{
		if (matchFilter(*i, sel, doSizeCompare, mode, size))
		{
			TStringList l;
			l.resize(COLUMN_LAST);
			l[COLUMN_NAME] = Text::toT(i->getName());
			string l_description = i->getDescription();
			boost::replace_all(l_description, ".px.", "");
			l[COLUMN_DESCRIPTION] = Text::toT(l_description);
			l[COLUMN_USERS] = Util::toStringW(i->getUsers());
			l[COLUMN_SERVER] = Text::toT(i->getServer());
			l[COLUMN_COUNTRY] = Text::toT(i->getCountry()); // !SMT!-IP
			l[COLUMN_SHARED] = Util::formatBytesW(i->getShared());
			l[COLUMN_MINSHARE] = Util::formatBytesW(i->getMinShare());
			l[COLUMN_MINSLOTS] = Util::toStringW(i->getMinSlots());
			l[COLUMN_MAXHUBS] = Util::toStringW(i->getMaxHubs());
			l[COLUMN_MAXUSERS] = Util::toStringW(i->getMaxUsers());
			l[COLUMN_RELIABILITY] = Util::toStringW(i->getReliability());
			l[COLUMN_RATING] = Text::toT(i->getRating());
			const auto l_country = i->getCountry();
			dcassert(!l_country.empty());
			const auto l_index_country = WinUtil::getFlagIndexByName(l_country.c_str());
			//const auto l_index =
			m_ctrlHubs.insert(cnt++, l, l_index_country); // !SMT!-IP
			
			/*
			LVITEM lvItem = { 0 };
			        lvItem.mask = LVIF_IMAGE;
			        lvItem.iItem = l_index;
			        lvItem.iImage = isOnline(i->getServer()) ? 0 : 1;
			        m_ctrlHubs.SetItem(&lvItem);
			*/
			visibleHubs++;
			users += i->getUsers();
		}
	}
	
	m_ctrlHubs.resort();
	
	updateStatus();
}
Beispiel #4
0
/**
* @brief 删除多个文件
* @param files 文件名过滤器, 如"*.dat", "k*", "y*.c"等等
* @return 0表示成功,否则表示失败
* @note 最好不要用来操作过长文件名或者过深路径名(总和不能超过64字节),
      否则操作效率不大大降低
*/
int SysRemoveFiles(const char *files)
{
	DIR *dir;
	struct dirent *ptr;
	char path[MAXLEN_PATH], filterhead[MAXLEN_HEAD], filtertail[MAXLEN_TAIL];
	char *filename;
	int pathlen;

	if(parseFilter(files, path, filterhead, filtertail)) return 1;
	//print_logo(0, "rm files %s*%s in %s\n", filterhead, filtertail, path);
	filename = path;
	pathlen = strlen(path);
	filename += pathlen;

	dir = opendir(path);
	if(NULL == dir) {
		printf("open dir failed\n");
		return 1;
	}

	while((ptr = readdir(dir)) != NULL) {
		//printf("dir: %d: %s\n", ptr->d_type, ptr->d_name);
		if(DT_REG != ptr->d_type) continue;

		if(compareFilter(ptr->d_name, filterhead, filtertail)) {
			if((pathlen+strlen(ptr->d_name)) >= MAXLEN_PATH) {  //too long
				char *tmppath, *tmpptr;
				int i;

				tmppath = malloc(pathlen+strlen(ptr->d_name)+1);
				if(NULL != tmppath) {
					tmpptr = tmppath;
					for(i=0; i<pathlen; i++) *tmpptr++ = path[i];
					for(i=0; i<strlen(ptr->d_name); i++) *tmpptr++ = ptr->d_name[i];
					*tmpptr = 0;
					remove(tmppath);
					free(tmppath);
				}
			}
			else {
				strcpy(filename, ptr->d_name);
				//print_logo(0, "remove %s...\n", path);
				remove(path);
			}
		}
	}

	closedir(dir);
	return 0;
}
void PublicHubsFrame::updateList() {
	ctrlHubs.DeleteAllItems();
	users = 0;
	visibleHubs = 0;

	ctrlHubs.SetRedraw(FALSE);

	double size = -1;
	FilterModes mode = NONE;

	int sel = ctrlFilterSel.GetCurSel();

	bool doSizeCompare = parseFilter(mode, size);

	for(HubEntryList::const_iterator i = hubs.begin(); i != hubs.end(); ++i) {
		if(matchFilter(*i, sel, doSizeCompare, mode, size)) {

			TStringList l;
			l.resize(COLUMN_LAST);
			l[COLUMN_NAME] = Text::toT(i->getName());
			l[COLUMN_DESCRIPTION] = Text::toT(i->getDescription());
			l[COLUMN_USERS] = Text::toT(Util::toString(i->getUsers()));
			l[COLUMN_SERVER] = Text::toT(i->getServer());
			l[COLUMN_COUNTRY] = Text::toT(i->getCountry());
			l[COLUMN_SHARED] = Text::toT(Util::formatBytes(i->getShared()));
			l[COLUMN_MINSHARE] = Text::toT(Util::formatBytes(i->getMinShare()));
			l[COLUMN_MINSLOTS] = Text::toT(Util::toString(i->getMinSlots()));
			l[COLUMN_MAXHUBS] = Text::toT(Util::toString(i->getMaxHubs()));
			l[COLUMN_MAXUSERS] = Text::toT(Util::toString(i->getMaxUsers()));
			l[COLUMN_RELIABILITY] = Text::toT(Util::toString(i->getReliability()));
			l[COLUMN_RATING] = Text::toT(i->getRating());
			ctrlHubs.insert(ctrlHubs.GetItemCount(), l);
			visibleHubs++;
			users += i->getUsers();
		}
	}

	ctrlHubs.SetRedraw(TRUE);
	ctrlHubs.resort();

	updateStatus();
}
Beispiel #6
0
SvgFilterHelper* SvgParser::findFilter(const QString &id, const QString &href)
{
    // check if filter was already parsed, and return it
    if (m_filters.contains(id))
        return &m_filters[ id ];

    // check if filter was stored for later parsing
    if (!m_context.hasDefinition(id))
        return 0;

    const KoXmlElement &e = m_context.definition(id);
    if (e.childNodesCount() == 0) {
        QString mhref = e.attribute("xlink:href").mid(1);

        if (m_context.hasDefinition(mhref))
            return findFilter(mhref, id);
        else
            return 0;
    } else {
        // ok parse filter now
        if (! parseFilter(m_context.definition(id), m_context.definition(href)))
            return 0;
    }

    // return successfully parsed filter or NULL
    QString n;
    if (href.isEmpty())
        n = id;
    else
        n = href;

    if (m_filters.contains(n))
        return &m_filters[ n ];
    else
        return 0;
}
Beispiel #7
0
void AdBlockRule::setFilter(const QString &filter)
{
    m_filter = filter;
    parseFilter();
}
Beispiel #8
0
bool Chain::parse (const ssi_char_t *filepath) {

	release ();

	if (filepath == 0 || filepath[0] == '\0') {
		ssi_wrn ("file is empty");
		return false;
	}

	FilePath fp (filepath);
	ssi_char_t *filepath_with_ext = 0;
	if (strcmp (fp.getExtension (), SSI_FILE_TYPE_CHAIN) != 0) {
		filepath_with_ext = ssi_strcat (filepath, SSI_FILE_TYPE_CHAIN);
	} else {
		filepath_with_ext = ssi_strcpy (filepath);
	}

	if (!ssi_exists (filepath_with_ext)) {
		ssi_wrn ("file not found '%s", filepath_with_ext);
		return false;
	}

	ssi_msg (SSI_LOG_LEVEL_BASIC, "load '%s'", filepath_with_ext);

	TiXmlDocument doc;
	if (!doc.LoadFile (filepath_with_ext)) {
		ssi_wrn ("failed loading chain from file '%s'", filepath_with_ext);
		delete[] filepath_with_ext;
		return false;
	}

	TiXmlElement *body = doc.FirstChildElement();	
	if (!body || strcmp (body->Value (), "chain") != 0) {
		ssi_wrn ("tag <chain> missing");
		delete[] filepath_with_ext;
		return false;	
	}

	TiXmlElement *filter = body->FirstChildElement ("filter");
	if (filter) {
		if (!parseFilter (filter)) {
			ssi_wrn ("failed parsing <filter> tag");
			return false;
		}
	}

	TiXmlElement *feature = body->FirstChildElement ("feature");
	if (feature) {
		if (!parseFeature (feature)) {
			ssi_wrn ("failed parsing <feature> tag");
			return false;
		}
	}

	_parsed = feature || filter;
	if (!_parsed) {
		ssi_wrn ("parsing failed because no feature/filter were loaded");
	}

	return _parsed;
}
Beispiel #9
0
int
parseResReq(char *resReq,
            struct resVal *resVal,
            struct lsInfo *lsInfo,
            int options)
{
    static char       fname[] = "parseResReq()";
    int               cc;
    struct sections   reqSect;

    if (logclass & (LC_TRACE | LC_SCHED))
        ls_syslog(LOG_DEBUG3, "%s: resReq=%s", fname, resReq);

    initResVal(resVal);

    ALLOC_STRING(resVal->selectStr,
                 resVal->selectStrSize,
                 MAX(3*strlen(resReq) + 1, MAXLINELEN + MAXLSFNAMELEN));

    if ((cc = parseSection(resReq, &reqSect)) != PARSE_OK)
        return cc;

    if ((cc = setDefaults(resVal, lsInfo, options)) < 0)
        return cc;

    if (options & PR_SELECT) {

        if (options & PR_XOR) {
            if ((cc = parseSelect(reqSect.select,
                                  resVal,
                                  lsInfo,
                                  TRUE,
                                  options)) != PARSE_OK)
                return cc;
        } else {
            if ((cc = parseSelect(reqSect.select,
                                  resVal,
                                  lsInfo,
                                  FALSE,
                                  options)) != PARSE_OK)
                return cc;
	}
    }

    if (options & PR_ORDER) {
        if ((cc = parseOrder(reqSect.order,
                             resVal,
                             lsInfo)) != PARSE_OK)
            return cc;
    }

    if (options & PR_RUSAGE) {
        if ((cc = parseUsage(reqSect.rusage,
                             resVal,
                             lsInfo)) != PARSE_OK)
            return cc;
    }

    if (options & PR_FILTER) {
        if ((cc = parseFilter(reqSect.filter,
                              resVal,
                              lsInfo)) != PARSE_OK)
            return cc;
    }

    if (options & PR_SPAN) {
        if ((cc = parseSpan(reqSect.span,
                            resVal)) != PARSE_OK)
            return cc;
    }

    return(PARSE_OK);
}
Beispiel #10
0
/** \brief parse option from configuration file.
*
* \param[in,out] as Pointer to session handle
* \param[in] opt name of option to set (left of =)
* \param[in] param name of value for option (right of =)
* \param type type for param, currently unused
* \return 0 if parsing was successful, -1 if an error occured.  currently
* always returns 0
*/
PRIVATE int set_option(auto_handle *as, const char *opt, const char *param, option_type type) {
  int32_t numval;
  int32_t result = SUCCESS;

  dbg_printf(P_INFO2, "[config] %s=%s (type: %d)", opt, param, type);

  assert(as != NULL);
  if(!strcmp(opt, "url")) {
    dbg_printf(P_ERROR, "the 'url' option is not supported any more, please use the 'feed' option instead!");
    result = FAILURE;
  } else if(!strcmp(opt, "feed")) {
    result = parseFeed(&as->feeds, param);
  } else if(!strcmp(opt, "transmission-home")) {
    set_path(param, &as->transmission_path);
  } else if(!strcmp(opt, "prowl-apikey")) {
    as->prowl_key = am_strdup(param);
  } else if(!strcmp(opt, "toasty-deviceid")) {
    as->toasty_key = am_strdup(param);
  } else if(!strcmp(opt, "pushalot-token")) {
    as->pushalot_key = am_strdup(param);
  } else if(!strcmp(opt, "transmission-version")) {
    if (!strcmp(param, "external")) {
      /* we should probably only set this when transmission-external is set */
      as->transmission_version = AM_TRANSMISSION_EXTERNAL;
    } else if(param[0] == '1' && param[1] == '.' && param[2] == '2') {
      as->transmission_version = AM_TRANSMISSION_1_2;
    } else if(param[0] == '1' && param[1] == '.' && param[2] == '3') {
      as->transmission_version = AM_TRANSMISSION_1_3;
    } else {
      dbg_printf(P_ERROR, "Unknown parameter: %s=%s", opt, param);
    }
  } else if (!strcmp(opt, "transmission-external")) {
    set_path(param, &as->transmission_external);
    as->transmission_version = AM_TRANSMISSION_EXTERNAL;
  } else if(!strcmp(opt, "torrent-folder")) {
    set_path(param, &as->torrent_folder);
  } else if(!strcmp(opt, "statefile")) {
    set_path(param, &as->statefile);
  } else if(!strcmp(opt, "rpc-host")) {
    as->host = am_strdup(param);
  } else if(!strcmp(opt, "rpc-auth")) {
    as->auth = am_strdup(param);
  } else if(!strcmp(opt, "upload-limit")) {
    numval = parseUInt(param);
    if(numval > 0) {
      as->upspeed = (uint16_t)numval;
    } else {
      dbg_printf(P_ERROR, "Unknown parameter: %s=%s", opt, param);
    }
  } else if(!strcmp(opt, "rpc-port")) {
    numval = parseUInt(param);
    if (numval > 1024 && numval < 65535) {
      as->rpc_port = numval;
    } else if(numval != -1) {
      dbg_printf(P_ERROR, "RPC port must be an integer between 1025 and 65535, reverting to default (%d)\n\t%s=%s", AM_DEFAULT_RPCPORT, opt, param);
    } else {
      dbg_printf(P_ERROR, "Unknown parameter: %s=%s", opt, param);
    }
  } else if(!strcmp(opt, "interval")) {
    numval = parseUInt(param);
    if(numval > 0) {
      as->check_interval = numval;
    } else if(numval != -1) {
      dbg_printf(P_ERROR, "Interval must be 1 minute or more, reverting to default (%dmin)\n\t%s=%s", AM_DEFAULT_INTERVAL, opt, param);
    } else {
      dbg_printf(P_ERROR, "Unknown parameter: %s=%s", opt, param);
    }
  } else if(!strcmp(opt, "use-transmission")) {
    if(!strncmp(param, "0", 1) || !strncmp(param, "no", 2)) {
      as->use_transmission = 0;
    } else if(!strncmp(param, "1", 1) || !strncmp(param, "yes", 3)) {
      as->use_transmission = 1;
    } else {
      dbg_printf(P_ERROR, "Unknown parameter: %s=%s", opt, param);
    }
  } else if(!strcmp(opt, "start-torrents")) {
    if(!strncmp(param, "0", 1) || !strncmp(param, "no", 2)) {
      as->start_torrent = 0;
    } else if(!strncmp(param, "1", 1) || !strncmp(param, "yes", 3)) {
      as->start_torrent = 1;
    } else {
      dbg_printf(P_ERROR, "Unknown parameter for option '%s': '%s'", opt, param);
    }
  } else if(!strcmp(opt, "patterns")) {
    dbg_printf(P_ERROR, "the 'patterns' option is not supported any more, please use the 'filter' option instead!");
    result = FAILURE;
  } else if(!strcmp(opt, "filter")) {
    result = parseFilter(&as->filters, param);
  } else {
    dbg_printf(P_ERROR, "Unknown option: %s", opt);
  }

  return result;
}
Beispiel #11
0
void main()
{
    uint8_t guid[16];
    char buf[512];
    int i,j,k;
    int rv;

    printf("GUID test 1\n");
    const char *strGUID0 = "";  
    memset( guid, 0xff, 16 );  
    rv = parseGuid( strGUID0, NULL, guid );
    if ( rv ) printf("GUID="" fail\n");
    for ( i=0; i<16; i++ ) {
        if ( 0 != guid[i] ) {
            printf("GUID="" fail. Index=%d\n", i);
        } 
    }

    printf("GUID test 2\n");
    const char *strGUID1 = "-"; 
    memset( guid, 0xff, 16 );
    rv = parseGuid( strGUID1, NULL, guid );
    if ( rv ) printf("GUID='-' fail\n");
    for ( int i=0; i<16; i++ ) {
        if ( 0 != guid[i] ) {
            printf("GUID='-' fail. Index=%d\n", i);
        } 
    }

    printf("GUID test 3\n");
    const char *strGUID2 = "00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF"; 
    const uint8_t GUID2_array[] = {0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xAA,0xBB,0xCC,0xDD,0xEE,0xFF};
    memset( guid, 0xff, 16 );   
    rv = parseGuid( strGUID2, NULL, guid );
    if ( VSCP_ERROR_SUCCESS != rv ) printf("GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF' parser return fail\n");
    for ( i=0; i<16; i++ ) {
        if ( GUID2_array[i] != guid[i] ) {
            printf("GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF' fail. Index=%d\n", i);
        } 
    }

    printf("GUID test 4\n");
    const char *strGUID3 = "00:11:22:33:44:55:66:77:88:99:AA:BB:CC:"; 
    const uint8_t GUID3_array[] = {0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xAA,0xBB,0xCC,0x00,0x00,0x00};
    memset( guid, 0xff, 16 );   
    rv = parseGuid( strGUID3, NULL, guid );
    if ( VSCP_ERROR_SUCCESS != rv ) printf("GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC:' parser return fail\n");
    for ( i=0; i<16; i++ ) {
        if ( GUID3_array[i] != guid[i] ) {
            printf("GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC:' fail. Index=%d\n", i);
        } 
    }

    printf("GUID test 5\n");
    const char *strGUID4 = "00:11:22:33:44:55:66:77:88:99:AA:BB:CC"; 
    const uint8_t GUID4_array[] = {0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xAA,0xBB,0xCC,0x00,0x00,0x00};
    memset( guid, 0xff, 16 );   
    rv = parseGuid( strGUID4, NULL, guid );
    if ( VSCP_ERROR_SUCCESS != rv ) printf("GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC' parser return fail\n");
    for ( i=0; i<16; i++ ) {
        if ( GUID4_array[i] != guid[i] ) {
            printf("GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC' fail. Index=%d\n", i);
        } 
    }

    printf("GUID test 6\n");
    const char *strGUID5 = "00:11:22:33:44:YW:66:77:88:99:AA:BB:CC:01:02:03"; 
    const uint8_t GUID5_array[] = {0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xAA,0xBB,0xCC,0x01,0x02,0x03};
    memset( guid, 0xff, 16 );   
    rv = parseGuid( strGUID5, NULL, guid );
    if ( VSCP_ERROR_SUCCESS == rv ) printf("GUID='00:11:22:33:44:YW:66:77:88:99:AA:BB:CC:01:02:03' parser return success but should have returned failure.\n");
    
    printf("GUID test 7\n");
    const char *strGUID6 = "00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF,11,22,33,44,55"; 
    const uint8_t GUID6_array[] = {0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xAA,0xBB,0xCC,0xDD,0xEE,0xFF};
    memset( guid, 0xff, 16 );   
    rv = parseGuid( strGUID6, NULL, guid );
    if ( VSCP_ERROR_SUCCESS != rv ) printf("GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF,11,22,33,44,55' parser return fail\n");
    for ( i=0; i<16; i++ ) {
        if ( GUID6_array[i] != guid[i] ) {
            printf("GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF,11,22,33,44,55' fail. Index=%d\n", i);
        } 
    }

    // ------------------------------------------------------------------------

    printf("Filter test 1 (filter)\n");
    vscpEventFilter evfilter;
    memset( &evfilter, 0, sizeof(vscpEventFilter) );
    if ( VSCP_ERROR_SUCCESS  != parseFilter( "2,0x20,6,00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF", 
                                        &evfilter ) ) {
        printf("Failed on filter test 1\n"); 
    }
    if ( evfilter.filter_priority != 2 ) printf("Filter test 1 - filter_priority fail.\n");
    if ( evfilter.filter_class != 32 ) printf("Filter test 1 - filter_class fail.\n");
    if ( evfilter.filter_type != 6 ) printf("Filter test 1 - filter_type fail.\n");
    for ( i=0; i<16; i++ ) {
        if ( GUID2_array[i] != evfilter.filter_GUID[i] ) {
            printf("Filter test 1 GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF' fail. Index=%d\n", i);
        } 
    }

    // ------------------------------------------------------------------------

    printf("Filter test 2 (mask)\n");
    memset( &evfilter, 0, sizeof(vscpEventFilter) );
    if ( VSCP_ERROR_SUCCESS  != parseMask( "0x22,1,077,00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF", 
                                        &evfilter ) ) {
        printf("Failed on filter test 2\n"); 
    }
    if ( evfilter.mask_priority != 34 ) printf("Filter test 2 - mask_priority fail.\n");
    if ( evfilter.mask_class != 1 ) printf("Filter test 2 - mask_class fail.\n");
    if ( evfilter.mask_type != 63 ) printf("Filter test 2 - mask_type fail.\n");
    for ( i=0; i<16; i++ ) {
        if ( GUID2_array[i] != evfilter.mask_GUID[i] ) {
            printf("Filter test 1 GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF' fail. Index=%d\n", i);
        } 
    }

    // ------------------------------------------------------------------------

    printf("Event test 1 (standard)\n");
    vscpEvent ev;
    memset( &ev, 0, sizeof(vscpEvent) );
    if ( VSCP_ERROR_SUCCESS  != parseEvent( "1,0x21,3,1234567,2062-11-17T19:32:44,7654321,00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF,11,0x22,33,0x44,55", &ev ) ) {
        printf("Failed on event test 1\n"); 
    }
    if ( ev.head != 1 ) printf("Event test 1, head failed.\n");
    if ( ev.vscp_class != 0x21 ) printf("Event test 1, vscp_class failed.\n");
    if ( ev.vscp_type != 3 ) printf("Event test 1, vscp_type failed.\n");
    if ( ev.obid != 1234567 ) printf("Event test 1, obid failed.\n");
    if ( ev.year != 2062 ) printf("Event test 1, year failed.\n");
    if ( ev.month != 11 ) printf("Event test 1, month failed.\n");
    if ( ev.day != 17 ) printf("Event test 1, day failed.\n");
    if ( ev.hour != 19 ) printf("Event test 1, hour failed.\n");
    if ( ev.minute != 32 ) printf("Event test 1, minute failed.\n");
    if ( ev.second != 44 ) printf("Event test 1, second failed.\n");
    if ( ev.timestamp != 7654321 ) printf("Event test 1, timestamp failed.\n");
    if ( ev.sizeData != 5 ) printf("Event test 1, sizeData failed (%d).\n", (int)ev.sizeData );
    for ( i=0; i<16; i++ ) {
        if ( GUID2_array[i] != ev.GUID[i] ) {
            printf("Event test 1, GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF' fail. Index=%d\n", i);
        } 
    }
    if ( NULL == ev.pdata ) {
        printf("Event test 1, pdata == NULL, Failure\n");
    }
    else {
        if ( ev.pdata[0] != 11 ) printf("Event test 1, Data byte 0 failed.\n");
        if ( ev.pdata[1] != 0x22 ) printf("Event test 1, Data byte 1 failed.\n");
        if ( ev.pdata[2] != 33 ) printf("Event test 1, Data byte 2 failed.\n");
        if ( ev.pdata[3] != 0x44 ) printf("Event test 1, Data byte 3 failed.\n");
        if ( ev.pdata[4] != 55 ) printf("Event test 1, Data byte 4 failed.\n");
    }


    // ------------------------------------------------------------------------


    printf("Event test 2 (standard)\n");
    memset( &ev, 0, sizeof(vscpEvent) );
    if ( VSCP_ERROR_SUCCESS  != parseEvent( "1,0x21,3,,,,00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF,11,0x22,33,0x44,55", &ev ) ) {
        printf("Failed on event test 2\n"); 
    }
    if ( ev.head != 1 ) printf("Event test 2, head failed.\n");
    if ( ev.vscp_class != 0x21 ) printf("Event test 2, vscp_class failed.\n");
    if ( ev.vscp_type != 3 ) printf("Event test 2, vscp_type failed.\n");
    if ( ev.obid != 0 ) printf("Event test 2, obid failed.\n");
    if ( ev.year != 0 ) printf("Event test 2, year failed.\n");
    if ( ev.month != 0 ) printf("Event test 2, month failed.\n");
    if ( ev.day != 0 ) printf("Event test 2, day failed.\n");
    if ( ev.hour != 0 ) printf("Event test 2, hour failed.\n");
    if ( ev.minute != 0 ) printf("Event test 2, minute failed.\n");
    if ( ev.second != 0 ) printf("Event test 2, second failed.\n");
    if ( ev.timestamp != 0 ) printf("Event test 2, timestamp failed.\n");
    if ( ev.sizeData != 5 ) printf("Event test 2, sizeData failed (%d).\n", (int)ev.sizeData );
    for ( i=0; i<16; i++ ) {
        if ( GUID2_array[i] != ev.GUID[i] ) {
            printf("Event test 2, GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF' fail. Index=%d\n", i);
        } 
    }
    if ( NULL == ev.pdata ) {
        printf("Event test 2, pdata == NULL, Failure\n");
    }
    else {
        if ( ev.pdata[0] != 11 ) printf("Event test 2, Data byte 0 failed.\n");
        if ( ev.pdata[1] != 0x22 ) printf("Event test 2, Data byte 1 failed.\n");
        if ( ev.pdata[2] != 33 ) printf("Event test 2, Data byte 2 failed.\n");
        if ( ev.pdata[3] != 0x44 ) printf("Event test 2, Data byte 3 failed.\n");
        if ( ev.pdata[4] != 55 ) printf("Event test 2, Data byte 4 failed.\n");
    }


    // ------------------------------------------------------------------------


    printf("EventEx test 1 (extended)\n");
    vscpEventEx evex;
    memset( &evex, 0, sizeof(vscpEventEx) );
    if ( VSCP_ERROR_SUCCESS  != parseEventEx( "1,0x21,3,1234567,2062-11-17T19:32:44,7654321,00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF,11,0x22,33,0x44,55", &evex ) ) {
        printf("Failed on eventex test 1\n"); 
    }
    if ( evex.head != 1 ) printf("EventEx test 1, head failed.\n");
    if ( evex.vscp_class != 0x21 ) printf("EventEx test 1, vscp_class failed.\n");
    if ( evex.vscp_type != 3 ) printf("EventEx test 1, vscp_type failed.\n");
    if ( evex.obid != 1234567 ) printf("EventEx test 1, obid failed.\n");
    if ( evex.year != 2062 ) printf("EventEx test 1, year failed.\n");
    if ( evex.month != 11 ) printf("EventEx test 1, month failed.\n");
    if ( evex.day != 17 ) printf("EventEx test 1, day failed.\n");
    if ( evex.hour != 19 ) printf("EventEx test 1, hour failed.\n");
    if ( evex.minute != 32 ) printf("EventEx test 1, minute failed.\n");
    if ( evex.second != 44 ) printf("EventEx test 1, second failed.\n");
    if ( evex.timestamp != 7654321 ) printf("EventEx test 1, timestamp failed.\n");
    if ( evex.sizeData != 5 ) printf("EventEx test 1, sizeData failed (%d).\n", (int)evex.sizeData );
    for ( i=0; i<16; i++ ) {
        if ( GUID2_array[i] != evex.GUID[i] ) {
            printf("EventEx test 1, GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF' fail. Index=%d\n", i);
        } 
    }
    if ( evex.data[0] != 11 ) printf("EventEx test 1, Data byte 0 failed.\n");
    if ( evex.data[1] != 0x22 ) printf("EventEx test 1, Data byte 1 failed.\n");
    if ( evex.data[2] != 33 ) printf("EventEx test 1, Data byte 2 failed.\n");
    if ( evex.data[3] != 0x44 ) printf("EventEx test 1, Data byte 3 failed.\n");
    if ( evex.data[4] != 55 ) printf("EventEx test 1, Data byte 4 failed.\n");


    // ------------------------------------------------------------------------


    printf("Event to string test\n");

    if ( VSCP_ERROR_SUCCESS  != parseEvent( "1,0x21,3,1234567,2062-11-17T19:32:44,7654321,00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF,011,0x22,33,0x44,55", &ev ) ) {
        printf("Event to string test failed creating event\n"); 
    }

    if ( VSCP_ERROR_SUCCESS  != eventToString( &ev, buf, sizeof( buf ) ) ) {
        printf("Failed to convert event to string\n");
    }
    else {
        printf("IN :%s\n", "1,0x21,3,1234567,2062-11-17T19:32:44,7654321,00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF,011,0x22,33,0x44,55" );
        printf("OUT:%s\n", buf );
    }

}