Example #1
0
/**
 * oh_uid_map_to_file: saves current uid and entity path mappings
 * to file, first element in file is 4 bytes for resource id,
 * then repeat EP_XREF structures holding uid and entity path pairings
 *
 * Return value: success 0, failed -1.
 **/
SaErrorT oh_uid_map_to_file(void)
{
        FILE *fp;

        if (!oh_uid_map_file) {
                return SA_OK;
        }

        uid_lock(&oh_uid_lock);

        fp = fopen(oh_uid_map_file, "wb");
        if(!fp) {
                CRIT("Configuration file '%s' could not be opened", oh_uid_map_file);
                uid_unlock(&oh_uid_lock);
                return SA_ERR_HPI_ERROR;
        }

        /* write resource id */
        if (fwrite((void *)&resource_id, sizeof(resource_id), 1, fp) != 1) {
		CRIT("write resource_id failed");
		fclose(fp);
                uid_unlock(&oh_uid_lock);
		return SA_ERR_HPI_ERROR;
	}

        /* write all EP_XREF data records */
        g_hash_table_foreach(oh_resource_id_table, write_ep_xref, fp);

        fclose(fp);

        uid_unlock(&oh_uid_lock);

        return SA_OK;
}
Example #2
0
int main(int argc, char **argv)
{
        oh_el *el;
        SaErrorT retc;


	/* test failure of oh_el_map_from_file with nonexistant filename */
	
	el = oh_el_create(20);

        retc = oh_el_map_from_file(el, "./notthere.data");
        if (retc == SA_OK) {
                CRIT("oh_el_map_from_file failed.");
                return 1;
	}

        /* close el */
        retc = oh_el_close(el);
        if (retc != SA_OK) {
                CRIT("oh_el_close on el failed.");
                return 1;
        }

        return 0;
}
Example #3
0
/* TODO: Documentation says "All  implementations  support  the  system-wide
 * real-time clock, which is identified by CLOCK_REALTIME. Check if the fallback
 * to unix time (without specifying the resolution) might be removed
 */
