Exemple #1
0
/** @memo   Allocate memory.

    @doc    Allocates, if possible, a portion of memory of
    'size' bytes.

    @precondition <b>Only use if dynamic memory is required. MUST</b>
    not be called directly. Use the <b>rtp_malloc</b> macro defined
    in rtpmem.h and turn on RTP_TRACK_LOCAL_MEMORY. If the preprocessor
    macros used are unavailable in the target environment, define
    them at the compiler to a chosen dummy value.

    @return Pointer to the location of the allocated spcae,
    0 otherwise. For debugging purposes; if the cause of the
    error is obtainable at the native Memory System layer,
    turn on RTP_DEBUG in rtpmem.c to display the native
    error value.
 */
void * _rtp_debug_malloc (
  unsigned long size,                   /** Number of bytes to allocate. */
  RTP_MALLOC_FN allocFn,                /** Memory allocation function pointer. */
  const char *file,                     /** The preprocessor macro __FILE__. */
  long line_num,                         /** The preprocessor macro __LINE__. */
  const char *comment,
  unsigned long flags
  )
{
	void * ptr;

	if (!size)
	{
		return ((void *)0);
	}

  #if (RTP_MEM_RESTRAIN)
	/* ----------------------------------- */
	/*  when we have more than giMemBase   */
	/*  used, randomly deny malloc         */
	/*  requests for torture purposes      */
	/* ----------------------------------- */
	if ((size + (unsigned long) giMemUsed > giMemLimit) ||
	    ((giMemUsed > (long) giMemBase) && (rtp_rand() % 1000 < gcMallocFailRate)))
	{
		giMemClipped++;
		return ((void *)0);
	}
  #endif

	ptr = allocFn (size +
	               RTP_MEM_BUFFER_GUARD +
	               RTP_MEM_BUFFER_PREPAD +
	               sizeof(RTPMemBlockHeader));

	if (ptr)
	{
		_rtp_AddMemBlock (ptr, size, file, line_num, comment, flags);
		ptr = (void *)(((unsigned char *)ptr) + sizeof(RTPMemBlockHeader));
	}

	if (!ptr)
	{
		return ((void *)0);
	}

  #if (RTP_MEM_BUFFER_PREPAD > 0)
	rtp_memset (ptr, RTP_MEM_PREPAD_BYTE, RTP_MEM_BUFFER_PREPAD);
	ptr = (void *)(((unsigned char *)ptr) + RTP_MEM_BUFFER_PREPAD);
  #endif

  #if (RTP_MEM_BUFFER_GAURD > 0)
	rtp_memset ((void *)(((unsigned char *)ptr) + size), RTP_MEM_GUARD_BYTE, RTP_MEM_BUFFER_GUARD);
  #endif

	return (ptr);
}
int wcWinCreateEx(
	wcCtx *Ctx,
	char *_windowname,
	wcEventCallback BodyCallback,
	char *_defaultUrl,
	char *_defaultContent,
	struct HTMLBrowserWindowConfig *pWindowConfig
  )
{
	HTMLBrowserConfig config, *pconfig;

    rtp_memset(Ctx, 0, sizeof(*Ctx));
	pconfig = (HTMLBrowserConfig *)&config;
    rtp_memset(pconfig, 0, sizeof(*pconfig));
	if (webc_GuiInitConfig(pconfig) < 0)
		return -1;
    pconfig->browserEventHandler = WinCreatecb;
    pconfig->privateData = (void*) BodyCallback;

	pconfig->WindowConfig = *pWindowConfig;
	Ctx->hbrowser = webc_CreateBrowser(pconfig,  WEBC_TRUE, _windowname , "");
	if (!Ctx->hbrowser)
		return -1;
	// Pass the user's callback structure to ourselves through browser private data.
	if (BodyCallback)
	{
		webc_BrowserSetPrivateData((HBROWSER_HANDLE) Ctx->hbrowser, (void*) BodyCallback);
	}

	if (pWindowConfig->WindowFlags & WF_DISABLESCROLLBARS)
		((HTMLBrowser *)Ctx->hbrowser)->SetScrollMode(SCROLL_MODE_NONE);
	else
		((HTMLBrowser *)Ctx->hbrowser)->SetScrollMode(SCROLL_MODE_AUTO);

	Ctx->hdoc = webc_BrowserGetDocument(Ctx->hbrowser);
	if (_defaultUrl)
		webc_BrowserLoadUrl(Ctx->hbrowser, _defaultUrl);
	else if (_defaultContent)
	{
		if (wcDocWriteHtml(Ctx, _defaultContent, rtp_strlen(_defaultContent), (wcBOOL)WEBC_TRUE) < 0)
			return -1;
	}


	if (pWindowConfig->WindowFlags & WF_MODAL)
	{
		// Lock the focus, may be released
		wcClaimBrowserFocus(Ctx->hbrowser);
	}
	return 0;
}
extern "C" void mouseCB(int buttonwithevent, int buttonupdownmask, int x, int y)
{
HTMLEventType mEvent = (HTMLEventType) 0;
int send_to_webc = 0;
void *hWnd=0;

	if ((buttonwithevent&0x1) &&  (buttonupdownmask&0x1))
		mEvent = HTML_EVENT_MOUSEDOWN;
	else if (buttonwithevent&0x1)
		mEvent = HTML_EVENT_MOUSEUP;
	else if (buttonwithevent==0)
		mEvent = HTML_EVENT_MOUSEMOVE;

	if (mEvent)
	{
		hWnd =  MouseEventToWindow(&x, &y);
		if (hWnd)
		{
		HTMLEvent e;
			rtp_memset(&e, 0, sizeof(e));
			e.data.position.x = x;
			e.data.position.y = y;
			e.type = mEvent;
			e.target = (WEBC_UINT8*) hWnd;
			//set modifier flags
			if (giShift)
				e.flags |= HTML_EVENT_FLAG_SHIFT_DOWN;
			if (giCtrl)
				e.flags |= HTML_EVENT_FLAG_CTRL_DOWN;
			if (giAlt)
				e.flags |= HTML_EVENT_FLAG_ALT_DOWN;
			QueCopyEventForWebCFromIsr(&e);				// Queue the event for dispatch when the polling loop runs.
		}
	}
}
static void OpenModalDialog(char *message)
{
	wcCtx newCtxt;
	int v;
	char modalmessage[1024];
	struct HTMLBrowserWindowConfig conf;
	rtp_memset(&conf, 0, sizeof(conf));
	conf.top=200;
	conf.left=100;
	conf.width = 200;
	conf.height= 200;
	conf.BorderThickness = 4;
	conf.BorderColor = 0xff0000;
	conf.SetBodyBackGroundColor    = WEBC_TRUE;
	conf.BackGroundColor =0x0000ff; ;
//#define BS_RAISED 				1  /* These 4 styles are exclusive of each other */
//#define BS_LOWERED				2
//#define BS_RIDGE				4
//#define BS_GROOVE				8
//#define BS_ROUNDED				16 /* This can be applied to the other styles */
	conf.BorderStyle = BS_LOWERED;
//#define WF_RESIZABLE 			1
//#define WF_DISABLESCROLLBARS 	2
//#define WF_MODAL 				4
	conf.WindowFlags = WF_MODAL;
	rtp_sprintf(modalmessage,"<html><body>%s<br><br></body></html>", message);
	v = wcWinCreateEx(&newCtxt, "Testwindow",wcTestBodyCallback,0,modalmessage, &conf);
	wcWinExecute(&newCtxt);
	wcWinClose(&newCtxt);
}
Exemple #5
0
static int http_client_init(HTTPManagedClient* phttpClient)
{
	rtp_memset(phttpClient, 0, sizeof(*phttpClient));

	if (HTTP_ManagedClientInit (
			phttpClient,
			"EBS MANAGED CLIENT" /* User-Agent */,
			0                      /* Accept (mime types) */,
			0                      /* KeepAlive (bool) */,
			0                      /* Cookie context */,
			0                      /* Authentication context */,
			0                      /* SSL context */,
			0                      /* SSL enabled? (bool) */,
			8192                   /* write buffer size */,
			0                      /* max connections (0 == no limit) */,
			0                      /* max connections per host (0 == no limit) */
			) >= 0)
	{
			return (0);
	}
	else
	{
		rtp_printf("HTTP_ManagedClientInit Failed\n");
		return (-1);
	}
}
static void OpenTest10Window(wcCtx *newCtxt, int left, int top,char *message)
{
	int v;
	struct HTMLBrowserWindowConfig conf;
	rtp_memset(&conf, 0, sizeof(conf));
	conf.top=top;
	conf.left=left;
	conf.width = 200;
	conf.height= 200;
	conf.BorderThickness = 4;
	conf.BorderColor = 0xff0000;
	conf.SetBodyBackGroundColor    = WEBC_TRUE;
	conf.BackGroundColor =0x0000ff; ;
//#define BS_RAISED 				1  /* These 4 styles are exclusive of each other */
//#define BS_LOWERED				2
//#define BS_RIDGE				4
//#define BS_GROOVE				8
//#define BS_ROUNDED				16 /* This can be applied to the other styles */
	conf.BorderStyle = BS_LOWERED;
//#define WF_RESIZABLE 			1
//#define WF_DISABLESCROLLBARS 	2
//#define WF_MODAL 				4
//	conf.WindowFlags = WF_MODAL;
	char page[1024];
	rtp_sprintf(page,"<html><body>%s<br>\
	<input type=\"text\" id=\"0\" value=\"0\"><br>\
	<input type=\"text\" id=\"1\" value=\"1\"><br>\
	<input type=\"text\" id=\"2\" value=\"Field 0\">\
	</body></html>", message);
	v = wcWinCreateEx(newCtxt, "Testwindow",0,0,page, &conf);
}
Exemple #7
0
/*================================================================
*   Function: Attr_init
*       Initializes an attribute node
*       External function.
*
*=================================================================*/
void
ixmlAttr_init( IN IXML_Attr * attr )
{
    if( attr != NULL ) {
        rtp_memset( attr, 0, sizeof( IXML_Attr ) );
    }
}
Exemple #8
0
unsigned char *RTSMB_MD4(const unsigned char *d, unsigned long n, unsigned char *md)
	{
	RTSMB_MD4_CTX c;
	static unsigned char m[RTSMB_MD4_DIGEST_LENGTH];

	if (md == (unsigned char *)0) md=m;
	RTSMB_MD4_Init(&c);
#ifndef CHARSET_EBCDIC
	RTSMB_MD4_Update(&c,d,n);
#else
	{
		char temp[1024];
		unsigned long chunk;

		while (n > 0)
		{
			chunk = (n > sizeof(temp)) ? sizeof(temp) : n;
			ebcdic2ascii(temp, d, chunk);
			RTSMB_MD4_Update(&c,temp,chunk);
			n -= chunk;
			d += chunk;
		}
	}
#endif
	RTSMB_MD4_Final(md,&c);
	rtp_memset(&c,0,sizeof(c)); /* security consideration */
	return(md);
	}
