예제 #1
0
파일: main.c 프로젝트: codywon/bell-jpg
int main( int argc, char** argv )
{
    /*
     *	Initialize the memory allocator. Allow use of malloc and start
     *	with a 60K heap.  For each page request approx 8KB is allocated.
     *	60KB allows for several concurrent page requests.  If more space
     *	is required, malloc will be used for the overflow.
     */
    bopen( NULL, ( 60 * 1024 ), B_USE_MALLOC );
    signal( SIGPIPE, SIG_IGN );

    /*
     *	Initialize the web server
     */
    if ( initWebs() < 0 )
    {
        return -1;
    }

#ifdef WEBS_SSL_SUPPORT
    websSSLOpen();
#endif

    /*
     *	Basic event loop. SocketReady returns true when a socket is ready for
     *	service. SocketSelect will block until an event occurs. SocketProcess
     *	will actually do the servicing.
     */
    while ( !finished )
    {
        if ( socketReady( -1 ) || socketSelect( -1, 1000 ) )
        {
            socketProcess( -1 );
        }

        websCgiCleanup();
        emfSchedProcess();
    }

#ifdef WEBS_SSL_SUPPORT
    websSSLClose();
#endif
#ifdef USER_MANAGEMENT_SUPPORT
    umClose();
#endif
    /*
     *	Close the socket module, report memory leaks and close the memory allocator
     */
    websCloseServer();
    socketClose();
#ifdef B_STATS
    memLeaks();
#endif
    bclose();
    return 0;
}
예제 #2
0
int main(int argc, char** argv)
{
/*
 *	Hook the unload routine in
 */
   signal( SIGTERM, SigTermSignalHandler ) ;

/*
 * Initialize the memory allocator. Allow use of malloc and start 
 * with a 60K heap.  For each page request approx 8KB is allocated.
 * 60KB allows for several concurrent page requests.  If more space
 * is required, malloc will be used for the overflow.
 */
   bopen(NULL, (60 * 1024), B_USE_MALLOC);

   P( 1 ) ;

/*
 *	Switch to LONG name-space. If LONG is not loaded, WEBS will default
 *	to 8.3
 */
   SetCurrentNameSpace( 4 ) ;

/*
 * Initialize the web server
 */
   if (initWebs() < 0) {
      return -1;
   }

#ifdef WEBS_SSL_SUPPORT
   websSSLOpen();
#endif

   P( 20 ) ;

/*
 * Basic event loop. SocketReady returns true when a socket is ready for
 * service. SocketSelect will block until an event occurs. SocketProcess
 * will actually do the servicing.
 */
   while (!finished) {
      if (socketReady(-1) || socketSelect(-1, 1000)) {
         socketProcess(-1);
         ThreadSwitch() ;
      }
      websCgiCleanup();
      emfSchedProcess();
   }

   NLMcleanup() ;

   return 0;
}
예제 #3
0
static void
rtems_httpd_daemon(rtems_task_argument args)
{
/*
 *	Initialize the memory allocator. Allow use of malloc and start with a 
 *	10K heap.
 */
	bopen(NULL, (10 * 1024), B_USE_MALLOC);

/*
 *	Initialize the web server
 */
	if (initWebs() < 0) {
	  rtems_panic("Unable to initialize Web server !!\n");
	}

#ifdef WEBS_SSL_SUPPORT
	websSSLOpen();
#endif

/*
 *	Basic event loop. SocketReady returns true when a socket is ready for
 *	service. SocketSelect will block until an event occurs. SocketProcess
 *	will actually do the servicing.
 */
	while (!finished) {
	  if (socketReady(-1) || socketSelect(-1, 2000)) {
			socketProcess(-1);
	  }
	  /*websCgiCleanup();*/
	  emfSchedProcess();
	}

#ifdef WEBS_SSL_SUPPORT
	websSSLClose();
#endif

#ifdef USER_MANAGEMENT_SUPPORT
	umClose();
#endif

/*
 *	Close the socket module, report memory leaks and close the memory allocator
 */
	websCloseServer();
	websDefaultClose();
	socketClose();
	symSubClose();
#if B_STATS
	memLeaks();
#endif
	bclose();
        rtems_task_delete( RTEMS_SELF );
}
예제 #4
0
/*
 *	Main -- entry point from LINUX
 */
