prg_preference_value_get()

Abstract

Obtains the value of a preference and ensures that the attribute appears when a user selects Edit Preferences.

Syntax

prg_preference_value_get (attr_type, group_name, attr_name, description_string, options, value_ptr)
Argument Type Description
attr_type PrgT_Env_Attr_Type the preference's data type. [This value must be a defined preference type, or an error will occur. The available types are listed in Symbolic Constants.
group_name const char* group name of the attribute-of-interest Standard, FLS, GUI, etc. This argument can be an empty string (“”).
attr_name const char* name of the attribute-of-interest
description_string const char* description of the attribute-of-interest. This argument can be an empty string (“”).
options int flag to specify binary options. This argument is reserved for future use. Currently the only defined value is PRGC_PREFERENCE_OPT_NONE.
value_ptr void* pointer to a variable to be filled with the specified attribute's value. See the Details section for more information.

Return Type

PrgT_Compcode

Completion code indicating whether the operation completed successfully. This code can be compared to the two symbolic constants PrgC_Compcode_Success and PrgC_Compcode_Failure.

prg_env.h

Example

	sprintf (attr_name, "engs_dir");
	if ((status = prg_preference_value_get (PrgC_Env_Attr_String,
			ENGSC_ATTR_GROUP, attr_name,
			ENGSC_ATTR_DIR_DESC, PRGC_PREFERENCE_OPT_NONE, attr_value)) ==
			PrgC_Compcode_Failure)
		{
		/* Unable to obtain the engs_dir environment variable. */
		printf("\nUnable to obtain %s preference\n\n", attr_name);
		}

Details

The value_ptr argument can accept a character string or a pointer to a variable of type integer, double, or PrgT_List. The data type of the argument pointer must match the data type of the specified attribute or an error will occur.

  • In the case of a character string, the array of characters must be large enough to contain the attribute's value.
  • If the attribute is of type PrgT_Boolean, the return value will either be PRGC_TRUE or PRGC_FALSE.
  • If the attribute is of type PrgT_List, the list for value_ptr must be allocated and initialized with a function such as prg_list_create() or prg_list_init() prior to calling this function.

Purpose

Provides a mechanism to obtain preferences from the current process. The value of a preference in the current process can be obtained.

This function differs from prg_env_attr_value_get() in that prg_preference_value_get() ensures that any attribute it requests will subsequently appear when a user selects Edit Preferences; prg_env_attr_value_get() does not ensure this behavior.

Errors

  • Program Abort: Segmentation violation (due to an invalid value pointer, pointer to an insufficient amount of memory, or invalid address for group_name, attr_name, description_string, or value_ptr)

Reference

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · Documentation compiled and provided by Beijing ZNetLink Technology Co., Ltd.

交流群 · QQ Group:OPNET/智网妙算网络仿真交流群(群号 486383494)

原文档 © 2017 Riverbed Technology · 本站为公益翻译,由 AI 辅助完成,请仔细甄别

Original documentation © 2017 Riverbed Technology. Community translation, AI-assisted. Contact: jiazequn@znetlink.com