コード例 #1
0
ファイル: Appli_Emit.c プロジェクト: Gis70/APPLI_MCZ
void parseParameters(mxml_node_t *tree, struct s_ParametersOfMCZ *pParam)
{
   char *SubValue, *SubTag = NULL;
   mxml_node_t *node = mxmlFindElement(tree, tree, "ParametersOfMCZ", NULL, NULL, MXML_DESCEND);
   mxml_node_t *fils=node->child;
   int name;

   while(fils != NULL) {
      if ((fils->type != MXML_ELEMENT)
       ||(fils->child == NULL)) {
         fils = fils->next;
         continue;
      }
      SubValue = fils->child->value.opaque;
      SubTag=fils->value.element.name;

      if (strcmp (SubTag, "Id") == 0)
         pParam->Id = strtol(SubValue, NULL, 10);
      else if (strcmp (SubTag, "Modes") == 0)
         pParam->Modes = strtol(SubValue, NULL, 10);
      else if (strcmp (SubTag, "User") == 0)
         pParam->User = strtol(SubValue, NULL, 10);
      else if (strcmp (SubTag, "Puissance") == 0)
         pParam->Puissance = strtol(SubValue, NULL, 10);
      else if (strcmp (SubTag, "Ventilateur1") == 0)
         pParam->Ventilateur1 = strtol(SubValue, NULL, 10);
      else if (strcmp (SubTag, "Ventilateur2") == 0)
         pParam->Ventilateur2 = strtol(SubValue, NULL, 10);
      fils=fils->next;	 
      }
}
コード例 #2
0
ファイル: genixllib-menu.c プロジェクト: broli/genixl
menu_items_t printmenuTableOptions(mxml_node_t *tree)
{
	mxml_node_t *TableOptions=NULL;

	system("clear");
	printf("TableOptions\n-----------\n\n");

	TableOptions = mxmlFindElement(tree, tree, 		/*Search from the top*/
				"TableOptions", NULL, NULL, 	/*The Table element*/
				MXML_DESCEND); 			/*Descending*/

	/*the search might return null*/
	if ( TableOptions != NULL )
	{

		/*Print IgnoreTables*/
		printf("01) IgnoreTables:\t\t%s\n",getElemValue(TableOptions,"IgnoreTables") );

		/*Print AddSeparators*/
		printf("02) AddSeparators:\t\t%s\n",getElemValue(TableOptions,"AddSeparators") );

		/*Print UseMinimumDepth*/
		printf("03) UseMinimumDepth:\t\t%s\n",getElemValue(TableOptions,"UseMinimumDepth") );

		/*Print MinimumDepth*/
		printf("04) MinimumDepth:\t\t%s\n",getElemValue(TableOptions,"MinimumDepth") );

		/*Print UseMaximumBottomReach*/
		printf("05) UseMaximumBottomReach:\t%s\n",getElemValue(TableOptions,"UseMaximumBottomReach") );

		/*Print MaximumBottomReach*/
		printf("06) MaximumBottomReach:\t\t%s\n",getElemValue(TableOptions,"MaximumBottomReach") );

		/*Print UnfoldFullPageTables*/
		printf("07) UnfoldFullPageTables:\t%s\n",getElemValue(TableOptions,"UnfoldFullPageTables") );

		/*Print IgnorePixelWidths*/
		printf("08) IgnorePixelWidths:\t\t%s\n",getElemValue(TableOptions,"IgnorePixelWidths") );


		printf("\n\n");

	}/*end of the TableOptions procesing*/
	else 
	{
		/*No TableOptions node, print empty*/
		printf("01) IgnoreTables: \t\t<n/a>\n"
			"02) AddSeparators: \t\t<n/a>\n"
			"03) UseMinimumDepth: \t\t<n/a>\n"
			"04) MinimumDepth: \t\t<n/a>\n"
			"05) UseMaximumBottomReach: \t<n/a>\n"
			"06) MaximumBottomReach: \t\t<n/a>\n"
			"07) UnfoldFullPageTables: \t<n/a>\n"
			"08) IgnorePixelWidths: \t\t<n/a>\n"
			"\n\n");
	}


	return MENU_TABLE;
}
コード例 #3
0
ファイル: StreamlineSetup.cpp プロジェクト: alexhe/gator
void StreamlineSetup::handleRequest(char* xml) {
	mxml_node_t *tree, *node;
	const char * attr = NULL;

	tree = mxmlLoadString(NULL, xml, MXML_NO_CALLBACK);
	node = mxmlFindElement(tree, tree, TAG_REQUEST, ATTR_TYPE, NULL, MXML_DESCEND_FIRST);
	if (node) {
		attr = mxmlElementGetAttr(node, ATTR_TYPE);
	}
	if (attr && strcmp(attr, VALUE_EVENTS) == 0) {
		sendEvents();
		logg.logMessage("Sent events xml response");
	} else if (attr && strcmp(attr, VALUE_CONFIGURATION) == 0) {
		sendConfiguration();
		logg.logMessage("Sent configuration xml response");
	} else if (attr && strcmp(attr, VALUE_COUNTERS) == 0) {
		sendCounters();
		logg.logMessage("Sent counters xml response");
	} else if (attr && strcmp(attr, VALUE_CAPTURED) == 0) {
		CapturedXML capturedXML;
		char* capturedText = capturedXML.getXML(false);
		sendData(capturedText, strlen(capturedText), RESPONSE_XML);
		free(capturedText);
		logg.logMessage("Sent captured xml response");
	} else if (attr && strcmp(attr, VALUE_DEFAULTS) == 0) {
		sendDefaults();
		logg.logMessage("Sent default configuration xml response");
	} else {
		char error[] = "Unknown request";
		sendData(error, strlen(error), RESPONSE_NAK);
		logg.logMessage("Received unknown request:\n%s", xml);
	}

	mxmlDelete(tree);
}
コード例 #4
0
ファイル: genixllib-menu.c プロジェクト: broli/genixl
menu_items_t printmenuMarginOptions(mxml_node_t *tree)
{
	mxml_node_t *MarginOptions=NULL;

	system("clear");
	printf("MarginOptions\n-----------\n\n");

	MarginOptions = mxmlFindElement(tree, tree, 		/*Search from the top*/
				"MarginOptions", NULL, NULL, 	/*The MarginOptions element*/
				MXML_DESCEND); 			/*Descending*/

	/*the search might return null*/
	if ( MarginOptions != NULL )
	{
	
		/*Print LeftRightMargins*/
		printf("01) LeftRightMargins:\t%s\n",getElemValue(MarginOptions,"LeftRightMargins") );
	
		/*Print LeftRightPadding*/
		printf("02) LeftRightPadding:\t%s\n",getElemValue(MarginOptions,"LeftRightPadding") );

		printf("\n\n");

	}/*end of the MarginOptions procesing*/
	else 
	{
		/*No MarginOptions node, print empty*/
		printf("01) LeftRightMargins: \t<n/a>\n"
			"02) LeftRightPadding:\t<n/a>\n"
			"\n\n");
	}
	
	return MENU_MARGIN;
}
コード例 #5
0
ファイル: twitter.cpp プロジェクト: ifish12/WiiTweet
int parseUsers(std::string &xmlstr, struct t_user ** dest){
	mxml_node_t *xml;
	mxml_node_t *unit;

	struct t_user * users = (struct t_user *)mem2_calloc(MAXUNITS, sizeof(struct t_user), MEM2_OTHER);
	if(!users){
		return 0;
	}
	size_t pos = 0;
	while(1){
		pos = xmlstr.find("&amp;amp;", pos);
		if(pos == std::string::npos) break;
		xmlstr.replace(pos, 9, "&amp;");
	}

	xml = mxmlLoadString(NULL, xmlstr.c_str(), MXML_OPAQUE_CALLBACK);

	if(!xml){
		mem2_free(users, MEM2_OTHER);
		return 0;
	}

	int t=0;
	for(unit = mxmlFindElement(xml, xml, "user", NULL, NULL, MXML_DESCEND); unit; unit = mxmlFindElement(unit, xml, "user", NULL, NULL, MXML_DESCEND)){
		parseUser(unit, &users[t++]);
	}

	mxmlDelete(xml);
	if(t < MAXUNITS){ //Free unused memory
		users = (struct t_user *)mem2_realloc(users, t*sizeof(struct t_user), MEM2_OTHER);
	}

	*dest = users;
return t;
}
コード例 #6
0
ファイル: hpd_xml.c プロジェクト: Tibo-lg/HomePort
/**
 * Adds a specific device to the XML document
 *
 * @param device_to_add The device to add
 *
 * @return returns HPD_E_SUCCESS if successful and HPD_E_DEVICE_ALREADY_IN_XML or HPD_E_XML_ERROR  if failed
 */
  int 
