int main (int argc, char ** argv) 
{
	VortexCtx * ctx;

	/* create a context */
	ctx = vortex_ctx_new ();

	vortex_log_enable (ctx, axl_true);
	vortex_color_log_enable (ctx, axl_true);

	signal (SIGSEGV, __sigsegv_handler);
	signal (SIGABRT, __sigsegv_handler);

	/* init vortex library */
	if (! vortex_init_ctx (ctx)) {
		printf ("Failed to start vortex library..\n");
		return -1;
	}

	/* register a profile */
	vortex_profiles_register (ctx, COYOTE_PROFILE, 
				  start_channel, NULL, NULL, NULL,
				  frame_received, NULL);

	/* create a vortex server */
	vortex_listener_new (ctx, "0.0.0.0", "44000", on_ready, ctx);

	/* wait for listeners (until vortex_exit is called)  */
	vortex_listener_wait (ctx);

	/* terminate library execution */
	vortex_exit_ctx (ctx, axl_true);

	return 0;
}
예제 #2
0
int  main (int  argc, char ** argv) 
{

	/* create the context */
	ctx = vortex_ctx_new ();

	/* init vortex library */
	if (! vortex_init_ctx (ctx)) {
		/* unable to init context */
		vortex_ctx_free (ctx);
		return -1;
	} /* end if */

	/* register a profile */
	vortex_profiles_register (ctx, PLAIN_PROFILE, 
				  start_channel, NULL, 
				  close_channel, NULL,
				  frame_received, NULL);
	
	vortex_greetings_set_features (ctx, "enable-tls");
	vortex_greetings_set_localize (ctx, "es-ES");

	/* create a vortex server */
	vortex_listener_new (ctx, "0.0.0.0", "44000", NULL, NULL);

	/* wait for listeners (until vortex_exit is called) */
	vortex_listener_wait (ctx);
	
	/* end vortex function */
	vortex_exit_ctx (ctx, axl_true);

	return 0;
}
예제 #3
0
int  main (int  argc, char ** argv) 
{

	/* create the context */
	ctx = vortex_ctx_new ();

	/* init vortex library */
	if (! vortex_init_ctx (ctx)) {
		/* unable to init context */
		vortex_ctx_free (ctx);
		return -1;
	} /* end if */

	/* register a profile */
	vortex_profiles_register (ctx, COYOTE_PROFILE, 
				  start_channel, NULL, NULL, NULL,
				  frame_received, NULL);

	/* create a vortex server */
	vortex_listener_new (ctx, "0.0.0.0", "44000", on_ready, NULL);

	/* wait for listeners (until vortex_exit is called) */
	vortex_listener_wait (ctx);

	/* do not call vortex_exit here if you define an on ready
	 * function which actually ends the execution */

	return 0;
}
int  main (int  argc, char ** argv)
{

    /* create the context */
    ctx = vortex_ctx_new ();

    vortex_thread_pool_set_num (1);

    /* init vortex library */
    if (! vortex_init_ctx (ctx)) {
        /* unable to init context */
        vortex_ctx_free (ctx);

        return -1;
    } /* end if */

    vortex_thread_pool_setup2 (ctx, 40, 1, 1, 1, 4, axl_true, axl_true);

    /* register a profile */
    vortex_profiles_register (ctx, PLAIN_PROFILE,
                              start_channel, NULL,
                              close_channel, NULL,
                              frame_received, NULL);

    /* create a vortex server */
    vortex_listener_new (ctx, "0.0.0.0", "44000", NULL, NULL);

    /* configure connection notification */
    vortex_listener_set_on_connection_accepted (ctx, on_accepted, NULL);

    /* wait for listeners (until vortex_exit is called) */
    vortex_listener_wait (ctx);

    /* end vortex function */
    vortex_exit_ctx (ctx, axl_true);

    return 0;
}
예제 #5
0
int main (int argc, char **argv)
{
	axlError   * error;
	char      ** paths;
	int          iterator;

	/* init exarg library */
	exarg_install_arg ("version", "v", EXARG_NONE,
			   "Shows version info");
	exarg_install_arg ("out-dir", "o", EXARG_STRING, 
			   "Configures the output directory to place stub and skeletons generated. Default value, if not provided, is \"out\", starting from the current directory.");
	exarg_install_arg ("disable-autoconf", "a", EXARG_NONE,
			   "Disables autoconf files generation. By default, activated.");
	exarg_install_arg ("only-client", "c", EXARG_NONE,
			   "Only produces the client connector, the stub library used to interface with the XML-RPC component. By default, the client stub is generated.");
	exarg_install_arg ("only-server", "s", EXARG_NONE,
			   "Only produces the server stub, the XML-RPC component that is receiving the invocation. By default, the server stub is generated.");
	exarg_install_arg ("xdl-format", "x", EXARG_NONE,
			   "Instruct the tool to expect and process only XDL formated files. This option is useful because the tool fails into parse IDL format if XDL parsing fails, getting not proper errors if a XDL format was defined. This option is not compatible with --idl-format.");
	exarg_install_arg ("idl-format", "i", EXARG_NONE,
			   "Instruct the tool to expect and process only IDL formated files");
	exarg_install_arg ("out-server-dir", NULL, EXARG_STRING, "Allows to fully configure server output source code. This is not the same as --out-dir which is a directory where is placed both products.");
	exarg_install_arg ("out-stub-dir", NULL, EXARG_STRING, "Allows to fully configure stub output source code. This is not the same as --out-dir which is a directory where is placed both products.");
	exarg_install_arg ("disable-main-file", NULL, EXARG_NONE, "Server side component option. It allows to disable creating a main.c file, allowing to produce a custom one. This option is useful while trying to create XML-RPC components mixed with other profiles");
	exarg_install_arg ("to-xml", NULL, EXARG_NONE, "Makes the IDL input file to be translated into XML");

	exarg_install_arg ("add-search-path", NULL, EXARG_STRING, "Allows to configure a list of directories (separated by ;) that are added to the search path. This allows to locate DTD files required by the tool.");

	
	/* configure headers to be showed */
	exarg_add_usage_header  (HELP_HEADER);
	exarg_add_help_header   (HELP_HEADER);
	exarg_post_help_header  (POST_HEADER);
	exarg_post_usage_header (POST_HEADER);	

	/* init and parse arguments */
	exarg_parse (argc, argv);

	if (exarg_is_defined ("xdl-format") && 
	    exarg_is_defined ("idl-format")) {
		fprintf (stderr, "error: --xdl-format and --idl-format options are incompatible.");

		/* do nothing */
		return -1;
	}

	/* init vortex ctx */
	ctx = vortex_ctx_new ();
	vortex_support_init (ctx);

	/* do not use the add_search_path_ref version to force
	   xml-rpc-gen library to perform a local copy path */
	xml_rpc_support_add_search_path (".");

	/* add additional search path */
	if (exarg_is_defined ("add-search-path")) {
		paths    = axl_stream_split (exarg_get_string ("add-search-path"), 1, ";");
		iterator = 0;
		while (paths[iterator]) {
			/* log and add path */
			xml_rpc_report ("adding search path: %s", paths[iterator]);
			xml_rpc_support_add_search_path (paths[iterator]);
			
			/* update iterator */
			iterator++;
		} /* end while */

		/* free vstring */
		axl_freev (paths);
	} /* end if */

	/* install search paths */
	xml_rpc_support_add_search_path_ref (vortex_support_build_filename (INSTALL_DIR, NULL));

	/* init the axl library and load the DTD */
	axl_init ();
	
	/* load the DTD XML-RPC definition */
	dtd = axl_dtd_parse (XML_RPC_DTD, -1, &error);
	if (dtd == NULL) {
		/* show error found */
		fprintf (stderr, "error: unable to load dtd file '%s', check your installation, \n%s\n",
			 "xml-rpc.dtd", axl_error_get (error));
		axl_error_free (error);

		/* terminate xml-rpc-gen tool */
		xml_rpc_gen_finish ();
		return -1;
	}
	
	/* check and show program version */
	if (exarg_is_defined ("version")) {
		/* show current version */
		show_version ();

		/* terminate xml-rpc-gen tool */
		xml_rpc_gen_finish ();
		return 0;
	}

	/* check the number of parameters */
	if (exarg_get_params_num () > 0) {
		/* a xdl file was received */
		xml_rpc_gen_compile ();

		/* terminate the xml-rpc-gen tool */
		xml_rpc_gen_finish ();
		return 0;
	}

	/* show mini tutorial */
	show_tutorial ();

	/* terminate xml-rpc-gen tool */
	xml_rpc_gen_finish ();
	return 0;
}
int main (int argc, char ** argv) {

	/* the all frames received queue */
	VortexAsyncQueue * queue;
	VortexFrame      * frame;
	VortexChannel    * channel;

	/* count */
	int             iterator = 0;
	
	/* create the context */
	ctx = vortex_ctx_new ();

	/* init vortex library */
	if (! vortex_init_ctx (ctx)) {
		/* unable to init context */
		vortex_ctx_free (ctx);
		return -1;
	} /* end if */
	
	/* create the queue */
	queue = vortex_async_queue_new ();

	/* register a profile */
	vortex_profiles_register (ctx, PROFILE_URI,
				  /* no start handler, accept all channels */
				  NULL, NULL,
				  /* no close channel, accept all
				   * channels to be closed */
				  NULL, NULL,
				  vortex_channel_queue_reply, queue);
	
	/* now create a vortex server listening on several ports */
	vortex_listener_new (ctx, "0.0.0.0", "4400", NULL, NULL);


	/* and handle all frames received */
	while (axl_true) {

		/* get the next message, blocking at this call. 
		 *
		 * NOTE: This call must be evolved to something with
		 * error handling, timeout and channel piggyback
		 * support, but, for the example will do.  */
		frame = vortex_async_queue_pop (queue);

		if (frame == NULL) {
			/* for our example, the default action is:
			 *     keep on reading!.
			 */
			continue;
		}
		printf ("Frame received, content: %s\n",
			(char*) vortex_frame_get_payload (frame));

		/* get the channel */
		channel = vortex_frame_get_channel_ref (frame);
		
		/* reply */
		vortex_channel_send_rpy (channel, 
					 vortex_frame_get_payload (frame),
					 vortex_frame_get_payload_size (frame),
					 vortex_frame_get_msgno (frame));

		/* deallocate the frame received */
		vortex_frame_free (frame);

		iterator++;

		/* close the channel */
		if (iterator == 10) {
			/* close the channel */
			if (! vortex_channel_close (channel, NULL)) {
				printf ("Unable to close the channel!\n");
			}

			printf ("Ok, channel closed\n");

			/* reset */
			iterator = 0;
			
		} /* end if */
	} /* end while */
	
	
	/* end vortex internal subsystem (if no one have done it yet!) */
	vortex_exit_ctx (ctx, axl_true);
 
	/* that's all to start BEEPing! */
	return 0;     
 }  