int main(int argc, char** argv)
{
    int i, demo = 0;
    printf("OK open data!!!\n");
    printf("open data OK!\n");
    for (i = 0; i < argc; i++) {
        if (strcmp(argv[i], "-demo") == 0) {
			demo++;
		}
	}
/*	Initialize the memory allocator. Allow use of malloc and start 
 *	with a 60K heap.  For each page request approx 8KB is allocated.
 *	60KB allows for several concurrent page requests.  If more space
 *	is required, malloc will be used for the overflow.
 */
	bopen(NULL, (60 * 1024), B_USE_MALLOC);
	signal(SIGPIPE, SIG_IGN);
	signal(SIGINT, sigintHandler);
    signal(SIGTERM, sigintHandler);
/*
 *	Initialize the web server
 */
	if (initWebs(demo) < 0) 
    {
		return -1;
	}
    printf("Init Web service ok!\n");
#ifdef WEBS_SSL_SUPPORT
	websSSLOpen();
        /*	websRequireSSL("/"); */	/* Require all files be served via https */
#endif

        /*
         *	Basic event loop. SocketReady returns true when a socket is ready for
         *	service. SocketSelect will block until an event occurs. SocketProcess
         *	will actually do the servicing.
         */
	finished = 0;
	while (!finished)
    {
		if (socketReady(-1) || socketSelect(-1, 1000))
        {
			socketProcess(-1);
		}
        websCgiCleanup();
        emfSchedProcess();
    }
#ifdef WEBS_SSL_SUPPORT
	websSSLClose();
#endif
#ifdef USER_MANAGEMENT_SUPPORT
	umClose();
#endif
/*
 *	Close the socket module, report memory leaks and close the memory allocator
 */
	websCloseServer();
	socketClose();
#ifdef B_STATS
	memLeaks();
#endif
	bclose();
	return 0;
}
예제 #5
0
/*********************************************************************************************************
** 函数名称: websStart
** 功能描述: 启动 GoAhead web 服务器
** 输 入  : addr          主机地址
**           path          web 路径
**           port          端口号
** 输 出  : 0
** 全局变量:
** 调用模块:
*********************************************************************************************************/
int websStart(char *addr, char *path, int port)
{
    /*
     *  Initialize the memory allocator. Allow use of malloc and start
     *  with a 60K heap.  For each page request approx 8KB is allocated.
     *  60KB allows for several concurrent page requests.  If more space
     *  is required, malloc will be used for the overflow.
     */
    bopen(NULL, (60 * 1024), B_USE_MALLOC);

    /*
     *  Initialize the web server
     */
    if (websInit(addr, path, port) < 0) {
        return -1;
    }

#ifdef WEBS_SSL_SUPPORT
    websSSLOpen();
#endif

    /*
     *  Basic event loop. SocketReady returns true when a socket is ready for
     *  service. SocketSelect will block for two seconds or until an event
     *  occurs. SocketProcess will actually do the servicing.
     */
    running = TRUE;
    while (!running) {
        if (socketReady(-1) || socketSelect(-1, 2000)) {
            socketProcess(-1);
        }
        websCgiCleanup();
        emfSchedProcess();
    }

#ifdef WEBS_SSL_SUPPORT
    websSSLClose();
#endif

#ifdef USER_MANAGEMENT_SUPPORT
    umClose();
#endif

    /*
     *  Close the socket module, report memory leaks and close the memory allocator
     */
    websCloseServer();
    websDefaultClose();
    socketClose();
    symSubClose();

#ifdef B_STATS
    {
        char *argv[2];
        argv[0] = "goaheadmemleak";
        argv[1] = "\0";
        memLeaks(1, argv);                                              /*  print message on stdout     */
    }
#endif

    bclose();

    if (logFile != NULL) {
        fclose(logFile);
        logFile = NULL;
    }

    return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
    int i, demo = 0;
    /*
    	for (i = 1; i < argc; i++) {
    		if (strcmp(argv[i], "-demo") == 0) {
    			demo++;
    		}
    	}
    */
    /*
     *	Initialize the memory allocator. Allow use of malloc and start
     *	with a 60K heap.  For each page request approx 8KB is allocated.
     *	60KB allows for several concurrent page requests.  If more space
     *	is required, malloc will be used for the overflow.
     */

    bopen(NULL, (60 * 1024), B_USE_MALLOC);


    /*
     *	Store the instance handle (used in socket.c)
     */

    /*
     *	Initialize the web server
     */
    if (initWebs(demo) < 0) {
        return FALSE;
    }

#ifdef WEBS_SSL_SUPPORT
    websSSLOpen();
#endif

    /*
     *	Basic event loop. SocketReady returns true when a socket is ready for
     *	service. SocketSelect will block until an event occurs. SocketProcess
     *	will actually do the servicing.
     */
    wprintf(L"begin loop\n");
    while (!finished) {
        if (socketReady(-1) || socketSelect(-1, sockServiceTime)) {
            wprintf(L"--->socketProcess\n");
            socketProcess(-1);
        }
        emfSchedProcess();
        //wprintf(L"cleanup\n");
        websCgiCleanup();
    }

#ifdef WEBS_SSL_SUPPORT
    websSSLClose();
#endif

    /*
     *	Close the User Management database
     */
#ifdef USER_MANAGEMENT_SUPPORT
    umClose();
#endif

    /*
     *	Close the socket module, report memory leaks and close the memory allocator
     */
    websCloseServer();
    socketClose();
#ifdef B_STATS
    memLeaks();
#endif
    bclose();
    return 0;
}
예제 #7
0
파일: main.c 프로젝트: codywon/bell-jpg
int APIENTRY WinMain( HINSTANCE hinstance, HINSTANCE hprevinstance,
                      char* args, int cmd_show )
{
    WPARAM	rc;
    /*
     *	Initialize the memory allocator. Allow use of malloc and start
     *	with a 60K heap.  For each page request approx 8KB is allocated.
     *	60KB allows for several concurrent page requests.  If more space
     *	is required, malloc will be used for the overflow.
     */
    bopen( NULL, ( 60 * 1024 ), B_USE_MALLOC );

    /*
     *	Store the instance handle (used in socket.c)
     */

    if ( windowsInit( hinstance ) < 0 )
    {
        return FALSE;
    }

    /*
     *	Initialize the web server
     */
    if ( initWebs() < 0 )
    {
        return FALSE;
    }

#ifdef WEBS_SSL_SUPPORT
    websSSLOpen();
#endif

    /*
     *	Basic event loop. SocketReady returns true when a socket is ready for
     *	service. SocketSelect will block until an event occurs. SocketProcess
     *	will actually do the servicing.
     */
    while ( !finished )
    {
        if ( socketReady( -1 ) || socketSelect( -1, sockServiceTime ) )
        {
            socketProcess( -1 );
        }

        emfSchedProcess();
        websCgiCleanup();

        if ( ( rc = checkWindowsMsgLoop() ) != 0 )
        {
            break;
        }
    }

#ifdef WEBS_SSL_SUPPORT
    websSSLClose();
#endif
    /*
     *	Close the User Management database
     */
#ifdef USER_MANAGEMENT_SUPPORT
    umClose();
#endif
    /*
     *	Close the socket module, report memory leaks and close the memory allocator
     */
    websCloseServer();
    socketClose();
    /*
     *	Free up Windows resources
     */
    windowsClose( hinstance );
#ifdef B_STATS
    memLeaks();
#endif
    bclose();
    return rc;
}
예제 #8
0
int main(int argc, char** argv)
{
	int i, demo = 0;

	for (i = 1; i < argc; i++) 
	{
		if (strcmp(argv[i], "-demo") == 0) 
		{
			demo++;
		}
	}

	#ifdef DEBUG
		printf("demo:%d\n",demo);		//Modify by :LuiShiLi 
	#endif								//date		:2011.09.28
	

	
	//首先分配一个大的内存块(60*1024字节),以后只要是以b开头的
	//对内存操作的函数都是在这个已经分好的内存块上的操作,
	//这些操作在Balloc.c中实现。

 
	bopen(NULL, (60 * 1024), B_USE_MALLOC);
	signal(SIGPIPE, SIG_IGN);			//管道破裂,写一个没有读端口的管道
	signal(SIGINT, sigintHandler);		//按键中断
	signal(SIGTERM, sigintHandler);		//终止信号


	/*
	
	Initialize the web server
	
	初始化用户管理部分,打开web服务器,注册URL处理函数。
	
	用户管理部分在um.c中实现,
	
	Web服务器的初始化是在default.c和webs.c中实现
	
	url处理函数在handler.c中实现
	
	 */

	if (initWebs(demo) < 0) 
	{
		return -1;
	}

	
#ifdef WEBS_SSL_SUPPORT
	websSSLOpen();
/*	websRequireSSL("/"); */	/* Require all files be served via https */
#endif

/*
 *	Basic event loop. SocketReady returns true when a socket is ready for
 *	service. SocketSelect will block until an event occurs. SocketProcess
 *	will actually do the servicing.
 */

//主循环
	finished = 0;
	while (!finished) 
	{
	
		/*
		
		1,socketReady()函数检查是否有准备好的sock事件
		
		2,socketSelect()函数首先把各个sock感兴趣的事件 (sp->handlerMask)
		注册给三个集合(读,写,例外),然后调用select系统调用,然后更新各个sock
		的 sp->currentEvents,表示各个sock的当前状态。
		
		这两个函数在sockGen.c中实现,他们主要操作的数据是socket_t变量 socketList中
		的handlerMask和currentEvents,socketList在sock.c中定义并主要由该文件中的 
		socketAlloc,socketFree和socketPtr三个函数维护。
		
		*/
		if (socketReady(-1) || socketSelect(-1, 1000)) 
		{
			
			/*
			
			该函数处理具体的sock事件
			
			1,调用socketReady(sid)对socketList[sid]进行检查,看是否有sock事件
			
			2,如果有sock事件,则调用socketDoEvent()函数,对事件进行处理
			
			*/
			socketProcess(-1);
		}

		
		/*
		
		该函数在cgi.c中实现,检查cgiRec变量cgilist,首先把cgi的结果输出,如果有的话,然后看cgi进程是否已对号束,如果结束,就清理该cgi进程。
		
		Cgilist在函数websCgiHandler和websCgiCleanup中维护。




		
		*/
		websCgiCleanup();
		
		/*
		
		该函数在websuemf.c中实现,功能是检查sched_t变量sched,断开超时的连接,sched变量在emfSchedCallback和emfUnschedCallback中维护
		
		*/
		emfSchedProcess();
	}

	
	/*
	
	退出时的清理工作,永远不会执行到这里
	
	*/

#ifdef WEBS_SSL_SUPPORT
	websSSLClose();
#endif

#ifdef USER_MANAGEMENT_SUPPORT
	umClose();
#endif

/*
 *	Close the socket module, report memory leaks and close the memory allocator
 */
	websCloseServer();
	socketClose();
#ifdef B_STATS
	memLeaks();
#endif
	bclose();
	return 0;
}