示例#1
0
bool CMsnProto::MSN_StoreCreateProfile(bool allowRecurse)
{
    char* reqHdr;
    ezxml_t tbdy;
    ezxml_t xmlp = storeSoapHdr("CreateProfile", "RoamingSeed", tbdy, reqHdr);

    ezxml_t pro = ezxml_add_child(tbdy, "profile", 0);
    ezxml_t node;

    pro = ezxml_add_child(pro, "ExpressionProfile", 0);
    ezxml_add_child(pro, "PersonalStatus", 0);
    node = ezxml_add_child(pro, "RoleDefinitionName", 0);
    ezxml_set_txt(node, "ExpressionProfileDefault");

    char* szData = ezxml_toxml(xmlp, true);

    ezxml_free(xmlp);

    unsigned status = 0;
    char *storeUrl, *tResult = NULL;

    storeUrl = mir_strdup("https://storage.msn.com/storageservice/SchematizedStore.asmx");
    tResult = getSslResult(&storeUrl, szData, reqHdr, status);

    mir_free(reqHdr);
    free(szData);

    if (tResult != NULL)
    {
        if (status == 200)
        {
            ezxml_t xmlm = ezxml_parse_str(tResult, strlen(tResult));
            UpdateStoreCacheKey(xmlm);
            ezxml_t body = getSoapResponse(xmlm, "CreateProfile");

            MSN_StoreShareItem(ezxml_txt(body));
            MSN_SharingMyProfile();

            ezxml_free(xmlm);
        }
        else if (status == 500)
        {
            ezxml_t xmlm = ezxml_parse_str(tResult, strlen(tResult));
            const char* szErr = ezxml_txt(getSoapFault(xmlm, true));
            if (strcmp(szErr, "PassportAuthFail") == 0 && allowRecurse)
            {
                MSN_GetPassportAuth();
                status = MSN_StoreCreateProfile(false) ? 200 : 500;
            }
            ezxml_free(xmlm);
        }
    }

    mir_free(tResult);
    mir_free(storeUrl);

    return status == 200;
}
示例#2
0
externC void
cyg_start( void )
{
  ezxml_t f1, team, driver;
  const char * teamname;
  int i;
  
  CYG_TEST_INIT();
  
  f1 = ezxml_parse_str(document, sizeof(document));

  for (team = ezxml_child(f1, "team"); team; team = team->next) {
    teamname = ezxml_attr(team, "name");
    for (i=0,driver = ezxml_child(team, "driver"); 
         driver; 
         driver = driver->next,i++) {
      if (strcmp(results[i].driver, ezxml_child(driver, "name")->txt) ||
          strcmp(results[i].team, teamname) ||
          strcmp(results[i].points, ezxml_child(driver, "points")->txt))
        CYG_TEST_FAIL("Parser failed first test");
    }
  }
  
  if (strcmp(ezxml_get(f1, "team", 0, "driver", 1, "name", -1)->txt,
              "David Coultard")) 
    CYG_TEST_FAIL_FINISH("Parser failed second test");
  else
    CYG_TEST_PASS_FINISH("Parser passed");
  
  ezxml_free(f1);
}
示例#3
0
void CMsnProto::getMetaData(void)
{
	char* getReqHdr;
	ezxml_t reqbdy;
	ezxml_t xmlreq = oimRecvHdr("GetMetadata", reqbdy, getReqHdr);

	char* szData = ezxml_toxml(xmlreq, true);
	ezxml_free(xmlreq);

	unsigned status;
	char* url = (char*)mir_strdup(oimRecvUrl);

	char* tResult = getSslResult(&url, szData, getReqHdr, status);

	mir_free(url);
	free(szData);
	mir_free(getReqHdr);

	if (tResult != NULL && status == 200) {
		ezxml_t xmlm = ezxml_parse_str(tResult, mir_strlen(tResult));
		ezxml_t xmli = ezxml_get(xmlm, "s:Body", 0, "GetMetadataResponse", 0, "MD", -1);
		if (!xmli)
			xmli = ezxml_get(xmlm, "soap:Body", 0, "GetMetadataResponse", 0, "MD", -1);

		getOIMs(xmli);
		ezxml_free(xmlm);
	}
	mir_free(tResult);
}
示例#4
0
bool CMsnProto::MSN_StoreCreateRelationships(bool allowRecurse)
{
    char* reqHdr;
    ezxml_t tbdy;
    ezxml_t xmlp = storeSoapHdr("CreateRelationships", "RoamingIdentityChanged", tbdy, reqHdr);

    ezxml_t rels = ezxml_add_child(tbdy, "relationships", 0);
    ezxml_t rel = ezxml_add_child(rels, "Relationship", 0);
    ezxml_t node = ezxml_add_child(rel, "SourceID", 0);
    ezxml_set_txt(node, expresid);
    node = ezxml_add_child(rel, "SourceType", 0);
    ezxml_set_txt(node, "SubProfile");
    node = ezxml_add_child(rel, "TargetID", 0);
    ezxml_set_txt(node, photoid);
    node = ezxml_add_child(rel, "TargetType", 0);
    ezxml_set_txt(node, "Photo");
    node = ezxml_add_child(rel, "RelationshipName", 0);
    ezxml_set_txt(node, "ProfilePhoto");

    char* szData = ezxml_toxml(xmlp, true);

    ezxml_free(xmlp);

    unsigned status = 0;
    char *storeUrl = NULL, *tResult = NULL;

    for (int k = 4; --k;)
    {
        mir_free(storeUrl);
        storeUrl = GetStoreHost("CreateRelationships");
        tResult = getSslResult(&storeUrl, szData, reqHdr, status);
        if (tResult == NULL) UpdateStoreHost("CreateRelationships", NULL);
        else break;
    }

    mir_free(reqHdr);
    free(szData);

    if (tResult != NULL)
    {
        UpdateStoreHost("CreateRelationships", storeUrl);

        if (status == 500)
        {
            ezxml_t xmlm = ezxml_parse_str(tResult, strlen(tResult));
            const char* szErr = ezxml_txt(getSoapFault(xmlm, true));
            if (strcmp(szErr, "PassportAuthFail") == 0 && allowRecurse)
            {
                MSN_GetPassportAuth();
                status = MSN_StoreCreateRelationships(false) ? 200 : 500;
            }
            ezxml_free(xmlm);
        }
    }

    mir_free(tResult);
    mir_free(storeUrl);

    return status == 200;
}
示例#5
0
文件: xml.c 项目: poume/spot
bool xml_parse_browse_album(struct album_browse* a, unsigned char* xml, int len)
{
    ezxml_t top = ezxml_parse_str(xml, len);
    parse_browse_album(top, a);
    ezxml_free(top);

    return true;
}
示例#6
0
static int osfy_artistbrowse_browse_callback(struct browse_callback_ctx *brctx) {
	sp_artistbrowse *arb;
	int i;
	struct buf *xml;
	ezxml_t root;

	for(i = 0; i < brctx->num_in_request; i++) {
		arb = brctx->data.artistbrowses[brctx->num_browsed + i];

		/* Set defaults */
		arb->is_loaded = 0;
		arb->error = SP_ERROR_OTHER_TRANSIENT;
	}

	/* Might happen because of a channel error */
	if(brctx->buf == NULL)
		return 0;

	xml = despotify_inflate(brctx->buf->ptr, brctx->buf->len);
#ifdef DEBUG
	{
		FILE *fd;
		DSFYDEBUG("Decompresed %d bytes data, xml=%p\n",
			  brctx->buf->len, xml);
		fd = fopen("browse-artistbrowse.xml", "w");
		if(fd) {
			fwrite(xml->ptr, xml->len, 1, fd);
			fclose(fd);
		}
	}
#endif

	root = ezxml_parse_str((char *) xml->ptr, xml->len);
	if(root == NULL) {
		DSFYDEBUG("Failed to parse XML\n");
		buf_free(xml);
		return -1;
	}

	for(i = 0; i < brctx->num_in_request; i++) {
		arb = brctx->data.artistbrowses[brctx->num_browsed + i];
		osfy_artistbrowse_load_from_xml(brctx->session, arb, root);
		arb->is_loaded = 1;
		arb->error = SP_ERROR_OK;
	}


	ezxml_free(root);
	buf_free(xml);


	/* Release references made in sp_artistbrowse_create() */
	for(i = 0; i < brctx->num_in_request; i++)
		sp_artistbrowse_release(brctx->data.artistbrowses[brctx->num_browsed + i]);


	return 0;
}
示例#7
0
文件: xml.c 项目: FauxFaux/despotify
void xml_parse_prodinfo(struct user_info* u, unsigned char* xml, int len)
{
    ezxml_t top = ezxml_parse_str(xml, len);
    xmlstrncpy(u->type, sizeof u->type, top, "product", 0, "type", -1);
    unsigned int expiry;
    xmlatoi(&expiry, top, "product", 0, "expiry", -1);
    u->expiry = expiry;
    ezxml_free(top);
}
示例#8
0
文件: xml.c 项目: hauk142/despotify
bool xml_parse_browse_album(struct ds_album_browse* a,
                            unsigned char* xml,
                            int len,
                            bool high_bitrate)
{
    ezxml_t top = ezxml_parse_str(xml, len);
    parse_browse_album(top, a, high_bitrate);
    ezxml_free(top);

    return true;
}
示例#9
0
文件: xml2dom.c 项目: Joouis/EVGUI
dom_xml_error dom_xml_parser_parse_chunk(dom_xml_parser *parser, const uint8_t *data, size_t len) {
  assert(parser);
  ezxml_t doc = ezxml_parse_str((char *)data, len);
  if (doc) {
	doc->type = XML_DOCUMENT_NODE;
    parser->doc->node = doc;
    parser->doc->ref = MAGIC_DOCUMENT_NODE;
    return DOM_XML_OK;
  }
  return  DOM_XML_MALFORMED;
}
示例#10
0
文件: xml.c 项目: poume/spot
int xml_parse_tracklist(struct track* firsttrack,
                        unsigned char* xml,
                        int len,
                        bool ordered)
{
    ezxml_t top = ezxml_parse_str(xml, len);

    ezxml_t tracks = ezxml_get(top, "tracks",-1);
    int num_tracks = parse_tracks(tracks, firsttrack, ordered);
    ezxml_free(top);

    return num_tracks;
}
示例#11
0
文件: wlan.c 项目: neufbox/misc
API_REGISTER_METHOD( wlan, getClientList, EWF_HTTP_REQUEST_METHOD_GET, API_ACCESS_POLICY_PRIVATE )
{
        char ipaddr[NBU_NET_SIZEOF_IPADDR];
        int ret;

        int n = 0;

        char *buf_xml = NULL;
        size_t buf_xml_size;
	ezxml_t xmln_root, xmln_mac;

	ret = nbd_wlan_list_assoc(NULL, 
                                  &buf_xml, 
                                  &buf_xml_size);

        if(ret == NBD_SUCCESS)
        {
                xmln_root = ezxml_parse_str(buf_xml, buf_xml_size);
                if(xmln_root != NULL)
                {
                        n = 0;
                        
                        for(xmln_mac = ezxml_get(xmln_root, 
                                                 "assoclist", 
                                                 0, "mac", -1); 
                            xmln_mac; 
                            xmln_mac = xmln_mac->next)
                        {
                                ++n;
                                
                                nbu_string_printf( buffer, sizeof buffer, "wlan.clients.%d.mac_addr", n );
                                api_set_value(buffer, ezxml_txt(xmln_mac));

                                if(nbd_lan_mac2ip(ezxml_txt(xmln_mac), 
                                                  ipaddr, 
                                                  sizeof(ipaddr)) != NBD_SUCCESS)
                                {
                                        ipaddr[0] = '\0';
                                }
                                
                                nbu_string_printf( buffer, sizeof buffer, "wlan.clients.%d.ip_addr", n );
                                api_set_value( buffer, ipaddr );
                        }
                        
                        ezxml_free(xmln_root);
                }
                        
                free(buf_xml);
        }
}
示例#12
0
文件: xml.c 项目: alt-/bada-spotify
int xml_parse_search(struct search_result* search,
                     struct track* firsttrack,
                     unsigned char* xml,
                     int len,
                     bool high_bitrate)
{
    ezxml_t top = ezxml_parse_str(xml, len);

    xmlstrncpy(search->suggestion, sizeof search->suggestion,
               top, "did-you-mean", -1);
    xmlatoi(&search->total_artists, top, "total-artists", -1);
    xmlatoi(&search->total_albums, top, "total-albums", -1);
    xmlatoi(&search->total_tracks, top, "total-tracks", -1);

    ezxml_t artists = ezxml_get(top, "artists",-1);
    struct artist *prev = NULL;
    struct artist *artist = calloc(1, sizeof(struct artist));
    search->artists = artist;
    ezxml_t xa;
    for (xa = ezxml_get(artists, "artist", -1); xa; xa = xa->next) {
        if(prev) {
            artist = calloc(1, sizeof(struct artist));
            prev->next = artist;
        }

        parse_artist(xa, artist);
        prev = artist;
    }

    ezxml_t albums = ezxml_get(top, "albums",-1);
    struct album *aprev = NULL;
    struct album *album = calloc(1, sizeof(struct album));
    search->albums = album;
    for (xa = ezxml_get(albums, "album", -1); xa; xa = xa->next) {
        if(aprev) {
            album = calloc(1, sizeof(struct album));
            aprev->next = album;
        }

        parse_album(xa, album);
        aprev = album;
    }

    ezxml_t tracks = ezxml_get(top, "tracks",-1);
    int num_tracks = parse_tracks(tracks, firsttrack, false, high_bitrate);

    ezxml_free(top);

    return num_tracks;
}
示例#13
0
文件: xml.c 项目: arichnad/pianobar
/*	create xml parser from string
 *	@param xml document
 *	@param returns document pointer (needed to free memory later)
 *	@param returns document root
 *	@return _OK or error
 */
