Exemplo n.º 1
0
static void
test_write_file_attribs(H5PartFile *file, int position)
{
	h5part_int64_t status;
	char name[ATTR_NAME_SIZE];

	TEST("Writing file attributes");

	get_attr_name(name, "str", position);
	status = H5PartWriteFileAttribString(file, name, ATTR_STR_VAL);
	RETURN(status, H5PART_SUCCESS, "H5PartWriteFileAttribString");

	get_attr_name(name, "i32", position);
	status = H5PartWriteFileAttribInt32(file, name, ATTR_INT32_VAL);
	RETURN(status, H5PART_SUCCESS, "H5PartWriteFileAttribInt32");

	get_attr_name(name, "i64", position);
	status = H5PartWriteFileAttribInt64(file, name, ATTR_INT64_VAL);
	RETURN(status, H5PART_SUCCESS, "H5PartWriteFileAttribInt64");

	get_attr_name(name, "f32", position);
	status = H5PartWriteFileAttribFloat32(file, name, ATTR_FLOAT_VAL);
	RETURN(status, H5PART_SUCCESS, "H5PartWriteFileAttribFloat32");

	get_attr_name(name, "f64", position);
	status = H5PartWriteFileAttribFloat64(file, name, ATTR_FLOAT_VAL);
	RETURN(status, H5PART_SUCCESS, "H5PartWriteFileAttribFloat64");
}
Exemplo n.º 2
0
SaErrorT show_Rpt(Rpt_t *Rpt, hpi_ui_print_cb_t proc)
{
	int		i = 0;
	Attributes_t	*Attrs;
	union_type_t	val;
	char		buf[1024];
	char		A[256], *name;
	SaHpiTextBufferT	tbuf;
	SaErrorT	rv;

	Attrs = &(Rpt->Attrutes);
	for (;; i++) {
		name = get_attr_name(Attrs, i);
		if (name == (char *)NULL)
			break;
		if (strcmp(name, "ResCapabilities") == 0) {
			rv = get_value(Attrs, i, &val);
			if (rv != SA_OK)
				continue;
			rv = oh_decode_capabilities(val.i, &tbuf);
			if (rv != SA_OK)
				continue;
			strncpy(A, tbuf.Data, 256);
		} else {
			rv = get_value_as_string(Attrs, i, A, 256);
			if (rv != SA_OK)
				continue;
		};
		snprintf(buf, 1024, "%s: %s\n", name, A);
		if (proc(buf) != 0)
			return(-1);
	};
	return(SA_OK);
}
Exemplo n.º 3
0
Attribute* Table::GetAttribute(string name)
{
	for (auto attr = ats_.begin(); attr != ats_.end(); attr++)
	{
		if (attr->get_attr_name() == name)
			return &(*attr);
	}
	return NULL;
}
Exemplo n.º 4
0
Arquivo: read.c Projeto: tfogal/h5part
static void
test_read_file_attribs(H5PartFile *file, int position)
{
	h5part_int64_t status;
	char name[ATTR_NAME_SIZE];

	char str[ATTR_NAME_SIZE];
	h5part_int32_t i32;
	h5part_int64_t i64;
	h5part_float32_t f32;
	h5part_float64_t f64;

	TEST("Reading file attributes");

	i64 = H5PartGetNumFileAttribs(file);
	VALUE(i64 % 5, 0, "file attribute count");

	get_attr_name(name, "str", position);
	status = H5PartReadFileAttrib(file, name, str);
	RETURN(status, H5PART_SUCCESS, "H5PartReadFileAttrib");
	SVALUE(str, ATTR_STR_VAL, "string attribute");

	get_attr_name(name, "i32", position);
	status = H5PartReadFileAttrib(file, name, &i32);
	RETURN(status, H5PART_SUCCESS, "H5PartReadFileAttrib");
	IVALUE(i32, ATTR_INT32_VAL, "int32 attribute");

	get_attr_name(name, "i64", position);
	status = H5PartReadFileAttrib(file, name, &i64);
	RETURN(status, H5PART_SUCCESS, "H5PartReadFileAttrib");
	IVALUE(i64, ATTR_INT64_VAL, "int64 attribute");

	get_attr_name(name, "f32", position);
	status = H5PartReadFileAttrib(file, name, &f32);
	RETURN(status, H5PART_SUCCESS, "H5PartReadFileAttrib");
	FVALUE(f32, ATTR_FLOAT_VAL, "float32 attribute");

	get_attr_name(name, "f64", position);
	status = H5PartReadFileAttrib(file, name, &f64);
	RETURN(status, H5PART_SUCCESS, "H5PartReadFileAttrib");
	FVALUE(f64, ATTR_FLOAT_VAL, "float64 attribute");
}
Exemplo n.º 5
0
SaErrorT show_Rdr(Rdr_t *Rdr, hpi_ui_print_cb_t proc)
{
	int		i = 0;
	Attributes_t	*Attrs;
	char		buf[1024];
	char		A[256], *name;
	SaErrorT	rv;

	Attrs = &(Rdr->Attrutes);
	for (;; i++) {
		name = get_attr_name(Attrs, i);
		if (name == (char *)NULL)
			break;
		rv = get_value_as_string(Attrs, i, A, 256);
		if (rv != SA_OK)
			continue;
		snprintf(buf, 1024, "%s: %s\n", name, A);
		if (proc(buf) != 0)
			return(-1);
	};
	return(SA_OK);
}
Exemplo n.º 6
0
static Pr_ret_t show_attrs(Attributes_t *Attrs, int delta, hpi_ui_print_cb_t proc)
{
	int		i, type, len, del;
	char		tmp[256], *name;
	char		buf[SHOW_BUF_SZ];
	union_type_t	val;
	SaErrorT	rv;
	Pr_ret_t	ret;

	memset(buf, ' ', SHOW_BUF_SZ);
	del = delta << 1;
	len = SHOW_BUF_SZ - del;
	for (i = 0; i < Attrs->n_attrs; i++) {
		name = get_attr_name(Attrs, i);
		if (name == (char *)NULL)
			break;
		rv = get_value(Attrs, i, &val);
		if (rv != SA_OK) continue;
		type = get_attr_type(Attrs, i);
		switch (type) {
			case NO_TYPE:	continue;
			case STRUCT_TYPE:
				snprintf(buf + del, len, "%s:\n", name);
				if (proc(buf) != 0) return(-1);
				rv = get_value(Attrs, i, &val);
				if (rv != SA_OK) continue;
				ret = show_attrs((Attributes_t *)(val.a),
					delta + 1, proc);
				if (ret != HPI_UI_OK) return(HPI_UI_END);
				continue;
			case LOOKUP_TYPE:
				strncpy(tmp, lookup_proc(Attrs->Attrs[i].lunum,
					val.i), 256);
				break;
			case DECODE_TYPE:
				rv = decode_proc(Attrs->Attrs[i].lunum, val.a,
					tmp, 256);
				if (rv != SA_OK) continue;
				break;
			case DECODE1_TYPE:
				rv = decode1_proc(Attrs->Attrs[i].lunum, val.i,
					tmp, 256);
				if (rv != SA_OK) continue;
				break;
			case READING_TYPE:
				if (thres_value(val.a, tmp, 256) != SA_OK)
					continue;
				break;
			case TEXT_BUFF_TYPE:
				snprintf(buf + del, len, "%s: ", name);
				if (proc(buf) != HPI_UI_OK) return(HPI_UI_END);
				ret = print_text_buffer(NULL, val.a, "\n", proc);
				if (ret != HPI_UI_OK) return(HPI_UI_END);
				continue;
			default:
				rv = get_value_as_string(Attrs, i, tmp, 256);
				if (rv != SA_OK) continue;
		};
		snprintf(buf + del, len, "%s: %s\n", name, tmp);
		if (proc(buf) != HPI_UI_OK) return(HPI_UI_END);
	};
	return(0);
}
Exemplo n.º 7
0
static char *get_event_condition(char *src, edg_wll_QueryRec *cond)
{
	char	   *s;


	s = get_attr_name(src, tmps, 500);

	if ( tmps[0] == '\0' ) return NULL;

	if ( !strcmp(tmps, "time") ) cond->attr = EDG_WLL_QUERY_ATTR_TIME;
	else if ( !strcmp(tmps, "state_enter_time") ) cond->attr = EDG_WLL_QUERY_ATTR_STATEENTERTIME;
	else if ( !strcmp(tmps, "last_update_time") ) cond->attr = EDG_WLL_QUERY_ATTR_LASTUPDATETIME;
	else if ( !strcmp(tmps, "jdl_attr") ) cond->attr = EDG_WLL_QUERY_ATTR_JDL_ATTR;
	else if ( !strcmp(tmps, "level") ) cond->attr = EDG_WLL_QUERY_ATTR_LEVEL;
	else if ( !strcmp(tmps, "host") ) cond->attr = EDG_WLL_QUERY_ATTR_HOST;
	else if ( !strcmp(tmps, "source") ) cond->attr = EDG_WLL_QUERY_ATTR_SOURCE;
	else if ( !strcmp(tmps, "instance") ) cond->attr = EDG_WLL_QUERY_ATTR_INSTANCE;
	else if ( !strcmp(tmps, "event_type") ) cond->attr = EDG_WLL_QUERY_ATTR_EVENT_TYPE;
	else
	{
		cond->attr = EDG_WLL_QUERY_ATTR_USERTAG;
		cond->attr_id.tag = strdup(tmps);
	}

	if ( !(s = get_op(s, &(cond->op))) ) return NULL;

	if ( !(s = get_attr_value(s, tmps, 500)) ) return NULL;

	switch ( cond->attr )
	{
	case EDG_WLL_QUERY_ATTR_USERTAG:
	case EDG_WLL_QUERY_ATTR_HOST:
	case EDG_WLL_QUERY_ATTR_INSTANCE:
	case EDG_WLL_QUERY_ATTR_JDL_ATTR:
		if ( !(cond->value.c = strdup(tmps)) )
			return 0;
		break;

	case EDG_WLL_QUERY_ATTR_SOURCE:
		if ( !strcasecmp(tmps, "UserInterface") ) cond->value.i = EDG_WLL_SOURCE_USER_INTERFACE;
		else if ( !strcasecmp(tmps, "NetworkServer") ) cond->value.i = EDG_WLL_SOURCE_NETWORK_SERVER;
		else if ( !strcasecmp(tmps, "WorkloadManager") ) cond->value.i = EDG_WLL_SOURCE_WORKLOAD_MANAGER;
		else if ( !strcasecmp(tmps, "BigHelper") ) cond->value.i = EDG_WLL_SOURCE_BIG_HELPER;
		else if ( !strcasecmp(tmps, "JobController") ) cond->value.i = EDG_WLL_SOURCE_JOB_SUBMISSION;
		else if ( !strcasecmp(tmps, "LogMonitor") ) cond->value.i = EDG_WLL_SOURCE_LOG_MONITOR;
		else if ( !strcasecmp(tmps, "LRMS") ) cond->value.i = EDG_WLL_SOURCE_LRMS;
		else if ( !strcasecmp(tmps, "Application") ) cond->value.i = EDG_WLL_SOURCE_APPLICATION;
		else
		{
			fprintf(stderr,"%s: invalid source value (%s)\n", myname, tmps);
			return NULL;
		}
		break;

	case EDG_WLL_QUERY_ATTR_EVENT_TYPE:
	case EDG_WLL_QUERY_ATTR_LEVEL:
		cond->value.i = atoi(tmps);
		if ( cond->op == EDG_WLL_QUERY_OP_WITHIN )
		{
			if ( !(s = get_attr_value(s, tmps, 500)) ) return NULL;
			if ( tmps[0] == '\0' )
			{
				fprintf(stderr,"%s: second interval boundary not set\n", myname);
				return NULL;
			}
			cond->value2.i = atoi(tmps);
		}
		break;

	case EDG_WLL_QUERY_ATTR_TIME:
		cond->value.t.tv_sec = StrToTime(tmps);
		if ( cond->op == EDG_WLL_QUERY_OP_WITHIN )
		{
			if ( !(s = get_attr_value(s, tmps, 500)) ) return NULL;
			if ( tmps[0] == '\0' )
			{
				fprintf(stderr,"%s: second interval boundary not set\n", myname);
				return NULL;
			}
			cond->value2.t.tv_sec = StrToTime(tmps);
		}
		break;

	default:
		break;
	}

	while ( isblank(*s) || (*s == ';') ) s++;			/* skip whitespaces */

	return s;
}
Exemplo n.º 8
0
static char *get_job_condition(char *src, edg_wll_QueryRec *cond)
{
	char	   *s;


	s = get_attr_name(src, tmps, 500);

	if ( tmps[0] == '\0' ) return NULL;

	if ( !strcmp(tmps, "jobid") ) cond->attr = EDG_WLL_QUERY_ATTR_JOBID;
	else if ( !strcmp(tmps, "owner") ) cond->attr = EDG_WLL_QUERY_ATTR_OWNER;
	else if ( !strcmp(tmps, "status") ) cond->attr = EDG_WLL_QUERY_ATTR_STATUS;
	else if ( !strcmp(tmps, "location") ) cond->attr = EDG_WLL_QUERY_ATTR_LOCATION;
	else if ( !strcmp(tmps, "destination") ) cond->attr = EDG_WLL_QUERY_ATTR_DESTINATION;
	else if ( !strcmp(tmps, "done_code") ) cond->attr = EDG_WLL_QUERY_ATTR_DONECODE;
	else if ( !strcmp(tmps, "exit_code") ) cond->attr = EDG_WLL_QUERY_ATTR_EXITCODE;
	else if ( !strcmp(tmps, "parent_job") ) cond->attr = EDG_WLL_QUERY_ATTR_PARENT;
	else if ( !strcmp(tmps, "time") ) cond->attr = EDG_WLL_QUERY_ATTR_TIME;
	else if ( !strcmp(tmps, "state_enter_time") ) cond->attr = EDG_WLL_QUERY_ATTR_STATEENTERTIME;
	else if ( !strcmp(tmps, "last_update_time") ) cond->attr = EDG_WLL_QUERY_ATTR_LASTUPDATETIME;
	else if ( !strcmp(tmps, "jdl_attr") ) cond->attr = EDG_WLL_QUERY_ATTR_JDL_ATTR;
	else if ( !strcmp(tmps, "job_type") ) cond->attr = EDG_WLL_QUERY_ATTR_JOB_TYPE;
	else if ( !strcmp(tmps, "vm_status") ) cond->attr = EDG_WLL_QUERY_ATTR_VM_STATUS; 


       /**< When entered current status */
        /**< Time of the last known event of the job */
         /**< Network server aka RB aka WMproxy endpoint */

	else
	{
		cond->attr = EDG_WLL_QUERY_ATTR_USERTAG;
		cond->attr_id.tag = strdup(tmps);
	}

	if ( !(s = get_op(s, &(cond->op))) ) return NULL;

	if ( !(s = get_attr_value(s, tmps, 500)) ) return NULL;

	switch ( cond->attr )
	{
	case EDG_WLL_QUERY_ATTR_JOBID:
	case EDG_WLL_QUERY_ATTR_PARENT:
		if ( glite_jobid_parse(tmps, (glite_jobid_t *)&cond->value.j) )
		{
			fprintf(stderr,"%s: %s: cannot parse jobId\n", myname, tmps);
			return NULL;
		}
		break;

	case EDG_WLL_QUERY_ATTR_OWNER:
		if ( !strcmp("NULL", tmps) )
			cond->value.c = NULL;
		else if ( !(cond->value.c = strdup(tmps)) )
			return 0;
		break;

	case EDG_WLL_QUERY_ATTR_LOCATION:
	case EDG_WLL_QUERY_ATTR_DESTINATION:
	case EDG_WLL_QUERY_ATTR_USERTAG:
		if ( !(cond->value.c = strdup(tmps)) )
			return 0;
		break;

	case EDG_WLL_QUERY_ATTR_JDL_ATTR:
		if ( !(cond->value.c = strdup(tmps)) )
			return 0;
		if ( !(s = get_attr_value(s, tmps, 500)) ) return NULL;
		if ( tmps[0] == '\0' )
		{
			fprintf(stderr,"%s: you need to specify attribute name\n", myname);
			return NULL;
		}
		if ( !(cond->attr_id.tag = strdup(tmps)) )
			return 0;
		break;

	case EDG_WLL_QUERY_ATTR_STATUS:
		if ( 0 > (cond->value.i = edg_wll_StringToStat(tmps))) {
			fprintf(stderr,"%s: invalid status value (%s)\n", myname, tmps);
			return 0;
		}
		break;

	case EDG_WLL_QUERY_ATTR_DONECODE:
	case EDG_WLL_QUERY_ATTR_EXITCODE:
	case EDG_WLL_QUERY_ATTR_RESUBMITTED:
		cond->value.i = atoi(tmps);
		if ( cond->op == EDG_WLL_QUERY_OP_WITHIN )
		{
			if ( !(s = get_attr_value(s, tmps, 500)) ) return NULL;
			if ( tmps[0] == '\0' )
			{
				fprintf(stderr,"%s: second interval boundary not set\n", myname);
				return NULL;
			}
			cond->value2.i = atoi(tmps);
		}
		break;
	case EDG_WLL_QUERY_ATTR_TIME:
		cond->value.t.tv_sec = StrToTime(tmps);
		if ( cond->op == EDG_WLL_QUERY_OP_WITHIN )
		{
			if ( !(s = get_attr_value(s, tmps, 500)) ) return NULL;
			if ( tmps[0] == '\0' )
			{
				fprintf(stderr,"%s: second interval boundary not set\n", myname);
				return NULL;
			}
			cond->value2.t.tv_sec = StrToTime(tmps);
		}
		if ( !(s = get_attr_value(s, tmps, 500)) ) return NULL;
		if ( tmps[0] == '\0' )
		{
			fprintf(stderr,"%s: time condition must be associated with state condition\n", myname);
			return NULL;
		}
		if ( 0 > (cond->value.i = edg_wll_StringToStat(tmps))) {
			fprintf(stderr,"%s: invalid status value (%s)\n", myname, tmps);
			return 0;
		}
        	break;

	case EDG_WLL_QUERY_ATTR_LASTUPDATETIME:
	case EDG_WLL_QUERY_ATTR_STATEENTERTIME:
		cond->value.t.tv_sec = StrToTime(tmps);
		if ( cond->op == EDG_WLL_QUERY_OP_WITHIN )
		{
			if ( !(s = get_attr_value(s, tmps, 500)) ) return NULL;
			if ( tmps[0] == '\0' )
			{
				fprintf(stderr,"%s: second interval boundary not set\n", myname);
				return NULL;
			}
			cond->value2.t.tv_sec = StrToTime(tmps);
		}
		break;

	case EDG_WLL_QUERY_ATTR_JOB_TYPE:
		if ( 0 > (cond->value.i = edg_wll_JobtypeStrToCode(tmps))) {
			fprintf(stderr,"%s: invalid job type (%s)\n", myname, tmps);
			return 0;
		}
		break;
	
	case EDG_WLL_QUERY_ATTR_VM_STATUS:
		if ( 0 > (cond->value.i = edg_wll_StringToVMStat(tmps))) {
			fprintf(stderr,"%s: invalid VM status value (%s)\n", myname, tmps);
			return 0;
		}
		break;

	default:
		break;
	}

	while ( isblank(*s) || (*s == ';') ) s++;			/* skip whitespaces */

	return s;
}
Exemplo n.º 9
0
std::string get_item_field_name(int i)
{
    return get_attr_name(i, item_attrs, item_attr_type_table);
}
Exemplo n.º 10
0
std::string get_player_field_name(int i)
{
    return get_attr_name(i, player_attrs, player_attr_type_table);
}