add_device_to_xml(Device *device_to_add)
{

  if(device_is_in_xml_file (device_to_add) == HPD_YES)
    return HPD_E_DEVICE_ALREADY_IN_XML;

  mxml_node_t *devicelist;
  mxml_node_t *new_device;

  devicelist = mxmlFindElement(service_xml_file->xml_tree, service_xml_file->xml_tree, "devicelist", NULL, NULL, MXML_DESCEND);
  if(devicelist == NULL)
  {
    printf("No \"devicelist\" in the XML file\n");
    return HPD_E_XML_ERROR;
  }

  new_device = mxmlNewElement(devicelist, "device");
  if(device_to_add->description != NULL) mxmlElementSetAttr(new_device, "desc", device_to_add->description);
  if(device_to_add->ID != NULL) mxmlElementSetAttr(new_device, "id", device_to_add->ID);
  if(device_to_add->vendorID != NULL) mxmlElementSetAttr(new_device, "vendorid", device_to_add->vendorID);
  if(device_to_add->productID != NULL) mxmlElementSetAttr(new_device, "productid", device_to_add->productID);
  if(device_to_add->version != NULL) mxmlElementSetAttr(new_device, "version", device_to_add->version);
  if(device_to_add->IP != NULL) mxmlElementSetAttr(new_device, "ip", device_to_add->IP);
  if(device_to_add->port != NULL) mxmlElementSetAttr(new_device, "port", device_to_add->port);
  if(device_to_add->location != NULL) mxmlElementSetAttr(new_device, "location", device_to_add->location);
  if(device_to_add->type != NULL) mxmlElementSetAttr(new_device, "type", device_to_add->type);

  save_xml_tree (); 

  return HPD_E_SUCCESS;
}
コード例 #7
0
ファイル: twitter.cpp プロジェクト: ifish12/WiiTweet
int parseSearch(std::string &xmlstr, struct t_tweet ** dest){
	mxml_node_t *xml;
	mxml_node_t *unit;

	struct t_tweet * tweets = (struct t_tweet *)mem2_calloc(MAXUNITS, sizeof(struct t_tweet), MEM2_OTHER);
	if(!tweets){
		return 0;
	}
	size_t pos = 0;
	while(1){
		pos = xmlstr.find("&amp;amp;", pos);
		if(pos == std::string::npos) break;
		xmlstr.replace(pos, 9, "&amp;");
	}

	xml = mxmlLoadString(NULL, xmlstr.c_str(), MXML_OPAQUE_CALLBACK);

	if(!xml){
		mem2_free(tweets, MEM2_OTHER);
		return 0;
	}

	int t=0;
	for(unit = mxmlFindElement(xml, xml, "entry", NULL, NULL, MXML_DESCEND); unit && t < MAXUNITS; unit = mxmlFindElement(unit, xml, "entry", NULL, NULL, MXML_DESCEND)){
		parseSearchEntry(unit, &tweets[t++]);
	}

	mxmlDelete(xml);
	if(t < MAXUNITS){ //Free unused memory
		tweets = (struct t_tweet *)mem2_realloc(tweets, t*sizeof(struct t_tweet), MEM2_OTHER);
	}

	*dest = tweets;
return t;
}
コード例 #8
0
void FSDriver::readEvents(mxml_node_t *const xml) {
	mxml_node_t *node = xml;
	while (true) {
		node = mxmlFindElement(node, xml, "event", NULL, NULL, MXML_DESCEND);
		if (node == NULL) {
			break;
		}
		const char *counter = mxmlElementGetAttr(node, "counter");
		if (counter == NULL) {
			continue;
		}

		if (counter[0] == '/') {
			logg->logError(__FILE__, __LINE__, "Old style filesystem counter (%s) detected, please create a new unique counter value and move the filename into the path attribute, see events-Filesystem.xml for examples", counter);
			handleException();
		}

		if (strncmp(counter, "filesystem_", 11) != 0) {
			continue;
		}

		const char *path = mxmlElementGetAttr(node, "path");
		if (path == NULL) {
			logg->logError(__FILE__, __LINE__, "The filesystem counter %s is missing the required path attribute", counter);
			handleException();
		}
		const char *regex = mxmlElementGetAttr(node, "regex");
		setCounters(new FSCounter(getCounters(), strdup(counter), strdup(path), regex));
	}
}
コード例 #9
0
ファイル: xml_db.c プロジェクト: TihsYloH/smart_server
/*
int xml_addnodes(uint16_t area, uint64_t ext_addr, uint8_t mod)
{
    char buffer[100];
    char ext_buf[10];
    mxml_node_t * node;
    mxml_node_t * xml = xml_root;

    uint64tostr(ext_addr, ext_buf);

    snprintf(buffer, 100, "%s %04d %02d", ext_buf, area, mod);

    XML_LOCK();
    do {
        node = mxmlFindElement(xml, xml, buffer, NULL, NULL, MXML_DESCEND_FIRST);
        if (node == NULL) {
            node = mxmlNewElement(xml, buffer);
            if (node == NULL) {
                log_error(LOG_DEBUG, "add node error");
                ret = -1;
                break;
            }
        }
        ret = 0;
    } while (0);
    XML_UNLOCK();
    return ret;
}

int xml_delnodes(uint64_t ext_addr)
{
    char buffer[100];
    char ext_buf[10];
    mxml_node_t * node;
    mxml_node_t * xml = xml_root;

    uint64tostr(ext_addr, ext_buf);

    snprintf(buffer, 100, "%s %04d %02d", ext_buf, area, mod);

    XML_LOCK();
    do {
        node = mxmlFindElement(xml, xml, buffer, NULL, NULL, MXML_DESCEND_FIRST);
        if (node == NULL) {
            node = mxmlNewElement(xml, buffer);
            if (node == NULL) {
                log_error(LOG_DEBUG, "add node error");
                ret = -1;
                break;
            }
        }
        ret = 0;
    } while (0);
    XML_UNLOCK();
    return ret;
}
*/
int xml_add_area(char * area)
{
    int ret = 0;
    int len;
    mxml_node_t * xml = xml_root;
    mxml_node_t * node;

    len = strlen(area);
    if (len >= AREA_SIZ)
        return -1;

    XML_LOCK();
    do {
        node = mxmlFindElement(xml, xml, area, NULL, NULL, MXML_DESCEND_FIRST);
        if (node == NULL) {
            node = mxmlNewElement(xml, area);
            if (node == NULL) {
                ret = -1;
                break;
            }
            ret = 0;
        }
        ret = 0;
    } while (0);
    XML_UNLOCK();
    return ret;
}
コード例 #10
0
ファイル: genixllib-menu.c プロジェクト: broli/genixl
menu_items_t printmenuColorOptions(mxml_node_t *tree)
{
	mxml_node_t *ColorOptions=NULL;

	system("clear");
	printf("ColorOptions\n-----------\n\n");

	ColorOptions = mxmlFindElement(tree, tree, 		/*Search from the top*/
				"ColorOptions", NULL, NULL, 	/*The ColorOptions element*/
				MXML_DESCEND); 			/*Descending*/

	/*the search might return null*/
	if ( ColorOptions != NULL )
	{
	
		/*Print BackgroundColors*/
		printf("01) BackgroundColors:\t%s\n",getElemValue(ColorOptions,"BackgroundColors") );
	
		/*Print TextColors*/
		printf("02) TextColors:\t\t%s\n",getElemValue(ColorOptions,"TextColors") );

		printf("\n\n");

	}/*end of the ColorOptions procesing*/
	else 
	{
		/*No ColorOptions node, print empty*/
		printf("01) BackgroundColors: \t<n/a>\n"
			"02) TextColors: \t\t<n/a>\n"
			"\n\n");
	}

	return MENU_COLOR;
}
コード例 #11
0
ファイル: backup.c プロジェクト: carrierwrt/easycwmp
int backup_update_all_complete_time_transfer_complete(void)
{
	mxml_node_t  *b, *n = backup_tree;
	while (n = mxmlFindElement(n, backup_tree, "transfer_complete", NULL, NULL, MXML_DESCEND)) {
		b = mxmlFindElement(n, n, "complete_time", NULL, NULL, MXML_DESCEND);
		if (!b) return -1;
		if (b->child && b->child->type == MXML_TEXT) {
			if (strcmp(b->child->value.text.string, UNKNOWN_TIME) != 0) continue;
			mxmlDelete(b->child);
			b = mxmlNewText(b, 0, mix_get_time());
			if (!b) return -1;
		}
	}
	backup_save_file();
	return 0;
}
コード例 #12
0
ファイル: preferences.cpp プロジェクト: RavenDrow/xmplayer
static void loadXMLSetting(float * var, const char * name) {
	item = mxmlFindElement(xml, xml, "setting", "name", name, MXML_DESCEND);
	if (item) {
		const char * tmp = mxmlElementGetAttr(item, "value");
		if (tmp)
			*var = atof(tmp);
	}
}
コード例 #13
0
ファイル: preferences.cpp プロジェクト: RavenDrow/xmplayer
static void loadXMLSetting(char * var, const char * name, int maxsize) {
	item = mxmlFindElement(xml, xml, "setting", "name", name, MXML_DESCEND);
	if (item) {
		const char * tmp = mxmlElementGetAttr(item, "value");
		if (tmp)
			snprintf(var, maxsize, "%s", tmp);
	}
}
コード例 #14
0
ファイル: verify.c プロジェクト: Sixthhokage2/cleanrip
int verify_findMD5Sum(const char * md5orig, int disc_type) {

	print_gecko("Looking for MD5 [%s]\r\n", md5orig);
	char *xmlPointer = (disc_type == IS_NGC_DISC) ? ngcDAT : wiiDAT;
	if(xmlPointer) {
		mxml_node_t *pointer = (disc_type == IS_NGC_DISC)  ? ngcXML : wiiXML;
		
		pointer = mxmlLoadString(NULL, xmlPointer, MXML_TEXT_CALLBACK);
		
		print_gecko("Looking in the %s XML\r\n", pointer == ngcXML ? "GameCube" : "Wii");
		if (pointer) {
			// open the <datafile>
			mxml_node_t *item = mxmlFindElement(pointer, pointer, "datafile", NULL,
					NULL, MXML_DESCEND);
			print_gecko("DataFile Pointer OK\r\n");
			if (item) {
				mxml_index_t *iterator = mxmlIndexNew(item, "game", NULL);
				mxml_node_t *gameElem = NULL;

				//print_gecko("Item Pointer OK\r\n");
				// iterate over all the <game> entries
				while ((gameElem = mxmlIndexEnum(iterator)) != NULL) {
					// get the md5 and compare it
					mxml_node_t *md5Elem = mxmlFindElement(gameElem, gameElem,
							NULL, "md5", NULL, MXML_DESCEND);
					// get the name too
					mxml_node_t *nameElem = mxmlFindElement(gameElem, gameElem,
							NULL, "name", NULL, MXML_DESCEND);

					char md5[64];
					memset(&md5[0], 0, 64);
					strncpy(&md5[0], mxmlElementGetAttr(md5Elem, "md5"), 32);

					//print_gecko("Comparing game [%s] and md5 [%s]\r\n",mxmlElementGetAttr(nameElem, "name"),mxmlElementGetAttr(md5Elem, "md5"));
					if (!strnicmp(&md5[0], md5orig, 32)) {
						snprintf(&gameName[0], 128, "%s", mxmlElementGetAttr(
								nameElem, "name"));
						print_gecko("Found a match!\r\n");
						return 1;
					}
				}
			}
		}
	}
	return 0;
}
コード例 #15
0
int XMLwrapper::enterbranch(const char *name,int id){
    snprintf(tmpstr,TMPSTR_SIZE,"%d",id);
    node=mxmlFindElement(peek(),peek(),name,"id",tmpstr,MXML_DESCEND_FIRST);
    if (node==NULL) return(0);

    push(node);
    return(1);
};
コード例 #16
0
ファイル: hpd_xml.c プロジェクト: Tibo-lg/HomePort
/**
 * Gets the internal node for a given Device
 *
 * @param _device The device concerned
 *
 * @return returns the mxml_node_t corresponding to the Device of NULL if not in the XML file
 */
  mxml_node_t *
