Loading...
Searching...
No Matches
clif.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019 HAW Hamburg
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
95#ifndef CLIF_H
96#define CLIF_H
97
98#include <sys/types.h>
99
100#include "clif_internal.h"
101
102#ifdef __cplusplus
103extern "C" {
104#endif
105
109enum {
112 CLIF_NOT_FOUND = -2
114
133
137typedef struct {
138 char *value;
139 unsigned value_len;
140 const char *key;
141 unsigned key_len;
143
147typedef struct {
148 char *target;
149 unsigned target_len;
151 unsigned attrs_len;
152} clif_t;
153
169ssize_t clif_encode_link(const clif_t *link, char *buf, size_t maxlen);
170
186ssize_t clif_decode_link(clif_t *link, clif_attr_t *attrs, unsigned attrs_len,
187 const char *buf, size_t maxlen);
188
206ssize_t clif_add_target_from_buffer(const char *target, size_t target_len,
207 char *buf, size_t maxlen);
208
225ssize_t clif_add_target(const char *target, char *buf, size_t maxlen);
226
245ssize_t clif_add_attr(clif_attr_t *attr, char *buf, size_t maxlen);
246
260ssize_t clif_add_link_separator(char *buf, size_t maxlen);
261
276ssize_t clif_get_target(const char *input, size_t input_len, char **output);
294ssize_t clif_get_attr(const char *input, size_t input_len, clif_attr_t *attr);
295
306clif_attr_type_t clif_get_attr_type(const char *input, size_t input_len);
307
317ssize_t clif_attr_type_to_str(clif_attr_type_t type, const char **str);
318
329
330#ifdef __cplusplus
331}
332#endif
333
334#endif /* CLIF_H */
Internal definitions for CoRE Link format module.
ssize_t clif_attr_type_to_str(clif_attr_type_t type, const char **str)
Returns a constant string of a given attribute type.
ssize_t clif_decode_link(clif_t *link, clif_attr_t *attrs, unsigned attrs_len, const char *buf, size_t maxlen)
Decodes a string of link format.
clif_attr_type_t
Types of link format attributes.
Definition clif.h:118
ssize_t clif_add_target(const char *target, char *buf, size_t maxlen)
Adds a given target to a given buffer buf using link format.
ssize_t clif_add_target_from_buffer(const char *target, size_t target_len, char *buf, size_t maxlen)
Adds a given target to a given buffer buf using link format.
int clif_init_attr(clif_attr_t *attr, clif_attr_type_t type)
Initializes the key of a given attribute according to a given type.
ssize_t clif_get_target(const char *input, size_t input_len, char **output)
Looks for a the target URI of a given link.
ssize_t clif_get_attr(const char *input, size_t input_len, clif_attr_t *attr)
Looks for the first attribute in a given link.
clif_attr_type_t clif_get_attr_type(const char *input, size_t input_len)
Returns the attribute type of a given string.
ssize_t clif_encode_link(const clif_t *link, char *buf, size_t maxlen)
Encodes a given link in link format into a given buffer.
ssize_t clif_add_link_separator(char *buf, size_t maxlen)
Adds the link separator character to a given buf, using link format.
ssize_t clif_add_attr(clif_attr_t *attr, char *buf, size_t maxlen)
Adds a given attr to a given buffer buf using link format.
@ CLIF_ATTR_CT
ct
Definition clif.h:129
@ CLIF_ATTR_SZ
sz
Definition clif.h:128
@ CLIF_ATTR_LANG
hreflang
Definition clif.h:121
@ CLIF_ATTR_RT
rt
Definition clif.h:126
@ CLIF_ATTR_OBS
obs
Definition clif.h:130
@ CLIF_ATTR_REL
rel
Definition clif.h:120
@ CLIF_ATTR_ANCHOR
anchor
Definition clif.h:119
@ CLIF_ATTR_TITLE
title
Definition clif.h:123
@ CLIF_ATTR_IF
if
Definition clif.h:127
@ CLIF_ATTR_TYPE
type
Definition clif.h:125
@ CLIF_ATTR_MEDIA
media
Definition clif.h:122
@ CLIF_ATTR_EXT
extensions
Definition clif.h:131
@ CLIF_ATTR_TITLE_EXT
title*
Definition clif.h:124
@ CLIF_NOT_FOUND
could not find a component in a buffer
Definition clif.h:112
@ CLIF_NO_SPACE
not enough space in the buffer
Definition clif.h:111
@ CLIF_OK
success
Definition clif.h:110
Link format attribute descriptor.
Definition clif.h:137
unsigned key_len
length of the attribute name
Definition clif.h:141
unsigned value_len
length of the value
Definition clif.h:139
const char * key
attribute name
Definition clif.h:140
char * value
string with the value
Definition clif.h:138
Link format descriptor.
Definition clif.h:147
unsigned target_len
length of target string
Definition clif.h:149
unsigned attrs_len
size of array of attributes
Definition clif.h:151
char * target
target string
Definition clif.h:148
clif_attr_t * attrs
array of attributes
Definition clif.h:150