| |
---|
| | |
---|
| | #include <errno.h> |
---|
| | #include <string.h> |
---|
| | |
---|
| | #include "httphead.h" |
---|
| | |
---|
| | const char usagemsg[] = |
---|
| | "usage: httphead [-r] [-q] [-p port] [-s host-] [-d path] [-s host] URL\n" |
---|
| | "\n" |
---|
| | "options:\n" |
---|
| |
---|
| | " -h display this help\n" |
---|
| | " -l display (BSD) license\n" |
---|
| | ; |
---|
| | |
---|
| | const char licensemsg[] = |
---|
| | "httphead is copyright (c) 2006 Andreas Jaggi <andreas.jaggi@waterwave.ch>\n" |
---|
| | "All rights reserved.\n" |
---|
| | "\n" |
---|
| | "Redistribution and use in source and binary forms, with or without\n" |
---|
| | "modification, are permitted provided that the following conditions\n" |
---|
| | "are met:\n" |
---|
| | "1. Redistributions of source code must retain the above copyright\n" |
---|
| | " notice, this list of conditions and the following disclaimer.\n" |
---|
| | "2. Redistributions in binary form must reproduce the above copyright\n" |
---|
| | " notice, this list of conditions and the following disclaimer in the\n" |
---|
| | " documentation and/or other materials provided with the distribution.\n" |
---|
| | "3. The name of the author may not be used to endorse or promote products\n" |
---|
| | " derived from this software without specific prior written permission.\n" |
---|
| | "\n" |
---|
| | "THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n" |
---|
| | "IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n" |
---|
| | "OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n" |
---|
| | "IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,\n" |
---|
| | "INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n" |
---|
| | "NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n" |
---|
| | "DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n" |
---|
| | "THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n" |
---|
| | "(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n" |
---|
| | "THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" |
---|
| | ; |
---|
| | |
---|
| | const char versionmsg[] = "httphead 0.2\n"; |
---|
| | |
---|
| | #define HH_BUFFSIZE 512 |
---|
| | |
---|
| | void usage ( ); |
---|
| | void license ( ); |
---|
| | void version ( ); |
---|
| | |
---|
| | void showerror ( char* type ); |
---|
| | |
---|
| | void crlf ( int s ); |
---|
| | |
---|
| | char* gethost ( char* url ); |
---|
| |
---|
| | void usage ( ) { |
---|
| | write(1, usagemsg, strlen(usagemsg)); |
---|
| | } |
---|
| | |
---|
| | void license ( ) { |
---|
| | write(1, licensemsg, strlen(licensemsg)); |
---|
| | } |
---|
| | |
---|
| | void version ( ) { |
---|
| | write(1, versionmsg, strlen(versionmsg)); |
---|
| | } |
---|
| | |
---|
| | void showerror ( char* type ) { |
---|
| | char* errstr = strerror(errno); |
---|
| | write(2, type, strlen(type)); |
---|
| | write(2, ": ", 2); |
---|
| | write(2, errstr, strlen(errstr)); |
---|
| | write(2, "\n", 1); |
---|
| | } |
---|
| | |
---|
| | |