Exemple #9
0
/** @memo   Create a list or menu object.

    @doc    Creates a list or menu object and returns a handle that may be passed
    to other functions that add to, access and execute user dialogs.
    storage location.

    @precondition None

    @return A non null void * handle on success. 0 otherwise.
*/
void *rtp_gui_list_init(
void *pguictx,				/** Hook for GUI context (parent window handle). Zero for generic implementation. */
int  style,					/**	<br>
     RTP_LIST_STYLE_MENU     - Format as a menu.<br>
     RTP_LIST_STYLE_HELP	 - Format as a help message<br>
     RTP_LIST_STYLE_LISTBOX  - Format as a list box.<br>
	 RTP_LIST_STYLE_NOFORMAT - Do not format greyed expandable etc.<br>
*/
char *title,				/** Title to display */
char *subtitle,				/** Sub-title to display */
char *prompt				/** Prompt to use when requesting input */
)
{
struct rtp_gui_list *plist;

	plist = (struct rtp_gui_list *) rtp_malloc(sizeof(*plist));
	if (plist)
	{
		rtp_memset(plist, 0, sizeof(*plist));
		plist->pguictx = pguictx;
        plist->style = style;
        plist->title = title;
        plist->subtitle = subtitle;
        plist->prompt = prompt;
	}
	return(void *) plist;
}
/** @memo Destroy an HTTP Managed Server instance.

    @doc  This function must be called to release sockets, semaphores and treads
          owned by this instance of the server. This function does not de-allocate the
		  HTTPServerContext or the server's connectCtxArray, that must be done explicitly.

    @see  HTTP_ServerInit

    @return nothing
 */