void
_ecore_time_init(void)
{
#ifdef HAVE_CLOCK_GETTIME
   struct timespec t;

   if (_ecore_time_clock_id != -1) return;

   if (!clock_gettime(CLOCK_MONOTONIC, &t))
     {
        _ecore_time_clock_id = CLOCK_MONOTONIC;
        DBG("using CLOCK_MONOTONIC.");
     }
   else if (!clock_gettime(CLOCK_REALTIME, &t))
     {
        /* may go backwards */
        _ecore_time_clock_id = CLOCK_REALTIME;
        WRN("CLOCK_MONOTONIC not available. Fallback to CLOCK_REALTIME.");
     }
   else
     {
        _ecore_time_clock_id = -2;
        CRIT("Cannot get a valid clock_gettime() clock id! "
             "Fallback to unix time.");
     }
#else
# ifndef HAVE_EVIL
#  warning "Your platform isn't supported yet"
   CRIT("Platform does not support clock_gettime. "
        "Fallback to unix time.");
# endif
#endif

   _ecore_time_loop_time = ecore_time_get();
}
Example #4
0
/* write a EL entry list to a file */
SaErrorT oh_el_map_to_file(oh_el *el, char *filename)
{
        FILE *fp;
        GList *node = NULL;

        if (el == NULL || filename == NULL) {
                return SA_ERR_HPI_INVALID_PARAMS;
        }

        fp = fopen(filename, "wb");
        if (!fp) {
                CRIT("EL file '%s' could not be opened", filename);
                return SA_ERR_HPI_ERROR;
        }
        
	for (node = el->list; node; node = node->next) {
                if (fwrite((void *)node->data, sizeof(oh_el_entry), 1, fp) != 1) {
			CRIT("Couldn't write to file '%s'.", filename);
			fclose(fp);
                	return SA_ERR_HPI_ERROR;
		}
        }

        fclose(fp);

        return SA_OK;
}
Example #5
0
int main(int argc, char **argv)
{
        oh_el *el;
        SaErrorT retc;


	/* test oh_el_info with info == NULL */

	el = oh_el_create(20);

        retc = oh_el_info(el, NULL);
        if (retc == SA_OK) {
                CRIT("oh_el_info failed.");
                return 1;
        }

        /* close el without saving to file*/
        retc = oh_el_close(el);
        if (retc != SA_OK) {
                CRIT("oh_el_close on el failed.");
                return 1;
        }

        return 0;
}
Example #6
0
int main(int argc, char **argv)
{
        oh_el *el;
	SaHpiTimeT timestamp = 0;
	SaErrorT retc;

	/* tests oh_el_timeset when el != NULL */

	el = oh_el_create(20);

	retc = oh_el_timeset(el, timestamp + 20);
	if (retc != SA_OK){
		CRIT("oh_el_timeset failed");
		return 1;
	}

	
        /* close el without saving to file*/
        retc = oh_el_close(el);
        if (retc != SA_OK) {
                CRIT("oh_el_close on el failed.");
                return 1;
        }


        return 0;
}
Example #7
0
void test_audio(void)
{
	struct aes_data aes_data;
	struct audio_stream audio_stream;
	char pcm_testdata[] = "pcm_testfile";

	CRIT("Testing audio send routines; no connections "
	     "will be made to the server\n");

	lt_set_level(LT_AUDIO_STREAM, LT_INFO);
	lt_set_level(LT_RAOP_PLAY_SEND_AUDIO, LT_INFO);

	generate_aes_data(&aes_data);

	syscalls_strncpy(audio_stream.pcm_data_file,
			 pcm_testdata,
			 sizeof(audio_stream.pcm_data_file));

	audio_stream.session_fd = syscalls_open("./fake_session",
						O_RDWR | O_CREAT | O_TRUNC,
						S_IRUSR | S_IWUSR);

	if (-1 == audio_stream.session_fd) {
		ERRR("Failed to open fake session file descriptor\n");
		goto out;
	}

	init_audio_stream(&audio_stream);
	send_audio_stream(&audio_stream, &aes_data);

out:
	CRIT("Audio test done; exiting\n");
	exit (1);
}
Example #8
0
static SaErrorT exechandlerdestroy(oHpiHandlerIdT handlerid)
{
   SaErrorT rv = SA_OK;
   if (copt.debug) DBG("Go and unload handler %u in domain %u", 
            handlerid, copt.domainid);
   
   rv = oHpiHandlerDestroy ( sessionid, handlerid );

   if (copt.debug) DBG("oHpiHandlerDestroy returned %s", oh_lookup_error(rv));

   if (rv==SA_OK) {
      printf("Handler %u successfully unloaded.\n\n", handlerid);
      return rv;
   }
   else if (rv==SA_ERR_HPI_NOT_PRESENT) {
      if (copt.domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) 
         CRIT("Handler %u is not existing in default domain.",
                handlerid);
      else CRIT("Handler %u is not existing in domain %u.",
                handlerid, copt.domainid);
      return rv;
   }
   else CRIT("\nHandler %u couldn't be unloaded, Returncode %s", 
                handlerid, oh_lookup_error(rv));
   return rv;
}
Example #9
0
/**
 * Initialize the configuration. Have to be called befor using the config variable.
 *
 * @return 0 on success, otherwise something else.
 */
