AMI (Asterisk Management Interface) messages read/create functions. More...
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "amipack.h"
Functions | |
AMIPacket * | amipack_init () |
AMIQueue * | amipack_queue_init () |
void | amipack_queue_destroy (AMIQueue *queue) |
void | amiheader_destroy (AMIHeader *hdr) |
AMIHeader * | amiheader_create (char *name, size_t name_size, char *value, size_t value_size) |
void | amipack_destroy (AMIPacket *pack) |
size_t | amiheader_to_str (AMIHeader *hdr, char *buf) |
size_t | amipack_to_str (AMIPacket *pack, char **pstr) |
int | amipack_append (AMIPacket *pack, char *hdr_name, size_t name_size, char *hdr_value, size_t value_size) |
int | amipack_list_append (AMIPacket *pack, AMIHeader *header) |
size_t | amiheader_find (AMIPacket *pack, const char *name, char **val) |
AMI (Asterisk Management Interface) messages read/create functions.
amiws – Library with functions for read/create AMI packets Copyright (C) 2017, Stas Kobzar stask obza r@mod ulis .ca
This file is part of amiws.
amiws is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
amiws is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with amiws. If not, see http://www.gnu.org/licenses/.
AMIHeader* amiheader_create | ( | char * | name, |
size_t | name_size, | ||
char * | value, | ||
size_t | value_size | ||
) |
Create new AMI header with given parameters. Will allocated memory for AMIHeader and return pointer to it.
name | AMI header name |
name_size | Name field size |
value | AMI header value |
value_size | Value field size |
void amiheader_destroy | ( | AMIHeader * | hdr | ) |
Destroy AMI header and free memory.
hdr | AMI header to destroy |
size_t amiheader_find | ( | AMIPacket * | pack, |
const char * | name, | ||
char ** | value | ||
) |
Search header by header name. Will return header value length in packet exists otherwise -1. Will return only first found header value.
pack | AMI packet structure pointer |
name | Header name |
value | String where the found value will be stored. |
size_t amiheader_to_str | ( | AMIHeader * | hdr, |
char * | buf | ||
) |
Convert AMIHeader pstr string.
hdr | AMI header structure pointer |
buf | Header as string "Name: value\r\n" |
int amipack_append | ( | AMIPacket * | pack, |
char * | hdr_name, | ||
size_t | name_size, | ||
char * | hdr_value, | ||
size_t | value_size | ||
) |
Append header to AMI packet. Will create new AMI header using given type and value string. New header will be appanded to the head of linked list.
pack | Pointer to AMI packet structure |
hdr_name | AMI header name as string. |
name_size | Header name size |
hdr_value | AMI header value as string. |
value_size | AMI header value size |
void amipack_destroy | ( | AMIPacket * | pack | ) |
Destroy AMI packet and free memory.
pack | AMI header to destroy |
AMIPacket* amipack_init | ( | ) |
Initiate AMIPacket and allocate memory. AMI packet is implemented as linked list data structure.
Append AMI header to packet.
pack | AMI packet structure pointer |
header | AMI header structure pointer |
void amipack_queue_destroy | ( | AMIQueue * | queue | ) |
Destroy Queue structrue.
pack | AMI header to destroy |
AMIQueue* amipack_queue_init | ( | ) |
Initiate Queue member
size_t amipack_to_str | ( | AMIPacket * | pack, |
char ** | pstr | ||
) |
Convert AMIPacket to string. Will allocate memory for the string, set packet as string and return pointer to the char array.
pack | AMI packet structure pointer |
pstr | AMI packet as string |