void HTTP_ServerDestroy (
		HTTPServerContext* server, /**     Pointer to structure that was initialized by HTTP_ServerInit */
		HTTPServerConnection** connectCtxArray /** The server's contextArray is returned in the variable. Call rtp_free() to release it.*/
	)
{
    rtp_net_closesocket(server->serverSocket);

  #ifdef HTTP_SERVER_MULTITHREAD
    {
        RTP_MUTEX helperThreadMutex;
	    RTP_SEMAPHORE helperThreadSemaphore;
        if (connectCtxArray)
        {
	        *connectCtxArray = server->connectionContextArray;
        }
        rtp_sig_mutex_free(server->lock);

        rtp_helper_thread_ctx_destroy (
		        &server->helperContext,
		        &helperThreadMutex,
		        &helperThreadSemaphore
	        );

        rtp_sig_mutex_free(helperThreadMutex);
        rtp_sig_semaphore_free(helperThreadSemaphore);
    }
  #endif /* HTTP_SERVER_MULTITHREAD */

	rtp_memset((unsigned char *) server, 0, sizeof(HTTPServerContext));
}
Exemple #11
0
/*================================================================
*   ixmlElement_Init
*       Initializes an element node.
*       External function.
*
*=================================================================*/
void
ixmlElement_init( IN IXML_Element * element )
{
    if( element != NULL ) {
        rtp_memset( element, 0, sizeof( IXML_Element ) );
    }
}
Exemple #12
0
/************************************************************************
* Semaphore Debug Utility Function Bodies
************************************************************************/
static unsigned __rtp_InitSemaphoreDebug (void)
{
	if (!rtpSemaphoreDebugInitialized)
	{
		if (_rtp_sig_mutex_alloc(&rtpSemaphoreDebugLock, 0) >= 0)
		{
			int i;
			rtp_memset(gSemaphorePool, 0, sizeof(struct __rtp_semaphore_header) * RTP_SEMAPHORE_NUM_TO_TRACK);
			
			gSemaphorePool[0].prev = 0;
			gSemaphorePool[0].next = &gSemaphorePool[1%RTP_SEMAPHORE_NUM_TO_TRACK];
			for (i = 1; i < RTP_SEMAPHORE_NUM_TO_TRACK; i++)
			{
				gSemaphorePool[i].next = &gSemaphorePool[(i+1)%RTP_SEMAPHORE_NUM_TO_TRACK];
				gSemaphorePool[i].prev = &gSemaphorePool[(i-1)%RTP_SEMAPHORE_NUM_TO_TRACK];
			}
			gSemaphorePool[i-1].next = 0;
			
			gpSemaphoreFreeList = gSemaphorePool;
			rtpSemaphoreDebugInitialized = 1;
		}
	}

	return (rtpSemaphoreDebugInitialized);
}
Exemple #13
0
/*----------------------------------------------------------------------*
                             rtp_file_gfirst
 *----------------------------------------------------------------------*/
