Exemple #1
0
static int http_demo_generate_configform(char **pContent)
{
	int line = 0;
	char temp_buff[512];
	pContent[line++] =	http_demo_alloc_string("<html><body><hr><center><b><big>Server Configuration form.</big></b></center><hr><br><br>");
	pContent[line++] =	http_demo_alloc_string("<form name=\"configure\" action=\"demo_configure\" method=\"get\">");

	rtp_sprintf(temp_buff,"Content Directory :<input type=\"text\" name=\"root\" value=%s/>", ExampleServerCtx.rootDirectory);
	pContent[line++] =	http_demo_alloc_string(temp_buff);
//	HTTP_UINT8         defaultFile[256];
//  	HTTP_BOOL          disableVirtualIndex;
//  	HTTP_BOOL          chunkedEncoding;
//	HTTP_INT16         numHelperThreads;
//	HTTP_INT16         numConnections;
//	HTTP_UINT8         defaultIpAddr[4];
//	HTTP_CHAR          defaultIpAddrstr[256];
//	HTTPServerConnection* connectCtxArray;
//	HTTPServerContext  httpServer;
//  	HTTP_BOOL          timeToReload;

	/* Create a form initialized from our current configuration */
	pContent[line++] =	http_demo_alloc_string("<form>"	);
	pContent[line++] =	http_demo_alloc_string("</form>"	);
	pContent[line++] =	http_demo_alloc_string("</body></html>"	);
	pContent[line++] =	0;

//  HEREHERE
//
//	if (HTTP_ServerAddPostHandler(phttpServer, "\\demo_form_submit", demo_form_cb, (void *)"demo_form_submit") < 0)
//		return -1;

	return(0);
}
/*----------------------------------------------------------------------*
                             rtp_term_aux_putc
 *----------------------------------------------------------------------*/
