/[public]/psiconv/trunk/lib/psiconv/list.h
ViewVC logotype

Diff of /psiconv/trunk/lib/psiconv/list.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 79 Revision 351
1/* 1/*
2 list.h - Part of psiconv, a PSION 5 file formats converter 2 list.h - Part of psiconv, a PSION 5 file formats converter
3 Copyright (c) 1999, 2000 Frodo Looijaard <frodol@dds.nl> 3 Copyright (c) 1999-2014 Frodo Looijaard <frodo@frodo.looijaard.name>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
21 be of the same size (solve it with pointers, if needed) */ 21 be of the same size (solve it with pointers, if needed) */
22 22
23#ifndef PSICONV_LIST_H 23#ifndef PSICONV_LIST_H
24#define PSICONV_LIST_H 24#define PSICONV_LIST_H
25 25
26#include <psiconv/general.h>
27#include <stddef.h> 26#include <stddef.h>
28#include <stdio.h> 27#include <stdio.h>
28
29#include <psiconv/general.h>
29 30
30#ifdef __cplusplus 31#ifdef __cplusplus
31extern "C" { 32extern "C" {
32#endif /* __cplusplus */ 33#endif /* __cplusplus */
33 34
56extern psiconv_u32 psiconv_list_length(const psiconv_list l); 57extern psiconv_u32 psiconv_list_length(const psiconv_list l);
57 58
58/* Return 1 if the list is empty, 0 if not */ 59/* Return 1 if the list is empty, 0 if not */
59extern int psiconv_list_is_empty(const psiconv_list l); 60extern int psiconv_list_is_empty(const psiconv_list l);
60 61
62/* Empty a list. Note this does not reclaim any memory space! */
63extern void psiconv_list_empty(psiconv_list l);
64
61/* Get an element from the list, and return a pointer to it. Note: you can 65/* Get an element from the list, and return a pointer to it. Note: you can
62 directly modify this element, but be careful not to write beyond the 66 directly modify this element, but be careful not to write beyond the
63 element memory space. 67 element memory space.
64 If indx is out of range, NULL is returned. */ 68 If indx is out of range, NULL is returned. */
65extern void * psiconv_list_get(const psiconv_list l, psiconv_u32 indx); 69extern void * psiconv_list_get(const psiconv_list l, psiconv_u32 indx);
69 pointers. 73 pointers.
70 As the lists extends itself, it may be necessary to allocate new 74 As the lists extends itself, it may be necessary to allocate new
71 memory. If this fails, a negative error-code is returned. If everything, 75 memory. If this fails, a negative error-code is returned. If everything,
72 succeeds, 0 is returned. */ 76 succeeds, 0 is returned. */
73extern int psiconv_list_add(psiconv_list l, const void *el); 77extern int psiconv_list_add(psiconv_list l, const void *el);
78
79/* Remove the last element from the list, and copy it to el. Note that
80 this will not reduce the amount of space reserved for the list.
81 An error code is returned, which will be 0 zero if everything
82 succeeded. It is your own responsibility to make sure enough
83 space is allocated to el. */
84extern int psiconv_list_pop(psiconv_list l, void *el);
85
86/* Replace an element within the list. The element is copied from the
87 supplied element. Fails if you try to write at or after the end of
88 the list. */
89extern int psiconv_list_replace(psiconv_list l, psiconv_u32 indx,
90 const void *el);
74 91
75/* Do some action for each element. Note: you can directly modify the 92/* Do some action for each element. Note: you can directly modify the
76 elements supplied to action, and they will be changed in the list, 93 elements supplied to action, and they will be changed in the list,
77 but never try a free(el)! */ 94 but never try a free(el)! */
78extern void psiconv_list_foreach_el(psiconv_list l, void action(void *el)); 95extern void psiconv_list_foreach_el(psiconv_list l, void action(void *el));

Legend:
Removed from v.79  
changed lines
  Added in v.351

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26