// -*- C++ -*- /* Copyright (C) 2000 Free Software Foundation, Inc. * * Gaius Mulley (gaius@glam.ac.uk) wrote output.cc * but it owes a huge amount of ideas and raw code from * James Clark (jjc@jclark.com) grops/ps.cc. * * output.cc * * provide the simple low level output routines needed by html.cc */ /* This file is part of groff. groff 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 2, or (at your option) any later version. groff 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 groff; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "driver.h" #include "stringclass.h" #include "cset.h" #include #include "html.h" #ifdef HAVE_UNISTD_H #include #endif #if !defined(TRUE) # define TRUE (1==1) #endif #if !defined(FALSE) # define FALSE (1==0) #endif /* * the classes and methods for simple_output manipulation */ simple_output::simple_output(FILE *f, int n) : fp(f), max_line_length(n), col(0), need_space(0), fixed_point(0) { } simple_output &simple_output::set_file(FILE *f) { fp = f; col = 0; return *this; } simple_output &simple_output::copy_file(FILE *infp) { int c; while ((c = getc(infp)) != EOF) putc(c, fp); return *this; } simple_output &simple_output::end_line() { if (col != 0) { putc('\n', fp); col = 0; need_space = 0; } return *this; } simple_output &simple_output::special(const char *s) { return *this; } simple_output &simple_output::simple_comment(const char *s) { if (col != 0) putc('\n', fp); fputs("\n", fp); col = 0; need_space = 0; return *this; } simple_output &simple_output::begin_comment(const char *s) { if (col != 0) putc('\n', fp); fputs("\n", fp); col = 0; need_space = 0; return *this; } simple_output &simple_output::comment_arg(const char *s) { int len = strlen(s); if (col + len + 1 > max_line_length) { fputs("\n ", fp); col = 1; } fputs(s, fp); col += len + 1; return *this; } simple_output &simple_output::set_fixed_point(int n) { assert(n >= 0 && n <= 10); fixed_point = n; return *this; } simple_output &simple_output::put_raw_char(char c) { putc(c, fp); col++; need_space = 0; return *this; } simple_output &simple_output::put_string(const char *s, int n) { int i=0; while (i