layout_object_getvalue Subroutine

Purpose

Queries the current layout values of a LayoutObject structure.

Library

Layout Library (libi18n.a)

Syntax

#include <sys/lc_layout.h> 

int layout_object_getvalue( layout_object,  values,  index)
LayoutObject layout_object;
LayoutValues values;
int *index;

Description

The layout_object_getvalue subroutine queries the current setting of layout values within the LayoutObject structure. The layout_object parameter specifies the LayoutObject structure created by the layout_object_create subroutine.

The name field of the LayoutValues structure contains the name of the layout value to be queried. The value field is a pointer to where the layout value is stored. The values are queried from the LayoutObject structure and represent its current state.

For example, if the layout value to be queried is of type T, the value parameter must be of type T*. If T itself is a pointer, the layout_object_getvalue subroutine allocates space to store the actual data. The caller must free this data by calling the free(T) subroutine with the returned pointer.

When setting the value field, an extra level of indirection is present that is not present using the layout_object_setvalue parameter. When you set a layout value of type T, the value field contains T. However, when querying the same layout value, the value field contains &T.

Note: If you are developing internationalized applications that may support multibyte locales, please see Use of the libcur Package inAIX® Version 7.1 General Programming Concepts: Writing and Debugging Programs

Parameters

Item Description
layout_object Specifies the LayoutObject structure created by the layout_object_create subroutine.
values Specifies an array of layout values of type LayoutValueRec that are to be queried in the LayoutObject structure. The end of the array is indicated by name=0.
index Specifies a layout value to be queried. If the value cannot be queried, the index parameter causing the error is returned and the subroutine returns a non-zero value.

Return Values

Upon successful completion, the layout_object_getvalue subroutine returns a value of 0. All layout values were successfully queried.

Error Codes

If the layout_object_getvalue subroutine fails, it returns the following values:

Item Description
LAYOUT_EINVAL The layout value specified by the index parameter is unknown or the layout_object parameter is invalid.
LAYOUT_EMOMEM Insufficient storage space is available.

Examples

The following example queries whether the locale is bidirectional and gets the values of the in and out orienations.

#include <sys/lc_layout.h>
#include <locale.h>
main()
{
LayoutObject plh;
int RC=0;
LayoutValues layout;
LayoutTextDescriptor Descr;
int index;

RC=layout_object_create(setlocale(LC_CTYPE,""),&plh); /* create object */
if (RC) {printf("Create error !!\n"); exit(0);}

layout=malloc(3*sizeof(LayoutValueRec));
                                         /* allocate layout array */
layout[0].name=ActiveBidirection;        /* set name */
layout[1].name=Orientation;              /* set name */
layout[1].value=(caddr_t)&Descr;
            /* send address of memory to be allocated by function */

layout[2].name=0;                     /* indicate end of array */
RC=layout_object_getvalue(plh,layout,&index);
if (RC) {printf("Getvalue error at %d !!\n",index); exit(0);}
printf("ActiveBidirection = %d \n",*(layout[0].value));
                                                    /*print output*/
printf("Orientation in = %x  out = %x \n", Descr->>in, Descr->>out);

free(layout);                        /* free layout array */
free (Descr);             /* free memory allocated by function */
RC=layout_object_free(plh);         /* free layout object */
if (RC) printf("Free error !!\n");
}