int config_init() {
  strncpy(config.mqtt_client_id, CONF_DEFAULT_MQTT_CLIENT_ID, CONF_MAX_LENGTH_MQTT_CLIENT_ID);
  strncpy(config.mqtt_broker,    CONF_DEFAULT_MQTT_BROKER,    CONF_MAX_LENGTH_MQTT_BROKER);
  strncpy(config.mqtt_topic,     CONF_DEFAULT_MQTT_TOPIC,     CONF_MAX_LENGTH_MQTT_TOPIC);
  strncpy(config.log_file,       CONF_DEFAULT_LOG_FILE,       CONF_MAX_LENGTH_LOG_FILE);

  config.mqtt_port          = CONF_DEFAULT_MQTT_PORT;
  config.mqtt_clean_session = CONF_DEFAULT_MQTT_CLEAN_SESSION;
  config.mqtt_keepalive     = CONF_DEFAULT_MQTT_KEEPALIVE;
  config.verbose            = CONF_DEFAULT_VERBOSE;

  config.start_time.tv_sec  = CONF_DEFAULT_SEC;
  config.start_time.tv_usec = CONF_DEFAULT_USEC;
  
  config.record_start_time.tv_sec  = CONF_DEFAULT_RECORD_SEC;
  config.record_start_time.tv_usec = CONF_DEFAULT_RECORD_USEC;

  config.ignore_timing      = CONF_DEFAULT_IGNORE_TIMING;
  config.repeat             = CONF_DEFAULT_REPEAT;

  config.mosq = NULL;
  if( 0 > sigemptyset(&config.sigset) ) {
    CRIT("sigemptyset()");
  }

  if( 0 > sigaddset(&config.sigset, SIGINT) ) {
    CRIT("sigaddset()");
  }

  return 0;
}
Example #10
0
/**
 * oh_ssl_init
 *
 * Intialize the OpenSSL library.  Note that the calls used in this routine
 * set up global data and are only to be called once for an SSL-based program.
 * To enforce this while allowing multiple callers (plugins) to initialize
 * the library, we use a static global variable to mark when we've done the
 * initialization.
 *
 * Note that the thread-safe initialization portion requires that
 * g_thread_init() has already been called, so don't call this routine
 * before then.
 *
 * Return value: 0 for success, -1 for failure
 **/
int		oh_ssl_init(void)
{
	if (! oh_ssl_init_done) {	/* Do this only once */
		oh_ssl_init_done = 1;

		/* Load error strings to provide human-readable error
		 * messages
		 */
		SSL_load_error_strings();
		ERR_load_BIO_strings();

		/* Initialize the SSL library */
		if (! SSL_library_init()) {
			CRIT("SSL_library_init() failed");
			return(-1);
		}

#ifndef NO_SSL_RAND_SEED		/* In case this isn't portable */
		/* Actions to seed PRNG */
		RAND_load_file("/dev/urandom", 1024);
#endif

		/* Set up multi-thread protection functions */
		if (thread_setup() ) {
			CRIT("SSL multi-thread protection setup call failed");
			return(-1);
		}

	}

	return(0);			/* Successful return */
}
Example #11
0
static SaErrorT exechandlercreate (int argc, char **argv, int i)
{
   SaErrorT rv = SA_OK;
   oHpiHandlerIdT handlerid = 0;
   GHashTable * createparams = g_hash_table_new_full (
      g_str_hash, g_str_equal, g_free, g_free);
   SaHpiBoolT pluginnamegiven = SAHPI_FALSE;

   if (copt.debug) DBG ("createhandler started\n");

   while (i<argc){
      if (strcmp(argv[i],"-f")==0) {
         CRIT("input from file not implemented yet");
         return (SA_OK);
      }
      else if (++i<argc) {
         if (strcmp(argv[i-1],"plugin")==0) pluginnamegiven = SAHPI_TRUE;
         g_hash_table_insert( createparams,
            g_strdup( argv[i-1] ), 
            g_strdup( argv[i] ));
          if (copt.debug) DBG ("Pair of arguments: %s - %s\n",
            g_strdup( argv[i-1] ), 
            g_strdup( argv[i] ));
      }
      else // parameters not in pairs
         return (SA_ERR_HPI_INVALID_PARAMS);
      i++;
   }

   if (!pluginnamegiven) {
      CRIT("You must enter a valid plugin name");
      return (SA_ERR_HPI_INVALID_PARAMS);
   }

   rv = ohc_session_open_by_option ( &copt, &sessionid);
   if (rv != SA_OK) return rv;

   if (copt.debug) DBG("Calling oHpiHandlerCreate!");
   rv = oHpiHandlerCreate(sessionid, createparams, &handlerid );

   if ( rv != SA_OK ) {
      CRIT("oHpiHandlerCreate returned %s", oh_lookup_error(rv));
      saHpiSessionClose(sessionid);
      return(rv);
   }
   
   printf("Handler %u successfully created!\n", handlerid);

   rv = saHpiSessionClose(sessionid);
        
   return(SA_OK);

}
Example #12
0
/**
 * main: Announcement test
 *
 * This test adds one announcement to the list
 *
 * Return value: 0 on success, 1 on failure
 **/