int rtp_file_gfirst (void ** dirobj, char * name)
{
VDSTAT* nativeDirObj;

#ifdef RTP_DEBUG
    int result;
    /* ----------------------------------- */
    /*  Clear the error state by setting   */
    /*  to 0.                              */
    /* ----------------------------------- */
    set_errno (0);
#endif

    nativeDirObj = (VDSTAT*) rtp_malloc(sizeof(VDSTAT));
    rtp_memset(nativeDirObj, 0, sizeof(VDSTAT));

	if (!vf_gfirst(nativeDirObj, (PFCHAR) name))
    {
        rtp_free(nativeDirObj);
#ifdef RTP_DEBUG
        result = xn_getlasterror( );
        RTP_DEBUG_OUTPUT_STR("rtp_file_gfirst: error returned ");
        RTP_DEBUG_OUTPUT_INT(result);
        RTP_DEBUG_OUTPUT_STR(".\n");
#endif
        return (-1);
    }

    *dirobj = (void*) nativeDirObj;
    return (0);
}
Exemple #14
0
/*================================================================
*   ixmlNodeList_init
*       initializes a nodelist
*       External function.
*
*=================================================================*/
void
ixmlNodeList_init( IXML_NodeList * nList )
{
    ixml_assert( nList != NULL );

    rtp_memset( nList, 0, sizeof( IXML_NodeList ) );

}
// Schedule sending and HTML_EVENT_TIMER to the body 40 miliseconds from now.
static void CalibrateRearmTimer(HBROWSER_HANDLE hbrowser, HELEMENT_HANDLE helem, char *data)
{
HTMLEvent event;
	rtp_memset(&event, 0, sizeof(event));
	event.type = HTML_EVENT_TIMER;
	event.elem = event.target = event.srcElement = helem;
	webc_BrowserQueueTimedEvent (hbrowser,helem,&event,CALIBRATEUPDATEPERIOD);
}
Exemple #16
0
void * _rtp_debug_calloc  (unsigned long num, unsigned long size, RTP_CALLOC_FN callocMethod, const char* file, long line_num)
{
void * p;
	p = (void *) _rtp_debug_malloc(size*num, _rtp_malloc, file, line_num, "rt__debug_calloc", 0);
	if (p)
		rtp_memset(p, 0, size*num);
    return ((void *)p);
}
extern "C" void keyboardCB(unsigned short keyCode,int isKeyPress)
{

int send_to_webc = 0;
HTMLEvent e;
int mEvent;
int x,y;
void *hWnd=0;
WebKey keyPressed;

	/*
	*  keyValue is the driver value of the key where keyValue must be set to either an ascii value from the keyBoard
	*  i.e. 'a' or 'A' or keyValue is one of the values defined in keyData i.e. WGK_TAB or WGK_SHIFT
	*  The assignment of keyValue must be changed to extract the keypressed from the drivers sent value
	*/
	hWnd = KeyboardEventToWindow();
	keyPressed = pcKbToWebKey(keyCode);
	rtp_memset(&e, 0, sizeof(e));

	e.target = (WEBC_UINT8*) hWnd;
	e.data.key = keyPressed;

	if (isKeyPress)
	{
		e.type = HTML_EVENT_KEYDOWN;
		//set modifier variables
		if(keyPressed == WGK_SHIFT)
			giShift = 1;
		else if(keyPressed == WGK_CTRL)
			giCtrl = 1;
		else if(keyPressed == WGK_CAPS)
			giCaps = ~giCaps;
		else if(keyPressed == WGK_ALT)
			giAlt = 1;
		else if(keyPressed == WGK_ESC)
			giEscapeDown = 1;
		//set modifier flags
		if (giShift)
			e.flags |= HTML_EVENT_FLAG_SHIFT_DOWN;
		if (giCtrl)
			e.flags |= HTML_EVENT_FLAG_CTRL_DOWN;
		if (giAlt)
			e.flags |= HTML_EVENT_FLAG_ALT_DOWN;
	}
	else
	{
		e.type = HTML_EVENT_KEYUP;
		if(keyPressed == WGK_SHIFT)
			giShift = 0;
		else if(keyPressed == WGK_CTRL)
			giCtrl = 0;
		else if(keyPressed == WGK_ALT)
			giAlt = 0;
		else if(keyPressed == WGK_ESC)
			giEscapeDown = 0;
	}
	QueCopyEventForWebCFromIsr(&e);
}
/*---------------------------------------------------------------------------*/
int  _HTTP_ServerInitRequestContext  (HTTPServerContext *server,
                                      HTTPServerRequestContext *ctx)
{
	rtp_memset(ctx, 0, sizeof(HTTPServerRequestContext));

	ctx->server = server;

	return (0);
}
static void RearmTimer(HBROWSER_HANDLE hbrowser, HELEMENT_HANDLE helem, char *data)
{
HTMLEvent event;
	rtp_memset(&event, 0, sizeof(event));
	event.type = HTML_EVENT_TIMER;
//	event.data = data;
	event.elem = event.target = event.srcElement = helem;
	webc_BrowserQueueTimedEvent (hbrowser,helem,&event,DEMOPERIOD);
}
Exemple #20
0
/*----------------------------------------------------------------------*
                         rtp_net_is_connected
 *----------------------------------------------------------------------*/
