/***********************************************************************/ /* MANEXT - Extract manual pages from C source code. */ /***********************************************************************/ /* * MANEXT - A program to extract manual pages from C source code. * Copyright (C) 1991-2001 Mark Hessling * * 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 2 of * the License, or 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, write to: * * The Free Software Foundation, Inc. * 675 Mass Ave, * Cambridge, MA 02139 USA. * * * If you make modifications to this software that you feel increases * it usefulness for the rest of the community, please email the * changes, enhancements, bug fixes as well as any and all ideas to me. * This software is going to be maintained and enhanced as deemed * necessary by the community. * * Mark Hessling, M.Hessling@qut.edu.au http://www.lightlink.com/hessling/ */ static char RCSid[] = "$Id: manext.c,v 1.4 2005/08/22 11:42:18 mark Exp $"; #ifdef HAVE_CONFIG_H # include #endif #include #ifdef HAVE_STDLIB_H # include #endif #ifdef HAVE_STRING_H # include #endif #ifdef HAVE_PROTO void display_info(void); #else void display_info(); #endif #if !defined(__cplusplus) typedef unsigned char bool; #endif typedef char CHARTYPE; #define TRUE 1 #define FALSE 0 #define MAX_LINE 255 #define FORMAT_MANUAL 0 #define FORMAT_QUICK_REF 1 #define STATE_IGNORE 0 #define STATE_SYNTAX 1 #define STATE_COMMAND 2 #define STATE_DEFAULT 3 /***********************************************************************/ #ifdef HAVE_PROTO short strzne(CHARTYPE *str,CHARTYPE ch) #else short strzne(str,ch) CHARTYPE *str; CHARTYPE ch; #endif /***********************************************************************/ { /*--------------------------- local data ------------------------------*/ register short len=0; register short i = 0; /*--------------------------- processing ------------------------------*/ len = strlen(str); for (; i=len) i = (-1); return(i); } /***********************************************************************/ #ifdef HAVE_PROTO short strzrevne(CHARTYPE *str,CHARTYPE ch) #else short strzrevne(str,ch) CHARTYPE *str; CHARTYPE ch; #endif /***********************************************************************/ { /*--------------------------- local data ------------------------------*/ register short len=0; /*--------------------------- processing ------------------------------*/ len = strlen(str); for (--len; len>=0 && str[len]==ch; len--); return(len); } /***********************************************************************/ #ifdef HAVE_PROTO bool blank_field(CHARTYPE *field) #else bool blank_field(field) CHARTYPE *field; #endif /***********************************************************************/ { /*--------------------------- local data ------------------------------*/ /*--------------------------- processing ------------------------------*/ if (strzne(field,' ') == (-1)) return(TRUE); /* field is NULL or just contains spaces */ return(FALSE); } /***********************************************************************/ #ifdef HAVE_PROTO CHARTYPE *strtrunc(CHARTYPE *string) #else CHARTYPE *strtrunc(string) CHARTYPE *string; #endif /***********************************************************************/ { /*--------------------------- local data ------------------------------*/ register short i=0; short pos=0; /*--------------------------- processing ------------------------------*/ pos = strzrevne(string,' '); if (pos == (-1)) strcpy(string,""); else *(string+pos+1) = '\0'; pos = strzne(string,' '); if (pos != (-1)) { for (i=0;*(string+i+pos)!='\0';i++) *(string+i) = *(string+i+pos); *(string+i) = '\0'; } return(string); } /***********************************************************************/ #ifdef HAVE_PROTO CHARTYPE *strtrim(CHARTYPE *string,char ch) #else CHARTYPE *strtrim(string,ch) CHARTYPE *string,ch; #endif /***********************************************************************/ { /*--------------------------- local data ------------------------------*/ register short i=0; short pos=0; /*--------------------------- processing ------------------------------*/ for (i=0;i