1 /*
2     libundo, an easy to use undo/redo management library
3     Copyright 1999 Matt Kimball
4 
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
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9 
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14 
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 */
19 
20 #ifndef __libundo_h
21 #define __libundo_h
22 
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26 #include <stdlib.h>  /* For size_t */
27 
28 typedef struct _UNDO UNDO;
29 
30 /*  Undo session management  */
31 int undo_new(char *session_name);
32 int undo_destroy(void);
33 
34 UNDO *undo_get_session(void);
35 int undo_set_session(UNDO *undo);
36 
37 /*  Undo limits  */
38 int undo_set_memory_limit(size_t max_memory);
39 
40 /*  Memory management for undo-watched memory  */
41 void *undo_malloc(size_t size);
42 void *undo_realloc(void *mem, size_t size);
43 void undo_free(void *mem);
44 
45 /*  Recording functions  */
46 int undo_snapshot(void);
47 
48 /*  Undo and redo  */
49 int undo_undo(void);
50 int undo_redo(void);
51 
52 unsigned undo_get_undo_count(void);
53 unsigned undo_get_redo_count(void);
54 
55 /*  Error codes  */
56 #define UNDO_NOERROR        0   /* No error */
57 #define UNDO_BADPARAM       1   /* Bad parameter passed to function */
58 #define UNDO_NOMEM          2   /* Not enough memory */
59 #define UNDO_NOSESSION      3   /* No undo session */
60 #define UNDO_NODO           4   /* Nothing to undo/redo */
61 #define UNDO_NOLIMIT        5   /* No memory limit specified */
62 
63 /*  Error recovery  */
64 int undo_get_errcode(void);
65 char *undo_strerror(int errcode);
66 
67 #endif
68