... | ... |
@@ -32,7 +32,7 @@ |
32 | 32 |
#define UNSAVEDHEADER "REUNSAV\n" |
33 | 33 |
#define UNSAVEDVERSION "\n000001\0" |
34 | 34 |
|
35 |
-static int redata_hash_gen(redata_t *redata, char *filename, char *buf, int buflen, char *resbuf129bytes); |
|
35 |
+static int redata_hash_gen(redata_t *redata, char *filename, char *buf, long buflen, char *resbuf129bytes); |
|
36 | 36 |
static char *unsaved_genname(char *filename, char *buf, int bufsize); |
37 | 37 |
static char *securesave_genname(char *filename, char *buf, int bufsize); |
38 | 38 |
static char *genname(char *filename,char *prefix, char *postfix, char *buf, int bufsize); |
... | ... |
@@ -106,7 +106,7 @@ redata_config_chunkdatasize(redata_t *redata, int chunkdatasize) |
106 | 106 |
return(0); |
107 | 107 |
} |
108 | 108 |
|
109 |
-int |
|
109 |
+long |
|
110 | 110 |
redata_getsize(redata_t *redata) |
111 | 111 |
{ |
112 | 112 |
if(redata==NULL) |
... | ... |
@@ -114,7 +114,7 @@ redata_getsize(redata_t *redata) |
114 | 114 |
return(redata->chunkdatasize*redata->sizechunks); |
115 | 115 |
} |
116 | 116 |
|
117 |
-int |
|
117 |
+long |
|
118 | 118 |
redata_getavailable(redata_t *redata) |
119 | 119 |
{ |
120 | 120 |
if(redata==NULL) |
... | ... |
@@ -122,10 +122,10 @@ redata_getavailable(redata_t *redata) |
122 | 122 |
return(redata->available); |
123 | 123 |
} |
124 | 124 |
|
125 |
-int |
|
125 |
+long |
|
126 | 126 |
redata_getused(redata_t *redata) |
127 | 127 |
{ |
128 |
- int used; |
|
128 |
+ long used; |
|
129 | 129 |
if(redata==NULL) |
130 | 130 |
return(0); /* sanity check failed */ |
131 | 131 |
used=redata->chunkdatasize*redata->sizechunks-redata->available; |
... | ... |
@@ -133,11 +133,11 @@ redata_getused(redata_t *redata) |
133 | 133 |
} |
134 | 134 |
|
135 | 135 |
int |
136 |
-redata_getposptr(redata_t *redata, int pos, int *numchunk, int *offset) |
|
136 |
+redata_getposptr(redata_t *redata, long pos, int *numchunk, long *offset) |
|
137 | 137 |
{ |
138 |
- int used; |
|
138 |
+ long used; |
|
139 | 139 |
int i; |
140 |
- int ipos; |
|
140 |
+ long ipos; |
|
141 | 141 |
used=redata_getused(redata); |
142 | 142 |
if(redata==NULL || pos<0 || pos>used || numchunk==NULL || offset==NULL) |
143 | 143 |
return(-1); /* sanity check failed */ |
... | ... |
@@ -199,12 +199,12 @@ redata_chunk_insertnew(redata_t *redata, int afterthischunk) |
199 | 199 |
|
200 | 200 |
|
201 | 201 |
int |
202 |
-redata_preallocate(redata_t *redata, int newsize) |
|
202 |
+redata_preallocate(redata_t *redata, long newsize) |
|
203 | 203 |
{ |
204 |
- int cursize; |
|
204 |
+ long cursize; |
|
205 | 205 |
int nchunks; |
206 | 206 |
int i; |
207 |
- int rechunksize; |
|
207 |
+ long rechunksize; |
|
208 | 208 |
rechunk_t **newchunks,*chunk; |
209 | 209 |
int oldsizechunks; |
210 | 210 |
if(redata==NULL || redata->chunkdatasize==0 || newsize<0) |
... | ... |
@@ -238,7 +238,7 @@ redata_preallocate(redata_t *redata, int newsize) |
238 | 238 |
} |
239 | 239 |
|
240 | 240 |
int |
241 |
-redata_chunk_movedata(redata_t *redata, int chunkfrom, int posfrom, int chunkto, int posto, int size) |
|
241 |
+redata_chunk_movedata(redata_t *redata, int chunkfrom, long posfrom, int chunkto, long posto, long size) |
|
242 | 242 |
{ |
243 | 243 |
if(redata==NULL || size<0 |
244 | 244 |
|| chunkfrom<0 || chunkfrom>=redata->sizechunks |
... | ... |
@@ -284,7 +284,7 @@ redata_chunk_movedata(redata_t *redata, int chunkfrom, int posfrom, int chunkto, |
284 | 284 |
} |
285 | 285 |
|
286 | 286 |
int |
287 |
-redata_chunk_insertdata(redata_t *redata, int chunkto, int posto, char *buf, int buflen) |
|
287 |
+redata_chunk_insertdata(redata_t *redata, int chunkto, long posto, char *buf, long buflen) |
|
288 | 288 |
{ |
289 | 289 |
rechunk_t *chunk; |
290 | 290 |
if(redata==NULL || buflen<0 || buf==NULL |
... | ... |
@@ -301,7 +301,7 @@ redata_chunk_insertdata(redata_t *redata, int chunkto, int posto, char *buf, int |
301 | 301 |
} |
302 | 302 |
|
303 | 303 |
int |
304 |
-redata_chunk_deletedata(redata_t *redata, int chunkno, int pos, int n) |
|
304 |
+redata_chunk_deletedata(redata_t *redata, int chunkno, long pos, long n) |
|
305 | 305 |
{ |
306 | 306 |
rechunk_t *chunk; |
307 | 307 |
if(redata==NULL || n<0 |
... | ... |
@@ -342,7 +342,7 @@ redata_whatin_refresh(redata_t *redata, int chunkno) |
342 | 342 |
void * |
343 | 343 |
mymemrchr(const void *s, int c, size_t n) |
344 | 344 |
{ |
345 |
- int i; |
|
345 |
+ long i; |
|
346 | 346 |
void *res=NULL; |
347 | 347 |
unsigned char b; |
348 | 348 |
b=(*((unsigned int *)(&c)))&0xff; |
... | ... |
@@ -649,11 +649,12 @@ redata_undo_new(redata_t *redata, undostack_t *stack, char *type) |
649 | 649 |
undo_t * |
650 | 650 |
redata_undo_newfromchunks(redata_t *redata, undostack_t *stack, char *type, int pos1, int len) |
651 | 651 |
{ |
652 |
- int startpos,startoff,endpos,endoff; |
|
652 |
+ int startpos,endpos; |
|
653 |
+ long startoff,endoff; |
|
653 | 654 |
undo_t *undo; |
654 | 655 |
int k; |
655 |
- int used; |
|
656 |
- int copyfrom,copysize; |
|
656 |
+ long used; |
|
657 |
+ long copyfrom,copysize; |
|
657 | 658 |
if(redata==NULL || type==NULL || len<=0 |
658 | 659 |
|| (stack!=&(redata->undostack) && stack!=&(redata->redostack))) |
659 | 660 |
return(NULL); /* sanity check failed */ |
... | ... |
@@ -759,10 +760,11 @@ redata_undo_wipe(redata_t *redata, undostack_t *stack) |
759 | 760 |
int |
760 | 761 |
redata_op_add(redata_t *redata, int insertpos, char *buf, int buflen, undostack_t *fromhere) |
761 | 762 |
{ |
762 |
- int chunkno,pos; |
|
763 |
+ int chunkno; |
|
764 |
+ long pos; |
|
763 | 765 |
undo_t *undo; |
764 | 766 |
rechunk_t *chunk,*nextchunk; |
765 |
- int avail,nextavail; |
|
767 |
+ long avail,nextavail; |
|
766 | 768 |
int i; |
767 | 769 |
int needed; |
768 | 770 |
char *ptr; |
... | ... |
@@ -905,7 +907,7 @@ redata_filehash(redata_t *redata, char *filename, char *resbuf129bytes) |
905 | 907 |
} |
906 | 908 |
|
907 | 909 |
int |
908 |
-redata_memhash(redata_t *redata, char *buf, int buflen, char *resbuf129bytes) |
|
910 |
+redata_memhash(redata_t *redata, char *buf, long buflen, char *resbuf129bytes) |
|
909 | 911 |
{ |
910 | 912 |
if(resbuf129bytes!=NULL) |
911 | 913 |
*resbuf129bytes='\0'; |
... | ... |
@@ -915,7 +917,7 @@ redata_memhash(redata_t *redata, char *buf, int buflen, char *resbuf129bytes) |
915 | 917 |
} |
916 | 918 |
|
917 | 919 |
static int |
918 |
-redata_hash_gen(redata_t *redata, char *filename, char *buf, int buflen, char *resbuf129bytes) |
|
920 |
+redata_hash_gen(redata_t *redata, char *filename, char *buf, long buflen, char *resbuf129bytes) |
|
919 | 921 |
{ |
920 | 922 |
static char conv[]={"0123456789ABCDEF"}; |
921 | 923 |
sha3_context sha3; |
... | ... |
@@ -946,7 +948,7 @@ redata_hash_gen(redata_t *redata, char *filename, char *buf, int buflen, char *r |
946 | 948 |
sha3_Update(&sha3,(void *) redata->chunks[i]->data,redata->chunks[i]->useddata); |
947 | 949 |
} else if(filename!=NULL) { |
948 | 950 |
char buf[16384]; |
949 |
- int totalread,nread; |
|
951 |
+ long totalread,nread; |
|
950 | 952 |
for(totalread=0,nread=0;totalread<statbuf.st_size;totalread+=nread,nread=0) { |
951 | 953 |
if((nread=read(fd,buf,sizeof(buf)))<=0) { |
952 | 954 |
close(fd),fd=-1; |
... | ... |
@@ -13,6 +13,7 @@ |
13 | 13 |
|
14 | 14 |
#include <limits.h> |
15 | 15 |
|
16 |
+#warning TODO: change "pos" (offset in data) to long |
|
16 | 17 |
typedef struct whatin_t { |
17 | 18 |
int nlcount; |
18 | 19 |
} whatin_t; |
... | ... |
@@ -26,10 +27,10 @@ typedef struct rechunk_t { |
26 | 27 |
|
27 | 28 |
typedef struct undo_t { |
28 | 29 |
char type[4]; |
29 |
- int off; |
|
30 |
- int len; |
|
31 |
- int posorig; |
|
32 |
- int posdest; |
|
30 |
+ long off; |
|
31 |
+ long len; |
|
32 |
+ long posorig; |
|
33 |
+ long posdest; |
|
33 | 34 |
char prehash[129]; |
34 | 35 |
char posthash[129]; |
35 | 36 |
} undo_t; |
... | ... |
@@ -45,15 +46,16 @@ typedef struct undostack_t { |
45 | 46 |
|
46 | 47 |
typedef struct redata_t { |
47 | 48 |
/* data */ |
48 |
- int chunkdatasize; |
|
49 |
+ long chunkdatasize; |
|
49 | 50 |
int sizechunks; |
50 | 51 |
rechunk_t **chunks; |
51 |
- int available; |
|
52 |
+ long available; |
|
52 | 53 |
rechunk_t *tmpchunk; |
53 | 54 |
/* undo */ |
54 | 55 |
undostack_t undostack; |
55 | 56 |
undostack_t redostack; |
56 | 57 |
/* unsaved (for recovery when the program closes unexpectedly) */ |
58 |
+ undostack_t unsavedstack; |
|
57 | 59 |
char filename[PATH_MAX]; |
58 | 60 |
char initialhash[129]; |
59 | 61 |
int unsavedfd; |
... | ... |
@@ -67,19 +69,18 @@ void redata_free(redata_t *redata); |
67 | 69 |
|
68 | 70 |
int redata_config_chunkdatasize(redata_t *redata, int chunkdatasize); |
69 | 71 |
|
70 |
-int redata_getsize(redata_t *redata); |
|
71 |
-int redata_getused(redata_t *redata); |
|
72 |
-int redata_getavailable(redata_t *redata); |
|
73 |
-int redata_getused(redata_t *redata); |
|
74 |
-int redata_getposptr(redata_t *redata, int pos, int *numchunk, int *offset); |
|
72 |
+long redata_getsize(redata_t *redata); |
|
73 |
+long redata_getused(redata_t *redata); |
|
74 |
+long redata_getavailable(redata_t *redata); |
|
75 |
+int redata_getposptr(redata_t *redata, long pos, int *numchunk, long *offset); |
|
75 | 76 |
|
76 | 77 |
/* low level stuff */ |
77 | 78 |
int redata_wipe(redata_t *redata); |
78 |
-int redata_preallocate(redata_t *redata, int size); |
|
79 |
+int redata_preallocate(redata_t *redata, long size); |
|
79 | 80 |
int redata_chunk_insertnew(redata_t *redata, int afterthischunk); |
80 |
-int redata_chunk_movedata(redata_t *redata, int chunkfrom, int posfrom, int chunkto, int posto, int size); |
|
81 |
-int redata_chunk_insertdata(redata_t *redata, int chunkto, int posto, char *buf, int buflen); |
|
82 |
-int redata_chunk_deletedata(redata_t *redata, int chunk, int pos, int n); |
|
81 |
+int redata_chunk_movedata(redata_t *redata, int chunkfrom, long posfrom, int chunkto, long posto, long size); |
|
82 |
+int redata_chunk_insertdata(redata_t *redata, int chunkto, long posto, char *buf, long buflen); |
|
83 |
+int redata_chunk_deletedata(redata_t *redata, int chunkno, long pos, long n); |
|
83 | 84 |
int redata_whatin_refresh(redata_t *redata, int chunkno); |
84 | 85 |
int redata_fix_nl(redata_t *redata, int chunkno); |
85 | 86 |
int redata_undobuf_reserve(redata_t *redata, undostack_t *stack, int minavail); |
... | ... |
@@ -98,6 +99,7 @@ int redata_unsaved_unlink(redata_t *redata); |
98 | 99 |
int redata_unsaved_trunc(redata_t *redata); |
99 | 100 |
int redata_unsaved_add(redata_t *redata, undo_t *undo); |
100 | 101 |
int redata_unsaved_unadd(redata_t *redata, undo_t *undo); |
102 |
+int redata_unsaved_commit(redata_t *redata); |
|
101 | 103 |
|
102 | 104 |
int redata_load(redata_t *redata, char *filename, int use_unsaved); |
103 | 105 |
int redata_save(redata_t *redata, char *filename); |
... | ... |
@@ -108,9 +110,8 @@ int redata_op_move(redata_t *redata, int posorig, int size, int posdest, undosta |
108 | 110 |
int redata_op_undo(redata_t *redata); |
109 | 111 |
int redata_op_redo(redata_t *redata); |
110 | 112 |
|
111 |
-int redata_commit_unsaved(redata_t *redata); |
|
112 | 113 |
|
113 | 114 |
int redata_hash(redata_t *redata, char *resbuf129bytes); |
114 | 115 |
int redata_filehash(redata_t *redata, char *filename, char *resbuf129bytes); |
115 |
-int redata_memhash(redata_t *redata, char *buf, int buflen, char *resbuf129bytes); |
|
116 |
+int redata_memhash(redata_t *redata, char *buf, long buflen, char *resbuf129bytes); |
|
116 | 117 |
|