Aw instance callback set

From ActiveWiki
Revision as of 05:02, 4 August 2009 by Macavity (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search



Minimum requirements
Added in version 4.1


int aw_instance_callback_set (AW_CALLBACK c, void (*callback)  (int rc))

Description

Establishes a callback handler for an asynchronous call for the current instance.

Callback

None (returns immediately)

Arguments

c
Callback (defined in Aw.h)
callback
Pointer to the callback handler. Setting it to NULL deactivates the callback.

Argument attributes

None

Return values

RC_SUCCESS
RC_NOT_INITIALIZED
RC_NO_INSTANCE
RC_INVALID_ATTRIBUTE
Not a callback.

Returned attributes

None

Usage

void handle_citizen_result (int rc)
{
  if (rc != RC_SUCCESS)
    printf ("Citizen manipulation failed (reason %d)\n", rc);
  else
    puts ("Citizen manipulation succeeded");
}

void change_homepage (int citizen, char *url)
{
  int rc;
  
  rc = aw_citizen_attributes_by_number (citizen);
  if (rc != RC_SUCCESS) 
    printf ("Citizen #%d query failed (reason %d)\n", citizen, rc);
  else
  {
    aw_instance_callback_set (AW_CALLBACK_CITIZEN_RESULT, handle_citizen_result);
    aw_string_set (AW_CITIZEN_URL, url);
    aw_citizen_change ();
  }
}

See also