static PianoReturn_t PianoXmlInitDoc (char *xmlStr, ezxml_t *xmlDoc) {
	PianoReturn_t ret;

	if ((*xmlDoc = ezxml_parse_str (xmlStr, strlen (xmlStr))) == NULL) {
		return PIANO_RET_XML_INVALID;
	}

	if ((ret = PianoXmlIsFault (*xmlDoc)) != PIANO_RET_OK) {
		ezxml_free (*xmlDoc);
		return ret;
	}

	return PIANO_RET_OK;
}
示例#14
0
文件: xml.c 项目: FauxFaux/despotify
bool xml_parse_confirm(struct playlist* pl,
                       unsigned char* xml,
                       int len)
{
    ezxml_t top = ezxml_parse_str(xml, len);

    bool confirm = !strncmp(top->name, "confirm", 7);

    if (confirm) {
        xml_parse_version(pl, top, "version", -1);
    }

    ezxml_free(top);
    return confirm;
}
示例#15
0
/*
 * Name: KeActorFactory::CreateActor
 * Desc: 
 */
KeStrongActorPtr KeActorFactory::CreateActor( const char* actor_resource )
{
	/* Parse the XML data */
	ezxml_t xml = ezxml_parse_str( (char*) actor_resource, strlen( actor_resource ) );
	if( !xml )
	{
		return KeStrongActorPtr();
	}

	/* Create a new actor instance */
	KeStrongActorPtr actor( new KeActor( GetNextActorId() ) );
	if( !actor->Init(xml) )
	{
	}
}
示例#16
0
bool LoadOldXMLData(const Category cat, bool update_age) {
	TCHAR xml_data_filename[MAX_PATH];
	TCHAR *ts;
	mir_sntprintf(xml_data_filename, SIZEOF(xml_data_filename), _T("%s\\%s.xml"),
		options.data_folder, (ts = GetTString(category_files[cat])));
	mir_free(ts);

	if(pData[cat]) free(pData[cat]);
	pData[cat] = 0;
	dataLength[cat] = 0;

	// load 
	HANDLE hDataFile = CreateFile(xml_data_filename, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
	if(hDataFile != INVALID_HANDLE_VALUE) {
		dataLength[cat] = GetFileSize(hDataFile, 0);
		if(dataLength[cat]) {
			unsigned long bytes_read;
			pData[cat] = (BYTE *)malloc(dataLength[cat]);
			if(ReadFile(hDataFile, pData[cat], dataLength[cat], &bytes_read, 0))
				dataLength[cat] = bytes_read;
			else {
				free(pData[cat]);
				pData[cat] = 0;
				dataLength[cat] = 0;
			}

		}

		if(update_age) {
			FILETIME ft_now;
			SYSTEMTIME now;
			GetSystemTime(&now);
			SystemTimeToFileTime(&now, &ft_now);
			SetFileTime(hDataFile, 0, 0, &ft_now);
		}

		CloseHandle(hDataFile);
	}
	
	if(pData[cat] && dataLength[cat]) {
		doc[cat] = ezxml_parse_str((char*)pData[cat], dataLength[cat]);
		return doc[cat] != NULL;
	}
	return false;
}
示例#17
0
文件: xml.c 项目: alt-/bada-spotify
bool xml_parse_browse_artist(struct artist_browse* a,
                             unsigned char* xml,
                             int len,
                             bool high_bitrate)
{
    ezxml_t top = ezxml_parse_str(xml, len);

    xmlstrncpy(a->name, sizeof a->name, top, "name", -1);
    xmlstrncpy(a->genres, sizeof a->genres, top, "genres", -1);
    xmlstrncpy(a->years_active, sizeof a->years_active, top, "years-active",-1);
    xmlstrncpy(a->id, sizeof a->id, top, "id", -1);
    xmlstrncpy(a->portrait_id, sizeof a->portrait_id, top,
               "portrait", 0, "id", -1);
    xmlatof(&a->popularity, top, "popularity", -1);

    ezxml_t x = ezxml_get(top, "bios",0,"bio",0,"text",-1);
    if (x) {
        int len = strlen(x->txt);
        a->text = malloc(len + 1);
        memcpy(a->text, x->txt, len+1);
    }

    /* traverse albums */
    x = ezxml_get(top, "albums",-1);
    struct album_browse* prev = NULL;
    struct album_browse* album = calloc(1, sizeof(struct album_browse));
    a->albums = album;
    int album_count = 0;
    ezxml_t xalb;
    for (xalb = ezxml_get(x, "album", -1); xalb; xalb = xalb->next) {
        if (prev) {
            album = calloc(1, sizeof(struct album));
            prev->next = album;
        }

        parse_browse_album(xalb, album, high_bitrate);

        prev = album;
        album_count++;
    }
    a->num_albums = album_count;
    ezxml_free(top);

    return true;
}
示例#18
0
bool CMsnProto::MSN_StoreShareItem(const char* id, bool allowRecurse)
{
    char* reqHdr;
    ezxml_t tbdy;
    ezxml_t xmlp = storeSoapHdr("ShareItem", "RoamingSeed", tbdy, reqHdr);

    ezxml_t node = ezxml_add_child(tbdy, "resourceID", 0);
    ezxml_set_txt(node, id);
    node = ezxml_add_child(tbdy, "displayName", 0);
    ezxml_set_txt(node, "Messenger Roaming Identity");

    char* szData = ezxml_toxml(xmlp, true);

    ezxml_free(xmlp);

    unsigned status = 0;
    char *storeUrl, *tResult = NULL;

    storeUrl = mir_strdup("https://storage.msn.com/storageservice/SchematizedStore.asmx");
    tResult = getSslResult(&storeUrl, szData, reqHdr, status);

    mir_free(reqHdr);
    free(szData);

    if (tResult != NULL && status == 500)
    {
        ezxml_t xmlm = ezxml_parse_str(tResult, strlen(tResult));
        const char* szErr = ezxml_txt(getSoapFault(xmlm, true));
        if (strcmp(szErr, "PassportAuthFail") == 0 && allowRecurse)
        {
            MSN_GetPassportAuth();
            status = MSN_StoreCreateProfile(false) ? 200 : 500;
        }
        ezxml_free(xmlm);
    }

    mir_free(tResult);
    mir_free(storeUrl);

    return status == 200;
}
示例#19
0
char* MSN_GetAvatarHash(char* szContext, char** pszUrl)
{
	if (pszUrl)
		*pszUrl = NULL;

	if (szContext == NULL)
		return NULL;

	char *res  = NULL;

	ezxml_t xmli = ezxml_parse_str(NEWSTR_ALLOCA(szContext), strlen(szContext));
	const char *szAvatarHash = ezxml_attr(xmli, "SHA1D");
	if (szAvatarHash != NULL) {
		unsigned hashLen;
		mir_ptr<BYTE> hash((BYTE*)mir_base64_decode(szAvatarHash, &hashLen));
		if (hash)
			res = arrayToHex(hash, hashLen);

		if (pszUrl) {
			const char *pszUrlAttr;
			for (int i=0; ; i++) {
				char szSetting[20];
				if (i == 0)
					strcpy(szSetting, "Url");
				else
					mir_snprintf(szSetting, sizeof(szSetting), "Url%d", i);
				pszUrlAttr = ezxml_attr(xmli, szSetting);
				if (pszUrlAttr == NULL)
					break;

				if (pszUrlAttr[0] != 0) {
					*pszUrl = mir_strdup(pszUrlAttr);
					break;
				}
			}
		}
	}
	ezxml_free(xmli);

	return res;
}
示例#20
0
void CMsnProto::processMailData(char* mailData)
{
	if (mir_strcmp(mailData, "too-large") == 0) {
		getMetaData();
	}
	else {
		ezxml_t xmli = ezxml_parse_str(mailData, mir_strlen(mailData));

		ezxml_t toke = ezxml_child(xmli, "E");

		const char* szIU = ezxml_txt(ezxml_child(toke, "IU"));
		if (*szIU) mUnreadMessages = atol(szIU);

		const char* szOU = ezxml_txt(ezxml_child(toke, "OU"));
		if (*szOU) mUnreadJunkEmails = atol(szOU);

		getOIMs(xmli);

		ezxml_free(xmli);
	}
}
示例#21
0
文件: cgi_user.c 项目: LinLL/ipc
int CGI_edit_user(HTTPD_SESSION_t* http_session)
{
	int ret = 0;
	AVal av_username = AVC(""), av_password = AVC(""), av_content = AVC("");

	USRM_I_KNOW_U_t* i_m = NULL;
	bool check_in = false;
	bool add_success = false;
	ezxml_t output_xml = NULL;
	const char* xml_text = NULL;

	char query_string[2048] = {""};

	// get current session username / password
	cgi_user_parse_query_string(http_session, query_string, &av_username, &av_password, &av_content);

	// user check in
	i_m = USRM_login(AVAL_STRDUPA(av_username), AVAL_STRDUPA(av_password));
	if(i_m){
		ezxml_t input_xml = NULL;
		ezxml_t add_node = NULL;

		APP_TRACE("Login success! Query string = \"%s\"", query_string);
		
		// check in success
		check_in = true;

		input_xml = ezxml_parse_str(av_content.av_val, av_content.av_len);
		if(input_xml){
			USRM_HOW_ABOUT_t how_about = USRM_GREAT;
			ezxml_t edit_node = ezxml_child(input_xml, "edit_user");
			if(add_node){
				const char* attr_name = ezxml_attr(edit_node, "name");
				const char* attr_admin = ezxml_attr(edit_node, "admin");
				const char* attr_permit_live = ezxml_attr(edit_node, "permit_live");
				const char* attr_permit_setting = ezxml_attr(edit_node, "permit_setting");
				const char* attr_permit_playback = ezxml_attr(edit_node, "permit_playback");

				bool const is_admin = attr_admin ? (STR_CASE_THE_SAME(attr_admin, "yes")) : false;
				uint32_t permit_flag = 0; // clear flag

				if(attr_permit_live ? (STR_CASE_THE_SAME(attr_permit_live, "permit_live")) : false){
					permit_flag |= USRM_PERMIT_LIVE;
				}
				if(attr_permit_setting ? (STR_CASE_THE_SAME(attr_permit_setting, "permit_setting")) : false){
					permit_flag |= USRM_PERMIT_SETTING;
				}
				if(attr_permit_playback ? (STR_CASE_THE_SAME(attr_permit_playback, "permit_playback")) : false){
					permit_flag |= USRM_PERMIT_PLAYBACK;
				}

				how_about = i_m->edit_user(i_m, attr_name, is_admin, permit_flag);
				if(USRM_GREAT == how_about){
					add_success = true;
					APP_TRACE("Edit user \"%s\" success!", attr_name);
					USRM_store();
				}else{
					// FIXME:

					
				}
			}

			ezxml_free(input_xml);
			input_xml = NULL;
		}

		// check out
		USRM_logout(i_m);
		i_m = NULL;
	}

	// make the xml content
	output_xml = ezxml_new_d("user");
	ezxml_set_attr_d(output_xml, "ver", CGI_USER_VERSION);
	ezxml_set_attr_d(output_xml, "you", AVAL_STRDUPA(av_username));
	ezxml_set_attr_d(output_xml, "ret", "success");
	if(!STR_CASE_THE_SAME(ezxml_attr(output_xml, "ret"), "success")){
		ezxml_set_attr_d(output_xml, "mesg", "");
	}
	xml_text = ezxml_toxml(output_xml);
	ezxml_free(output_xml);
	output_xml = NULL;

	// response
	cgi_user_http_response(http_session, xml_text);
	
	free(output_xml);
	output_xml = NULL;
	
	return 0;
}
示例#22
0
bool CMsnProto::MSN_StoreCreateDocument(const TCHAR *sztName, const char *szMimeType, const char *szPicData, bool allowRecurse)
{
    char* reqHdr;
    ezxml_t tbdy;
    char* szName = mir_utf8encodeT(sztName);
    ezxml_t xmlp = storeSoapHdr("CreateDocument", "RoamingIdentityChanged", tbdy, reqHdr);

    ezxml_t hndl = ezxml_add_child(tbdy, "parentHandle", 0);
    ezxml_t node = ezxml_add_child(hndl, "RelationshipName", 0);
    ezxml_set_txt(node, "/UserTiles");

    ezxml_t alias = ezxml_add_child(hndl, "Alias", 0);
    node = ezxml_add_child(alias, "Name", 0);
    ezxml_set_txt(node, mycid);
    node = ezxml_add_child(alias, "NameSpace", 0);
    ezxml_set_txt(node, "MyCidStuff");

    ezxml_t doc = ezxml_add_child(tbdy, "document", 0);
    ezxml_set_attr(doc, "xsi:type", "Photo");
    node = ezxml_add_child(doc, "Name", 0);
    ezxml_set_txt(node, szName);

    doc = ezxml_add_child(doc, "DocumentStreams", 0);
    doc = ezxml_add_child(doc, "DocumentStream", 0);
    ezxml_set_attr(doc, "xsi:type", "PhotoStream");
    node = ezxml_add_child(doc, "DocumentStreamType", 0);

    ezxml_set_txt(node, "UserTileStatic");
    node = ezxml_add_child(doc, "MimeType", 0);
    ezxml_set_txt(node, szMimeType);
    node = ezxml_add_child(doc, "Data", 0);
    ezxml_set_txt(node, szPicData);
    node = ezxml_add_child(doc, "DataSize", 0);
    ezxml_set_txt(node, "0");

    node = ezxml_add_child(tbdy, "relationshipName", 0);
    ezxml_set_txt(node, "Messenger User Tile");

    char* szData = ezxml_toxml(xmlp, true);

    ezxml_free(xmlp);
    mir_free(szName);

    unsigned status = 0;
    char *storeUrl = NULL, *tResult = NULL;

    for (int k = 4; --k;)
    {
        mir_free(storeUrl);
        storeUrl = GetStoreHost("CreateDocument");
        tResult = getSslResult(&storeUrl, szData, reqHdr, status);
        if (tResult == NULL) UpdateStoreHost("CreateDocument", NULL);
        else break;
    }

    mir_free(reqHdr);
    free(szData);

    if (tResult != NULL)
    {
        UpdateStoreHost("CreateDocument", storeUrl);
        if (status == 200)
        {
            ezxml_t xmlm = ezxml_parse_str(tResult, strlen(tResult));
            ezxml_t bdy = getSoapResponse(xmlm, "CreateDocument");
            mir_snprintf(photoid, sizeof(photoid), "%s", ezxml_txt(bdy));
            ezxml_free(xmlm);
        }
        else if (status == 500)
        {
            ezxml_t xmlm = ezxml_parse_str(tResult, strlen(tResult));
            const char* szErr = ezxml_txt(getSoapFault(xmlm, true));
            if (strcmp(szErr, "PassportAuthFail") == 0 && allowRecurse)
            {
                MSN_GetPassportAuth();
                status = MSN_StoreCreateDocument(sztName, szMimeType, szPicData, false) ? 200 : 500;
            }
            ezxml_free(xmlm);
        }
    }

    mir_free(tResult);
    mir_free(storeUrl);

    return status == 200;
}
示例#23
0
bool CMsnProto::MSN_StoreDeleteRelationships(bool tile, bool allowRecurse)
{
    char* reqHdr;
    ezxml_t tbdy;
    ezxml_t xmlp = storeSoapHdr("DeleteRelationships", "RoamingIdentityChanged", tbdy, reqHdr);

    ezxml_t srch = ezxml_add_child(tbdy, "sourceHandle", 0);

    ezxml_t node;
    if (tile)
    {
        node = ezxml_add_child(srch, "RelationshipName", 0);
        ezxml_set_txt(node, "/UserTiles");

        ezxml_t alias = ezxml_add_child(srch, "Alias", 0);
        node = ezxml_add_child(alias, "Name", 0);
        ezxml_set_txt(node, mycid);
        node = ezxml_add_child(alias, "NameSpace", 0);
        ezxml_set_txt(node, "MyCidStuff");
    }
    else
    {
        node = ezxml_add_child(srch, "ResourceID", 0);
        ezxml_set_txt(node, expresid);
    }

    node = ezxml_add_child(tbdy, "targetHandles", 0);
    node = ezxml_add_child(node, "ObjectHandle", 0);
    node = ezxml_add_child(node, "ResourceID", 0);
    ezxml_set_txt(node, photoid);

    char* szData = ezxml_toxml(xmlp, true);

    ezxml_free(xmlp);

    unsigned status = 0;
    char *storeUrl = NULL, *tResult = NULL;

    for (int k = 4; --k;)
    {
        mir_free(storeUrl);
        storeUrl = GetStoreHost("DeleteRelationships");
        tResult = getSslResult(&storeUrl, szData, reqHdr, status);
        if (tResult == NULL) UpdateStoreHost("DeleteRelationships", NULL);
        else break;
    }

    mir_free(reqHdr);
    free(szData);

    if (tResult != NULL)
    {
        UpdateStoreHost("DeleteRelationships", storeUrl);
        if (status == 500)
        {
            ezxml_t xmlm = ezxml_parse_str(tResult, strlen(tResult));
            const char* szErr = ezxml_txt(getSoapFault(xmlm, true));
            if (strcmp(szErr, "PassportAuthFail") == 0 && allowRecurse)
            {
                MSN_GetPassportAuth();
                status = MSN_StoreDeleteRelationships(tile, false) ? 200 : 500;
            }
            ezxml_free(xmlm);
        }
    }

    mir_free(tResult);
    mir_free(storeUrl);

    return status == 200;
}
示例#24
0
bool CMsnProto::MSN_StoreUpdateDocument(const TCHAR *sztName, const char *szMimeType, const char *szPicData, bool allowRecurse)
{
    char* reqHdr;
    char* szName = mir_utf8encodeT(sztName);
    ezxml_t tbdy;
    ezxml_t xmlp = storeSoapHdr("UpdateDocument", "RoamingIdentityChanged", tbdy, reqHdr);

    ezxml_t doc = ezxml_add_child(tbdy, "document", 0);
    ezxml_set_attr(doc, "xsi:type", "Photo");
    ezxml_t node = ezxml_add_child(doc, "ResourceID", 0);
    ezxml_set_txt(node, photoid);
    node = ezxml_add_child(doc, "Name", 0);
    ezxml_set_txt(node, szName);

    doc = ezxml_add_child(doc, "DocumentStreams", 0);
    doc = ezxml_add_child(doc, "DocumentStream", 0);
    ezxml_set_attr(doc, "xsi:type", "PhotoStream");

    node = ezxml_add_child(doc, "MimeType", 0);
    ezxml_set_txt(node, szMimeType);
    node = ezxml_add_child(doc, "Data", 0);
    ezxml_set_txt(node, szPicData);
    node = ezxml_add_child(doc, "DataSize", 0);
    ezxml_set_txt(node, "0");
    node = ezxml_add_child(doc, "DocumentStreamType", 0);
    ezxml_set_txt(node, "UserTileStatic");

    char* szData = ezxml_toxml(xmlp, true);

    ezxml_free(xmlp);
    mir_free(szName);

    unsigned status = 0;
    char *storeUrl = NULL, *tResult = NULL;

    for (int k = 4; --k;)
    {
        mir_free(storeUrl);
        storeUrl = GetStoreHost("UpdateDocument");
        tResult = getSslResult(&storeUrl, szData, reqHdr, status);
        if (tResult == NULL) UpdateStoreHost("UpdateDocument", NULL);
        else break;
    }

    mir_free(reqHdr);
    free(szData);

    if (tResult != NULL)
    {
        UpdateStoreHost("UpdateDocument", storeUrl);
        if (status == 500 && allowRecurse)
        {
            ezxml_t xmlm = ezxml_parse_str(tResult, strlen(tResult));
            const char* szErr = ezxml_txt(getSoapFault(xmlm, true));
            if (strcmp(szErr, "PassportAuthFail") == 0)
            {
                MSN_GetPassportAuth();
                status = MSN_StoreUpdateDocument(sztName, szMimeType, szPicData, false) ? 200 : 500;
            }
            else if (szErr[0])
            {
                MSN_StoreDeleteRelationships(true);
                MSN_StoreDeleteRelationships(false);

                MSN_StoreCreateDocument(sztName, szMimeType, szPicData);
                MSN_StoreCreateRelationships();
            }
            ezxml_free(xmlm);
        }
    }

    mir_free(tResult);
    mir_free(storeUrl);

    return status == 200;
}
示例#25
0
/* ------------------------------------------------------------------------- */
int main(int argc, char* argv[])
{
    int ret;
    ezxml_t xml;
    bool retrieve;
    TMessage message;
    int connection;

    if (argc < 2)
    {
        printf("usage: %s <xml file>\n", argv[0]);
        return -EXIT_FAILURE;
    }

    xml = ezxml_parse_file(argv[1]);
    if (!xml)
    {
        printf("Failed to parse the file '%s'.\n", argv[1]);
        return -EXIT_FAILURE;
    }
    message.m_body = ezxml_toxml(xml, false);
    message.m_len = strlen(message.m_body);
    {
        const char *const name = ezxml_name(xml);
        retrieve = (0 == strcmp("retrieve", name));
    }
    ezxml_free(xml);


    ret = -EXIT_FAILURE;
    do
    {
        if (-1 == (connection = Connect(SERVER_IP, SERVER_PORT)))
            break;

        if (SendMessage(connection, &message))
        {
            printf("Failed to send the message.\n");
            break;
        }

        if (!retrieve)
        {
            ret = -EXIT_SUCCESS;
            break;
        }

        if (ReceiveMessage(connection, &message))
        {
            printf("Failed to receive the reply message.\n");
            break;
        }

        xml = ezxml_parse_str(message.m_body, message.m_len);
        if (xml)
        {
            const char *const str = ezxml_toxml(xml, true);
            if (str)
            {
                puts(str);
                free((char*)str);
            }
            ezxml_free(xml);
        }
        else
        {
            printf("Failed to parse the reply message.\n");
            break;
        }

        ret = -EXIT_SUCCESS;
    } while(0);

    free(message.m_body);
    close(connection);
    return ret;
}
示例#26
0
文件: passwd.c 项目: zh-cool/restful
int post_passwd_server(int client, char *ibuf, int len, char *torken)
{
        if(torken){
                return response_state(client, NO_SERVICE, err_msg[NO_SERVICE]);
        }

        ezxml_t root = NULL, name=NULL, oldpasswd=NULL, passwd=NULL;

        root = ezxml_parse_str(ibuf, len);
        if(!root){
                ezxml_free(root);
                return response_state(client, FORMAT_ERR, err_msg[FORMAT_ERR]);
        }
        if(root && *ezxml_error(root)) {
                ezxml_free(root);
                return response_state(client, FORMAT_ERR, err_msg[FORMAT_ERR]);
        }

        name = ezxml_child(root, "USER_NAME");
        oldpasswd = ezxml_child(root, "OLD_PASSWD");
        passwd = ezxml_child(root, "PASSWD");

        if(!name || !name->txt[0] ||
                        !oldpasswd ||!oldpasswd->txt[0] ||
                        !passwd || !passwd->txt[0]){
                return response_state(client, FORMAT_ERR,
                                "Need name oldpasswd and new passwd"
                                );
        }

        char salt[128] = {0}, *ptr = 0;
        struct spwd *pw = getspnam(name->txt);
        if(!pw){
                return response_state(client, SYS_ERR,
                                "Invalid name");
        }

        ptr = strchr(pw->sp_pwdp+1, '$');
        if(!ptr){
                return response_state(client, SYS_ERR,
                                "Unkonw passwd format");
        }
        ptr = strchr(ptr+1, '$');
        if(!ptr){
                return response_state(client, SYS_ERR,
                                "Unkonw passwd format");
        }
        strncpy(salt, pw->sp_pwdp, ptr-pw->sp_pwdp);

        ptr = crypt(oldpasswd->txt, salt);
        if(strcmp(ptr, pw->sp_pwdp)){
                return response_state(client, SYS_ERR, "Invalid old passwd");
        }

        char cmd[XMLLEN] = {0};
        snprintf(cmd, sizeof(cmd), "echo -e '%s\n%s'|/usr/bin/passwd",
                        passwd->txt, passwd->txt);
        system(cmd);
        return 0;

}
ClParserPtrT clParserParseStr(char *s, size_t len)
{
    return ezxml_parse_str(s, len);
}
示例#28
0
bool CMsnProto::MSN_StoreFindDocuments(bool allowRecurse)
{
    char* reqHdr;
    ezxml_t tbdy;
    ezxml_t xmlp = storeSoapHdr("FindDocuments", "RoamingIdentityChanged", tbdy, reqHdr);

    ezxml_t srch = ezxml_add_child(tbdy, "objectHandle", 0);
    ezxml_t node = ezxml_add_child(srch, "RelationshipName", 0);
    ezxml_set_txt(node, "/UserTiles");

    ezxml_t alias = ezxml_add_child(srch, "Alias", 0);
    node = ezxml_add_child(alias, "Name", 0);
    ezxml_set_txt(node, mycid);
    node = ezxml_add_child(alias, "NameSpace", 0);
    ezxml_set_txt(node, "MyCidStuff");

    ezxml_t doc = ezxml_add_child(tbdy, "documentAttributes", 0);
    node = ezxml_add_child(doc, "ResourceID", 0);
    ezxml_set_txt(node, "true");
    node = ezxml_add_child(doc, "Name", 0);
    ezxml_set_txt(node, "true");

    doc = ezxml_add_child(tbdy, "documentFilter", 0);
    node = ezxml_add_child(doc, "FilterAttributes", 0);
    ezxml_set_txt(node, "None");

    doc = ezxml_add_child(tbdy, "documentSort", 0);
    node = ezxml_add_child(doc, "SortBy", 0);
    ezxml_set_txt(node, "DateModified");

    doc = ezxml_add_child(tbdy, "findContext", 0);
    node = ezxml_add_child(doc, "FindMethod", 0);
    ezxml_set_txt(node, "Default");
    node = ezxml_add_child(doc, "ChunkSize", 0);
    ezxml_set_txt(node, "25");

    char* szData = ezxml_toxml(xmlp, true);

    ezxml_free(xmlp);

    unsigned status = 0;
    char *storeUrl = NULL, *tResult = NULL;

    for (int k = 4; --k;)
    {
        mir_free(storeUrl);
        storeUrl = GetStoreHost("FindDocuments");
        tResult = getSslResult(&storeUrl, szData, reqHdr, status);
        if (tResult == NULL) UpdateStoreHost("FindDocuments", NULL);
        else break;
    }

    mir_free(reqHdr);
    free(szData);

    if (tResult != NULL)
    {
        UpdateStoreHost("FindDocuments", storeUrl);
        if (status == 500)
        {
            ezxml_t xmlm = ezxml_parse_str(tResult, strlen(tResult));
            const char* szErr = ezxml_txt(getSoapFault(xmlm, true));
            if (strcmp(szErr, "PassportAuthFail") == 0 && allowRecurse)
            {
                MSN_GetPassportAuth();
                status = MSN_StoreFindDocuments(false) ? 200 : 500;
            }
            ezxml_free(xmlm);
        }
    }

    mir_free(tResult);
    mir_free(storeUrl);

    return status == 200;
}
示例#29
0
文件: xml.c 项目: FauxFaux/despotify
struct playlist* xml_parse_playlist(struct playlist* pl,
                                    unsigned char* xml,
                                    int len,
                                    bool list_of_lists)
{
    ezxml_t top = ezxml_parse_str(xml, len);
    ezxml_t tmpx = ezxml_get(top, "next-change",0, "change", 0, "ops", 0,
                             "add", 0, "items", -1);
    char* items = NULL;
    if (tmpx)
        items = tmpx->txt;

    while (items && *items && isspace(*items))
        items++;

    if (list_of_lists) {
        /* create list of playlists */
        struct playlist* prev = NULL;
        struct playlist* p = pl;

        for (char* id = strtok(items, ",\n"); id; id = strtok(NULL, ",\n"))
        {
            if (prev) {
                p = calloc(1, sizeof(struct playlist));
                prev->next = p;
            }
            DSFYstrncpy(p->playlist_id, id, sizeof p->playlist_id);
            prev = p;
        }
    }
    else {
        /* create list of tracks */
        struct track* prev = NULL;
        struct track* root = NULL;
        struct track* t = NULL;

        int track_count = 0;
        for (char* id = strtok(items, ",\n"); id; id = strtok(NULL, ",\n"))
        {
            t = calloc(1, sizeof(struct track));
            if (prev)
                prev->next = t;
            else
                root = t;
            DSFYstrncpy(t->track_id, id, sizeof t->track_id);
            prev = t;
            track_count++;
        }
        pl->tracks = root;
        pl->num_tracks = track_count; // FIXME: <version> parsing overwrites track_count
    }

    xmlstrncpy(pl->author, sizeof pl->author, top,
               "next-change",0, "change", 0, "user", -1);
    xmlstrncpy(pl->name, sizeof pl->name, top,
               "next-change",0, "change", 0, "ops",0, "name", -1);
    xml_parse_version(pl, top, "next-change", 0, "version", -1);

    ezxml_free(top);
    return pl;
}
示例#30
0
文件: cgi_user.c 项目: LinLL/ipc
int CGI_user_set_password(HTTPD_SESSION_t* http_session)
{
	int ret = 0;
	AVal av_username = AVC(""), av_password = AVC(""), av_content = AVC("");
	USRM_I_KNOW_U_t* i_m = NULL;
	bool checkin_success = false;
	bool set_success = false;
	ezxml_t output_xml = NULL;
	char* response_xml = NULL;
	
	char query_string[2048] = {""};
	
	// get current session username / password
	cgi_user_parse_query_string(http_session, query_string, &av_username, &av_password, &av_content);

	// user check in
	i_m = USRM_login(AVAL_STRDUPA(av_username), AVAL_STRDUPA(av_password));
	if(i_m){
		ezxml_t input_xml = NULL;
		checkin_success = true;

		APP_TRACE("Login success! Query string = \"%s\"", query_string);

		input_xml = ezxml_parse_str(av_content.av_val, av_content.av_len);
		if(input_xml){
			USRM_HOW_ABOUT_t how_about = USRM_GREAT;
			ezxml_t add_node = ezxml_child(input_xml, "set_pass");
			if(add_node){
				const char* attr_old_pass = ezxml_attr(add_node, "old_pass");
				const char* attr_new_pass = ezxml_attr(add_node, "new_pass");

				how_about = i_m->set_password(i_m, attr_old_pass, attr_new_pass);
				if(USRM_GREAT == how_about){
					set_success = true;
					APP_TRACE("Set user \"%s\" password success!", AVAL_STRDUPA(av_username));
					USRM_store();
				}else{
					// FIXME:
				}
			}

			ezxml_free(input_xml);
			input_xml = NULL;
		}

		// check out
		USRM_logout(i_m);
		i_m = NULL;
	}

	// make the xml content
	output_xml = ezxml_new_d("user");
	ezxml_set_attr_d(output_xml, "ver", CGI_USER_VERSION);
	ezxml_set_attr_d(output_xml, "you", AVAL_STRDUPA(av_username));
	ezxml_set_attr_d(output_xml, "ret", "success");
	if(!STR_CASE_THE_SAME(ezxml_attr(output_xml, "ret"), "success")){
		ezxml_set_attr_d(output_xml, "mesg", "");
	}
	response_xml = ezxml_toxml(output_xml);
	ezxml_free(output_xml);
	output_xml = NULL;

	// response
	cgi_user_http_response(http_session, response_xml);
	
	free(output_xml);
	output_xml = NULL;
	
	return 0;
}