本文整理汇总了C++中pmesg函数的典型用法代码示例。如果您正苦于以下问题:C++ pmesg函数的具体用法?C++ pmesg怎么用?C++ pmesg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pmesg函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: oph_id_to_index
long long oph_id_to_index(UDF_INIT * initid, UDF_ARGS * args, char *is_null, char *error)
{
long long size, id = *((long long *) args->args[0]) - 1, index = id;
if (id < 0) {
pmesg(LOG_ERROR, __FILE__, __LINE__, "Invalid value %d\n", id);
*is_null = 0;
*error = 1;
return -1;
}
unsigned int counter = 1;
while (counter < args->arg_count) {
size = *((long long *) args->args[counter++]);
index = id % size;
id = (id - index) / size;
}
*is_null = 0;
*error = 0;
return index + 1;
}
开发者ID:indigo-dc,项目名称:ophidia-primitives,代码行数:19,代码来源:oph_id_to_index.c
示例2: latestForwardedTableFind
/* Returns the latestForwarded_table_entry pointer to the latestForwardedTable
* entry representing the neighbor node address passed as a parameter. If
* no such neighbor exists, returns NULL.
*/
latestForwarded_table_entry* latestForwardedTableFind(rimeaddr_t *neighbor_p) {
pmesg(200, "%s :: %s :: Line #%d\n", __FILE__, __func__, __LINE__);
static uint8_t i = 0;
static bool isBroadcast = 0;
isBroadcast = rimeaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
&rimeaddr_null);
if (isBroadcast)
return NULL;
for (i = 0; i < latestForwardedTableActive; i++) {
if (rimeaddr_cmp(&(latestForwardedTable[i].neighbor), neighbor_p))
break;
}
if(i == latestForwardedTableActive)
return NULL;
return &(latestForwardedTable[i]);
}
开发者ID:RanHuang,项目名称:nick-project-contiki,代码行数:24,代码来源:BcpForwardingEngine.c
示例3: conditionalFQDiscard
void conditionalFQDiscard() {
pmesg(200, "%s :: %s :: Line #%d\n", __FILE__, __func__, __LINE__);
static fe_queue_entry_t* discardQe;// = memb_alloc(&send_stack_mem);
if(list_length(send_stack) >= SEND_STACK_SIZE) {
discardQe = list_chop(send_stack);
list_remove(message_pool, discardQe -> msg);
memb_free(&message_pool_mem, discardQe -> msg);
list_remove(q_entry_pool, discardQe);
memb_free(&q_entry_pool_mem, discardQe);
#ifdef VIRTQ
// Dropped a data packet, increase virtual queue size
virtualQueueSize++;
#endif
}
}
开发者ID:RanHuang,项目名称:nick-project-contiki,代码行数:20,代码来源:BcpForwardingEngine.c
示例4: oph_hier_get_attribute
int oph_hier_get_attribute(const char *name, oph_hier_attribute * attribute, const char *hierarchy, oph_hier_document * document)
{
if (!name || !strlen(name)) {
pmesg(LOG_ERROR, __FILE__, __LINE__, "Property '%s' not given\n", OPH_HIER_STR_NAME);
return OPH_HIER_DATA_ERR;
}
if (!hierarchy || !strlen(hierarchy))
pmesg(LOG_WARNING, __FILE__, __LINE__, "Hierarchy not given\n", OPH_HIER_STR_NAME);
int result;
if ((result = oph_hier_basic_control(document)) != OPH_HIER_OK)
return result;
xmlXPathContextPtr context = xmlXPathNewContext(document->document);
if (!context) {
pmesg(LOG_ERROR, __FILE__, __LINE__, "Context is not gettable\n");
return OPH_HIER_SYSTEM_ERR;
}
char target[OPH_HIER_MAX_STRING_LENGTH];
if (hierarchy && (strlen(hierarchy) > 0))
sprintf(target, "//%s[@%s='%s']/%s[@%s='%s']", OPH_HIER_STR_HIERARCHY, OPH_HIER_STR_NAME, hierarchy, OPH_HIER_STR_ATTRIBUTE, OPH_HIER_STR_LONG_NAME, name);
else
sprintf(target, "//%s[@%s()='%s']", OPH_HIER_STR_ATTRIBUTE, OPH_HIER_STR_LONG_NAME, name);
xmlXPathObjectPtr object = xmlXPathEvalExpression((xmlChar *) target, context);
if (!object) {
xmlXPathFreeContext(context);
pmesg(LOG_ERROR, __FILE__, __LINE__, "XPath error\n");
return OPH_HIER_SYSTEM_ERR;
}
xmlNodeSetPtr nodeset = object->nodesetval;
if (!nodeset || !nodeset->nodeNr) {
pmesg(LOG_ERROR, __FILE__, __LINE__, "No attribute '%s'\n", name);
result = OPH_HIER_DATA_ERR;
} else if ((nodeset->nodeNr > 1) && hierarchy && (strlen(hierarchy) > 0)) {
pmesg(LOG_ERROR, __FILE__, __LINE__, "Malformed file\n");
result = OPH_HIER_XML_ERR;
} else
result = _oph_hier_get_attribute(nodeset->nodeTab[0], attribute);
xmlXPathFreeObject(object);
xmlXPathFreeContext(context);
if (result == OPH_HIER_OK)
pmesg(LOG_DEBUG, __FILE__, __LINE__, "Attribute '%s' read\n", name);
return result;
}
开发者ID:indigo-dc,项目名称:ophidia-analytics-framework,代码行数:42,代码来源:oph_hierarchy_library.c
示例5: memory_check
int memory_check() // Check for memory swap
{
struct sysinfo info;
if (pthread_rwlock_wrlock(&syslock)) return OPH_SERVER_UTIL_ERROR;
if (sysinfo(&info))
{
pthread_rwlock_unlock(&syslock);
return OPH_SERVER_UTIL_ERROR;
}
if (pthread_rwlock_unlock(&syslock)) return OPH_SERVER_UTIL_ERROR;
if ((info.freeram + info.bufferram < OPH_MIN_MEMORY) && (info.totalswap - info.freeswap > OPH_MIN_MEMORY))
{
pmesg(LOG_ERROR, __FILE__, __LINE__, "Out of memory\n");
return OPH_SERVER_UTIL_ERROR;
}
return OPH_SERVER_UTIL_SUCCESS;
}
开发者ID:AAmedeo,项目名称:ophidia-io-server,代码行数:22,代码来源:oph_server_utility.c
示例6: _oph_odb_update_session_label
int _oph_odb_update_session_label(ophidiadb * oDB, const char *sessionid, char *label, pthread_mutex_t * flag)
{
if (!oDB || !sessionid) {
pmesg_safe(flag, LOG_ERROR, __FILE__, __LINE__, "Null input parameter\n");
return OPH_ODB_NULL_PARAM;
}
if (oph_odb_check_connection_to_ophidiadb(oDB)) {
pmesg_safe(flag, LOG_ERROR, __FILE__, __LINE__, "Unable to reconnect to OphidiaDB.\n");
return OPH_ODB_MYSQL_ERROR;
}
int id_session;
if (_oph_odb_retrieve_session_id(oDB, sessionid, &id_session, flag)) {
pmesg_safe(flag, LOG_ERROR, __FILE__, __LINE__, "Unable to retrieve session id\n");
return OPH_ODB_MYSQL_ERROR;
}
char insertQuery[MYSQL_BUFLEN];
int n = snprintf(insertQuery, MYSQL_BUFLEN, MYSQL_QUERY_UPDATE_OPHIDIADB_SESSION_LABEL, label ? label : "", id_session);
if (n >= MYSQL_BUFLEN) {
pmesg_safe(flag, LOG_ERROR, __FILE__, __LINE__, "Size of query exceed query limit.\n");
return OPH_ODB_STR_BUFF_OVERFLOW;
}
if (mysql_set_server_option(oDB->conn, MYSQL_OPTION_MULTI_STATEMENTS_ON)) {
pmesg(LOG_ERROR, __FILE__, __LINE__, "MySQL query error: %s\n", mysql_error(oDB->conn));
return OPH_ODB_MYSQL_ERROR;
}
if (mysql_query(oDB->conn, insertQuery)) {
pmesg_safe(flag, LOG_ERROR, __FILE__, __LINE__, "MySQL query error: %s\n", mysql_error(oDB->conn));
return OPH_ODB_MYSQL_ERROR;
}
return OPH_ODB_SUCCESS;
}
开发者ID:indigo-dc,项目名称:ophidia-server,代码行数:38,代码来源:oph_odb_job.c
示例7: chooseAdvertiseTime
/*---------------------------------------------------------------------------*/
void chooseAdvertiseTime() {
pmesg(200, "%s :: %s :: Line #%d\n", __FILE__, __func__, __LINE__);
static uint32_t rand =0;
//Create a 32bit pseudo random number
rand = ((uint32_t)random_rand());
rand = rand << 16;
rand = rand | ((uint32_t)random_rand());
t = currentInterval;
t /= 2;
t += rand % t;
tHasPassed = false;
isBeaconTimerPeriodic = false;
ctimer_stop(&beacon_timer);
#ifdef BEACON_ONLY
timer_set(&beacon_timerTime, ULONG_MAX);
#endif
ctimer_set(&beacon_timer, t, beacon_timer_fired, 0);
timer_reset(&beacon_timerTime); // Reset the tandem timer
}
开发者ID:RanHuang,项目名称:nick-project-contiki,代码行数:24,代码来源:BcpForwardingEngine.c
示例8: oph_http_get
// Thread unsafe
int oph_http_get(struct soap *soap)
{
pmesg(LOG_DEBUG, __FILE__, __LINE__, "Received a HTTP GET Request\n");
if (!oph_server_protocol || !oph_server_host || !oph_server_port) {
pmesg(LOG_DEBUG, __FILE__, __LINE__, "Return SOAP Fault\n");
return SOAP_GET_METHOD;
}
FILE *fd = NULL;
char buffer[OPH_MAX_STRING_SIZE] = { '\0' }, *s = strchr(soap->path, '?');
if (!s) {
snprintf(buffer, OPH_MAX_STRING_SIZE, OPH_SERVER_STD_HTTP_RESPONSE, oph_server_protocol, oph_server_host, oph_server_port, oph_server_protocol, oph_server_host, oph_server_port,
oph_server_protocol, oph_server_host, oph_server_port);
soap->http_content = "text/html";
pmesg(LOG_DEBUG, __FILE__, __LINE__, "Return HTML description of web service\n");
} else if (strcmp(s, "?wsdl")) {
pmesg(LOG_DEBUG, __FILE__, __LINE__, "Return SOAP Fault\n");
return SOAP_GET_METHOD;
} else {
snprintf(buffer, OPH_MAX_STRING_SIZE, OPH_SERVER_WSDL, oph_server_location);
fd = fopen(buffer, "rb");
if (!fd) {
pmesg(LOG_DEBUG, __FILE__, __LINE__, "Return HTTP 'Not Found' error\n");
return 404;
}
soap->http_content = "text/xml";
pmesg(LOG_DEBUG, __FILE__, __LINE__, "Return WSDL description of web service\n");
}
soap_response(soap, SOAP_FILE);
size_t r;
if (fd) {
for (;;) {
r = fread(soap->tmpbuf, 1, sizeof(soap->tmpbuf), fd);
if (!r)
break;
if (soap_send_raw(soap, soap->tmpbuf, r))
break;
}
fclose(fd);
} else {
r = snprintf(soap->tmpbuf, sizeof(soap->tmpbuf), "%s", buffer);
soap_send_raw(soap, soap->tmpbuf, r);
}
soap_end_send(soap);
return SOAP_OK;
}
开发者ID:OphidiaBigData,项目名称:ophidia-server,代码行数:46,代码来源:oph_utils.c
示例9: _memory_get_frag
int _memory_get_frag(oph_iostore_handler * handle, oph_iostore_resource_id * res_id, oph_iostore_frag_record_set ** frag_record)
{
if (!handle || !res_id || !res_id->id || !frag_record) {
pmesg(LOG_ERROR, __FILE__, __LINE__, MEMORY_LOG_NULL_INPUT_PARAM);
logging(LOG_ERROR, __FILE__, __LINE__, MEMORY_LOG_NULL_INPUT_PARAM);
return MEMORY_DEV_NULL_PARAM;
}
*frag_record = NULL;
//Read resource id
oph_iostore_frag_record_set *internal_record = *((oph_iostore_frag_record_set **) res_id->id);
//Get in-memory copy of frag
/* if(_memory_copy_frag_record_set(internal_record, frag_record) || frag_record == NULL){
pmesg(LOG_ERROR, __FILE__, __LINE__, MEMORY_LOG_MEMORY_ERROR);
logging(LOG_ERROR, __FILE__, __LINE__, MEMORY_LOG_MEMORY_ERROR);
return MEMORY_DEV_ERROR;
}*/
*frag_record = internal_record;
return MEMORY_DEV_SUCCESS;
}
开发者ID:OphidiaBigData,项目名称:ophidia-io-server,代码行数:23,代码来源:MEMORY_device.c
示例10: stack_check_timer_fired
void stack_check_timer_fired(void){
pmesg(200, "%s :: %s :: Line #%d\n", __FILE__, __func__, __LINE__);
static bool bpIncrease = false;
static uint16_t diffBackpressure =0;
static uint16_t newLocalBackpressure =0;
static uint32_t beacon_time =0;
beacon_time = ULONG_MAX - (uint32_t)timer_remaining(&beacon_timerTime);
newLocalBackpressure = list_length(send_stack) + sendQeOccupied + virtualQueueSize;
if(beacon_time >= BEACON_TH_INTERVAL){ //recently we have not broadcast a beacon
//update backpressure to other nodes
if(oldLocalBackpressure < newLocalBackpressure)
bpIncrease = true;
if(bpIncrease)
diffBackpressure = newLocalBackpressure - oldLocalBackpressure;
else
diffBackpressure = oldLocalBackpressure - newLocalBackpressure;
if(diffBackpressure>=DIFF_QUEUE_TH){
if( extraBeaconSending == false){
extraBeaconSending = true;
} else { return; }
beaconType = NORMAL_BEACON;
process_post(&sendBeaconTask, NULL, NULL);
skipExtraBeaconCnt=3;
}
} else {
if(skipExtraBeaconCnt>0) {
skipExtraBeaconCnt--;
}
}
oldLocalBackpressure = newLocalBackpressure;
}
开发者ID:RanHuang,项目名称:nick-project-contiki,代码行数:37,代码来源:BcpForwardingEngine.c
示例11: beacon_timer_fired
/*---------------------------------------------------------------------------*/
void beacon_timer_fired(){
pmesg(200, "%s :: %s :: Line #%d\n", __FILE__, __func__, __LINE__);
#ifdef BEACON_ONLY
// check stack size timer
if(ctimer_expired(&stack_check_timer)) {
ctimer_set(&stack_check_timer, (clock_time_t)STACK_CHECK_INTERVAL, stack_check_timer_fired, NULL);
}
#endif
if (isRunningForwardingEngine) {
if (!tHasPassed) {
beaconType = NORMAL_BEACON;
process_post(&sendBeaconTask, NULL, NULL);
remainingInterval();
}
else {
decayInterval();
}
}
if(isBeaconTimerPeriodic == true){
ctimer_set(&beacon_timer, BEACON_TIME, beacon_timer_fired, NULL);
timer_reset(&beacon_timerTime); // Reset the tandem timer
}
}
开发者ID:RanHuang,项目名称:nick-project-contiki,代码行数:25,代码来源:BcpForwardingEngine.c
示例12: malloc
char *oph_sum_array_r(UDF_INIT * initid, UDF_ARGS * args, char *result, unsigned long *length, char *is_null, char *error)
{
// Allocate space for the result_array; result_array[i] = measurea[i] + measureb[i]
//initid->ptr=(char *)malloc(*(measure.length) * (core_sizeof(measure.type)));
if (!initid->ptr) {
initid->ptr = (char *) malloc(args->lengths[0]);
if (!initid->ptr) {
pmesg(1, __FILE__, __LINE__, "Error allocating result string\n");
*length = 0;
*is_null = 1;
*error = 1;
return NULL;
}
}
barrier_wait(&(((th_data *) (initid->extension))->barr_start));
barrier_wait(&(((th_data *) (initid->extension))->barr_end));
*length = args->lengths[0];
*error = 0;
*is_null = 0;
return initid->ptr;
}
开发者ID:indigo-dc,项目名称:ophidia-primitives,代码行数:24,代码来源:oph_sum_array_r.c
示例13: core_oph_roll_up
int core_oph_roll_up(oph_roll_up_param* param)
{
if (param->rows < param->size)
{
oph_string* measure = (oph_string*)param->measure;
unsigned long row_size = measure->numelem * param->result_elemsize;
if (param->result_type != measure->type)
{
unsigned long i;
char *input_ptr = measure->content, *output_ptr = param->result + param->rows*row_size;
for (i=0; i<measure->numelem; ++i, input_ptr += measure->elemsize, output_ptr += param->result_elemsize)
{
if(core_oph_type_cast(input_ptr, output_ptr, measure->type, param->result_type))
{
pmesg(1, __FILE__, __LINE__, "Unable to find result\n");
return 1;
}
}
}
else memcpy(param->result + param->rows*row_size, measure->content, row_size);
param->rows++;
}
return 0;
}
开发者ID:OphidiaBigData,项目名称:ophidia-primitives,代码行数:24,代码来源:oph_roll_up.c
示例14: oph_subset_size
int oph_subset_size(oph_subset* subset, unsigned long long initial_size, unsigned long long* final_size, unsigned long long* sizes, int size_number)
{
if (!subset)
{
pmesg(LOG_ERROR, __FILE__, __LINE__, "Null pointer\n");
return OPH_SUBSET_LIB_NULL_POINTER_ERR;
}
*final_size=0;
unsigned long long j;
if (!sizes || !size_number)
{
for (j=1; j<=initial_size; ++j) // It is not C-like indexing
if (oph_subset_index_is_in_subset(j, subset)) (*final_size)++;
}
else
{
for (j=1; j<=initial_size; ++j) // It is not C-like indexing
if (oph_subset_id_is_in_subset(j, subset, sizes, size_number)) (*final_size)++;
}
return OPH_SUBSET_LIB_OK;
}
开发者ID:OphidiaBigData,项目名称:ophidia-analytics-framework,代码行数:24,代码来源:oph_subset_library.c
示例15: pmesg
char *oph_predicate2(UDF_INIT * initid, UDF_ARGS * args, char *result, unsigned long *length, char *is_null, char *error)
{
oph_string measure;
char *buffer;
char **names;
int count;
oph_predicate2_param *param;
int i = 0;
if (core_set_type(&(measure), args->args[0], &(args->lengths[0]))) {
pmesg(1, __FILE__, __LINE__, "Type not recognized\n");
*length = 0;
*is_null = 0;
*error = 1;
return NULL;
}
measure.content = args->args[2];
measure.length = &(args->lengths[2]);
measure.missingvalue = NULL;
core_set_elemsize(&(measure));
if (core_set_numelem(&(measure))) {
pmesg(1, __FILE__, __LINE__, "Error on counting elements\n");
*length = 0;
*is_null = 0;
*error = 1;
return NULL;
}
if (!initid->ptr) {
initid->ptr = (char *) malloc(sizeof(oph_predicate2_param));
if (!initid->ptr) {
pmesg(1, __FILE__, __LINE__, "Error allocating result string\n");
*length = 0;
*is_null = 0;
*error = 1;
return NULL;
}
param = (oph_predicate2_param *) initid->ptr;
for (i = 0; i < 4; ++i)
param->f[i] = NULL;
param->occurrence = 0; // ALL
buffer = (char *) malloc(1 + args->lengths[3]);
strncpy(buffer, args->args[3], args->lengths[3]);
buffer[args->lengths[3]] = '\0';
pthread_rwlock_wrlock(&lock);
param->f[1] = evaluator_create(buffer);
pthread_rwlock_unlock(&lock);
free(buffer);
if (!param->f[1]) {
pmesg(1, __FILE__, __LINE__, "Error allocating evaluator\n");
*length = 0;
*is_null = 0;
*error = 1;
return NULL;
}
evaluator_get_variables(param->f[1], &names, &count);
if (count > 1) {
pmesg(1, __FILE__, __LINE__, "Too variables in expression\n");
*length = 0;
*is_null = 0;
*error = 1;
return NULL;
}
// Comparison operator
if (core_set_comp(¶m->op, args->args[4], &(args->lengths[4]))) {
pmesg(1, __FILE__, __LINE__, "Comparison operator not recognized\n");
*length = 0;
*is_null = 0;
*error = 1;
return NULL;
}
if (args->args[5] && args->lengths[5]) {
buffer = (char *) malloc(1 + args->lengths[5]);
core_strncpy(buffer, args->args[5], &(args->lengths[5]));
if (!strcasecmp(buffer, "nan"))
sprintf(buffer, "0/0");
} else
buffer = strdup("0/0");
pthread_rwlock_wrlock(&lock);
param->f[2] = evaluator_create(buffer);
pthread_rwlock_unlock(&lock);
free(buffer);
if (!param->f[2]) {
pmesg(1, __FILE__, __LINE__, "Error allocating evaluator\n");
*length = 0;
*is_null = 0;
*error = 1;
return NULL;
}
evaluator_get_variables(param->f[2], &names, &count);
if (count > 1) {
pmesg(1, __FILE__, __LINE__, "Too variables in expression\n");
*length = 0;
//.........这里部分代码省略.........
开发者ID:indigo-dc,项目名称:ophidia-primitives,代码行数:101,代码来源:oph_predicate2.c
示例16: core_oph_predicate2
int core_oph_predicate2(oph_stringPtr byte_array, char *result)
{
unsigned long i, occurrence, occurrence_number = 0;
unsigned short r;
double res, temporary;
oph_predicate2_param *_result = (oph_predicate2_param *) result;
if (_result->occurrence < 0)
occurrence = 1;
else
occurrence = (unsigned long) _result->occurrence;
switch (byte_array->type) {
case OPH_DOUBLE:
{
for (i = _result->occurrence < 0 ? byte_array->numelem - 1 : 0; (0 <= i) && (i < byte_array->numelem); _result->occurrence < 0 ? --i : ++i) {
res = evaluator_evaluate_x(_result->f[1], *((double *) (byte_array->content + i * byte_array->elemsize)));
switch (_result->op) {
case OPH_GREATER_THAN_ZERO:
{
r = res > 0.0;
break;
}
case OPH_LESS_THAN_ZERO:
{
r = res < 0.0;
break;
}
case OPH_EQUAL_TO_ZERO:
{
r = res == 0.0;
break;
}
case OPH_GREATER_OR_EQUAL_TO_ZERO:
{
r = res >= 0.0;
break;
}
case OPH_LESS_OR_EQUAL_TO_ZERO:
{
r = res <= 0.0;
break;
}
case OPH_NOT_EQUAL_TO_ZERO:
{
r = res != 0.0;
break;
}
case OPH_NULL:
{
r = isnan(res);
break;
}
default:
pmesg(1, __FILE__, __LINE__, "Comparison value non recognized\n");
return -1;
}
if (occurrence && r) {
occurrence_number++;
if (occurrence != occurrence_number)
r = 0;
}
temporary = evaluator_evaluate_x(_result->f[r ? 2 : 3], *((double *) (byte_array->content + i * byte_array->elemsize)));
if (core_oph_type_cast(&temporary, (((char *) _result->f[0]) + i * _result->result_elemsize), OPH_DOUBLE, _result->result_type, byte_array->missingvalue)) {
pmesg(1, __FILE__, __LINE__, "Unable to find result\n");
return 1;
}
}
break;
}
case OPH_FLOAT:
{
for (i = _result->occurrence < 0 ? byte_array->numelem - 1 : 0; (0 <= i) && (i < byte_array->numelem); _result->occurrence < 0 ? --i : ++i) {
res = evaluator_evaluate_x(_result->f[1], *((float *) (byte_array->content + i * byte_array->elemsize)));
switch (_result->op) {
case OPH_GREATER_THAN_ZERO:
{
r = res > 0.0;
break;
}
case OPH_LESS_THAN_ZERO:
{
r = res < 0.0;
break;
}
case OPH_EQUAL_TO_ZERO:
{
r = res == 0.0;
break;
}
case OPH_GREATER_OR_EQUAL_TO_ZERO:
{
r = res >= 0.0;
break;
}
case OPH_LESS_OR_EQUAL_TO_ZERO:
{
r = res <= 0.0;
break;
}
case OPH_NOT_EQUAL_TO_ZERO:
{
//.........这里部分代码省略.........
开发者ID:indigo-dc,项目名称:ophidia-primitives,代码行数:101,代码来源:oph_predicate2.c
示例17: workflow_validate_fco
int workflow_validate_fco(oph_workflow * wf)
{
if (!wf) {
pmesg(LOG_ERROR, __FILE__, __LINE__, "Null pointer!\n");
return OPH_WORKFLOW_EXIT_BAD_PARAM_ERROR;
}
int i, k, kk, child;
char flag[wf->tasks_num];
unsigned int number;
for (k = 0; k < wf->tasks_num; k++)
wf->tasks[k].parent = wf->tasks[k].child = -1;
for (k = 0; k < wf->tasks_num; k++) {
if (!strncasecmp(wf->tasks[k].operator, OPH_OPERATOR_FOR, OPH_WORKFLOW_MAX_STRING)) {
for (i = 0; i < wf->tasks_num; ++i)
flag[i] = 1;
number = workflow_number_of(wf, k, k, k, OPH_OPERATOR_ENDFOR, OPH_OPERATOR_FOR, flag, 0, &child);
if (!number || (number > 1))
break;
for (i = 0; i < wf->tasks_num; ++i)
if ((wf->tasks[i].parent == k) && strncasecmp(wf->tasks[k].operator, OPH_OPERATOR_ENDFOR, OPH_WORKFLOW_MAX_STRING) && !oph_workflow_is_child_of(wf, i, child))
break;
if (i < wf->tasks_num)
break;
} else if (!strncasecmp(wf->tasks[k].operator, OPH_OPERATOR_IF, OPH_WORKFLOW_MAX_STRING)) {
for (i = 0; i < wf->tasks_num; ++i)
flag[i] = 1;
child = -1;
number = workflow_number_of(wf, k, k, k, OPH_OPERATOR_ELSEIF, OPH_OPERATOR_IF, flag, 0, &child);
if (number > 1)
break;
if (child >= 0) {
for (i = 0; i < wf->tasks_num; ++i)
if ((wf->tasks[i].parent == k) && strncasecmp(wf->tasks[k].operator, OPH_OPERATOR_ELSEIF, OPH_WORKFLOW_MAX_STRING) && !oph_workflow_is_child_of(wf, i, child))
break;
if (i < wf->tasks_num)
break;
} else {
for (i = 0; i < wf->tasks_num; ++i)
flag[i] = 1;
child = -1;
number = workflow_number_of(wf, k, k, k, OPH_OPERATOR_ELSE, OPH_OPERATOR_IF, flag, 0, &child);
if (number > 1)
break;
if (child >= 0) {
for (i = 0; i < wf->tasks_num; ++i)
if ((wf->tasks[i].parent == k) && strncasecmp(wf->tasks[k].operator, OPH_OPERATOR_ELSE, OPH_WORKFLOW_MAX_STRING)
&& !oph_workflow_is_child_of(wf, i, child))
break;
if (i < wf->tasks_num)
break;
}
}
for (i = 0; i < wf->tasks_num; ++i)
flag[i] = 1;
number = workflow_number_of(wf, k, k, k, OPH_OPERATOR_ENDIF, OPH_OPERATOR_IF, flag, 0, &child);
if (!number && (number > 1))
break;
for (i = 0; i < wf->tasks_num; ++i)
if ((wf->tasks[i].parent == k) && strncasecmp(wf->tasks[k].operator, OPH_OPERATOR_ENDIF, OPH_WORKFLOW_MAX_STRING) && !oph_workflow_is_child_of(wf, i, child))
break;
if (i < wf->tasks_num)
break;
} else if (!strncasecmp(wf->tasks[k].operator, OPH_OPERATOR_ELSEIF, OPH_WORKFLOW_MAX_STRING)) {
kk = oph_gparent_of(wf, k);
for (i = 0; i < wf->tasks_num; ++i)
flag[i] = 1;
child = -1;
number = workflow_number_of(wf, k, k, kk, OPH_OPERATOR_ELSEIF, OPH_OPERATOR_IF, flag, 0, &child);
if (number > 1)
break;
if (child >= 0) {
for (i = 0; i < wf->tasks_num; ++i)
if ((wf->tasks[i].parent == k) && strncasecmp(wf->tasks[k].operator, OPH_OPERATOR_ELSEIF, OPH_WORKFLOW_MAX_STRING) && !oph_workflow_is_child_of(wf, i, child))
break;
if (i < wf->tasks_num)
break;
} else {
for (i = 0; i < wf->tasks_num; ++i)
flag[i] = 1;
child = -1;
number = workflow_number_of(wf, k, k, kk, OPH_OPERATOR_ELSE, OPH_OPERATOR_IF, flag, 0, &child);
if (number > 1)
break;
if (child >= 0) {
for (i = 0; i < wf->tasks_num; ++i)
if ((wf->tasks[i].parent == k) && strncasecmp(wf->tasks[k].operator, OPH_OPERATOR_ELSE, OPH_WORKFLOW_MAX_STRING)
&& !oph_workflow_is_child_of(wf, i, child))
break;
if (i < wf->tasks_num)
break;
} else {
for (i = 0; i < wf->tasks_num; ++i)
flag[i] = 1;
number = workflow_number_of(wf, k, k, kk, OPH_OPERATOR_ENDIF, OPH_OPERATOR_IF, flag, 0, &child);
if (!number || (number > 1))
break;
for (i = 0; i < wf->tasks_num; ++i)
//.........这里部分代码省略.........
开发者ID:OphidiaBigData,项目名称:ophidia-server,代码行数:101,代码来源:oph_workflow_setup.c
示例18: oph_workflow_validate
int oph_workflow_validate(oph_workflow * workflow)
{
if (!workflow || !(workflow->tasks)) {
pmesg(LOG_ERROR, __FILE__, __LINE__, "Null param\n");
return OPH_WORKFLOW_EXIT_BAD_PARAM_ERROR;
}
// Check for uniqueness of task name
int i, j, k;
for (i = 0; i < workflow->tasks_num; i++)
for (j = 0; j < workflow->tasks_num; j++)
if ((i != j) && !strcmp(workflow->tasks[i].name, workflow->tasks[j].name))
return OPH_WORKFLOW_EXIT_TASK_NAME_ERROR;
// Create graph from tasks
workflow_node *graph = NULL;
graph = (workflow_node *) calloc(workflow->tasks_num, sizeof(workflow_node));
if (!graph) {
pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating graph\n");
return OPH_WORKFLOW_EXIT_MEMORY_ERROR;
}
for (i = 0; i < workflow->tasks_num; i++) {
if (workflow->tasks[i].deps_num >= 1) {
graph[i].in_edges = (int *) calloc(workflow->tasks[i].deps_num, sizeof(int));
if (!(graph[i].in_edges)) {
for (k = 0; k < workflow->tasks_num; k++)
workflow_node_free(&(graph[k]));
free(graph);
graph = NULL;
pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating in_edges\n");
return OPH_WORKFLOW_EXIT_MEMORY_ERROR;
}
graph[i].in_edges_size = workflow->tasks[i].deps_num;
graph[i].in_edges_num = workflow->tasks[i].deps_num;
for (j = 0; j < workflow->tasks[i].deps_num; j++)
graph[i].in_edges[j] = workflow->tasks[i].deps[j].task_index;
}
if (workflow->tasks[i].dependents_indexes_num >= 1) {
graph[i].out_edges = (int *) calloc(workflow->tasks[i].dependents_indexes_num, sizeof(int));
if (!(graph[i].out_edges)) {
for (k = 0; k < workflow->tasks_num; k++)
workflow_node_free(&(graph[k]));
free(graph);
graph = NULL;
pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating out_edges\n");
return OPH_WORKFLOW_EXIT_MEMORY_ERROR;
}
graph[i].out_edges_size = workflow->tasks[i].dependents_indexes_num;
graph[i].out_edges_num = workflow->tasks[i].dependents_indexes_num;
for (j = 0; j < workflow->tasks[i].dependents_indexes_num; j++)
graph[i].out_edges[j] = workflow->tasks[i].dependents_indexes[j];
}
graph[i].index = i;
}
/* Test for DAG through Topological Sort
*
* S ← Set of all nodes with no incoming edges
* while S is non-empty do
* remove a node n from S
* for each node m with an edge e from n to m do
* remove edge e from the graph
* if m has no other incoming edges then
* insert m into S
* if graph has edges then
* return error (graph has at least one cycle)
* else
* return success (graph has no cycles)
*/
// S ← Set of all nodes with no incoming edges
workflow_s_nodes S;
S.head = NULL;
S.tail = NULL;
S.nodes_num = 0;
for (i = 0; i < workflow->tasks_num; i++) {
if (graph[i].in_edges_num == 0) {
if (workflow_s_add(&S, &(graph[i]))) {
for (k = 0; k < workflow->tasks_num; k++)
workflow_node_free(&(graph[k]));
free(graph);
graph = NULL;
workflow_s_nodes_free(&S);
pmesg(LOG_ERROR, __FILE__, __LINE__, "Error setting S\n");
return OPH_WORKFLOW_EXIT_MEMORY_ERROR;
}
}
}
workflow_node *n = NULL;
// while S is non-empty do
while (S.nodes_num != 0) {
// remove a node n from S
if (workflow_s_remove(&S, &n)) {
for (k = 0; k < workflow->tasks_num; k++)
workflow_node_free(&(graph[k]));
free(graph);
graph = NULL;
workflow_s_nodes_free(&S);
//.........这里部分代码省略.........
开发者ID:OphidiaBigData,项目名称:ophidia-server,代码行数:101,代码来源:oph_workflow_setup.c
示例19: oph_gsl_spline
char* oph_gsl_spline(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned long *length, char *is_null, char *error)
{
if (*error)
{
*length=0;
*is_null=0;
*error=1;
return NULL;
}
if (*is_null || !args->lengths[2] || !args->lengths[3] || !args->lengths[4])
{
*length=0;
*is_null=1;
*error=0;
return NULL;
}
oph_generic_param_multi* param;
if (!initid->ptr)
{
param = (oph_generic_param_multi*)malloc(sizeof(oph_generic_param_multi));
if (!param)
{
pmesg(1, __FILE__, __LINE__, "Error in allocating parameters\n");
*length=0;
*is_null=0;
*error=1;
return NULL;
}
param->measure = NULL;
param->result = NULL;
param->error = 0;
param->extend = NULL;
initid->ptr = (char*)param;
}
else param = (oph_generic_param_multi*)initid->ptr;
if (param->error)
{
*length=0;
*is_null=0;
*error=1;
return NULL;
}
oph_multistring* measure;
if (!param->error && !param->measure)
{
if(core_set_oph_multistring(&measure, args->args[0], &(args->lengths[0])))
{
param->error = 1;
pmesg(1, __FILE__, __LINE__, "Error setting measure structure\n");
*length=0;
*is_null=0;
*error=1;
return NULL;
}
if (!measure->islast)
{
param->error = 1;
pmesg(1, __FILE__, __LINE__, "Wrong number of input data type\n");
*length=0;
*is_null=0;
*error=1;
return NULL;
}
measure->length = args->lengths[2];
if(measure->length % measure->blocksize)
{
param->error = 1;
pmesg(1, __FILE__, __LINE__, "Wrong input type or data corrupted\n");
*length=0;
*is_null=0;
*error=1;
return NULL;
}
measure->numelem = measure->length / measure->blocksize;
if (measure->numelem*sizeof(double) != args->lengths[3])
{
param->error = 1;
pmesg(1, __FILE__, __LINE__, "Wrong input type or data corrupted\n");
*length=0;
*is_null=0;
*error=1;
return NULL;
}
param->measure = measure;
}
else measure = param->measure;
measure->content = args->args[2];
oph_multistring* output;
if (!param->error && !param->result)
{
if(core_set_oph_multistring(&output, args->args[1], &(args->lengths[1])))
{
param->error = 1;
//.........这里部分代码省略.........
开发者ID:OphidiaBigData,项目名称:ophidia-primitives,代码行数:101,代码来源:oph_gsl_spline.c
示例20: oph_subset_parse
int oph_subset_parse(const char *cond, unsigned long len, oph_subset * subset, long max)
{
char *result, *result2, temp0[OPH_SUBSET_LIB_MAX_STRING_LENGTH], temp1[OPH_SUBSET_LIB_MAX_STRING_LENGTH], temp2[OPH_SUBSET_LIB_MAX_STRING_LENGTH], *next, *temp, *savepointer = NULL;
unsigned int number;
if (!subset) {
pmesg(LOG_ERROR, __FILE__, __LINE__, "Null pointer\n");
return OPH_SUBSET_LIB_NULL_POINTER_ERR;
}
subset->number = 0;
strncpy(temp0, cond, len);
temp0[len] = '\0';
strcpy(temp2, temp0);
result = strtok_r(temp0, OPH_SUBSET_LIB_SUBSET_SEPARATOR, &savepointer);
while (result) {
subset->number++;
result = strtok_r(NULL, OPH_SUBSET_LIB_SUBSET_SEPARATOR, &savepointer);
}
if (!subset->number)
return OPH_SUBSET_LIB_DATA_ERR;
int retval = OPH_SUBSET_LIB_OK, i = 0;
subset->type = (oph_subset_type *) malloc(subset->number * sizeof(oph_subset_type));
subset->start = (long *) malloc(subset->number * sizeof(long));
subset->end = (long *) malloc(subset->number * sizeof(long));
subset->stride = (unsigned long *) malloc(subset->number * sizeof(unsigned long));
subset->count = (unsigned long *) malloc(subset->number * sizeof(unsigned long));
subset->total = 0;
next = temp2;
result = strchr(temp2, OPH_SUBSET_LIB_SUBSET_SEPARATOR[0]);
while (next && (retval == OPH_SUBSET_LIB_OK)) {
if (result) {
result[0] = '\0';
temp = result + 1;
} else
temp = 0;
result = next;
next = temp;
number = 0;
strncpy(temp1, result, OPH_SUBSET_LIB_MAX_STRING_LENGTH);
result2 = strtok_r(temp1, OPH_SUBSET_LIB_PARAM_SEPARATOR, &savepointer);
while (result2 && (retval == OPH_SUBSET_LIB_OK)) {
switch (number) {
case 0:
if (!strncasecmp(result2, OPH_SUBSET_LIB_PARAM_END, strlen(OPH_SUBSET_LIB_PARAM_END))) {
if (max)
subset->end[i] = max;
else {
pmesg(LOG_ERROR, __FILE__, __LINE__, "Clause '%s' cannot be used in this context\n", OPH_SUBSET_LIB_PARAM_END);
retval = OPH_SUBSET_LIB_DATA_ERR;
}
} else
subset->end[i] = strtol(result2, NULL, 10);
subset->start[i] = subset->end[i];
subset->stride[i] = 1;
subset->type[i] = OPH_SUBSET_LIB_SINGLE;
break;
case 1:
if (!strncasecmp(result2, OPH_SUBSET_LIB_PARAM_END, strlen(OPH_SUBSET_LIB_PARAM_END))) {
if (max)
subset->end[i] = max;
else {
pmesg(LOG_ERROR, __FILE__, __LINE__, "Clause '%s' cannot be used in this context\n", OPH_SUBSET_LIB_PARAM_END);
retval = OPH_SUBSET_LIB_DATA_ERR;
}
} else
subset->end[i] = strtol(result2, NULL, 10);
subset->type[i] = OPH_SUBSET_LIB_INTERVAL;
break;
case 2:
subset->stride[i] = subset->end[i];
if (!strncasecmp(result2, OPH_SUBSET_LIB_PARAM_END, strlen(OPH_SUBSET_LIB_PARAM_END))) {
if (max)
subset->end[i] = max;
else {
pmesg(LOG_ERROR, __FILE__, __LINE__, "Clause '%s' cannot be used in this context\n", OPH_SUBSET_LIB_PARAM_END);
retval = OPH_SUBSET_LIB_DATA_ERR;
}
} else
subset->end[i] = strtol(result2, NULL, 10);
if (subset->stride[i] > 1)
subset->type[i] = OPH_SUBSET_LIB_STRIDE;
break;
default:
pmesg(LOG_ERROR, __FILE__, __LINE__, "Wrong input data: too many '%s' in subset\n", OPH_SUBSET_LIB_PARAM_SEPARATOR);
retval = OPH_SUBSET_LIB_DATA_ERR;
}
number++;
result2 = strtok_r(NULL, OPH_SUBSET_LIB_PARAM_SEPARATOR, &savepointer);
}
if (retval != OPH_SUBSET_LIB_OK)
break;
//.........这里部分代码省略.........
开发者ID:indigo-dc,项目名称:ophidia-server,代码行数:101,代码来源:oph_subset_library.c
注:本文中的pmesg函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论