unsigned rtp_net_is_connected (RTP_SOCKET sockHandle)
{
    struct sockaddr_in peerAddr;
    int peerLen;

    peerLen = sizeof (peerAddr);
    rtp_memset(&peerAddr, 0, peerLen);

    return (getpeername ((int)sockHandle, (PSOCKADDR)&peerAddr, (PFINT)&peerLen) == 0);
}
Exemple #21
0
/*---------------------------------------------------------------------------*/
void rtp_pbuf_ctx_init (RTP_PBUF_CTX* pbufCtx, short alignment, short elementSize)
{
	rtp_memset(pbufCtx, 0, sizeof(RTP_PBUF_CTX));
	pbufCtx->alignment   = alignment;
	pbufCtx->elementSize = elementSize;

	pbufCtx->add	= _rtp_pbuf_ctx_add;
	pbufCtx->destroy= _rtp_pbuf_ctx_destroy;
	pbufCtx->pop	= _rtp_pbuf_ctx_pop;
	pbufCtx->push	= _rtp_pbuf_ctx_push;
}
Exemple #22
0
/** @memo   Checks the memory block list.

    @doc    Checks the memory block list and print the memory debug
    session information to the indicated logFile.

    @precondition <b>Only use if dynamic memory is required. MUST</b>
    not be called directly. Use the <b>rtp_debug_CheckMemBlockList</b>
    macro defined in rtpmem.h and turn on RTP_TRACK_LOCAL_MEMORY.
    The rtpstdio file system support and/or the rtpterm terminal
    layer must be present to make use of this debugging feature.

    @return void
 */
