X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=visor;a=blobdiff_plain;f=libvisor%2Finclude%2Fvisor.h;fp=libvisor%2Finclude%2Fvisor.h;h=4c8d1f116328204cecf1ef3fd8ce7581c54bfb40;hp=165e2b27ef0c8f024d575474811aaa65302e29c7;hb=4f957b16f77eb7761afd9e0b9064c7f08deb45be;hpb=dc83bdff56d4dd7454559f5e918652f32f7e9d6d diff --git a/libvisor/include/visor.h b/libvisor/include/visor.h index 165e2b2..4c8d1f1 100644 --- a/libvisor/include/visor.h +++ b/libvisor/include/visor.h @@ -60,6 +60,11 @@ enum vi_motdir { #define VI_MOTION(d, n) (((long)(n) << 8) | ((long)(d))) +struct vi_alloc { + void *(*malloc)(unsigned long); + void (*free)(void*); + void *(*realloc)(void*, unsigned long); /* can be null, will use malloc/free */ +}; struct vi_fileops { void *(*open)(const char *path); @@ -69,6 +74,7 @@ struct vi_fileops { void (*unmap)(void *file); long (*read)(void *file, void *buf, long count); long (*write)(void *file, void *buf, long count); + long (*seek)(void *file, long offs, int whence); }; struct vi_ttyops { @@ -84,9 +90,14 @@ struct vi_ttyops { void (*status)(char *s, void *cls); }; - -struct visor *vi_init(void); -void vi_cleanup(struct visor *vi); +/* Create a new instance of the visor editor. + * The alloc argument can be used to provide custom memory allocation + * functions. It can be null in a hosted build, or if you set the HAVE_LIBC + * preprocessor macro, in which case the standard library allocator will be + * used. + */ +struct visor *vi_create(struct vi_alloc *mm); +void vi_destroy(struct visor *vi); void vi_set_fileops(struct visor *vi, struct vi_fileops *fop);