/*
 * The code in the following example updates the out_of_date drawings
 * or views in the current part.
*/
#include <stdio.h>
#include <uf.h>
#include <uf_defs.h>
#include <uf_draw.h>
#include <uf_draw_types.h>
#include <uf_obj.h>
#include <uf_view.h>
void ufusr(char *param, int *retcod, int param_len)
{
    int           ifail = 0;
    char          drawing_name[MAX_ENTITY_NAME_SIZE + 1] = "";
    char          view_name [MAX_ENTITY_NAME_SIZE + 1] = "";
    char          error_message[133];
    tag_t         view_tag = NULL_TAG;
    tag_t         drawing_tag = NULL_TAG;
    logical       out_of_date;
    ifail = UF_initialize();

    if (ifail == 0)
    {
        ifail = UF_DRAW_ask_current_drawing(&drawing_tag);
    }
    if ( ifail == 0 && drawing_tag != NULL_TAG )
    {
        ifail = UF_OBJ_ask_name( drawing_tag, drawing_name );
    }
    if (ifail == 0)
    {
        /* Get the name of the drawing's first view. */
        ifail = uc6499 (drawing_name, view_name);
    }
    if (ifail == 0)
    {
        /* Get the view's tag. */
        ifail = UF_VIEW_ask_tag_of_view_name (view_name,
&view_tag);
    }
    if (ifail == 0)
    {
        /* Query the drawing's out of date status. */
        ifail = UF_DRAW_is_object_out_of_date(drawing_tag,
&out_of_date);
    }
    if (ifail == 0 && out_of_date && view_tag != NULL_TAG)
    {
       /* Update the view. */
        ifail = UF_DRAW_update_one_view(drawing_tag,view_tag);
    }
    printf ("UF_DRAW_update_one_view sample ");

    if (ifail != 0)
    {
        ifail = UF_get_fail_message( ifail, error_message );
        printf( "fails.\nError is: %s\n", error_message );
    }
    else
        printf( "is successful.\n" );
    UF_terminate();
}