void _rtp_debug_check_mem (const char *logFile, const char* mode)
{
#ifdef RTP_MEM_DEBUG_FILE
#ifdef RTP_MEM_DEBUG_PRINTF
	RTPMemBlockHeader *pBlock = gpMemBlockList;

	if (!pBlock)
	{
		void * fp;
		char buffer[RTP_MEM_REPORT_BUF_SIZE];
		if (rtp_stdio_fopen (&fp, logFile, "a+") == 0)
		{
    		rtp_memset (buffer, 0, sizeof(buffer));
    	    rtp_sprintf (buffer, "\n***** Beginning new memory debug session *****\n\n");
    	    rtp_stdio_fwrite (buffer, sizeof(char *), rtp_strlen(buffer), &fp);
    		rtp_stdio_fclose (fp);
    	}
	}

	while (pBlock)
	{
		if (!__rtp_CheckMemBlock(pBlock))
		{
			void * fp;
			char buffer[RTP_MEM_REPORT_BUF_SIZE];
			if (rtp_stdio_fopen (&fp, logFile, "a+") == 0)
			{
    			rtp_memset (buffer, 0, sizeof(buffer));
    	        rtp_sprintf (buffer, "Memory Corruption Detected at: %08Xl\n", (long)(pBlock + sizeof(RTPMemBlockHeader)));
    	        rtp_stdio_fwrite (buffer, sizeof(char *), rtp_strlen(buffer), &fp);
    			rtp_stdio_fclose (fp);
    		}
			break;
		}

		pBlock = pBlock->prev;
	}
#endif
#endif
}
Exemple #23
0
/*---------------------------------------------------------------------------*/
void rtp_pbuf_ctx_init_ts (RTP_PBUF_CTX* pbufCtx, short alignment, short elementSize, RTP_MUTEX lock)
{
	rtp_memset(pbufCtx, 0, sizeof(RTP_PBUF_CTX));
	pbufCtx->alignment   = alignment;
	pbufCtx->elementSize = elementSize;

	pbufCtx->lock   = lock;
	
	pbufCtx->add	= _rtp_pbuf_ctx_add_ts;
	pbufCtx->destroy= _rtp_pbuf_ctx_destroy_ts;
	pbufCtx->pop	= _rtp_pbuf_ctx_pop_ts;
	pbufCtx->push	= _rtp_pbuf_ctx_push_ts;
}
Exemple #24
0
/** @memo   Add an text entry and a void * value a list or menu object.

    @doc    Adds text and to a list or object. Also provides a void * value to attach to the item that will be returned
    when the item is selected. <br>
    If rtp_gui_list_execute() is called itemvalue will be returned. <br>
    If rtp_gui_list_execute_handle() is called the handle to the item is returned.

    @precondition rtp_gui_list_init must be called first.

    @return A handle to the menu or list entry object.
*/
void *rtp_gui_list_add_item(void *vplist, /** Handle returned from rtp_gui_list_init(). */
char *item, 							  /** Text to display for the choice. */
void *itemvalue,						  /** void *value to return when the item is selected. */
int indentlevel, 						  /** Spaces to indent when text is displayed. */
int isgreyed, 							  /** 1 if the item may not be selected. */
int style								  /** Additional style attributes. <br>
RTP_LIST_ITEM_STYLE_NOBREAK - Display this and the next list item side by side. <br>
RTP_LIST_ITEM_STYLE_SUBMENU - Itemvalue is a menu or list handle returned from rtp_gui_list_init(). <br>
RTP_LIST_ITEM_STYLE_COLLAPSED - Don't display the submenu/sublist.<br>
RTP_LIST_ITEM_STYLE_EXPANDED  - Expand and display the submenu/sublist. <br>
*/
)
{
	struct rtp_gui_list *plist;
	struct rtp_gui_list_item *newitem;

	plist = (struct rtp_gui_list *) vplist;

	newitem = (struct rtp_gui_list_item *) rtp_malloc(sizeof(*newitem));
	if (!newitem)
		return(0);
	rtp_memset(newitem, 0, sizeof(*newitem));
	newitem->item = rtp_strdup(item);
	if (!newitem->item)
	{
		rtp_free(newitem);
		return(0);
	}
	newitem->itemid = itemvalue;
	newitem->indentlevel = indentlevel;
	newitem->isgreyed = isgreyed;
	newitem->style = style;
	{
	struct rtp_gui_list_item *pthis;
		pthis = plist->itemlist;
		if (!pthis)
			plist->itemlist = newitem;
		else
		{
			while (pthis->pnext)
			{
				pthis = pthis->pnext;
			}
			pthis->pnext = newitem;
		}
	}
	plist->itemlistcount += 1;
	return((void *) newitem);
}
Exemple #25
0
/** @memo   Opens a file using the supplied name.

    @doc    Opens a file using the mode settings, and sets the 
    file information.

    @return 0 if successful, -1 on failure, and -2 if a non-fatal 
    error occurred.
 */
