| 6 |
details. |
details. |
| 7 |
|
|
| 8 |
Dynamically allocated buffers |
Dynamically allocated buffers |
| 9 |
$Id: buffers.c,v 1.3.2.1 2002/10/04 23:49:16 rabbi Exp $ */ |
$Id: buffers.c,v 1.3.2.2 2002/10/09 20:29:43 weaselp Exp $ */ |
| 10 |
|
|
| 11 |
|
|
| 12 |
#include "mix3.h" |
#include "mix3.h" |
| 17 |
#include <stdarg.h> |
#include <stdarg.h> |
| 18 |
#ifdef WIN32 |
#ifdef WIN32 |
| 19 |
#include <io.h> |
#include <io.h> |
| 20 |
#endif |
#endif /* WIN32 */ |
| 21 |
#include <assert.h> |
#include <assert.h> |
| 22 |
#ifdef POSIX |
#ifdef POSIX |
| 23 |
#include <unistd.h> |
#include <unistd.h> |
| 24 |
#endif |
#endif /* POSIX */ |
| 25 |
|
|
| 26 |
static void fail(void) |
static void fail(void) |
| 27 |
{ |
{ |
| 65 |
assert(b->length >= 0 && b->length < b->size); |
assert(b->length >= 0 && b->length < b->size); |
| 66 |
assert(b->ptr >= 0 && b->ptr <= b->length); |
assert(b->ptr >= 0 && b->ptr <= b->length); |
| 67 |
} |
} |
| 68 |
#else |
#else /* not DEBUG */ |
| 69 |
#define sanity_check(arg) |
#define sanity_check(arg) |
| 70 |
#endif |
#endif /* else not DEBUG */ |
| 71 |
|
|
| 72 |
int buf_reset(BUFFER *buffer) |
int buf_reset(BUFFER *buffer) |
| 73 |
{ |
{ |
| 326 |
errlog(ERRORMSG, "Message file too large. Giving up.\n"); |
errlog(ERRORMSG, "Message file too large. Giving up.\n"); |
| 327 |
return (1); |
return (1); |
| 328 |
} |
} |
| 329 |
#endif |
#endif /* BUFFER_MAX */ |
| 330 |
} |
} |
| 331 |
|
|
| 332 |
#ifdef WIN32 |
#ifdef WIN32 |
| 333 |
if (isatty(fileno(infile)) && isatty(fileno(stdout))) |
if (isatty(fileno(infile)) && isatty(fileno(stdout))) |
| 334 |
printf("\n"); |
printf("\n"); |
| 335 |
#endif |
#endif /* WIN32 */ |
| 336 |
|
|
| 337 |
return (err); |
return (err); |
| 338 |
} |
} |
| 362 |
/* dir entry not synced */ |
/* dir entry not synced */ |
| 363 |
if (fsync(fileno(out)) != 0) |
if (fsync(fileno(out)) != 0) |
| 364 |
ret = -1; |
ret = -1; |
| 365 |
#endif |
#endif /* POSIX */ |
| 366 |
|
|
| 367 |
if (fclose(out) != 0) |
if (fclose(out) != 0) |
| 368 |
ret = -1; |
ret = -1; |
| 544 |
#if 1 |
#if 1 |
| 545 |
buf_nl(content); |
buf_nl(content); |
| 546 |
buf_cat(content, line); |
buf_cat(content, line); |
| 547 |
#else |
#else /* end of 1 */ |
| 548 |
buf_appendc(content, ' '); |
buf_appendc(content, ' '); |
| 549 |
buf_appends(content, line->data + 1); |
buf_appends(content, line->data + 1); |
| 550 |
#endif |
#endif /* else if not 1 */ |
| 551 |
} |
} |
| 552 |
buffer->ptr = p; |
buffer->ptr = p; |
| 553 |
end: |
end: |