예제 #7
0
/**
 * @brief    Start the TMLCoreListener.
 */
int TMLCoreListener::TMLCoreListener_Start(const char* host, const char*port, const char** resPort) 
{
  int iRet = TML_SUCCESS;

//tml_log(0xFFFFFFFF, "tmlCoreWrapper", "~tmlCoreWrapper", "POS", "Start-a");

  if (!m_hValidListenerThread){
    axl_bool bSuccess = axl_true;
    if (NULL == m_ctx){
      //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      // create vortex execution context because the listener needs it's own
      // A reference from the tmlCoreWrapper don't work because the listener and the sender must work on the same platform
      m_log->log (TML_LOG_VORTEX_CMD, "TMLCoreListener", "TMLCoreListener_Start", "Vortex CMD", "vortex_ctx_new");
      m_ctx = vortex_ctx_new ();
      /////////////////////////////////////////////////////////////
      // init vortex library /  SIDEX-72 has only to be done once
      m_log->log (TML_LOG_VORTEX_CMD, "TMLCoreListener", "TMLCoreListener_Start", "Vortex CMD", "vortex_init_ctx");
      bSuccess = vortex_init_ctx (m_ctx);
      if (axl_true != bSuccess){
        m_ctx = NULL;
        m_log->log ("TMLCoreListener", "TMLCoreListener;TMLCoreListener_Start", "vortex_init_ctx", "FAILLED");
        iRet = TML_ERR_LISTENER_NOT_INITIALIZED;
      }
    }
    tmlListenerObj* listenerMngObj = NULL;
    TML_LISTENER_HANDLE listenerHandle = TML_HANDLE_TYPE_NULL;
    TML_BOOL bHasAnyListener = TML_FALSE;
    if (TML_SUCCESS == iRet){
      bHasAnyListener = ((tmlCoreWrapper*)m_coreHandle)->tmlCoreWrapper_Has_Any_Listener();
      if (!bHasAnyListener){
        iRet = ((tmlCoreWrapper*)m_coreHandle)->tmlCoreWrapper_Listener_Create(host, port, &listenerHandle);
      }
      else{
        iRet = ((tmlCoreWrapper*)m_coreHandle)->tmlCoreWrapper_Get_Listener(0, &listenerHandle);
      }
      if (TML_SUCCESS == iRet){
        listenerMngObj = (tmlListenerObj*) listenerHandle;
        iRet = listenerMngObj->set_Enabled(TML_TRUE);
        if (TML_SUCCESS != iRet && !bHasAnyListener){
          ((tmlCoreWrapper*)m_coreHandle)->tmlCoreWrapper_Listener_Close(&listenerHandle);
        }
      }
    }
    if (TML_SUCCESS == iRet){
      //////////////////////////////////////////////////////////////
      // in case of port equals 0 the vortex_listener_new will find
      // the next free port, so I want to know it's identification:
      m_log->log (TML_LOG_VORTEX_CMD, "TMLCoreListener", "TMLCoreListener_Start", "Vortex CMD", "vortex_connection_get_port");
      iRet = listenerMngObj->getPort((char**)resPort);
      if (TML_SUCCESS != iRet){
        if (!bHasAnyListener){
          ((tmlCoreWrapper*)m_coreHandle)->tmlCoreWrapper_Listener_Close(&listenerHandle);
        }
        iRet = TML_ERR_LISTENER_NOT_INITIALIZED;
      }
    }
    if (TML_SUCCESS == iRet){
      m_hValidListenerThread = true;
    }
  }
  else{
    // Error / context already exists
    iRet = TML_ERR_LISTENER_ALREADY_STARTED;
  }
  return iRet;
}
예제 #8
0
파일: main.c 프로젝트: ASPLes/turbulence
int main (int argc, char ** argv)
{
	/* install headers for help */
	exarg_add_usage_header  (HELP_HEADER);
	exarg_add_help_header   (HELP_HEADER);
	exarg_post_help_header  (POST_HEADER);
	exarg_post_usage_header (POST_HEADER);

	/* install exarg options */
	exarg_install_arg ("version", "v", EXARG_NONE,
			   "Provides tool version");

	exarg_install_arg ("template", "t", EXARG_NONE,
			   "Produce a module xml template. Use this file as starting point to create a module. Then use --compile.");

	exarg_install_arg ("compile", "p", EXARG_STRING,
			   "Produces the source code associated to a module, using as description the xml module definition provided.");
	
	exarg_install_arg ("out-dir", "o", EXARG_STRING,
			   "Allows to configure the out put dir to be used. If not provided, '.' will be used as default value");

	exarg_install_arg ("enable-autoconf", "e", EXARG_NONE,
			   "Makes the output to produce autoconf support files: autogen.sh and configure.ac. It provides an starting point to build and compile your module.");

	exarg_install_arg ("debug2", NULL, EXARG_NONE,
			   "Increase the level of log to console produced.");

	exarg_install_arg ("debug3", NULL, EXARG_NONE,
			   "Makes logs produced to console to inclue more information about the place it was launched.");

	exarg_install_arg ("color-debug", "c", EXARG_NONE,
			   "Makes console log to be colorified.");	

	/* call to parse arguments */
	exarg_parse (argc, argv);

	ctx = turbulence_ctx_new ();

	/* create a vortex context and init the support module */
	vortex_ctx = vortex_ctx_new ();
	turbulence_ctx_set_vortex_ctx (ctx, vortex_ctx);
	vortex_support_init (vortex_ctx);

	/* configure context debug according to values received */
	turbulence_log_enable  (ctx, axl_true);
	turbulence_log2_enable (ctx, exarg_is_defined ("debug2"));
	turbulence_log3_enable (ctx, exarg_is_defined ("debug3"));

	/* check console color debug */
	turbulence_color_log_enable (ctx, exarg_is_defined ("color-debug"));

	/* check version argument */
	if (exarg_is_defined ("version")) {
		msg ("tbc-mod-gen version: %s", VERSION);
		goto finish;
	} else if (exarg_is_defined ("template")) {
		/* produce a template definition */
		tbc_mod_gen_template_create ();
	} else if (exarg_is_defined ("compile")) {
		/* compile template provided */
		tbc_mod_gen_compile ();
	} else {

		/* no argument was produced */
		error ("no argument was provided, try to use %s --help", argv[0]);
	}

 finish:
	/* terminate exarg */
	exarg_end ();

	/* cleanup support module */
	vortex_support_cleanup (vortex_ctx);
	axl_free (out_dir);

	/* free context */
	turbulence_ctx_free (ctx);
	vortex_ctx_free (vortex_ctx);

	return 0;
}