int main(int argc, char **argv)
{
        oh_announcement *ann;
        SaHpiAnnouncementT announ;
        SaErrorT rc;

        announ.EntryId = 0;         // modified by oh_announcement_append
        announ.Timestamp = 0;       // modified by oh_announcement_append
        announ.AddedByUser = FALSE; // modified by oh_announcement_append
        announ.Severity = SAHPI_CRITICAL;
        announ.Acknowledged = FALSE;
        announ.StatusCond.Type= SAHPI_STATUS_COND_TYPE_SENSOR;
        announ.StatusCond.Entity.Entry[0].EntityType = SAHPI_ENT_SYSTEM_BOARD;
        announ.StatusCond.Entity.Entry[0].EntityLocation = 1;
        announ.StatusCond.Entity.Entry[1].EntityType = SAHPI_ENT_ROOT;
        announ.StatusCond.Entity.Entry[1].EntityLocation = 0;
        announ.StatusCond.DomainId = 1;
        announ.StatusCond.ResourceId = 1;
        announ.StatusCond.SensorNum = 1;
        announ.StatusCond.EventState = SAHPI_ES_UNSPECIFIED;
        announ.StatusCond.Name.Length = 5;
        memcpy(&announ.StatusCond.Name.Value,"announ", 5);
        announ.StatusCond.Mid = 123;
        /* we will not worry about the Data field for this test */

        ann = oh_announcement_create();

        rc = oh_announcement_append(ann, &announ);

        announ.Severity = SAHPI_MAJOR;
        rc = oh_announcement_append(ann, &announ);

        announ.Severity = SAHPI_MINOR;
        rc = oh_announcement_append(ann, &announ);

        rc = oh_announcement_ack(ann, 2, SAHPI_MAJOR);
        if(rc != SA_OK) {
                CRIT("on_announcement_ack returned %d.", rc);
                return 1;
        }

        rc = oh_announcement_get(ann, 2, &announ);
        if(rc != SA_OK) {
                CRIT("on_announcement_get returned %d.", rc);
                return 1;
        }
        if(announ.Acknowledged != TRUE) {
                CRIT("announ.Acknowledged invalid");
                return 1;
        }

        return 0;
}
Example #13
0
int main(int argc, char **argv)
{
        oh_el *el;
        SaErrorT retc;
	int x;
	SaHpiEventT event;
	static char *data[5] = {
        	"Test data one",
		"Test data two",
		"Test data three",
		"Test data four",
		"Test data five"
	};


	/* test oh_el_prepend with existing EL*/
	el = oh_el_create(20);


        /* get EL from file (el) */
        retc = oh_el_map_from_file(el, "./elTest.data");
        if (retc != SA_OK) {
                CRIT("oh_el_map_from_file failed.");
                return 1;
        }

	/* add 5 more events to el */
	for(x=0;x<5;x++){
        	event.Source = 1;
        	event.EventType = SAHPI_ET_USER;
        	event.Timestamp = SAHPI_TIME_UNSPECIFIED;
        	event.Severity = SAHPI_DEBUG;
		strcpy((char *) &event.EventDataUnion.UserEvent.UserEventData.Data, data[x]);


        	retc = oh_el_prepend(el, &event, NULL, NULL);
        	if (retc != SA_OK) {
              	  CRIT("oh_el_append failed.");
               	  return 1;
        	}       
	}

        /* close el */
        retc = oh_el_close(el);
        if (retc != SA_OK) {
                CRIT("oh_el_close on el failed.");
                return 1;
        }


        return 0;
}
Example #14
0
static gboolean
IsSimpleType( tMarshalType type )
{
  switch( type )
     {
       case eMtVoid:
       case eMtInt8:
       case eMtUint8:
       case eMtInt16:
       case eMtUint16:
       case eMtInt32:
       case eMtUint32:
       case eMtInt64:
       case eMtUint64:
       case eMtFloat32:
       case eMtFloat64:
	    return TRUE;

       case eMtArray:
       case eMtVarArray:
       case eMtStruct:
       case eMtStructElement:
       case eMtUnion:
       case eMtUnionElement:
       case eMtUserDefined:
	    return FALSE;

       default:
            CRIT( "Unknown marshal type %d!", type );
	    return FALSE;
     }
}
Example #15
0
static int process_hpi_event(struct oh_domain *d, struct oh_event *e)
{
        int i;
        GArray *sessions = NULL;
        SaHpiSessionIdT sid;
        SaHpiEventT *event = NULL;
        SaHpiRptEntryT *resource = NULL;
        SaHpiRdrT *rdr = NULL;

        if (!d || !e) return -1;

        event = &e->event;
        resource = &e->resource;
        rdr = (e->rdrs) ? (SaHpiRdrT *)e->rdrs->data : NULL;

        if (event->EventType == SAHPI_ET_USER) {
                resource->ResourceCapabilities = 0;
                if (rdr) rdr->RdrType = SAHPI_NO_RECORD;
        }

        oh_add_event_to_del(d, e);
        DBG("Added event to EL");

        /*
         * Here is the SESSION MULTIPLEXING code
         */
        sessions = oh_list_sessions(d->id);
        if (!sessions) {
                CRIT("Error: Got an empty session list on domain id %u", d->id);
                return -2;
        }
        DBG("Got session list for domain %u", d->id);

        /* Drop events if there are no sessions open to receive them.
         */
        if (sessions->len < 1) {
                g_array_free(sessions, TRUE);
                DBG("No sessions open for event's domain %u. "
                    "Dropping hpi_event", d->id);
                return 0;
        }

        /* multiplex event to the appropriate sessions */
        for (i = 0; i < sessions->len; i++) {
                SaHpiBoolT is_subscribed = SAHPI_FALSE;
#if defined(__sparc) || defined(__sparc__)
                sid = ((SaHpiSessionIdT *)((void *)(sessions->data)))[i];
#else
                sid = g_array_index(sessions, SaHpiSessionIdT, i);
#endif
                oh_get_session_subscription(sid, &is_subscribed);
                if (is_subscribed) {
                        oh_queue_session_event(sid, e);
                }
        }
        g_array_free(sessions, TRUE);
        DBG("done multiplexing event into sessions");

        return 0;
}
Example #16
0
/*
 * build_uid_map_data: used by uid_map_from_file(),  recursively
 * reads map file and builds two hash tables and EP_XREF data
 * structures
 *
 * @file: key into a GHashTable
 *
 * Return value: success 0, error -1.
 */
