Esempio n. 1
0
pwr_tStatus
plc_UtlWaitForPlc ()
{
  pwr_tStatus sts = 1;
  qcom_sQid wait_q;

  if (!qcom_CreateQ(&sts, &wait_q, NULL, "plcUtlWaitForPlc"))
    return sts;

  qcom_WaitAnd(&sts, &wait_q, &qcom_cQini, ini_mEvent_newPlcStartDone, qcom_cTmoEternal);

  qcom_DeleteQ(NULL, &wait_q);

  return sts;
}
Esempio n. 2
0
int main()
{
	logg_ctx	loggctx;
	pwr_tStatus	sts;
	pwr_tUInt32	ident;
	char		*msg;
	logg_t_loggconf_list	*conflist_ptr;
	int		i;

#if defined OS_LYNX || defined OS_LINUX

	/* Exit handler */

	atexit(&exit_hdlr);
	signal(SIGINT, interrupt_hdlr);

#endif

	sts = gdh_Init("rs_remote_logg");
	if (EVEN(sts)) LogAndExit(sts);

	/* Errh init */

	errh_Init("rs_remote_logg", 0);

	/* Initialize qcom que attributes */

	remlogg_qattr.type = qcom_eQtype_private;
	remlogg_qattr.quota = 100;

	/* Delete the queue if it exists */

        qcom_DeleteQ(&sts, &remlogg_qid);
	
	/* Create the remlogg queue */

        if (!qcom_CreateQ(&sts, &remlogg_qid, &remlogg_qattr, "Logg")) {
	  LogAndExit(sts);
        }

	/* Bind it to rt_ini event-queue */
	
        if (!qcom_Bind(&sts, &remlogg_qid, &qcom_cQini)) {
          errh_Fatal("qcom_Bind, %m", sts);
//          errh_SetStatus( PWR__SRVTERM);
          exit(-1);
        }

	loggctx = calloc( 1 , sizeof( *loggctx));
	if ( loggctx == 0 ) LogAndExit( REM__NOMEMORY);

	sts = logg_init( loggctx);
	if ( EVEN(sts)) LogAndExit(sts);
	
	for (;;)
	{
	  /* Get logg message */
	  sts = logg_get_message( loggctx, &ident, &msg);
	  if ( EVEN(sts))
	  {
	    Log( REM__LOGGRCV, sts);
	  }
	  else if ( sts != REM__TIMEOUT)
	  {
	    logg_print( loggctx, ident, msg);
	    sts = logg_free_message();
	  }

	  /* Check if its time to open any file... */
	  conflist_ptr = loggctx->loggconflist;
	  for ( i = 0; i < loggctx->loggconf_count; i++)
	  {
	    if ( conflist_ptr->loggconf->NewVersion)
	    {
	      conflist_ptr->loggconf->NewVersion = 0;
	      if ( conflist_ptr->file_open)
	      {
	        fclose( conflist_ptr->outfile);
	        conflist_ptr->file_open = 0;
	        sts = logg_open_file( conflist_ptr, 1);
	      }
	    }
	    else if ( !conflist_ptr->file_open)
	    {
	      sts = logg_open_file( conflist_ptr, 0);
	    }
	    conflist_ptr++;
	  }
	}
}