Main Page | Data Structures | Directories | File List | Data Fields | Globals

ks_bquery.c File Reference

Implementation of the bquery protocol. More...

#include "ks_config.h"
#include "ks_bquery.h"
#include "ks_malloc.h"
#include <stdio.h>
#include <string.h>

Go to the source code of this file.

Functions

ks_type_tks_bquery_type (void)
ks_bquery_tks_bquery_new (void)
void ks_bquery_free (ks_bquery_t *q)
void ks_bquery_id_set (ks_bquery_t *q, const char *id, size_t len)
ks_string_tks_bquery_id_get (ks_bquery_t *q)
void ks_bquery_feed_add (ks_bquery_t *q, const char *id)
void ks_bquery_composite_add (ks_bquery_t *q, const char *id)
void ks_bquery_combiner_add (ks_bquery_t *q, const char *id)
void ks_bquery_identity_add (ks_bquery_t *q, const char *id, int idt)
void ks_bquery_identity_add_tagged (ks_bquery_t *q, const char *id, int idt, const char *tag)
void ks_bquery_flags_set (ks_bquery_t *q, long flags)
ks_string_tks_bquery_packet (ks_bquery_t *q)
int ks_bquery_has_auth (ks_bquery_t *q)
void ks_bquery_set_auth (ks_bquery_t *q, const char *p, const char *c)


Detailed Description

Implementation of the bquery protocol.

Definition in file ks_bquery.c.


Function Documentation

void ks_bquery_combiner_add ks_bquery_t q,
const char *  id
 

Add an additional combiner ito be queried to a ks_bquery_t.

Parameters:
q a pointer to the ks_bquery_t to which the combiner is to be added
id the combiner's name (a NUL terminated string)
Returns:
nothing

Definition at line 260 of file ks_bquery.c.

References _ks_bquery_t::combiners, ks_array_add(), and ks_string_new().

void ks_bquery_composite_add ks_bquery_t q,
const char *  id
 

Add a composite (aka feedset) to be queried to a ks_bquery_packet.

Parameters:
q a pointer to the ks_bquery_t to which the composite should be added
id the name of the composite to be queried (a NUL terminated string)
Returns:
nothing

Definition at line 245 of file ks_bquery.c.

References _ks_bquery_t::composites, ks_array_add(), and ks_string_new().

Referenced by main().

void ks_bquery_feed_add ks_bquery_t q,
const char *  id
 

Adds a feed to be queried to a ks_bquery_t.

Parameters:
q a pointer to the ks_bquery_t the feed is to be added to
id the number of the id to be queried
Returns:
nothing

Definition at line 229 of file ks_bquery.c.

References _ks_bquery_t::feeds, ks_array_add(), and ks_string_new().

Referenced by main().

void ks_bquery_flags_set ks_bquery_t q,
long  flags
 

Set the flags in a ks_bquery_t.

Parameters:
q a pointer to the ks_bquery_t whose flags are to be set
flags the flags to be set XOR'd together. Valid flags are:
  • KS_FL_FACTS
Returns:
nothing

Definition at line 355 of file ks_bquery.c.

References _ks_bquery_t::flags, and ks_number_set().

Referenced by main().

void ks_bquery_free ks_bquery_t q  ) 
 

Destroys a ks_bquery_t, freeing all memory that has been allocated for it.

Parameters:
q a pointer to the ks_bquery_t to be destroyed
Returns:
nothing

Definition at line 159 of file ks_bquery.c.

References _ks_bquery_t::combiners, _ks_bquery_t::composites, _ks_bquery_t::credentials, _ks_bquery_t::feeds, _ks_bquery_t::flags, _ks_bquery_t::id, _ks_bquery_t::identities, ks_array_fini(), ks_free(), ks_number_fini(), ks_string_free(), and _ks_bquery_t::principal.

Referenced by main().

int ks_bquery_has_auth ks_bquery_t q  ) 
 

Determine whether or not a ks_bquery_t has authentication tokens.

Parameters:
q a pointer to the ks_bquery_t being inspected
Returns:
zero if the given ks_bquery_t does not have authentication tokens, or nonzero otherwise.

Definition at line 386 of file ks_bquery.c.

References _ks_bquery_t::principal.

Referenced by ks_socket_send().

ks_string_t* ks_bquery_id_get ks_bquery_t q  ) 
 

Returns the cookie value from a ks_bquery_t.

If the ks_bquery_t does not already have an ID, one is generated and stored within it. libkarmaclient does not generate bquery packets that do not have cookies.

Parameters:
q a pointer to the ks_bquery_t whose id is to be inspected
Returns:
a pointer to the ks_bquery_t's cookie on success, or NULL on failure