void rtp_term_aux_putc (char ch)
{
    HANDLE hComm;
    OVERLAPPED osWrite = {0};
    unsigned long bytesWritten;
    unsigned long error;

    hComm = (HANDLE) auxComm;

    // Create this write operation's OVERLAPPED structure's hEvent.
    osWrite.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
    if (osWrite.hEvent == NULL)
    {
        rtp_term_puts("rtp_term_aux_putc: error creating overlapped event handle\n");
        return;
    }
    if (WriteFile( hComm, &ch, 1, &bytesWritten, &osWrite) == 0)
    {
        if ((error = GetLastError()) != ERROR_IO_PENDING) 
        { 
            char test[100];
            rtp_sprintf(test, "rtp_term_aux_putc: Error in Write! %d\n", error);
            rtp_term_puts(test);    
            // WriteFile failed, but it isn't delayed. Report error and abort.
        }
        else 
        {
            // Write is pending.
            GetOverlappedResult(hComm, &osWrite, &bytesWritten, TRUE);
        }
    }
    CloseHandle(osWrite.hEvent);
}
static int FormatSlidingWindowTextList(HBROWSER_HANDLE hbrowser, HDOC_HANDLE hdoc, HELEMENT_HANDLE ContainingDiv,char **pSelections, int nSelections)
{
	for (int i = 0; i < nSelections; i++,pSelections++)
	{
	char html_buff[512];
	HELEMENT_HANDLE SelectionDiv, Br;
		for (int i = 0; i < 4; i++)
		{
			Br = webc_CreateElementFromHtml(hbrowser, hdoc, "&nbsp;");if (!Br)	goto error;
			if (webc_ElementInsertLast(ContainingDiv,Br) != 0)goto error;
		}
		rtp_sprintf(html_buff, "<a href=\"anything\" id=\"%s\">%s</a>",*pSelections,*pSelections);
		SelectionDiv = webc_CreateElementFromHtml(hbrowser, hdoc, html_buff);
		if (!SelectionDiv)
			goto error;
		/* Assign a handler here */
		webc_ElementSetTagEventHandler(SelectionDiv, TextListEventHandler);
		/* Insert into the Containing Div */
		if (webc_ElementInsertLast(ContainingDiv,SelectionDiv) != 0)
				goto error;
		Br = webc_CreateElementFromHtml(hbrowser, hdoc, "<br>");
		if (!Br)
			goto error;
		if (webc_ElementInsertLast(ContainingDiv,Br) != 0)
				goto error;
	}
	return 0;
error:
	assert (0);
	return -1;
}
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);
}
void rtp_log_write(char *prompt, void *pData, long nBytes)
{
    if (debugfd_valid)
    {
        unsigned long elapsed;
        char outbuff[256];
        elapsed = rtp_get_system_msec () - start_system_msec;
        rtp_sprintf(outbuff,"\r\n ==<%s (t=%8d) (c=%4d) >== \r\n", (const unsigned char*) prompt,elapsed, nBytes);
        rtp_file_write (debugfd, (const unsigned char*) outbuff, (long) rtp_strlen(outbuff));
        if (pData && nBytes > 0)
        {
            rtp_file_write (debugfd, (const unsigned char*) pData, (long) nBytes);
            rtp_sprintf(outbuff,"\r\n ==<===========================================>==\r\n");
            rtp_file_write (debugfd, (const unsigned char*) outbuff, (long) rtp_strlen(outbuff));
        }
        rtp_file_flush (debugfd);
    }
}
Exemple #6
0
void Auth_Init (void)
{
#if (CFG_RTSMB_PRINT_SIZES)
    char buffer[128];

    rtp_sprintf (buffer, "access table: %i\n", sizeof (ACCESS_TABLE_T));
    tm_puts (buffer);
    rtp_sprintf (buffer, "groups: %i\n", sizeof (GROUPS_T));
    tm_puts (buffer);
    rtp_sprintf (buffer, "user data: %i\n", sizeof (USERDATA_T));
    tm_puts (buffer);
#endif
    CLAIM_AUTH ();
    prtsmb_srv_ctx->shareMode = AUTH_SHARE_MODE;
    prtsmb_srv_ctx->guestAccount = -1;
    RELEASE_AUTH ();

    RTSMB_DEBUG_OUTPUT_STR("Auth_Init:  Initializing authorization data.\n", RTSMB_DEBUG_TYPE_ASCII);
}
void SoftKeyPad::ReSizeTextWindow(int height, wcBOOL doUpdate)
{
char stylebuff[80];

	if ((Height + height) > ScreenHeight)
		height = ScreenHeight-Height;
	KeypadOffsetY = height;
	// Resize and reposition the window */
	wcWinSetPos(&WindowCtx, 0, ScreenHeight-(Height + height), Width, Height + height);

	rtp_sprintf(stylebuff, "height:%dpx;width:%dpx;", height, Width);
	if (pTextWinObj)
		wcElSetStyle(pTextWinObj, stylebuff , doUpdate);
	if (pImageObj)
	{
		rtp_sprintf(stylebuff, "position:absolute;left:%dpx;top:%dpx;", 0, height);
		wcElSetStyle(pImageObj, stylebuff , doUpdate);
	}
}
Exemple #8
0
SOAP_INT32 SOAP_SendActionRequest (
		SOAPAction* action
	)
{
	SOAP_CHAR*    requestBuffer;
	SOAP_INT32    contentLen;
	HTTPRequest   request;

	/* Create soap envelope for the request */
	requestBuffer = (char *)rtp_malloc(action->bodyLen +
						SOAP_ACTION_ENVELOPE_LENGTH);
	if (requestBuffer)
	{
		rtp_sprintf(requestBuffer, SOAP_ACTION_REQUEST_TEMPLATE,
					   action->bodyStr);

		/* get the length of the envelope which is the content length of SOAP Request */
		contentLen = rtp_strlen(requestBuffer);

		/* send a Post or a M-Post request */
		switch(action->state)
		{
			case SOAP_ACTION_CONNECTING_POST:
				/* Create soap envelope for the request */
#if (USE_EXPERIMENTAL_REQUEST)
				HTTP_ManagedClientRequestExExperimental(action->httpSession, "POST", action->postTargetURL.field.http.path, NULL,
					"text/xml; charset=\"utf-8\"", &contentLen, &request, "SOAPAction", action->soapAction);
#else
				HTTP_ManagedClientRequestEx (action->httpSession, "POST", action->postTargetURL.field.http.path, NULL,
					"text/xml; charset=\"utf-8\"", contentLen, &request);
#endif
				break;

			case SOAP_ACTION_CONNECTING_M_POST:
				HTTP_ManagedClientRequestEx (action->httpSession, "M-POST", action->postTargetURL.field.http.path, NULL,
					"text/xml; charset=\"utf-8\"", contentLen, &request);
				HTTP_SetRequestHeaderStr (&request, "Man", "\"http://schemas.xmlsoap.org/soap/envelope/\"; ns=s");
				HTTP_SetRequestHeaderStr (&request, "s-SOAPAction", action->soapAction);
				break;
		}
		HTTP_ManagedClientRequestHeaderDone (action->httpSession, &request);

		/* write the POST data */
		HTTP_ManagedClientWrite (action->httpSession, (SOAP_UINT8*)requestBuffer, contentLen);

		/* signal that the request is compete */
		HTTP_ManagedClientWriteDone (action->httpSession);

		rtp_free(requestBuffer);

		return(0);
	}

	return (-1);
}
Exemple #9
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 #10
0
SSDP_INT32 SSDP_SendResponse (
    SSDPServerContext *ctx,       /** pointer to SSDP context */
    SSDPPendingResponse *response /** buffer holding response information */)
{
    SSDP_CHAR     *msgBuffer;
    SSDP_SOCKET    responseSock = ctx->announceSocket;

    msgBuffer = (SSDP_CHAR *) rtp_malloc(sizeof(SSDP_CHAR) * SSDP_BUFFER_SIZE);

    if (msgBuffer)
    {
        /* Send response */
        rtp_sprintf(msgBuffer,"HTTP/1.1 200 OK\r\n"
                    "LOCATION: %s\r\n"
                    "EXT: \r\n"
                    "USN: %s\r\n"
                    "SERVER: %s\r\n"
                    "CACHE-CONTROL: max-age=%d\r\n"
                    "ST: %s\r\n"
                    "\r\n",
                    response->targetLocation,
                    response->targetUSN,
                    ctx->serverName,
                    response->targetTimeoutSec,
                    response->searchTarget);

        RTP_LOG_WRITE("SSDPSendResponse SEND", msgBuffer, rtp_strlen(msgBuffer))

        /* Send response to the requesting client */
        if (rtp_net_sendto(responseSock, (unsigned char*)msgBuffer,
                           rtp_strlen(msgBuffer),
                           response->clientAddr.ipAddr,
                           response->clientAddr.port,
                           response->clientAddr.type) < 0)
        {
            SSDP_ProcessError("Response");
            rtp_free(msgBuffer);
            return(-1);
        }

        /* Free up the allocated memory */
        rtp_free(msgBuffer);
    }
    else
    {
        return (-1);
Exemple #11
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);

}
Exemple #12
0
/**
	@memo Create a SOAP action request.

	@doc
		Creates an XML document which will hold the SOAP action request
		message. This function returns the address of newly formed XML document.
		After finishing the process of sending action request the application
		must release this xml document.

    @return pointer to newly created RTPXML_Document, which can be passed into
    	\Ref{UPnP_SetActionArg} to set the action arguments; NULL on error
 */
