mirror of
https://github.com/bobbimanners/emailler.git
synced 2024-07-06 19:28:56 +00:00
Added explicit param to get_line() to specify write buffer
This commit is contained in:
parent
5c7265980f
commit
e203ea3e0c
16
apps/email.c
16
apps/email.c
@ -497,13 +497,15 @@ void update_highlighted(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read a text file a line at a time leaving the line in linebuf[]
|
* Read a text file a line at a time
|
||||||
* Returns number of chars in the line, or -1 if EOF.
|
* Returns number of chars in the line, or -1 if EOF.
|
||||||
* Expects Apple ][ style line endings (CR) and does no conversion
|
* Expects Apple ][ style line endings (CR) and does no conversion
|
||||||
* fp - file to read from
|
* fp - file to read from
|
||||||
* reset - if 1 then just reset the buffer and return
|
* reset - if 1 then just reset the buffer and return
|
||||||
|
* writep - Pointer to buffer into which line will be written
|
||||||
|
* pos - position in file is updated via this pointer
|
||||||
*/
|
*/
|
||||||
int16_t get_line(FILE *fp, uint8_t reset, uint32_t *pos) {
|
int16_t get_line(FILE *fp, uint8_t reset, char *writep, uint32_t *pos) {
|
||||||
static uint16_t rd = 0; // Read
|
static uint16_t rd = 0; // Read
|
||||||
static uint16_t wt = 0; // Write
|
static uint16_t wt = 0; // Write
|
||||||
uint8_t found = 0;
|
uint8_t found = 0;
|
||||||
@ -516,14 +518,14 @@ int16_t get_line(FILE *fp, uint8_t reset, uint32_t *pos) {
|
|||||||
}
|
}
|
||||||
while (1) {
|
while (1) {
|
||||||
while (rd < wt) {
|
while (rd < wt) {
|
||||||
linebuf[j++] = buf[rd++];
|
writep[j++] = buf[rd++];
|
||||||
++(*pos);
|
++(*pos);
|
||||||
if (linebuf[j - 1] == '\r') {
|
if (writep[j - 1] == '\r') {
|
||||||
found = 1;
|
found = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
linebuf[j] = '\0';
|
writep[j] = '\0';
|
||||||
if (rd == wt) // Empty buf[]
|
if (rd == wt) // Empty buf[]
|
||||||
rd = wt = 0;
|
rd = wt = 0;
|
||||||
if (found)
|
if (found)
|
||||||
@ -821,10 +823,10 @@ restart:
|
|||||||
fputs("\nSubject: ", stdout);
|
fputs("\nSubject: ", stdout);
|
||||||
printfield(h->subject, 0, 70);
|
printfield(h->subject, 0, 70);
|
||||||
fputs("\n\n", stdout);
|
fputs("\n\n", stdout);
|
||||||
get_line(fp, 1, &pos); // Reset buffer
|
get_line(fp, 1, linebuf, &pos); // Reset buffer
|
||||||
while (1) {
|
while (1) {
|
||||||
if (!readp) {
|
if (!readp) {
|
||||||
if (get_line(fp, 0, &pos) == -1)
|
if (get_line(fp, 0, linebuf, &pos) == -1)
|
||||||
eof = 1;
|
eof = 1;
|
||||||
readp = linebuf;
|
readp = linebuf;
|
||||||
++linecount;
|
++linecount;
|
||||||
|
Loading…
Reference in New Issue
Block a user