libsparklepaw
PawSD library
Loading...
Searching...
No Matches
service.h File Reference

Services, records and tags. More...

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>

Go to the source code of this file.

Data Structures

struct  sprkl_tag
 A tag (as seen in records), aka a fancy 128-bit integer. More...
struct  sprkl_tagval_pair
 A tag-value pair, contains one labelled piece of data. More...
struct  sprkl_record
 A record, made up of multiple tag-value pairs. More...
struct  sprkl_service
 A service, contains a collection of related records and is cryptographically signed. More...

Functions

int sprkl_record_write (struct sprkl_record *record, FILE *stream)
 Encodes and writes a record in wire format to a stream.
int sprkl_record_read (struct sprkl_record *record, FILE *stream)
 Reads and decodes a record in wire format from a stream.
void sprkl_record_freepairs (struct sprkl_record *record, bool freevalues)
 Frees all the pairs in a record (but not the record itself).
void sprkl_record_freeall (struct sprkl_record *record)
 Frees all the pairs in a record, and then the record itself.
int sprkl_service_write (struct sprkl_service *service, FILE *stream)
 Encodes and writes a service in wire format to a stream.
int sprkl_service_read (struct sprkl_service *service, FILE *stream)
 Reads and decodes a service in wire format from a stream.
int sprkl_service_printdebug (struct sprkl_service *service, FILE *stream)
 Prints out a service for debugging purposes.
void sprkl_service_freeparts (struct sprkl_service *service, bool records, bool signature)
 Frees all the records and/or signature of a service (but not the service itself).
void sprkl_service_freeall (struct sprkl_service *service)
 Frees all the stuff in the service, and then the service itself.

Detailed Description

Services, records and tags.

Function Documentation

◆ sprkl_record_freeall()

void sprkl_record_freeall ( struct sprkl_record * record)

Frees all the pairs in a record, and then the record itself.

Also frees all the values within the pairs.

Parameters
recordRecord to free.

◆ sprkl_record_freepairs()

void sprkl_record_freepairs ( struct sprkl_record * record,
bool freevalues )

Frees all the pairs in a record (but not the record itself).

Parameters
recordRecord whose pairs will be freed.
freevaluesIf true, also free the value buffers within each pair.

◆ sprkl_record_read()

int sprkl_record_read ( struct sprkl_record * record,
FILE * stream )

Reads and decodes a record in wire format from a stream.

Allocates memory for the new pairs.

Parameters
[out]recordEmpty record to read into.
[in]streamStream to read it from.
Returns
number of bytes read.

◆ sprkl_record_write()

int sprkl_record_write ( struct sprkl_record * record,
FILE * stream )

Encodes and writes a record in wire format to a stream.

Parameters
[in]recordRecord to write.
[out]streamStream to write the record to.
Returns
number of bytes written.

◆ sprkl_service_freeall()

void sprkl_service_freeall ( struct sprkl_service * service)

Frees all the stuff in the service, and then the service itself.

Same as sprkl_service_freeparts() (with both options set to true), except it also calls free(service) at the end.

Parameters
serviceService to free.

◆ sprkl_service_freeparts()

void sprkl_service_freeparts ( struct sprkl_service * service,
bool records,
bool signature )

Frees all the records and/or signature of a service (but not the service itself).

When freeing the records it will also free all of their contents, including the pairs and the pairs' value buffers. Afterwards, the sprkl_service::reccnt and/or sprkl_service::sigsz fields will be zeroed as needed.

Parameters
serviceService to free.
recordsWhether to free the records.
signatureWhether to free the buffer containing the signature.

◆ sprkl_service_printdebug()

int sprkl_service_printdebug ( struct sprkl_service * service,
FILE * stream )

Prints out a service for debugging purposes.

Parameters
[in]serviceService to print out.
[out]streamStream to print it to.
Returns
number of bytes written.

◆ sprkl_service_read()

int sprkl_service_read ( struct sprkl_service * service,
FILE * stream )

Reads and decodes a service in wire format from a stream.

Allocates memory for the new records and the signature.

Parameters
[out]serviceEmpty service to read into.
[in]streamStream to read it from.
Returns
number of bytes read.

◆ sprkl_service_write()

int sprkl_service_write ( struct sprkl_service * service,
FILE * stream )

Encodes and writes a service in wire format to a stream.

Parameters
[in]serviceService to write.
[out]streamStream to write the service to.
Returns
number of bytes written.