RTPXML_Document * UPnP_CreateAction (
		const UPNP_CHAR *serviceTypeURI, /** string containing service type of the target service */
		const UPNP_CHAR *actionName      /** name on action on the target service */
	)
{
char temp[256];

	if (actionName && serviceTypeURI &&
	    (rtp_strlen(actionName) * 2 + rtp_strlen(serviceTypeURI) < 216))
	{
		rtp_sprintf(temp, "<u:%s xmlns:u=\"%s\"></u:%s>",
		           actionName,
		           serviceTypeURI,
		           actionName);

		return (rtpxmlParseBuffer(temp));
	}

	return (0);
}
Exemple #13
0
static void DragStart(HBROWSER_HANDLE hbrowser, HDOC_HANDLE hdoc, HELEMENT_HANDLE helem, HTMLEvent* event)
{
	char ShadowId[80];
	char xmlDomstr[512];
	char *p;
	ShadowId[0]=0;
	rtp_strcat(ShadowId, "Shadow");
	p = webc_ElementGetIdASCII(helem);
	if (p)
	{
		rtp_sprintf(xmlDomstr,"%s.%s",PALLETDOMSTR,p);
		rtp_strcat(ShadowId, p);
		webc_FreeASCIIString(p);
	}
	else
		goto error;
	int X;
	int Y;
	IXML_Element *xmlElement;
	xmlElement = rtpxmlGetElemInDocFromDomStr(PalletTemplate,xmlDomstr);
	if (rtpxmlGetElemTextInElem (xmlElement, "left"))
		X = rtp_atoi(rtpxmlGetElemTextInElem (xmlElement, "left"));
	else
		X = 0;
	if (rtpxmlGetElemTextInElem (xmlElement, "top"))
		Y = rtp_atoi(rtpxmlGetElemTextInElem (xmlElement, "top"));
	else
		Y = 0;
	HELEMENT_HANDLE h = webc_DocFindElement (hdoc, ShadowId, 0, HTML_ELEMENT_ANY, 0);
	if (h)
	{
		webc_ElementSetXYPosition(h, X, Y);
		webc_ElementSetZindex(h, 2000);
		webc_ElementHide(h, WEBC_FALSE);
		webc_DragStart(hbrowser, hdoc, h, X, Y, DragCb, event->data.position.x,event->data.position.y);
	}
	return;
error:
	assert(0);
	;
}
Exemple #14
0
const char *rtsmb_des_options(void)
	{
	static int init=1;
	static char buf[32];

	if (init)
		{
		const char *ptr,*unroll,*risc,*size;

#ifdef RTSMB_DES_PTR
		ptr="ptr";
#else
		ptr="idx";
#endif
#if defined(RTSMB_DES_RISC1) || defined(RTSMB_DES_RISC2)
#ifdef RTSMB_DES_RISC1
		risc="risc1";
#endif
#ifdef RTSMB_DES_RISC2
		risc="risc2";
#endif
#else
		risc="cisc";
#endif
#ifdef RTSMB_DES_UNROLL
		unroll="16";
#else
		unroll="4";
#endif
		if (sizeof(RTSMB_DES_LONG) != sizeof(long))
			size="int";
		else
			size="long";
		rtp_sprintf(buf,"des(%s,%s,%s,%s)",ptr,risc,unroll,size);
		init=0;
		}
	return(buf);
	}
Exemple #15
0
/**
	@memo Creates a SOAP action response message.

	@doc
		Creates a response message skeleton for the supplied SOAP action request

    @return error code
 */
