libsparklepaw
PawSD library
Loading...
Searching...
No Matches
service.h
Go to the documentation of this file.
1
3
4#ifndef SPRKL_SERVICE_H
5#define SPRKL_SERVICE_H
6
7#include <stdbool.h>
8#include <stdint.h>
9#include <stdio.h>
10
12struct sprkl_tag {
13 uint64_t upper;
14 uint64_t lower;
15};
16
19 struct sprkl_tag tag;
20 uint32_t valuesz;
21 uint8_t* value;
22};
23
26 uint16_t paircnt;
28};
29
33 uint16_t sigsz;
34 uint8_t* signature;
35 uint16_t index;
39 uint32_t flags;
40 uint16_t reccnt;
42};
43
44
49int sprkl_record_write(struct sprkl_record* record, FILE* stream);
50
56int sprkl_record_read(struct sprkl_record* record, FILE* stream);
57
61void sprkl_record_freepairs(struct sprkl_record* record, bool freevalues);
62
66void sprkl_record_freeall(struct sprkl_record* record);
67
68
73int sprkl_service_write(struct sprkl_service* service, FILE* stream);
74
80int sprkl_service_read(struct sprkl_service* service, FILE* stream);
81
86int sprkl_service_printdebug(struct sprkl_service* service, FILE* stream);
87
98 struct sprkl_service* service,
99 bool records,
100 bool signature
101 );
102
107void sprkl_service_freeall(struct sprkl_service* service);
108
109#endif
void sprkl_record_freepairs(struct sprkl_record *record, bool freevalues)
Frees all the pairs in a record (but not the record itself).
Definition service.c:115
int sprkl_record_write(struct sprkl_record *record, FILE *stream)
Encodes and writes a record in wire format to a stream.
Definition service.c:83
int sprkl_service_write(struct sprkl_service *service, FILE *stream)
Encodes and writes a service in wire format to a stream.
Definition service.c:6
int sprkl_service_printdebug(struct sprkl_service *service, FILE *stream)
Prints out a service for debugging purposes.
Definition service.c:34
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).
Definition service.c:59
int sprkl_record_read(struct sprkl_record *record, FILE *stream)
Reads and decodes a record in wire format from a stream.
Definition service.c:97
void sprkl_service_freeall(struct sprkl_service *service)
Frees all the stuff in the service, and then the service itself.
Definition service.c:77
void sprkl_record_freeall(struct sprkl_record *record)
Frees all the pairs in a record, and then the record itself.
Definition service.c:124
int sprkl_service_read(struct sprkl_service *service, FILE *stream)
Reads and decodes a service in wire format from a stream.
Definition service.c:19
A record, made up of multiple tag-value pairs.
Definition service.h:25
struct sprkl_tagval_pair * pairs
Array of pairs.
Definition service.h:27
uint16_t paircnt
Number of pairs in the record.
Definition service.h:26
A service, contains a collection of related records and is cryptographically signed.
Definition service.h:32
struct sprkl_record * records
Array of records.
Definition service.h:41
uint16_t sigsz
Length (in bytes) of the signature.
Definition service.h:33
uint8_t * signature
Signature (no terminator).
Definition service.h:34
uint32_t flags
Flags (bitfield).
Definition service.h:39
uint16_t index
Service index within its zone.
Definition service.h:35
uint16_t reccnt
Number of records in the service.
Definition service.h:40
A tag (as seen in records), aka a fancy 128-bit integer.
Definition service.h:12
uint64_t lower
Least significant half of the tag.
Definition service.h:14
uint64_t upper
Most significant half of the tag.
Definition service.h:13
A tag-value pair, contains one labelled piece of data.
Definition service.h:18
uint32_t valuesz
Length (in bytes) of the value.
Definition service.h:20
uint8_t * value
Raw value (no terminator).
Definition service.h:21