TutOptionGetVerifyFunc


Name

TutOptionGetVerifyFunc — get the verify function of an option

Synopsis

T_BOOL TutOptionGetVerifyFunc(option, verify_func_return) 
T_OPTION option; 
T_OPTION_VERIFY_FUNC *verify_func_return;   

Arguments

option — option to get the verify function from

verify_func_return — pointer to a T_OPTION_VERIFY_FUNC into which TutOptionGetVerifyFunc copies a pointer to the verify function

Return Values

TRUE if value is retrieved successfully, FALSE otherwise.

Diagnostics

If TutOptionGetVerifyFunc fails, it returns FALSE and sets the global SmartSockets error number to:

Description

TutOptionGetVerifyFunc retrieves the verify function from option. For more information on verify functions, see TutOptionSetVerifyFunc on page 188.

Caution

None

See Also

TutOptionSetVerifyFunc

Examples

This example retrieves and calls a verify function:

/* This verify function is called when the */ 
/* value of option "num_opt" changes. */ 
T_BOOL VerifyNum(option, new_value, arg) 
T_OPTION option; 
T_PTR new_value; 
T_PTR arg; 
{ 
  T_REAL8 num_return; 
 
  num_return = *((T_REAL8 *)new_value); 
  if (num_return >= 0.0 && num_return <= 10.0) { 
    /* Value of "num_opt" will be changed to new_value */ 
    return TRUE; 
  } 
  else { 
    /* Value of "num_opt" will NOT be changed */ 
    return FALSE; 
  } 
} /* VerifyNum */ 
 
/* Below is a code fragment that could go into   */ 
/* an initialization routine.                                */ 
T_OPTION option; 
 
option =     TutOptionCreate("num_opt", T_OPT_TYPE_NUMERIC); 
if (option == NULL) { 
  /* error */ 
} 
 
if (!TutOptionSetVerifyFunc(option, VerifyNum, NULL) ) { 
  /* error */ 
} 
 
... 
 
/* The function below retrieves the verify */ 
/* function of option "num_opt", and then calls the */ 
/* verify function directly to see if the value */ 
/* of num is valid. */ 
void CheckNum(num) 
T_REAL8 num; 
{ 
  T_OPTION option; 
  T_OPTION_VERIFY_FUNC verify_func; 
 
  /* Retrieve the verify function */ 
  option = TutOptionLookup("num_opt"); 
  if (option == NULL) { 
    /* error */ 
  } 
   
  if (TutOptionGetVerifyFunc(option, &verify_func)) { 
    /* Provides a way to check a value to determine   */ 
    /* if it passes the option’s validation test.              */ 
    /* Note that the address of the value is expected   */ 
    /* by the verify function.                                       */ 
    if ((*verify_func)(option, (T_PTR)&num, NULL)) { 
    TutOut("Value of %f is valid.\n", num); 
    } 
    else { 
    TutOut("Value of %f is invalid.\n", num); 
    } 
  } 
} /* CheckNum */ 

TIBCO SmartSockets™ Utilities
Software Release 6.8, July 2006
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com