Queries the current layout values of a LayoutObject structure.
Layout Library (libi18n.a)
#include <sys/lc_layout.h>
int layout_object_getvalue( layout_object, values, index)
LayoutObject layout_object;
LayoutValues values;
int *index;
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.
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. |
Upon successful completion, the layout_object_getvalue subroutine returns a value of 0. All layout values were successfully queried.
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. |
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");
}