From 5c8e5985871496ae41340e271c58b1e2810fc869 Mon Sep 17 00:00:00 2001 From: James Maki Date: Fri, 23 Apr 2010 15:38:24 -0500 Subject: first commit --- src/Makefile.am | 8 +++++ src/helloworld.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/helloworld.h | 6 ++++ 3 files changed, 108 insertions(+) create mode 100644 src/Makefile.am create mode 100644 src/helloworld.c create mode 100644 src/helloworld.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..bb98200 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,8 @@ +AUTOMAKE_OPTIONS = gnu +AM_CFLAGS = -Wall +bin_PROGRAMS = helloworld +helloworld_SOURCES = helloworld.c +noinst_HEADERS = helloworld.h + +EXTRA_DIST = + diff --git a/src/helloworld.c b/src/helloworld.c new file mode 100644 index 0000000..396f300 --- /dev/null +++ b/src/helloworld.c @@ -0,0 +1,94 @@ +/* + * Hello World Recipe + * + * Copyright (C) 2010 by Multi-Tech Systems + * + * Author: James Maki + * + * 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 + * (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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include +#include +#include +#include +#include + +#include "helloworld.h" + +static void print_version(const char *name) { + printf("%s (" PACKAGE ") " VERSION " (" __DATE__ " " __TIME__ ")\n", name); + printf("Copyright (C) 2010 by Multi-Tech Systems\n"); + printf( +"This program is free software; you may redistribute it under the terms of\n" +"the GNU General Public License version 2 or (at your option) any later version.\n" +"This program has absolutely no warranty.\n"); +} + +static void usage(FILE *out) { + fprintf(out, "Usage: helloworld [ ]\n"); + fprintf(out, "\n"); +} + +enum { + OPT_VERSION = 128, + OPT_HELP, +}; + +static char *short_options = ""; +static struct option long_options[] = { + {"version", 0, NULL, OPT_VERSION}, + {"help", 0, NULL, OPT_HELP}, + {0, 0, 0, 0}, +}; + +int main(int argc, char *argv[]) { + int i; + int option_index; + + while((i = getopt_long(argc, argv, short_options, long_options, &option_index)) >= 0) { + switch(i) { + case 0: + break; + + case OPT_VERSION: + print_version("helloworld"); + exit(0); + break; + + case OPT_HELP: + usage(stdout); + exit(0); + break; + + default: + usage(stderr); + exit(1); + } + } + + if(optind < argc) { + while(optind < argc) { + printf("Hello %s!\n", argv[optind++]); + } + } else { + printf("Hello Autotools!\n"); + } + + return 0; +} + diff --git a/src/helloworld.h b/src/helloworld.h new file mode 100644 index 0000000..77c44ec --- /dev/null +++ b/src/helloworld.h @@ -0,0 +1,6 @@ +#ifndef __HELLOWORLD_H +#define __HELLOWORLD_H + +#include "config.h" + +#endif /* ~__HELLOWORLD_H */ -- cgit v1.2.3