int UPnP_CreateActionResponse (
		UPnPActionRequest *request /* pointer to action request */
	)
{
char temp[256];
int result = -1;

	if (request->in.actionName && request->in.serviceTypeURI &&
	    (rtp_strlen(request->in.actionName) * 2 + rtp_strlen(request->in.serviceTypeURI) < 200))
	{
		rtp_sprintf(temp, "<u:%sResponse xmlns:u=\"%s\"></u:%sResponse>",
		           request->in.actionName,
		           request->in.serviceTypeURI,
		           request->in.actionName);

		request->out.result = rtpxmlParseBuffer(temp);
		if(request->out.result)
		{
			result = 0;
		}
	}

	return (result);
}
static JSBool jwindow_dialog(JSContext *cx, JSObject *obj,uintN argc, jsval *argv, jsval *rval, int which_dialogue)
{
	WebcJSDocumentContext *jsmgr = (WebcJSDocumentContext *) jhutil_GetPrivate(cx, obj);
	HTMLDocument *pDoc = (jsmgr)? jsmgr->GetDocument() : 0;

	if (argc < 1)
        return(JS_FALSE);

    char *prompt_str = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
// << EDIT 20080120 - Needs work

	// Clone the graphics abstraction layer function pointers so we know who to call
	HTMLBrowserConfig config, docConfig;
    rtp_memset(&config, 0, sizeof(config));
    rtp_memset(&docConfig, 0, sizeof(docConfig));
	pDoc->GetBrowser()->GetConfig(&docConfig);
	config.graphics = docConfig.graphics;

    switch (which_dialogue) {
        case WHICH_DIALOGUE_ALERT:
            config.WindowConfig.left =   WEBC_SKIN_ALERT_LEFT;
            config.WindowConfig.top =    WEBC_SKIN_ALERT_TOP;
            config.WindowConfig.width =  WEBC_SKIN_ALERT_WIDTH;
            config.WindowConfig.height = WEBC_SKIN_ALERT_HEIGHT;
            break;
        case WHICH_DIALOGUE_PROMPT:
            config.WindowConfig.left =   WEBC_SKIN_PROMPT_LEFT;
            config.WindowConfig.top =    WEBC_SKIN_PROMPT_TOP;
            config.WindowConfig.width =  WEBC_SKIN_PROMPT_WIDTH;
            config.WindowConfig.height = WEBC_SKIN_PROMPT_HEIGHT;
            break;
        case WHICH_DIALOGUE_CONFIRM:
        default:
            config.WindowConfig.left =   WEBC_SKIN_CONFIRM_LEFT;
            config.WindowConfig.top =    WEBC_SKIN_CONFIRM_TOP;
            config.WindowConfig.width =  WEBC_SKIN_CONFIRM_WIDTH;
            config.WindowConfig.height = WEBC_SKIN_CONFIRM_HEIGHT;
            break;
    }
	config.WindowConfig.WindowFlags |= WF_MODAL;

    HBROWSER_HANDLE Browser = webc_CreateBrowser(&config,  WEBC_TRUE,"dialog", "");
    if (Browser)
    {
     HDOC_HANDLE hDoc = webc_BrowserGetDocument(Browser);
	 wcCtx Ctx;
     char buff[128];
	  wcCtxtInit(&Ctx, (wcBROW) Browser, (wcDOC) hDoc);
     /* Experimental */
     wcDocClear(&Ctx, wcFALSE);
     wcDocOpen(&Ctx);


     // Create a link between 'C' and Javascript the Native 'C' function PromptDismiss will
     // be called with the value of the input field.
     webc_JScriptDefineFunction(hDoc, "PromptDismiss", (JSNative) PromptDismiss, 0);
     if (which_dialogue == WHICH_DIALOGUE_ALERT)
     {
         WriteDlgLine(&Ctx, WEBC_SKIN_ALERT_SOURCE_1);
         WriteDlgLine(&Ctx, prompt_str);
         WriteDlgLine(&Ctx, WEBC_SKIN_ALERT_SOURCE_2);
         WriteDlgLine(&Ctx, WEBC_SKIN_ALERT_SOURCE_3);
     }
     else if (which_dialogue == WHICH_DIALOGUE_CONFIRM)
     {
         WriteDlgLine(&Ctx, WEBC_SKIN_CONFIRM_SOURCE_1);
         WriteDlgLine(&Ctx, prompt_str);
         WriteDlgLine(&Ctx, WEBC_SKIN_CONFIRM_SOURCE_2);
         WriteDlgLine(&Ctx, WEBC_SKIN_CONFIRM_SOURCE_3);
     }
     else if (which_dialogue == WHICH_DIALOGUE_PROMPT)
     {
         char *default_str = "";
         if (argc > 1)
             default_str = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
         WriteDlgLine(&Ctx, prompt_str);
         rtp_sprintf(&buff[0],WEBC_SKIN_PROMPT_SOURCE_1,default_str);
         WriteDlgLine(&Ctx, &buff[0]);
         WriteDlgLine(&Ctx, WEBC_SKIN_PROMPT_SOURCE_2);
         WriteDlgLine(&Ctx, WEBC_SKIN_PROMPT_SOURCE_3);
     }
     wcDocClose(&Ctx);
     wcDocRefresh(&Ctx);

     /* Go modal here */
  //   HBROWSER_HANDLE Browser = webc_CreateBrowser(&config,  WEBC_TRUE, "");
     HTMLBrowser *pBrowser = (HTMLBrowser *) Browser;
     while (pBrowser->ProcessInputQueue(WEBC_TRUE) >= 0)
     {
         WebString *user_WebString;
         void* privateData = webc_BrowserGetPrivateData(Browser);
         if (privateData)
         {
             user_WebString = (WebString *) privateData;
             if (which_dialogue == WHICH_DIALOGUE_PROMPT)
             {
                 if (user_WebString && user_WebString->getLength())
 			        *rval = STRING_TO_JSVAL(WEBC_JS_NEW_STRING_COPY_Z(cx, user_WebString->getChars()));
                 else
                     *rval = JSVAL_VOID;
             }
             else if (which_dialogue == WHICH_DIALOGUE_ALERT)
                 *rval = JSVAL_VOID;
             else if (which_dialogue == WHICH_DIALOGUE_CONFIRM)
             {
                 if (user_WebString && webc_c_strcmp(user_WebString->getChars(), "OK")==0)
                     *rval = BOOLEAN_TO_JSVAL(JS_TRUE);
                 else
                     *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
             }
             WEBC_DELETE(user_WebString);
             webc_JScriptExecuteSource(hDoc, "window.close();");
             break;
         }
     }
     }
     return jutils_CheckContextState(cx);
}
Exemple #17
0
SSDP_INT32 SSDP_SendByebye (
    SSDPServerContext *ctx,         /** pointer to SSDP context */
    const SSDP_CHAR *notifyType,    /** the notification type (NT) string */
    const SSDP_CHAR *usn           /** pointer to string containing USN header */)
{
    SSDP_CHAR     ipAddr[RTP_NET_NI_MAXHOST];
    SSDP_CHAR     *msgBfr;
    SSDP_SOCKET    notifySock = ctx->announceSocket;

    if(ctx->ipType == RTP_NET_TYPE_IPV6)
    {
        rtp_sprintf(ipAddr, "[FF02::C]:1900");
    }
    else if (ctx->ipType == RTP_NET_TYPE_IPV4)
    {
        rtp_sprintf(ipAddr, "239.255.255.250:1900");
    }

    msgBfr = (SSDP_CHAR *) rtp_malloc(sizeof(SSDP_CHAR) * SSDP_BUFFER_SIZE);

    if (!msgBfr)
    {
        return (-1);
    }

    /* Send Advertisements */

    /* Fix (03/18/2007) - Correct formatting changed format fields from:
                      "HOST:%s\r\n"
                      "Cache-Control:max-age=%d\r\n"
                      "Location:%s\r\n"
                      "NT:%s\r\n"
                      "NTS:%s\r\n"
                      "Server:%s\r\n"
                      "USN:%s\r\n"

    */
#if (USE_INTEL_SDK_ORDER)
    rtp_sprintf(msgBfr,"NOTIFY * HTTP/1.1\r\n"
                "HOST: %s\r\n"
                "NTS: ssdp:byebye\r\n"
                "USN: %s\r\n"
                "NT: %s\r\n"
                "\r\n",
                ipAddr,
                usn,
                notifyType);
#else
    rtp_sprintf(msgBfr,"NOTIFY * HTTP/1.1\r\n"
                "HOST: %s\r\n"
                "NT: %s\r\n"
                "NTS: ssdp:byebye\r\n"
                "USN: %s\r\n"
                "\r\n",
                ipAddr,
                notifyType,
                usn);
#endif
    if(ctx->ipType == RTP_NET_TYPE_IPV6)
    {
        rtp_strcpy(ipAddr, IPV6_LINK_LOCAL_ADDRESS);
    }
    else if (ctx->ipType == RTP_NET_TYPE_IPV4)
    {
        rtp_strcpy(ipAddr, (const char*)v4mcastAddr);
    }
    RTP_LOG_WRITE("SSDP_SendByeBye SEND", msgBfr, rtp_strlen(msgBfr))
    /* Send the message to the multicast channel */
    if (rtp_net_sendto(notifySock, (unsigned char*)msgBfr, rtp_strlen(msgBfr),(unsigned char *) ipAddr, mcastPort, ctx->ipType) < 0)
    {
        SSDP_ProcessError("SendTo");
        rtp_free(msgBfr);
        return(-1);
    }

    /* Free up the allocated memory */
    rtp_free(msgBfr);
    return(0);
}
Exemple #18
0
int wcache_flush(struct wcache_ctx *cc)
{
struct wcache_entry *entry;
WEBC_UINT16 saveFlags;
void *fp;
char filename[WEBC_CACHE_MAX_PATH_LEN];
#if (WEBC_CACHE_SAVE_DIRECTORY)
void *fpDir;
char lineBuffer[512];
#endif

	tc_strcpy(filename, cc->cachePrefix);
	tc_strcat(filename, "index.dat");

	if (cc->spec.sys_open(cc->sysPtr, filename, &fp, WEBC_CO_CREATE) < 0)
	{
		return (-1);
	}

#if (WEBC_CACHE_SAVE_DIRECTORY)
	tc_strcpy(filename, cc->cachePrefix);
	tc_strcat(filename, "index.txt");

	if (cc->spec.sys_open(cc->sysPtr, filename, &fpDir, WEBC_CO_CREATE) < 0)
	{
		cc->spec.sys_close(cc->sysPtr, fp);
		return (-1);
	}
#endif

	cc->spec.sys_write(cc->sysPtr, fp, (WEBC_PFBYTE) cc, sizeof(struct wcache_ctx));

#if (WEBC_CACHE_SAVE_DIRECTORY)
	rtp_sprintf(lineBuffer,
			"   index   mime-type          size   flags   date                            expires                         key\r\n"
			"   =====   =========          ====   =====   ====                            =======                         ===\r\n"
			"\r\n");
	cc->spec.sys_write(cc->sysPtr, fpDir, (WEBC_PFBYTE) lineBuffer, tc_strlen(lineBuffer));
#endif


	// reverse the order of all entries so we'll load it back in mru order
	entry = cc->lru;
	while (entry)
	{
		// if we dump the index in the middle of a cache op, then we don't want to have
		//  the entry marked as "open" when we re-load the index
		saveFlags = entry->flags;
		entry->flags &= ~(WEBC_CACHE_ENTRY_LOCKED | WEBC_CACHE_ENTRY_INUSE | WEBC_CACHE_ENTRY_LOCK_MASK);

		cc->spec.sys_write(cc->sysPtr, fp, (WEBC_PFBYTE) entry, sizeof(struct wcache_entry) - sizeof(char *));
		cc->spec.sys_write(cc->sysPtr, fp, (WEBC_PFBYTE) entry->key, entry->keyLen*sizeof(char));

#if (WEBC_CACHE_SAVE_DIRECTORY)
		rtp_sprintf(lineBuffer, "%8x   %9d  %12ld    %04hx   ",
		             entry->fileIndex,
		             entry->dataType,
		             entry->size,
		             entry->flags);

		ebs_print_time(lineBuffer + tc_strlen(lineBuffer), entry->date, 0);
		tc_strcat(lineBuffer, "   ");

		ebs_print_time(lineBuffer + tc_strlen(lineBuffer), entry->expires, 0);
		tc_strcat(lineBuffer, "   ");

		tc_strcat(lineBuffer, entry->key);
		tc_strcat(lineBuffer, "\r\n");

		cc->spec.sys_write(cc->sysPtr, fpDir, (WEBC_PFBYTE) lineBuffer, tc_strlen(lineBuffer));
#endif // WEBC_CACHE_SAVE_DIRECTORY

		entry->flags = saveFlags;
		entry = entry->prev;
	}

	cc->spec.sys_close(cc->sysPtr, fp);

#if (WEBC_CACHE_SAVE_DIRECTORY)
	cc->spec.sys_close(cc->sysPtr, fpDir);
#endif

	return (0);
}
Exemple #19
0
/** SOAP callback for UPnP.  Handles a single incoming SOAP control request by
    parsing the action document and calling the device callback.

    @return error code; tells SOAP whether the action was successful or
            generated a fault
 */
