atom.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _KLONE_ATOM_H_
00012 #define _KLONE_ATOM_H_
00013
00014 #include <stdlib.h>
00015 #include <u/libu.h>
00016
00017 #ifdef __cplusplus
00018 extern "C" {
00019 #endif
00020
00021
00022 typedef struct atom_s
00023 {
00024 LIST_ENTRY(atom_s) np;
00025 char *id;
00026 char *data;
00027 size_t size;
00028 void *arg;
00029 } atom_t;
00030
00031
00032 LIST_HEAD(atom_list_s, atom_s);
00033 typedef struct atom_list_s atom_list_t;
00034
00035 struct atoms_s
00036 {
00037 atom_list_t list;
00038 size_t size, count;
00039 };
00040
00041
00042 int atom_create(const char *id, const char *data, size_t size, void* arg,
00043 atom_t**pa);
00044
00045 int atom_free(atom_t* atom);
00046
00047
00048 struct atoms_s;
00049 typedef struct atoms_s atoms_t;
00050
00051
00052 int atoms_create(atoms_t **);
00053
00054
00055 int atoms_free(atoms_t *);
00056
00057
00058 size_t atoms_size(atoms_t *);
00059
00060
00061 size_t atoms_count(atoms_t *);
00062
00063
00064 int atoms_getn(atoms_t *, size_t n, atom_t**);
00065
00066
00067 int atoms_get(atoms_t *, const char *id, atom_t**);
00068
00069
00070 int atoms_add(atoms_t *, atom_t*);
00071
00072
00073 int atoms_remove(atoms_t *, atom_t*);
00074
00075 #ifdef __cplusplus
00076 }
00077 #endif
00078
00079 #endif