1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
|
/*
* fhist - file history and comparison tools
* Copyright (C) 2000, 2002, 2008 Peter Miller
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include <error.h> /* for assert */
#include <mem.h>
#include <mprintf.h>
#include <output/private.h>
#include <str.h>
#include <trace.h>
void
output_delete(output_ty *fp)
{
trace(("output_delete(fp = %08lX)\n{\ntype is output_%s\n",
(long)fp, fp->vptr->typename));
if (fp->vptr->destructor)
fp->vptr->destructor(fp);
mem_free(fp);
trace(("}\n"));
}
#ifdef output_filename
#undef output_filename
#endif
const char *
output_filename(output_ty *fp)
{
const char *result;
trace(("output_filename(fp = %08lX)\n{\ntype is output_%s\n",
(long)fp, fp->vptr->typename));
assert(fp->vptr->filename);
result = fp->vptr->filename(fp);
trace(("return \"%s\"\n", result));
trace(("}\n"));
return result;
}
#ifdef output_ftell
#undef output_ftell
#endif
long
output_ftell(output_ty *fp)
{
long result;
trace(("output_ftell(fp = %08lX)\n{\ntype is output_%s\n",
(long)fp, fp->vptr->typename));
assert(fp->vptr->ftell);
result = fp->vptr->ftell(fp);
trace(("return %ld;\n", result));
trace(("}\n"));
return result;
}
#ifdef output_fputc
#undef output_fputc
#endif
void
output_fputc(output_ty *fp, int c)
{
trace(("output_fputc(fp = %08lX, c = %d)\n{\ntype is output_%s\n",
(long)fp, c, fp->vptr->typename));
assert(fp->vptr->fputc);
fp->vptr->fputc(fp, c);
trace(("}\n"));
}
#ifdef output_fputs
#undef output_fputs
#endif
void
output_fputs(output_ty *fp, const char *s)
{
trace(("output_fputs(fp = %08lX, s = \"%s\")\n{\ntype is output_%s\n",
(long)fp, s, fp->vptr->typename));
assert(fp->vptr->fputs);
fp->vptr->fputs(fp, s);
trace(("}\n"));
}
#ifdef output_write
#undef output_write
#endif
void
output_write(output_ty *fp, const void *data, size_t len)
{
trace(("output_write(fp = %08lX, data = %08lX, len = %ld)\n\
{\ntype is output_%s\n", (long)fp, (long)data, (long)len, fp->vptr->typename));
assert(fp->vptr->write);
fp->vptr->write(fp, data, len);
trace(("}\n"));
}
#ifdef output_flush
#undef output_flush
#endif
void
output_flush(output_ty *fp)
{
trace(("output_flusg(fp = %08lX)\n{\ntype is output_%s\n",
(long)fp, fp->vptr->typename));
assert(fp->vptr->flush);
fp->vptr->flush(fp);
trace(("}\n"));
}
void
output_fprintf(output_ty *fp, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
output_vfprintf(fp, fmt, ap);
va_end(ap);
}
void
output_vfprintf(output_ty *fp, const char *fmt, va_list ap)
{
char *tmp;
tmp = mem_copy_string(vmprintf(fmt, ap));
assert(fp->vptr->fputs);
fp->vptr->fputs(fp, tmp);
mem_free(tmp);
}
void
output_put_str(output_ty *fp, string_ty *s)
{
if (!s || !s->str_length)
return;
output_write(fp, s->str_text, s->str_length);
}
|