int UPnP_DeviceControlSOAPCallback (
		SOAPServerContext *ctx, /** the SOAP context */
		SOAPRequest *request,   /** the action request */
		void *cookie            /** the UPnPService being controlled */)
{
UPnPService *service = (UPnPService *) cookie;
UPnPRootDevice *rootDevice = service->device->rootDevice;

	/* first to check if the device callback is set */
	if (rootDevice->userCallback)
	{
		/* parse the service type URI and the action name out of the
		   SOAPAction header string */
		UPNP_CHAR *soapAction = (UPNP_CHAR *) rtp_malloc(
				(rtp_strlen(request->in.soapAction) + 1) * sizeof(UPNP_CHAR));

		if (soapAction)
		{
			UPNP_CHAR *actionName;
			UPNP_CHAR *serviceTypeURI;
			char *str;

			/* work with a copy of the soapAction since we'll be
			   chopping it up */
			rtp_strcpy(soapAction, request->in.soapAction);

			serviceTypeURI = soapAction;

			/* SOAPAction is often quote-enclosed */
			if (*serviceTypeURI == '"')
			{
				serviceTypeURI++;
			}

			/* '#' signals the beginning of the action tag name */
			str = rtp_strstr(serviceTypeURI, "#");
			if (str)
			{
				long len;
				RTPXML_NodeList *nodeList;

				*str = 0;
				str++;
				actionName = str;

				len = rtp_strlen(actionName);

				/* remove the trailing quote if there is one */
				if (actionName[len-1] == '"')
				{
					actionName[len-1] = 0;
				}

				/* the action tag must be qualified by the xml namespace
				   of the service type */
	  			nodeList = rtpxmlElement_getElementsByTagNameNS (
	  							request->in.envelope.bodyElem,
	  							serviceTypeURI,
	  							actionName);

	  			if (nodeList)
	  			{
	  				RTPXML_Element *actionElement;

	  				actionElement = (RTPXML_Element *) rtpxmlNodeList_item(nodeList, 0);
	  				rtpxmlNodeList_free(nodeList);

	  				if (actionElement)
	  				{
		  				UPnPActionRequest actionRequest;

		  				rtp_memset(&actionRequest, 0, sizeof(UPnPActionRequest));

		  				actionRequest.in.actionName = actionName;
		  				actionRequest.in.serviceTypeURI = serviceTypeURI;
		  				actionRequest.in.actionElement = actionElement;
		  				actionRequest.in.serviceId = service->serviceId;
		  				actionRequest.in.deviceUDN = service->device->UDN;
		  				actionRequest.in.clientAddr = request->in.clientAddr;

		  				rootDevice->userCallback(rootDevice->userData,
						                         rootDevice->deviceRuntime,
						                         rootDevice,
						                         UPNP_DEVICE_EVENT_ACTION_REQUEST,
						                         &actionRequest);

						if (actionRequest.out.errorCode == 0)
						{
							/* success */
							request->out.body = actionRequest.out.result;
							rtp_free(soapAction);
							return (0);
						}
						else
						{
							/* fault */
							char temp[UPNP_MAX_ERROR_DESC_LEN + 176];

							rtp_sprintf(temp, "<UPnPError xmlns=\"urn:schemas-upnp-org:control-1-0\">"
							                 "<errorCode>%d</errorCode>"
							                 "<errorDescription>%s</errorDescription>"
							                 "</UPnPError>",
							           actionRequest.out.errorCode,
							           actionRequest.out.errorDescription);

							rtp_strcpy(request->out.fault.code, "s:Client");
							rtp_strcpy(request->out.fault.string, "UPnPError");

							/* XML document will be freed by SOAP */
							request->out.fault.detail = rtpxmlParseBuffer(temp);
							rtp_free(soapAction);

							return (-1);
						}
	  				}
	  			}
			}

			rtp_free(soapAction);
		}
	}

	return (-1);
}
Exemple #20
0
/* pfAddrStr must be at least 16 bytes large */
int rtsmb_net_ip_to_str (PFBYTE pfAddr, PFCHAR pfAddrStr)
{
    tc_memset(pfAddrStr, 0, 16);
    rtp_sprintf(pfAddrStr,"%i.%i.%i.%i", pfAddr[0], pfAddr[1], pfAddr[2], pfAddr[3]);
    return(0);
}
/* Start dragging helem. */
int webc_SlidingWindowOpen(
	HBROWSER_HANDLE hbrowser,
	HDOC_HANDLE hdoc,
	int WindowTop,
	int WindowLeft,
	int WindowHeight,
	int WindowWidth,
	HELEMENT_HANDLE SlidingElement,
	int SlidingElementStartTop,
	int SlidingElementStartLeft,
	unsigned long Controlflags,
	SlidingCallbackFunction cb)
{
struct _webcSlidingWindowView *SlideObject;
HELEMENT_HANDLE SlideWindow;
char style_buff[512];

	SlideWindow = webc_GetSlidingWindow(hbrowser, hdoc);
	if (!SlideWindow)
		goto error;

	SlideObject = (struct _webcSlidingWindowView *) rtp_malloc(sizeof(* SlideObject));
	if (!SlideObject)
		goto error;
	rtp_memset(SlideObject,0,sizeof(*SlideObject));
//	SlideObject->WindowRect.Set(WindowLeft, WindowTop, WindowLeft+WindowWidth-1, WindowTop+WindowHeight-1);

	SlideObject->WindowTop     = WindowTop;
	SlideObject->WindowLeft    = WindowLeft;
	SlideObject->WindowHeight  = WindowHeight;
	SlideObject->WindowWidth   = WindowWidth;
	SlideObject->Controlflags  = Controlflags;
	SlideObject->SlidingElement = SlidingElement;

	SlideObject->SlidingElementStartTop    =  SlidingElementStartTop;
	SlideObject->SlidingElementStartLeft   =  SlidingElementStartLeft;
	SlideObject->SlidingElementCurrentTop  =  SlidingElementStartTop;
	SlideObject->SlidingElementCurrentLeft =  SlidingElementStartLeft;
	SlideObject->cb = cb;

	/* Install a listener for display events */
	webc_ElementEnableDisplayEvents(SlidingElement);
	/* Move the start position of the element underneath us and show it */
	/* Done below too, may not be needed. */
	webc_ElementSetXYPosition(SlidingElement, SlidingElementStartLeft, SlidingElementStartTop);
	/* Hide the sliding window */
  	webc_ElementHide(SlidingElement, WEBC_TRUE);
	/* Put it inside the SlideWindow */
	if (webc_ElementGetParent(SlidingElement))
		webc_ElementRemoveChild(webc_ElementGetParent(SlidingElement),SlidingElement);
	webc_ElementInsertFirst(SlideWindow,SlidingElement);
	/* Set an event handler */
	webc_ElementSetPrivateData(SlidingElement,SlideObject);
	webc_ElementSetTagEventHandler(SlidingElement, SlidingWindowEventHandler);

	/* Show the viewport with the sliding window inside it, clipped. */
	rtp_sprintf(style_buff,"height:%dpx;width:%dpx;\"", WindowHeight, WindowWidth);
    webc_ElementSetStyleASCII(SlideWindow, style_buff, WEBC_TRUE);
	webc_ElementSetXYPosition(SlideWindow, WindowLeft, WindowTop);
   	webc_ElementHide(SlideWindow, WEBC_FALSE);

	/* Move the start position of the element underneath us and show it */
	webc_ElementSetXYPosition(SlidingElement, SlidingElementStartLeft, SlidingElementStartTop);
	webc_ElementHide(SlidingElement, WEBC_FALSE);

	return 0;
error:
	assert(0);
	return -1;
}
Exemple #22
0
/*
==============

==============
*/
void rtsmb_srv_net_init (void)
{
RTSMB_STATIC PNET_THREAD tempThread;

#if (CFG_RTSMB_PRINT_SIZES)
    char buffer[128];

    rtp_sprintf (buffer, "net thread: %i\n", sizeof (NET_THREAD_T));
    tm_puts (buffer);
#endif

#if INCLUDE_RTSMB_DC
    next_pdc_find = rtp_get_system_msec () + rtsmb_srv_net_pdc_next_interval ();
#endif

    /**
     * You will note that we consistently use the term 'thread' to refer to the 'mainThread.'
     * In fact, it is not a full blown thread, but is only treated the same, for coding simplicity
     * purposes.  This first thread always runs in the same thread/process as the caller of our API
     * functions.  If CFG_RTSMB_MAX_THREADS is 0, no threads will ever be created.
     */
    tempThread = rtsmb_srv_net_thread_new ();   /* this will succeed because there is at least one thread free at start */

    if (!tempThread)
    {
        RTSMB_DEBUG_OUTPUT_STR("rtsmb_srv_net_init: Error -- could not allocate main pseudo-thread.\n", RTSMB_DEBUG_TYPE_ASCII);
        return;
    }

    mainThread = tempThread;
    rtsmb_srv_net_thread_init (mainThread, 0);

    /* -------------------- */
    /* get the three major sockets */
    /* Name Service Datagram Socket */
    if (rtsmb_net_socket_new (&net_nsSock, rtsmb_nbns_port, FALSE) < 0)
    {
        rtp_printf(("Could not allocate Name & Datagram service socket\n"));
    }

    /* SSN Reliable Socket */
  #ifdef RTSMB_ALLOW_SMB_OVER_TCP
    if (rtsmb_net_socket_new (&net_ssnSock, rtsmb_nbss_direct_port, TRUE) < 0)
    {
        rtp_printf(("Could not allocate Name & Datagram service socket\n"));
    }
  #else
    if (rtsmb_net_socket_new (&net_ssnSock, rtsmb_nbss_port, TRUE) < 0)
    {
        rtp_printf (("Could not allocate SSN Reliable socket\n"));
    }
  #endif
    if (rtp_net_listen ((RTP_SOCKET) net_ssnSock, prtsmb_srv_ctx->max_sessions) != 0)
    {
        RTSMB_DEBUG_OUTPUT_STR("Error occurred while trying to listen on SSN Reliable socket.\n", RTSMB_DEBUG_TYPE_ASCII);
    }

    if (rtp_net_setbroadcast((RTP_SOCKET) net_nsSock, 1) < 0)
    {
        RTSMB_DEBUG_OUTPUT_STR("Error occurred while trying to set broadcast on Name & Datagram service socket\n", RTSMB_DEBUG_TYPE_ASCII);
    }
}
/* SPR - was RTP_HANDLE but didn't build */
long rtp_term_aux_open(void)
{
    HANDLE hComm;
    DCB dcb;

    /* JRT */
    COMMTIMEOUTS comm_timeouts;

    hComm = CreateFile( RTP_TERM_AUX_COMM_PORT,  
                    GENERIC_READ | GENERIC_WRITE, 
                    0, 
                    0, 
                    OPEN_EXISTING,
                    FILE_FLAG_OVERLAPPED,
                    0);
    if (hComm == INVALID_HANDLE_VALUE)
    {
        rtp_term_puts("Error in opening serial comm\n");
        return -1;
    }
    if (!GetCommState(hComm, &dcb))     // get current DCB
          // Error in GetCommState
          return FALSE;

    FillMemory(&dcb, sizeof(dcb), 0);
    dcb.DCBlength = sizeof(dcb);
    if (!BuildCommDCB("baud=9600 parity=n data=8 stop=1 dtr=on rts=on", &dcb)) {   
          // Couldn't build the DCB. Usually a problem
          // with the communications specification string.
          return FALSE;
    }

    // Update DCB rate.
    //dcb.BaudRate =  RTP_TERM_AUX_BAUD_RATE;

    // Set new state.
    if (!SetCommState(hComm, &dcb))
    {
      // Error in SetCommState. Possibly a problem with the communications 
      // port handle or a problem with the DCB structure itself.
    } 

    /* JRT - Get the timeout and set it appropriately */
    rtp_memset(&comm_timeouts, 0x0, sizeof(comm_timeouts));

#define GET_COMM_TIMEOUTS 0
#if GET_COMM_TIMEOUTS
    GetCommTimeouts(hComm, &comm_timeouts);
#endif

    if (!SetCommTimeouts(hComm, &comm_timeouts))
    {
        char err_string[100];
        int error;
        
        error = GetLastError();
        rtp_sprintf(err_string,
                    "rtp_term_aux_open: SetCommTimeouts failed, error = %d\n",
                    error);
        rtp_term_puts(err_string);
        return (-1);
    }

    auxComm = (RTP_HANDLE) hComm;
    
    return (auxComm);
 
}