summaryrefslogtreecommitdiff
path: root/src/shared.c
diff options
context:
space:
mode:
author@syxhe <https://t.me/syxhe>2025-03-24 18:10:58 -0500
committer@syxhe <https://t.me/syxhe>2025-03-24 18:10:58 -0500
commita407458a893fd0716cfee564ad98756364c25a7a (patch)
treee2117ffeef747dd503c4b354e13c0ab34399d063 /src/shared.c
parent3b5bf3b6ab23c6a5157919490cc07787614f95b8 (diff)
Change the name of readwholebuffer and writewholebuffer so that they won't autocomplete when typing "return"
Diffstat (limited to 'src/shared.c')
-rw-r--r--src/shared.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/shared.c b/src/shared.c
index 72ede56..cc11fe1 100644
--- a/src/shared.c
+++ b/src/shared.c
@@ -22,12 +22,14 @@ void* xreallocarray(void *ptr, size_t nmemb, size_t size) {
22 return mem; 22 return mem;
23} 23}
24 24
25int readwholebuffer(char **str, unsigned long int initsize, int fd) { 25int rwbuf(char **str, unsigned long int initsize, int fd) {
26 // Try to read bytes from fd into str 26 // Try to read bytes from fd into str
27 // Bytes read == 0, return 0 27 // Bytes read == 0, return 0
28 // Bytes read < 0, free string, return -1; 28 // Bytes read < 0, free string, return -1;
29 // When string hits capacity, double the capacity, and reallocate the string 29 // When string hits capacity, double the capacity, and reallocate the string
30 30
31 const int ECODE = -100;
32
31 char *lstr = NULL, *tmp = NULL; 33 char *lstr = NULL, *tmp = NULL;
32 ssize_t bytesread = -1; 34 ssize_t bytesread = -1;
33 int csize = initsize, ccap = initsize; 35 int csize = initsize, ccap = initsize;
@@ -46,13 +48,13 @@ int readwholebuffer(char **str, unsigned long int initsize, int fd) {
46 48
47 free(lstr); 49 free(lstr);
48 lstr = NULL; // Need to set this because of the break 50 lstr = NULL; // Need to set this because of the break
49 bytesread = -100; 51 bytesread = ECODE;
50 break; 52 break;
51 } 53 }
52 lstr = tmp; 54 lstr = tmp;
53 } 55 }
54 } 56 }
55 if(bytesread < 0 && bytesread != -100) { 57 if(bytesread < 0 && bytesread != ECODE) {
56 if(___VXGG___VERBOSE_ERRORS___) 58 if(___VXGG___VERBOSE_ERRORS___)
57 error(0, errno, "Ran into a read() error"); 59 error(0, errno, "Ran into a read() error");
58 60
@@ -67,7 +69,7 @@ int readwholebuffer(char **str, unsigned long int initsize, int fd) {
67 error(0, errno, "Could not shrink lstr after reading buffer"); 69 error(0, errno, "Could not shrink lstr after reading buffer");
68 70
69 free(lstr); 71 free(lstr);
70 bytesread = -100; 72 bytesread = ECODE;
71 } 73 }
72 lstr = tmp; 74 lstr = tmp;
73 } 75 }
@@ -81,7 +83,7 @@ int readwholebuffer(char **str, unsigned long int initsize, int fd) {
81} 83}
82 84
83 85
84int writewholebuffer(int fd, const unsigned char *buf, int len) { 86int wwbuf(int fd, const unsigned char *buf, int len) {
85 int total = 0; 87 int total = 0;
86 int left = len; 88 int left = len;
87 int n; 89 int n;