int rtp_stdio_fopen (
  void ** rtpfile,                      /** A pointer to the address of an RTP_FILE to store the file information. */
  const char * fname,                   /** The name of the file to open. */
  const char * mode                     /** For the mode argument:<br>
	<pre>
|		"r"     Open a file for reading only                RTP_FILE_O_RDONLY
|		"r+"    Open a file for reading and writing         RTP_FILE_O_RDWR
|		"w"     Open a file for writing only                RTP_FILE_O_WRONLY
|		        Create a file if it does not exist          RTP_FILE_O_CREAT
|		        Truncate a file to 0 bytes after opening    RTP_FILE_O_TRUNC
|		"w+"    Open a file for reading and writing         RTP_FILE_O_RDWR
|		        Create a file if it does not exist          RTP_FILE_O_CREAT
|		        Truncate a file to 0 bytes after opening    RTP_FILE_O_TRUNC
|		"a"     All writes will be appended to the file     RTP_FILE_O_APPEND
|		        Create a file if it does not exist          RTP_FILE_O_CREAT
|		"a+"    Open a file for reading and writing         RTP_FILE_O_RDWR
|		        All writes will be appended to the file     RTP_FILE_O_APPEND
|		        Create a file if it does not exist          RTP_FILE_O_CREAT
|		"b..."  b prepended to the mode in the open call    
|		        causes the file to be opened in binary mode RTP_FILE_O_BINARY
|		"t..."  t prepended to the mode in the open call    
|		        causes the file to be opened in text mode   RTP_FILE_O_TEXT
|		Note:   If neither the b or t are prepended, text   
|		        mode is the default implementation.         
	</pre> */
  )
{
RTP_STDIO_FILE * p;
int result;

    result = (-1);
    p = (RTP_STDIO_FILE *) rtp_malloc ((unsigned int) sizeof (*p), 0);  /* SPRZ */
    if (p)
    {
        rtp_memset(p, 0, sizeof(*p));
        p->verify = RTP_FILE_VERIFICATION_VALUE;
     
        if ((result = rtp_file_open (&(p->handle), fname, _rtp_mode_to_permission(mode), RTP_FILE_S_IWRITE | RTP_FILE_S_IREAD)) != 0)
        {
            /* --------------------------------------- */
            /*       ERROR: drop the handle block.     */
            /* --------------------------------------- */
            rtp_free ((void *)p);
        }
    }
    *rtpfile = (void *)p;
    return (result);
}
Exemple #26
0
int http_server_demo(void)
{
	HTTP_INT16 ipType = 4;
	rtp_net_init();
	rtp_threads_init();


	rtp_memset(&ExampleServerCtx, 0, sizeof(ExampleServerCtx));
	rtp_strcpy(ExampleServerCtx.rootDirectory, DEMO_WWW_ROOT);
	ExampleServerCtx.chunkedEncoding 		= 0;
	ExampleServerCtx.numHelperThreads 		= DEMO_MAX_HELPERS;
	ExampleServerCtx.numConnections		 	= DEMO_MAX_CONNECTIONS;
	rtp_strcpy(ExampleServerCtx.defaultFile,"index.htm");
	ExampleServerCtx.defaultIpAddr[0] = DEFAULT_DEMO_IPADDRESS[0];
	ExampleServerCtx.defaultIpAddr[1] = DEFAULT_DEMO_IPADDRESS[1];
	ExampleServerCtx.defaultIpAddr[2] = DEFAULT_DEMO_IPADDRESS[2];
	ExampleServerCtx.defaultIpAddr[3] = DEFAULT_DEMO_IPADDRESS[3];
	rtp_sprintf(ExampleServerCtx.defaultIpAddrstr, "%d.%d.%d.%d",
	ExampleServerCtx.defaultIpAddr[0],	ExampleServerCtx.defaultIpAddr[1],
	ExampleServerCtx.defaultIpAddr[2],	ExampleServerCtx.defaultIpAddr[3]);


	/* Initialize the server */
	if (http_server_demo_restart() != 0)
		return(-1);


	for (;;)
	{
		HTTP_ServerProcessOneRequest (&ExampleServerCtx.httpServer, 1000*60);
		if (ExampleServerCtx.timeToReload)
		{
			ExampleServerCtx.timeToReload = 0;
			HTTP_ServerDestroy(&ExampleServerCtx.httpServer, &ExampleServerCtx.connectCtxArray);
			rtp_free(ExampleServerCtx.connectCtxArray);
			/* Initialize the server */
			if (http_server_demo_restart() != 0)
				return(-1);
		}
	}


	rtp_net_exit();
	return (0);

}
static void CycleTest10(void)
{
	HTMLEvent Event;

	if (Test10Focus == 0)
	{
		printf("Set Test10WindowZero, element 0 \n");
		wcWinSetFocus(&Test10WindowZero, Test10Elements[0][0]);
	}
	else if (Test10Focus == 1)
	{
		printf("Set Test10WindowZero, element 1 \n");
		wcWinSetFocus(&Test10WindowZero, Test10Elements[0][1]);
	}
	else if (Test10Focus == 2)
	{
		printf("Set Test10WindowOne, element 0 \n");
		wcWinSetFocus(&Test10WindowOne,  Test10Elements[1][0]);
	}
	else if (Test10Focus == 3)
	{
		printf("Set Test10WindowOne element 1 \n");
		wcWinSetFocus(&Test10WindowOne,  Test10Elements[1][1]);
	}
	Test10Focus += 1;
	Test10CycleCount++;

	if (Test10Focus > 3)
	{
		if (Test10CycleCount < FOCUSTESTCOUNT)
			Test10Focus = 0;
	}
	if (Test10Focus > 3)
		CycleTest10WindowMove();
	rtp_memset(&Event, 0 ,sizeof(Event));
	Event.type = HTML_EVENT_TIMER;

	if (Test10CycleCount < FOCUSTESTCOUNT)
		wcTriggerEvent(Test10Elements[0][0], &Event, 500);
	else if (Test10CycleCount < 300)
		wcTriggerEvent(Test10Elements[0][0], &Event, 500);
	else
		StartFlyingWindowDemo(0,10,WF_SPRITE);
}
Exemple #28
0
	/*
    @return error code
 */