static gint build_uid_map_data(FILE *fp)
{
        EP_XREF *ep_xref;
        EP_XREF ep_xref1;
        gpointer value;
        gpointer key;

        while (fread(&ep_xref1, sizeof(EP_XREF), 1, fp) == 1) {

                /* copy read record from ep_xref1 to malloc'd ep_xref */
                ep_xref = g_new0(EP_XREF, 1);
                if (!ep_xref)
                        return -1;
                memcpy(ep_xref, &ep_xref1, sizeof(EP_XREF));

                value = (gpointer)ep_xref;

                /* entity path based key */
                key = (gpointer)&ep_xref->entity_path;
                g_hash_table_insert(oh_ep_table, key, value);

                /* resource id based key */
                key = (gpointer)&ep_xref->resource_id;
                g_hash_table_insert(oh_resource_id_table, key, value);
        }

        if ((feof(fp) == 0) || (ferror(fp) != 0)) {
                CRIT("error building ep xref from map file");
                return -1;
        }
        return 0;
}
Example #17
0
int serial_init(char *port) {
  struct termios options;
  int fd;

  INFO(1, "Opening serial port %s\n", port);

  fd = open(port, O_RDWR | O_NOCTTY | O_NDELAY);
  if (!fd) {
    CRIT(1, "Error opening serial port: %d (%s)", errno, strerror(errno));
  }

  /* set raw input, 1 second timeout */
  fcntl(fd, F_SETFL, 0);
  tcgetattr(fd, &options);
  options.c_cflag |= (CLOCAL | CREAD);
  options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
  options.c_oflag &= ~OPOST;
  options.c_cc[VMIN]  = 0;
  options.c_cc[VTIME] = 10;

  options.c_cflag &= ~PARENB;
  options.c_cflag &= ~CSTOPB;
  options.c_cflag &= ~CSIZE;
  options.c_cflag |= CS8;

  cfsetispeed(&options, B19200);
  cfsetospeed(&options, B19200);

  tcsetattr(fd, TCSANOW, &options);

  return fd;
}
Example #18
0
/* read a EL entry list from a file */
SaErrorT oh_el_map_from_file(oh_el *el, char *filename)
{
        FILE *fp;
        oh_el_entry entry;

        /* check el params and state */
        if (el == NULL || filename == NULL) {
                return SA_ERR_HPI_INVALID_PARAMS;
        } else if (el->info.Enabled == FALSE) {
                return SA_ERR_HPI_INVALID_REQUEST;
        }

        fp = fopen(filename, "rb");
        if (!fp) {
                CRIT("EL file '%s' could not be opened", filename);
                return SA_ERR_HPI_ERROR;
        }

        oh_el_clear(el); // ensure list is empty
        while (fread(&entry, sizeof(oh_el_entry), 1, fp) == 1) {
		oh_el_entry *elentry = g_new0(oh_el_entry, 1);
		el->nextid = entry.event.EntryId;
		el->nextid++;
		*elentry = entry;
		el->list = g_list_append(el->list, elentry);
        }

        fclose(fp);

        return SA_OK;
}
Example #19
0
/**
 * Retrieves the current system time as a floating point value in seconds.
 *
 * This uses a monotonic clock and thus never goes back in time while
 * machine is live (even if user changes time or timezone changes,
 * however it may be reset whenever the machine is restarted).
 *
 * @see ecore_loop_time_get().
 * @see ecore_time_unix_get().
 *
 * @return The number of seconds. Start time is not defined (it may be
 *         when the machine was booted, unix time, etc), all it is
 *         defined is that it never goes backwards (unless you got big critical
 *         messages when the application started).
 */
