Difference between revisions of "Truxton option get boolean"

From truxwiki.com
Jump to navigation Jump to search
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
 
=Syntax=
 
=Syntax=
<syntaxhighlight lang="C">
+
<source lang="C">
 
int64_t truxton_options_get_boolean( uint64_t options_handle, char const * name );
 
int64_t truxton_options_get_boolean( uint64_t options_handle, char const * name );
</syntaxhighlight>
+
</source>
  
 
=Parameters=
 
=Parameters=
Line 15: Line 15:
 
=Return value=
 
=Return value=
 
Zero if the boolean value is false, one if the boolean value is true.
 
Zero if the boolean value is false, one if the boolean value is true.
 +
If the named option is not found, false is returned.
  
 
=Sample=
 
=Sample=
<syntaxhighlight lang="C" highlight="5">
+
<source lang="C" highlight="5">
void process_free(void)
+
void process_free( void )
 
{
 
{
 
   uint64_t options = truxton_options_create();
 
   uint64_t options = truxton_options_create();
  
   if ( truxton_options_get_boolean("pfree") == 1 )
+
   if ( truxton_options_get_boolean( "pfree" ) == 1 )
 
   {
 
   {
 
       printf( "Yes, we will process free space\n" );
 
       printf( "Yes, we will process free space\n" );
Line 31: Line 32:
 
   }
 
   }
  
   truxton_options_destroy(options);
+
   truxton_options_destroy( options );
 
}
 
}
</syntaxhighlight>
+
</source>

Latest revision as of 14:07, 9 February 2021

Reads a boolean setting.

Syntax

int64_t truxton_options_get_boolean( uint64_t options_handle, char const * name );

Parameters

options_handle

The handle to the options object created by calling the truxton_options_create function.

name

The name of the option to read.

Return value

Zero if the boolean value is false, one if the boolean value is true. If the named option is not found, false is returned.

Sample

void process_free( void )
{
   uint64_t options = truxton_options_create();

   if ( truxton_options_get_boolean( "pfree" ) == 1 )
   {
      printf( "Yes, we will process free space\n" );
   }
   else
   {
      printf( "No, we will not process free space\n" );
   }

   truxton_options_destroy( options );
}