SOAP_INT32 SOAP_ReadActionResponse (
		SOAPAction* action
	)
{
	HTTPResponseInfo   info;
	SOAPActionResponse response;

	rtp_memset(&response, 0, sizeof(response));

	HTTP_ManagedClientReadResponseInfo(action->httpSession, &info);
	/* If the response to a post request is 'Method Not Allowed' then, resend
       as a M-Post request */
    /* Close http session for Post and open new http session for MPost */
	if(info.status == 405 && action->state == SOAP_ACTION_READING_POST_RESPONSE)
	{
		action->state = SOAP_ACTION_CONNECTING_M_POST;
		HTTP_ManagedClientCloseSession(action->httpSession);
		/* open new http session for M-Post */
		if(SOAP_CreateHttpSession(action) < 0)
		{
			action->state = SOAP_ACTION_ERROR;
			return(-1);
		}
		return(0); /* failure is when mpost fails */
	}

	action->state = _SOAP_ParseActionRespose(
		&info, action->httpSession, &response);

    /* invoke the callback to process the response */
	if (action->callbackFn && action->state == SOAP_ACTION_RESPONSE_READ)
	{
		if(action->callbackFn(action->callbackData,	&response) >= 0)
		{
			if (response.envelope.doc)
            	rtpxmlDocument_free (response.envelope.doc);
            return(0);
		}
	}
	action->state = SOAP_ACTION_ERROR;
	return(-1);
}
Exemple #29
0
/*---------------------------------------------------------------------------*/
int HTTP_ClientSessionInitEx (
		HTTPClientContext* clientContext,
		HTTPClientSession* clientSession,
		HTTPStreamReadFn readFn,
		HTTPStreamWriteFn writeFn
	)
{
	rtp_memset(clientSession, 0, sizeof(HTTPClientSession));

	if (HTTP_InitSession(&clientSession->session,
	                     readFn,
	                     writeFn,
	                     clientSession) >= 0)
	{
		clientSession->clientContext = clientContext;
		return (0);
	}

	return (-1);
}
static void StartFlyingWindowDemo( int top, int left,WEBC_UINT32 WindowFlags)
{
	wcCtx newCtxt;
	struct HTMLBrowserWindowConfig conf;
	rtp_memset(&conf, 0, sizeof(conf));
	conf.top=top;
	conf.left=left;
	conf.width = 50;
	conf.height= 60;
	conf.BorderThickness = 4;
	conf.BorderColor = 0xff0000;
	conf.SetBodyBackGroundColor    = WEBC_TRUE;
	conf.BackGroundColor =0x0000ff; ;
	conf.BorderStyle = BS_LOWERED;
	conf.WindowFlags = WindowFlags;
	// v =
	wcWinCreateEx(&newCtxt, "Testwindow",FlyingWindowBodyCallback,0,
	"<html><body><div><center>I<br>can<br>fly!!<br></center></div></body></html>",
	&conf);
}