X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=visor;a=blobdiff_plain;f=libvisor%2Finclude%2Fvisor.h;h=58b6ac4c121b274b65bb1b8874f362c655f0b3e1;hp=55dcc48630639aefd5da934c9b0e0c86645978cb;hb=7357e1f153279a9d84d8671f02fa146575d4935e;hpb=a3d913263bd55389a60c8db96d1ea1fc11acf178 diff --git a/libvisor/include/visor.h b/libvisor/include/visor.h index 55dcc48..58b6ac4 100644 --- a/libvisor/include/visor.h +++ b/libvisor/include/visor.h @@ -26,8 +26,9 @@ struct visor; struct vi_buffer; struct vi_span { - vi_addr beg; + vi_addr start; unsigned long size; + int src; }; enum vi_motdir { @@ -68,10 +69,16 @@ struct vi_alloc { void *(*realloc)(void*, unsigned long); /* can be null, will use malloc/free */ }; +/* open flags (same as POSIX O_*) */ +enum { VI_RDONLY, VI_WRONLY, VI_RDWR, VI_CREAT = 0x100 }; +/* seek origin (same as C SEEK_*) */ +enum { VI_SEEK_SET, VI_SEEK_CUR, VI_SEEK_END }; + + struct vi_fileops { - vi_file *(*open)(const char *path); - long (*size)(vi_file *file); + vi_file *(*open)(const char *path, unsigned int flags); void (*close)(vi_file *file); + long (*size)(vi_file *file); void *(*map)(vi_file *file); void (*unmap)(vi_file *file); long (*read)(vi_file *file, void *buf, long count); @@ -135,6 +142,13 @@ int vi_buf_read(struct vi_buffer *vb, const char *path); int vi_buf_write(struct vi_buffer *vb, const char *path); long vi_buf_size(struct vi_buffer *vb); +/* find the span which corresponds to the specified text position + * if soffs is not null, the relative offset of the specified address from the + * start of the span is stored there. + */ +struct vi_span *vi_buf_find_span(struct vi_buffer *vb, vi_addr at, vi_addr *soffs); +const char *vi_buf_span_text(struct vi_buffer *vb, struct vi_span *span); + void vi_buf_ins_begin(struct vi_buffer *vb, vi_motion mot); void vi_buf_insert(struct vi_buffer *vb, char *s); void vi_buf_ins_end(struct vi_buffer *vb);