EAPI double
ecore_time_get(void)
{
#ifdef HAVE_CLOCK_GETTIME
   struct timespec t;

   if (EINA_UNLIKELY(_ecore_time_clock_id < 0))
      return ecore_time_unix_get();

   if (EINA_UNLIKELY(clock_gettime(_ecore_time_clock_id, &t)))
     {
        CRIT("Cannot get current time.");
        /* Try to at least return the latest value retrieved*/
        return _ecore_time_loop_time;
     }

   return (double)t.tv_sec + (((double)t.tv_nsec) / 1000000000.0);
#else
# ifdef HAVE_EVIL
   return evil_time_get();
# else
   return ecore_time_unix_get();
# endif
#endif
}
Example #20
0
void log_output_test(const char *file, Base::LOGLEVEL level)
{
	int i = 5;
	float f = 9.5;
	char str[] = "test";

	if(file != NULL) {
		Base::LogInit(file, level);
	}

	EMERG("---------log level: %d-----------\n", level);

	DEBUG("Log for Debug i=%d f=%f str=%s \n", i, f, str);
	INFO("Log for Info i=%d f=%f str=%s \n", i, f, str);
	NOTICE("Log for Notice i=%d f=%f str=%s \n", i, f, str);
	WARN("Log for Warning i=%d f=%f str=%s \n", i, f, str);
	ERROR("Log for Error i=%d f=%f str=%s \n", i, f, str);
	CRIT("Log for Crit i=%d f=%f str=%s \n", i, f, str);
	ALERT("Log for Alert i=%d f=%f str=%s \n", i, f, str);
	EMERG("Log for Emerg i=%d f=%f str=%s \n", i, f, str);

	if(file != NULL) {
		Base::LogUninit();
	}

	return;
}
Example #21
0
static 
SaErrorT exechandlerinfo(oHpiHandlerIdT handlerid)
{
   oHpiHandlerInfoT handlerinfo;
   SaErrorT rv = SA_OK;
   GHashTable *handlerconfig = g_hash_table_new_full(
                        g_str_hash, g_str_equal,
                        g_free, g_free );

   if (copt.debug) DBG("Go and display handler info for %u", handlerid);
   
   rv = oHpiHandlerInfo ( sessionid, handlerid, &handlerinfo, handlerconfig );

   if (rv==SA_ERR_HPI_NOT_PRESENT) {
      if (copt.domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) 
         CRIT("Handler %u is not existing in default domain.",
                handlerid);
      else CRIT("Handler %u is not existing in domain %u.",
                handlerid, copt.domainid);
      g_hash_table_destroy(handlerconfig);
      return SA_OK;
   }
   else if (rv!=SA_OK) {
      CRIT("oHpiHandlerInfo returned %s", oh_lookup_error(rv));
      g_hash_table_destroy(handlerconfig);
      return rv;
   }
   if (copt.domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) 
      printf("\n\nInfo for handler %u in default domain:\n\n",handlerid);
   else printf("\n\nInfo for handler %u in domain %u:\n\n",handlerid, copt.domainid);
   printf("Plugin name: %s\n",(const char *)handlerinfo.plugin_name);

   printf("Root ");
   oh_print_ep (&(handlerinfo.entity_root),0);

   printf("Failed attempts to load handler: %u\n",handlerinfo.load_failed);

   printf("\nHandler configuration:\n");
   printf ("   plugin %s\n", (const char *)handlerinfo.plugin_name);
   printf ("   entity_root \"%s\"\n",(const char *) g_hash_table_lookup(handlerconfig, "entity_root")); 
   g_hash_table_foreach(handlerconfig, print_pair, NULL);
   printf("\n\n");

   g_hash_table_destroy(handlerconfig);
   return rv;
}
Example #22
0
bool cHandler::Init()
{
    bool rc;

    rc = cConsole::Init();
    if ( !rc ) {
        CRIT( "cannot initialize console" );
        return false;
    }
    rc = m_timers.Start();
    if ( !rc ) {
        CRIT( "cannot start timers" );
        return false;
    }

    return true;
}
Example #23
0
File: worker.c Project: maczpc/csf
static void
set_maxfd(void)
{
	struct rlimit rl;

	if (getrlimit(RLIMIT_NOFILE, &rl) < 0) {
		CRIT("can't get file limit");
	} else {
		rl.rlim_cur = maxfd;
		if (rl.rlim_cur > rl.rlim_max) {
			rl.rlim_cur = rl.rlim_max;
			maxfd = rl.rlim_cur;
		}
		if (setrlimit(RLIMIT_NOFILE, &rl) < 0) {
			CRIT("setrlimit() error! ");
		}
	}
}
Example #24
0
/**
 * oh_ssl_ctx_init
 *
 * Create a new SSL_CTX object as a framework for TLS/SSL enabled functions.
 * In particular:
 * - Creates a new CTX object with default option values
 * - Sets common compatibility options
 * - Sets the default locations for trusted CA certificates.
 *   SSL_CTX_set_default_verify_paths() is used to add system-wide default
 *   certificate paths to the verify CApath without having to specify a
 *   default location.  The intent is that the distribution's configured
 *   location will be used.
 *
 * Return value: pointer to SSL_CTX or NULL for failure
 **/
