示例#1
0
PRIVATE void
net_ParseHTMLHelpFree(HTMLHelpParseObj * obj)
{
	XP_ASSERT(obj);

	if(!obj)
		return;

	FREEIF(obj->window_name);
	FREEIF(obj->id_value);
	FREEIF(obj->default_id_value);
	FREEIF(obj->url_to_map_file);
	FREEIF(obj->line_buffer);
	FREEIF(obj->id);

	if(obj->frame_group_stack)
	  {
		frame_set_struct * frame_group_ptr;

		while((frame_group_ptr = XP_ListRemoveTopObject(obj->frame_group_stack)) != NULL)
			net_help_free_frame_group_struct(frame_group_ptr);

		FREE(obj->frame_group_stack);
	  }

	FREE(obj);
}
示例#2
0
/* parse lines in an HTML help mapping file.
 * get window_size and name, etc...
 *
 * when the id is found function returns HTML_HELP_ID_FOUND
 * on error function returns negative error code.
 */
PRIVATE int
net_ParseHTMLHelpLine(HTMLHelpParseObj *obj, char *line_data)
{
	char *line = XP_StripLine(line_data);
	char *token;
	char *next_word;

	if(*line == '<')
	  {
		/* find and terminate the end '>' */
		XP_STRTOK(line, ">");

		token = XP_StripLine(line+1);

		if(!strncasecomp(token, 
						 ID_MAP_TOKEN, 
						 sizeof(ID_MAP_TOKEN)-1))
		  {
			obj->in_id_mapping = TRUE;
		  }
		else if(!strncasecomp(token, 
						 END_ID_MAP_TOKEN, 
						 sizeof(END_ID_MAP_TOKEN)-1))
		  {
			obj->in_id_mapping = FALSE;
		  }
		else if(!strncasecomp(token, 
						 FRAME_GROUP_TOKEN, 
						 sizeof(FRAME_GROUP_TOKEN)-1))
		  {
			char *cp = token + sizeof(FRAME_GROUP_TOKEN)-1;
			frame_set_struct * fgs = XP_NEW(frame_set_struct);

			while(isspace(*cp)) cp++;

			if(fgs)
			  {
				XP_MEMSET(fgs, 0, sizeof(frame_set_struct));

				next_word=NULL; /* init */

				do {
					if(!strncasecomp(cp, SRC_TOKEN, sizeof(SRC_TOKEN)-1))
				  	  {
						char *address = net_get_html_help_token(
														cp+sizeof(SRC_TOKEN)-1,
														&next_word);
						cp = next_word;
						fgs->address = XP_STRDUP(address);
				  	  }
					else if(!strncasecomp(cp, 
									  WINDOW_TOKEN, 
									  sizeof(WINDOW_TOKEN)-1))
				      {
					    char *window = net_get_html_help_token(
													cp+sizeof(WINDOW_TOKEN)-1, 
													&next_word);
					    cp = next_word;
					    fgs->target = XP_STRDUP(window);
				      }
					else
					  {
						/* unknown attribute.  Skip to next whitespace
						 */ 
						while(*cp && !isspace(*cp)) 
							cp++;


						if(*cp)
						  {
							while(isspace(*cp)) cp++;
							next_word = cp;
						  }
						else
						  {
							next_word = NULL;
						  }
					  }

				  } while(next_word);
			
				XP_ListAddObject(obj->frame_group_stack, fgs);
			  }
		  }
		else if(!strncasecomp(token, 
						 END_FRAME_GROUP_TOKEN, 
						 sizeof(END_FRAME_GROUP_TOKEN)-1))
		  {
			frame_set_struct *fgs;

			fgs = XP_ListRemoveTopObject(obj->frame_group_stack);

			if(fgs)
				net_help_free_frame_group_struct(fgs);
		  }
	  }
	else if(!obj->in_id_mapping)
	  {
		if(!strncasecomp(line, 
					 	WINDOW_SIZE_TOKEN, 
					 	sizeof(WINDOW_SIZE_TOKEN)-1))
		  {
			/* get window size */
			char *comma=0;
			char *window_size = net_get_html_help_token(line+
												sizeof(WINDOW_SIZE_TOKEN)-1, 
												NULL);

			if(window_size)
				comma = XP_STRCHR(window_size, ',');

			if(comma)
			  {
				*comma =  '\0';
				obj->window_width = XP_ATOI(window_size);
				obj->window_height = XP_ATOI(comma+1);
			  }
		  }
		else if(!strncasecomp(line, 
						 	WINDOW_NAME_TOKEN, 
						 	sizeof(WINDOW_NAME_TOKEN)-1))
		  {
			char *window_name = net_get_html_help_token(line+
												sizeof(WINDOW_NAME_TOKEN)-1,
												NULL);

			if(window_name)
			  {
				FREEIF(obj->window_name);
				obj->window_name = XP_STRDUP(window_name);
			  }
		  }
		else if(!strncasecomp(line, 
					 	HELP_VERSION_TOKEN, 
					 	sizeof(HELP_VERSION_TOKEN)-1))
		  {
			/* get window size */
			char *help_version = net_get_html_help_token(line+
												sizeof(HELP_VERSION_TOKEN)-1, 
												NULL);

			if(help_version)
			  {
				obj->helpVersion = XP_ATOI(help_version);
			  }
		  }
	  }
	else
	  {
		/* id mapping pair */
		if(!strncasecomp(line, obj->id, XP_STRLEN(obj->id)))
		  {
			char *id_value = net_get_html_help_token(line+XP_STRLEN(obj->id),
													 &next_word);

			if(id_value)
			  {
			  	obj->id_value = XP_STRDUP(id_value);

				while(next_word)
				  {
					char *cp = next_word;

                    if(!strncasecomp(cp,
                                     TARGET_TOKEN,
                                      sizeof(TARGET_TOKEN)-1))
                      {
                        char *target = net_get_html_help_token(
                                                    cp+sizeof(TARGET_TOKEN)-1,
                                                    &next_word);
                        cp = next_word;
                        obj->content_target = XP_STRDUP(target);
                      }
					else
					  {
                        /* unknown attribute.  Skip to next whitespace
                         */
                        while(*cp && !isspace(*cp))
                            cp++;

                        if(*cp)
                          {
                            while(isspace(*cp)) cp++;
                            next_word = cp;
                          }
                        else
                          {
                            next_word = NULL;
                          }
					  }
				  }
			  }
		
			return(HTML_HELP_ID_FOUND);
		  }
		if(!strncasecomp(line, DEFAULT_HELP_ID, sizeof(DEFAULT_HELP_ID)-1))
		  {
			char *default_id_value = net_get_html_help_token(
												line+sizeof(DEFAULT_HELP_ID)-1,
												NULL);

            if(default_id_value)
                obj->default_id_value = XP_STRDUP(default_id_value);
		  }
		
	  }

	return(0);
}
示例#3
0
LONG CHiddenFrame::OnFoundDNS(WPARAM wParam, LONG lParam) 
{
	int iError = WSAGETASYNCERROR(lParam);

	//  Go through the DNS cache, find the correct task ID.
	//  The find should always be successful.
    //  Be sure to initalize values.
	POSITION pos = NULL;
	CString key;
	CDNSObj *obj = NULL;
	int i_found = 0;
	LONG return_value = 1;

	for(pos = DNSCacheMap.GetStartPosition(); pos != NULL;) {
		DNSCacheMap.GetNextAssoc(pos, key, (CObject *&)obj);
                
		if(!obj)
			return return_value;
		// Since the handle is not unique for the session only
		// compare handles that are currently in use (i.e. active entries)
		if(!obj->i_finished && obj->m_handle == (HANDLE)wParam) {
	  		i_found = 1;
	  		break;
		}

        //  Clear out object if we didn't break.
        //  That way we don't retain value if we leave the loop.
        obj = NULL;
	}

	if(!obj)
		return return_value;
  
	TRACE("%s error=%d h_name=%d task=%d\n", obj->m_host, iError,
		(obj->m_hostent->h_name != NULL) ? 1 : 0, obj->m_handle);

	//  If by chance we couldn't find it, we have a problem.
	//
	ASSERT(i_found == 1);

	/* temp fix */
	if(!i_found)
		return return_value;

	//  Mark this as completed.
	//
	obj->i_finished = 1;
  
	//  If there was an error, set it.
	if (iError) {
		TRACE("DNS Lookup failed! \n"); 
		obj->m_iError = iError;
		return_value = 0;
	}
  	
	/* call ProcessNet for each socket in the list */
	/* use a for loop so that we don't reference the "obj"
	 * after our last call to processNet.  We need to do
	 * this because the "obj" can get free'd by the call
	 * chain after all the sockets have been removed from
	 * sock_list
	 */
	PRFileDesc *tmp_sock;
	int count = XP_ListCount(obj->m_sock_list);
	for(; count; count--) {

		tmp_sock = (PRFileDesc *) XP_ListRemoveTopObject(obj->m_sock_list);

		//    Make sure we call into the Netlib on this socket in particular,
		//    	NET_SOCKET_FD type.
        OnForceIOSelect((WPARAM)SocketSelect, (LPARAM)tmp_sock);
	}

	return(return_value);
}