Definition at line 210 of file ks_bquery.c.

References _ks_bquery_t::id, and ks_string_new().

Referenced by ks_socket_ask().

void ks_bquery_id_set ks_bquery_t q,
const char *  id,
size_t  len
 

Sets the value of the cookie for this query.

This will be returned by the karmaserver in the response packet to allow the client to keep track of query/response pairs.

Parameters:
q a pointer to the ks_bquery_t whose id is to be set
id a string to uniquely identify this ks_bquery_t and its associated ks_response_t
len the length of the id string (in chars)
Returns:
nothing

Definition at line 189 of file ks_bquery.c.

References _ks_bquery_t::id, ks_string_new(), and ks_string_set().

void ks_bquery_identity_add ks_bquery_t q,
const char *  id,
int  idt
 

Add an identity (on which an opinion is sought from a karmaserver) to a ks_bquery_t.

To pass additional context information about the identity, use ks_bquery_identity_add_tagged.

Parameters:
q a pointer to the ks_bquery_t to which the identity should be added.
id the identity to add to the ks_bquery_t (a NUL terminated string)
idt an integer describing the type of the identity. Valid values for types are:
  • KS_IDT_IP4_ADDRESS
  • KS_IDT_IP6_ADDRESS
  • KS_IDT_DOMAIN_NAME
  • KS_IDT_EMAIL_ADDRESS
  • KS_IDT_URI
Returns:
nothing

Definition at line 314 of file ks_bquery.c.

void ks_bquery_identity_add_tagged ks_bquery_t q,
const char *  id,
int  idt,
const char *  tag
 

Add an identity (on which an opinion is sought from a karmaserver) and a tag string to a ks_bquery_t.

Parameters:
q a pointer to the ks_bquery_t to which the identity should be added.
id the identity to add to the ks_bquery_t (a NUL terminated string)
idt an integer describing the type of the identity. Valid values for types are:
  • KS_IDT_IP4_ADDRESS
  • KS_IDT_IP6_ADDRESS
  • KS_IDT_DOMAIN_NAME
  • KS_IDT_EMAIL_ADDRESS
  • KS_IDT_URI
tag a NUL terminated string to be used as a tag
Returns:
nothing

Definition at line 338 of file ks_bquery.c.

References ks_array_add(), and ks_string_new().

ks_bquery_t* ks_bquery_new void   ) 
 

Constructs a new ks_bquery_t.

This function allocates memory that must be freed by ks_bquery_free().

Returns:
a pointer to the newly created ks_bquery_t on success, or NULL on failure.

Definition at line 135 of file ks_bquery.c.

References _ks_bquery_t::base, _ks_bquery_t::combiners, _ks_bquery_t::composites, _ks_bquery_t::credentials, _ks_bquery_t::feeds, _ks_bquery_t::flags, _ks_bquery_t::id, _ks_bquery_t::identities, ks_array_init(), ks_malloc(), ks_number_init(), _ks_bquery_t::principal, and _ks_base_t::type.

Referenced by main().

ks_string_t* ks_bquery_packet ks_bquery_t q  ) 
 

Convert a ks_bquery_t object into a bquery packet.

Parameters:
q a pointer to the ks_bquery_t to be converted
Returns:
a pointer to a ks_string_t containing the bquery packet. The memory used for this ks_string_t can be reclaimed by destroying the ks_string_t with ks_string_free().

Definition at line 370 of file ks_bquery.c.

References ks_string_new().

Referenced by ks_socket_send().

void ks_bquery_set_auth ks_bquery_t q,
const char *  p,
const char *  c
 

Set authentication tokens for a bquery object.

Parameters:
q a pointer to the ks_bquery_t to be authenticated
p a NUL terminated string containing an identifier used to authenticate client connections. This may be a login or account name. The precise details will depend on the policy of the query server being used.
c a NUL terminated string containing the credentials used to authenticate the principal, p. this may be a password, or a certificate. The precise details may depend on the policy of the query server being used.
Returns:
nothing.

Definition at line 407 of file ks_bquery.c.

References _ks_bquery_t::credentials, ks_string_free(), ks_string_new(), ks_string_set(), and _ks_bquery_t::principal.

Referenced by ks_socket_send().

ks_type_t* ks_bquery_type void   ) 
 

Returns the metaclass for ks_bquery_t objects.

Returns:
a pointer to the ks_bquery_t metaclass, ks_type_bquery

Definition at line 120 of file ks_bquery.c.


Generated on Tue Aug 7 21:11:31 2007 for libkarmaclient by  doxygen 1.4.4