SSL_CTX         *oh_ssl_ctx_init()
{
        SSL_CTX         *ctx;

        ctx = SSL_CTX_new(SSLv23_client_method());
        if (ctx == NULL) {
                CRIT("SSL_CTX_new() failed");
                return(NULL);
        }

        SSL_CTX_set_options(ctx, SSL_OP_TLS_ROLLBACK_BUG | SSL_OP_ALL);

        if (! SSL_CTX_set_default_verify_paths(ctx)) {
                CRIT("SSL_CTX_set_default_verify_paths() failed");
                return(NULL);
        }

        return(ctx);
}
Example #25
0
File: main.c Project: Limsik/e17
void
evas_debug_error(void)
{
   if (!_evas_debug_init)
     {
        _evas_debug_init_from_env();
     }
   if (_evas_debug_show == _EVAS_DEBUG_SHOW)
     CRIT("Evas Magic Check Failed!!!");
}
Example #26
0
int locate_cmp(sxi_hdist_t *model1, sxi_hdist_t *model2, uint64_t hash, int replica, int bidx)
{
    sx_nodelist_t *nodelist1, *nodelist2;
    int i;

    nodelist1 = sxi_hdist_locate(model1, hash, replica, bidx);
    if(!nodelist1) {
	CRIT("Can't locate hash with model1");
	return 1;
    }

    nodelist2 = sxi_hdist_locate(model2, hash, replica, bidx);
    if(!nodelist1) {
	CRIT("Can't locate hash with model2");
	sx_nodelist_delete(nodelist1);
	return 1;
    }

    if(sx_nodelist_count(nodelist1) != sx_nodelist_count(nodelist2) || sx_nodelist_count(nodelist1) != replica) {
	CRIT("Numbers of target nodes don't match");
	sx_nodelist_delete(nodelist1);
	sx_nodelist_delete(nodelist2);
	return 1;
    }

    if(dbg)
	fprintf(stderr, "Locate (hash: %llx, replica: %u, bidx: %d) = ", (unsigned long long) hash, replica, bidx);
    for(i = 0; i < sx_nodelist_count(nodelist1); i++) {
	if(strcmp(sx_node_uuid_str(sx_nodelist_get(nodelist1, i)), sx_node_uuid_str(sx_nodelist_get(nodelist2, i)))) {
	    CRIT("Different nodes reported for duplicate models");
	    sx_nodelist_delete(nodelist1);
	    sx_nodelist_delete(nodelist2);
	    return 1;
	}
	if(dbg)
	    fprintf(stderr, "%s ", sx_node_addr(sx_nodelist_get(nodelist1, i)));
    }
    if(dbg)
	fprintf(stderr, "\n");
    sx_nodelist_delete(nodelist1);
    sx_nodelist_delete(nodelist2);
    return 0;
}
Example #27
0
/**
 * oh_ssl_ctx_free
 * @ctx:        pointer to SSL_CTX as returned by oh_ssl_ctx_init()
 *
 * Free an SSL_CTX object
 *
 * Return value: 0 for success, -1 for failure
 **/