get_xml_node_of_device(Device *_device)
{
  mxml_node_t *device;

  for (device = mxmlFindElement(service_xml_file->xml_tree, service_xml_file->xml_tree,"device", NULL, NULL, MXML_DESCEND);
      device != NULL;
      device = mxmlFindElement(device, service_xml_file->xml_tree, "device", NULL, NULL, MXML_DESCEND))
  {
    if(strcmp(mxmlElementGetAttr(device,"type") , _device->type) == 0
	&& strcmp(mxmlElementGetAttr(device,"id") , _device->ID) == 0)
    {
      return device;
    }
  }
  return NULL;
}
コード例 #17
0
ファイル: networkop.cpp プロジェクト: ifish12/WiiTweet
bool UpdateCheck()
{
	bool ret = 0;

	// we only check for an update if we have internet
	if(!networkInit)
		return 0;

	ShowAction("Checking for updates...");
	class twitCurl twitterObj;
	std::string tmp("392315277"); // @WiiTwiity userid
	if( twitterObj.userGet(tmp, 1) ){
		tmp.clear();
		twitterObj.getLastWebResponse(tmp);
	}else{
		CancelAction();
		return 0;
	}
	mxml_node_t *xml;
	mxml_node_t *item;

	xml = mxmlLoadString(NULL, tmp.c_str(), MXML_OPAQUE_CALLBACK);

	if(!xml){
		CancelAction();
		return 0;
	}

	item = mxmlFindElement(xml, xml, "text", NULL, NULL, MXML_DESCEND);
	if(item) // Tweet found!
	{
		const char * tweet = item->child->value.opaque;
		int verMajor, verMinor, verPoint;

		if(sscanf(tweet, "WiiTweet %d.%d.%d released! SHA-1: %s", &verMajor, &verMinor, &verPoint, updateHash) == 4)
		{
			int curMajor = APPVERSION[0] - '0';
			int curMinor = APPVERSION[2] - '0';
			int curPoint = APPVERSION[4] - '0';

			// check that the versioning is valid and is a newer version
			if((verMajor >= 0 && verMajor <= 9 &&
				verMinor >= 0 && verMinor <= 9 &&
				verPoint >= 0 && verPoint <= 9) &&
				(verMajor > curMajor ||
				(verMajor == curMajor && verMinor > curMinor) ||
				(verMajor == curMajor && verMinor == curMinor && verPoint > curPoint)))
			{
				snprintf(updateURL, 128, "http://wiitweet.googlecode.com/files/wiitweet%%20%d.%d.%d.zip", verMajor, verMinor, verPoint);
				ret = 1;
			}
		}
	}

	mxmlDelete(xml);
	CancelAction();
	return ret;
}
コード例 #18
0
ファイル: tehpatcher.c プロジェクト: luza/tehpatcher
BOOL
main_parse_patches_list(CHAR *list)
{
    mxml_node_t *tree, *node;

    if (list == NULL)
        return RES_FAIL;

    tree = mxmlLoadString(NULL, list, MXML_TEXT_CALLBACK);
    if (tree == NULL)
    {
        dialog_set_status("main_parse_patches_list: mxmlLoadString() выполнена с ошибкой");
        return RES_FAIL;
    }

    for (node = mxmlFindElement(tree, tree, "patch", NULL, NULL, MXML_DESCEND);
         node != NULL;
         node = mxmlFindElement(node, tree, "patch", NULL, NULL, MXML_DESCEND))
    {
        CHAR *number, *grf, *action, *patch_file, *target;

        number = (CHAR *)mxmlElementGetAttr(node, "number");
        grf = (CHAR *)mxmlElementGetAttr(node, "grf");
        action = (CHAR *)mxmlElementGetAttr(node, "action");
        target = (CHAR *)mxmlElementGetAttr(node, "target");

        if (number &&
            node->child &&
            node->child->type == MXML_TEXT)
        {
            if (atoi(number) <= options.last_patch)
                continue;

            patch_file = node->child->value.text.string;

            if (main_perform_patch(patch_file, action, grf, target))
                return RES_FAIL;

            options.last_patch = atoi(number);
            options_save_last_patch();
        }
    }

    return RES_OK;
}
コード例 #19
0
ファイル: twitter.cpp プロジェクト: ifish12/WiiTweet
void parseEntities(mxml_node_t *entities, struct t_tweet *dest){
	mxml_node_t *group = NULL;
	mxml_node_t *unit = NULL;
	mxml_node_t *value = NULL;

	dest->hashtags = NULL;
	dest->mentions = NULL;

	group = mxmlFindElement(entities, entities, "user_mentions", NULL, NULL, MXML_DESCEND);
	if(group && group->child){
		for(unit = mxmlFindElement(group, group, "user_mention", NULL, NULL, MXML_DESCEND); unit && unit->child; unit = mxmlFindElement(unit, group, "user_mention", NULL, NULL, MXML_DESCEND)){
			dest->mentions = (struct t_mention *)mem2_realloc(dest->mentions, (++(dest->mentions_count))*sizeof(struct t_mention), MEM2_OTHER);
			value = mxmlFindElement(unit, unit, "screen_name", NULL, NULL, MXML_DESCEND);
			snprintf(dest->mentions[dest->mentions_count - 1].screenname, 20, "@%s", value->child->value.opaque);
			value = mxmlFindElement(unit, unit, "id", NULL, NULL, MXML_DESCEND);
			sscanf(value->child->value.opaque, "%llu", &(dest->mentions[dest->mentions_count - 1].id));
		}
	}

	group = mxmlFindElement(entities, entities, "hashtags", NULL, NULL, MXML_DESCEND);
	if(group && group->child){
		for(unit = mxmlFindElement(group, group, "hashtag", NULL, NULL, MXML_DESCEND); unit && unit->child; unit = mxmlFindElement(unit, group, "hashtag", NULL, NULL, MXML_DESCEND)){
			dest->hashtags = (struct t_hashtag *)mem2_realloc(dest->hashtags, (++(dest->hashtags_count))*sizeof(struct t_hashtag), MEM2_OTHER);
			value = mxmlFindElement(unit, unit, "text", NULL, NULL, MXML_DESCEND);
			snprintf(dest->hashtags[dest->hashtags_count - 1].text, 64, "#%s", value->child->value.opaque);
		}
	}

	mxmlDelete(value);
	mxmlDelete(unit);
	mxmlDelete(group);
}
コード例 #20
0
REALTYPE XMLwrapper::getparreal(const char *name,REALTYPE defaultpar){
    node=mxmlFindElement(peek(),peek(),"par_real","name",name,MXML_DESCEND_FIRST);
    if (node==NULL) return(defaultpar);

    const char *strval=mxmlElementGetAttr(node,"value");
    if (strval==NULL) return(defaultpar);
    
    return(str2real(strval));
};
コード例 #21
0
int XMLwrapper::getparbool(const char *name,int defaultpar){
    node=mxmlFindElement(peek(),peek(),"par_bool","name",name,MXML_DESCEND_FIRST);
    if (node==NULL) return(defaultpar);

    const char *strval=mxmlElementGetAttr(node,"value");
    if (strval==NULL) return(defaultpar);
    
    if ((strval[0]=='Y')||(strval[0]=='y')) return(1);
	else return(0);
};
コード例 #22
0
ファイル: validation.c プロジェクト: sanyaade-iot/ong
int
PLCvalidation_ST(mxml_node_t *pou) {
    mxml_node_t *ST = pou;
    int flg = MXML_DESCEND;
    while ((ST=mxmlFindElement(ST, pou, "ST", NULL, NULL, flg))) {
        if	(PLCvalidation_precompileST (pou, ST) < 0)
            return -1;
    }
    return	0;
}
コード例 #23
0
ファイル: preferences.cpp プロジェクト: askotx/vba-wii
static mxml_node_t *mxmlFindNewElement(mxml_node_t *parent, const char *nodename, const char *attr=NULL, const char *value=NULL)
{
	mxml_node_t *node = mxmlFindElement(parent, xml, nodename, attr, value, MXML_DESCEND);
	if (!node)
	{
		node = mxmlNewElement(parent, nodename);
		if (attr && value) mxmlElementSetAttr(node, attr, value);
	}
	return node;
}
コード例 #24
0
ファイル: preferences.cpp プロジェクト: askotx/vba-wii
static void loadXMLController(unsigned int controller[], const char * name)
{
	item = mxmlFindElement(xml, xml, "controller", "name", name, MXML_DESCEND);

	if(item)
	{
		// populate buttons
		for(int i=0; i < MAXJP; i++)
		{
			elem = mxmlFindElement(item, xml, "button", "number", toStr(i), MXML_DESCEND);
			if(elem)
			{
				const char * tmp = mxmlElementGetAttr(elem, "assignment");
				if(tmp)
					controller[i] = atoi(tmp);
			}
		}
	}
}
コード例 #25
0
ファイル: som.c プロジェクト: verzhak/fmll
fmll_som * fmll_som_load(const char * fname_prefix,
		double (* distance_w)(const double *, const double *, const unsigned), double (* distance)(const double *, const double *, const unsigned))
{
	char node_name[4096];
	int map_dim, dim;
	unsigned u, v, num, * N = NULL;
	double ** w;
	fmll_som * som = NULL;
	mxml_node_t * sub_sub_node, * sub_node, * node, * content_node, * main_node = NULL;

	fmll_try;

		fmll_throw_if(xml_load(fname_prefix, TYPE_SOM, & main_node, & content_node));

		fmll_throw_if(xml_get_int(content_node, "map_dim", & map_dim));
		fmll_throw_if(xml_get_int(content_node, "dim", & dim));

		fmll_throw_null(N = fmll_alloc(sizeof(unsigned), 1, map_dim));
		fmll_throw_null(node = mxmlFindElement(content_node, content_node, "N", NULL, NULL, MXML_DESCEND_FIRST));

		for(u = 0, sub_node = mxmlFindElement(node, node, NULL, NULL, NULL, MXML_DESCEND_FIRST); u < map_dim; u++)
		{
			fmll_throw_null(sub_node);
			N[u] = sub_node->child->value.integer;
			sub_node = mxmlFindElement(sub_node, node, NULL, NULL, NULL, MXML_DESCEND);
		}

		fmll_throw_null(som = fmll_som_init(N, map_dim, dim, distance_w, distance));
		fmll_throw_null(node = mxmlFindElement(content_node, content_node, "W", NULL, NULL, MXML_DESCEND_FIRST));

		w = som->w;
		num = som->num;

		for(u = 0; u < num; u++)
		{
			sprintf(node_name, "w_%u", u);
			fmll_throw_null(sub_node = mxmlFindElement(node, node, node_name, NULL, NULL, MXML_DESCEND_FIRST));

			for(v = 0, sub_sub_node = mxmlFindElement(sub_node, sub_node, NULL, NULL, NULL, MXML_DESCEND_FIRST); v < dim; v++)
			{
				w[u][v] = sub_sub_node->child->value.real;
				sub_sub_node = mxmlFindElement(sub_sub_node, sub_node, NULL, NULL, NULL, MXML_DESCEND);
			}
		}


	fmll_catch;

		fmll_som_destroy(som);
		som = NULL;

	fmll_finally;

		fmll_free(N);
		xml_destroy(main_node);

	return som;
}
コード例 #26
0
ファイル: pca.c プロジェクト: verzhak/fmll
fmll_pca * fmll_pca_load(const char * fname_prefix)
{
	int dim, num;
	char node_name[4096];
	unsigned u, v;
	double ** w;
	fmll_pca * pca = NULL;
	mxml_node_t * sub_sub_node, * sub_node, * node, * content_node, * main_node = NULL;

	fmll_try;

		fmll_throw_if(xml_load(fname_prefix, TYPE_PCA, & main_node, & content_node));

		fmll_throw_if(xml_get_int(content_node, "dim", & dim));
		fmll_throw_if(xml_get_int(content_node, "num", & num));

		fmll_throw_null(pca = fmll_pca_init(dim, num));
		fmll_throw_null(node = mxmlFindElement(content_node, content_node, "W", NULL, NULL, MXML_DESCEND_FIRST));

		for(u = 0, w = pca->w; u < num; u++)
		{
			sprintf(node_name, "w_%u", u);
			fmll_throw_null(sub_node = mxmlFindElement(node, node, node_name, NULL, NULL, MXML_DESCEND_FIRST));

			for(v = 0, sub_sub_node = mxmlFindElement(sub_node, sub_node, NULL, NULL, NULL, MXML_DESCEND_FIRST); v < dim; v++)
			{
				w[u][v] = sub_sub_node->child->value.real;
				sub_sub_node = mxmlFindElement(sub_sub_node, sub_node, NULL, NULL, NULL, MXML_DESCEND);
			}
		}

	fmll_catch;

		fmll_pca_destroy(pca);
		pca = NULL;

	fmll_finally;

		xml_destroy(main_node);

	return pca;
}
コード例 #27
0
void oss_list_objects_content_parse(aos_pool_t *p, mxml_node_t *xml_node, oss_list_object_content_t *content)
{
    char *key;
    char *last_modified;
    char *etag;
    char *size;
    char *node_content;
    mxml_node_t *node;

    node = mxmlFindElement(xml_node, xml_node, "Key", NULL, NULL, MXML_DESCEND);
    if (NULL != node) {
        node_content = node->child->value.opaque;
        key = apr_pstrdup(p, (char *)node_content);
        aos_str_set(&content->key, key);
    }

    node = mxmlFindElement(xml_node, xml_node, "LastModified", NULL, NULL, MXML_DESCEND);
    if (NULL != node) {
        node_content = node->child->value.opaque;
        last_modified = apr_pstrdup(p, (char *)node_content);
        aos_str_set(&content->last_modified, last_modified);
    }

    node = mxmlFindElement(xml_node, xml_node, "ETag", NULL, NULL, MXML_DESCEND);
    if (NULL != node) {
        node_content = node->child->value.opaque;
        etag = apr_pstrdup(p, (char *)node_content);
        aos_str_set(&content->etag, etag);
    }

    node = mxmlFindElement(xml_node, xml_node, "Size", NULL, NULL, MXML_DESCEND);
    if (NULL != node) {
        node_content = node->child->value.opaque;
        size = apr_pstrdup(p, (char *)node_content);
        aos_str_set(&content->size, size);
    }

    node = mxmlFindElement(xml_node, xml_node, "Owner", NULL, NULL, MXML_DESCEND);
    if (NULL != node) {
        oss_list_objects_owner_parse(p, node, content);
    }
}
コード例 #28
0
void XMLwrapper::getparstr(const char *name,char *par,int maxstrlen){
    ZERO(par,maxstrlen);
    node=mxmlFindElement(peek(),peek(),"string","name",name,MXML_DESCEND_FIRST);
    
    if (node==NULL) return;
    if (node->child==NULL) return;
    if (node->child->type!=MXML_OPAQUE) return;
    
    snprintf(par,maxstrlen,"%s",node->child->value.element.name);
    
};
コード例 #29
0
ファイル: XmlNode.cpp プロジェクト: Smallthing/blitzd
	XmlNode * XmlNode::GetChild( const char * n )
	{
		mxml_node_t * root = (mxml_node_t *)_data;
		mxml_node_t * node = mxmlFindElement(root, root, n, NULL, NULL, MXML_DESCEND_FIRST);
		if(node == NULL)
			return NULL;
		XmlNode * r = new XmlNode;
		r->_parent = this;
		r->_data = (void *)node;
		return r;
	}