int             oh_ssl_ctx_free(SSL_CTX *ctx)
{
        if (ctx == NULL) {
                CRIT("unexpected NULL ctx pointer");
                return(-1);
        }

        SSL_CTX_free(ctx);

        return(0);
}
Example #28
0
File: main.c Project: Limsik/e17
void
evas_debug_input_null(void)
{
   if (!_evas_debug_init)
     {
        _evas_debug_init_from_env();
     }
   if (_evas_debug_show == _EVAS_DEBUG_SHOW)
     CRIT("Input object pointer is NULL!");
   if (_evas_debug_abort) abort();
}
Example #29
0
static void lxc_monitord_sockfd_remove(struct lxc_monitor *mon, int fd) {
	int i;

	if (lxc_mainloop_del_handler(&mon->descr, fd))
		CRIT("fd:%d not found in mainloop", fd);
	close(fd);

	for (i = 0; i < mon->clientfds_cnt; i++) {
		if (mon->clientfds[i] == fd)
			break;
	}
	if (i >= mon->clientfds_cnt) {
		CRIT("fd:%d not found in clients array", fd);
		lxc_monitord_cleanup();
		exit(EXIT_FAILURE);
	}

	memmove(&mon->clientfds[i], &mon->clientfds[i+1],
		(mon->clientfds_cnt - i - 1) * sizeof(mon->clientfds[0]));
	mon->clientfds_cnt--;
}
Example #30
0
int main(int argc, char **argv)
{
    oh_el *el;
    SaErrorT retc;

    /* map el from file*/
    el = oh_el_create(20);
    retc = oh_el_map_from_file(el, "./elTest.data");
    if (retc != SA_OK) {
        CRIT("oh_el_map_from_file failed.");
        return 1;
    }

    retc = oh_el_overflowreset(el);
    if (retc != SA_OK) {
        CRIT("el info.OverflowFlagreset failed.");
        return 1;
    }

    return 0;
}