コード例 #30
0
ファイル: preferences.cpp プロジェクト: RavenDrow/xmplayer
/****************************************************************************
 * decodePrefsData
 *
 * Decodes preferences - parses XML and loads preferences into the variables
 ***************************************************************************/
static bool decodePrefsData() {
	bool result = false;

	xml = mxmlLoadString(NULL, (char*) savebuffer, MXML_TEXT_CALLBACK);

	if (xml) {
		// check settings version
		item = mxmlFindElement(xml, xml, "file", "version", NULL, MXML_DESCEND);
		
		result = true;
		
//		if (item) // a version entry exists
//		{
//			const char * version = mxmlElementGetAttr(item, "version");
//
//			if (version && strlen(version) == 5) {
//				// this code assumes version in format X.X.X
//				// XX.X.X, X.XX.X, or X.X.XX will NOT work
//				int verMajor = version[0] - '0';
//				int verMinor = version[2] - '0';
//				int verPoint = version[4] - '0';
//				int curMajor = APPVERSION[0] - '0';
//				int curMinor = APPVERSION[2] - '0';
//				int curPoint = APPVERSION[4] - '0';
//
//				// first we'll check that the versioning is valid
//				if (!(verMajor >= 0 && verMajor <= 9 &&
//						verMinor >= 0 && verMinor <= 9 &&
//						verPoint >= 0 && verPoint <= 9))
//					result = false;
//				else if (verMajor < 4) // less than version 4.0.0
//					result = false; // reset settings
//				else if (verMajor == 4 && verMinor == 0 && verPoint < 2) // anything less than 4.0.2
//					result = false; // reset settings
//				else if ((verMajor * 100 + verMinor * 10 + verPoint) >
//						(curMajor * 100 + curMinor * 10 + curPoint)) // some future version
//					result = false; // reset settings
//				else
//					result = true;
//			}
//		}

		if (result) {
			// Menu Settings
			loadXMLSetting(&XMPlayerCfg.exit_action, "ExitAction");
			loadXMLSetting(&XMPlayerCfg.language, "language");
			loadXMLSetting(&XMPlayerCfg.sort_order, "sort_order");
		}
		mxmlDelete(xml);
		printf("XMPlayerCfg.language : %d\n",XMPlayerCfg.language);
	}
	printf("[decodePrefsData] xml: %s result: %s\n", (xml)?"true":"false", (result)?"true":"false");
	return result;
}