cvs commit: ALFS/halfling/src main.c Makefile.am

highos at linuxfromscratch.org highos at linuxfromscratch.org
Wed Apr 17 12:03:43 PDT 2002


highos      02/04/17 12:03:43

  Modified:    halfling configure.ac
               halfling/src Makefile.am
  Added:       halfling/src main.c
  Log:
  A basic little program was created.  Has support for command line switches,
  presently just -h/--help or -v/--version.  It starts the process of checking
  out a profile.  Makes a few sanity checks and so forth.
  
  Some clean up's in the build system and more libxml2 support.
  
  Revision  Changes    Path
  1.3       +6 -5      ALFS/halfling/configure.ac
  
  Index: configure.ac
  ===================================================================
  RCS file: /home/cvsroot/ALFS/halfling/configure.ac,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- configure.ac	17 Apr 2002 07:13:49 -0000	1.2
  +++ configure.ac	17 Apr 2002 19:03:39 -0000	1.3
  @@ -1,9 +1,6 @@
   AC_INIT(halfling, CVS, highos at linuxfromscratch.org)
   AM_INIT_AUTOMAKE(halfling, CVS, no-define)
   
  -LIBXML2_REQUIRED_VERSION=2.4.1
  -dnl AC_SUBST(LIBXML2_REQUIRED_VERSION)
  -
   
   dnl Add our extra little libxml2 switch to configure..
   
  @@ -13,13 +10,14 @@
   )
   
   
  -
   AC_PROG_CC
   AC_PROG_INSTALL
   
   
   dnl Let's find libxml2 and get setup.
   
  +LIBXML2_REQUIRED_VERSION=2.4.1
  +
   AC_MSG_CHECKING(for libxml2 libraries >= $LIBXML2_REQUIRED_VERSION)
   
   if test "$LIBXML2_PREFIX" != ""
  @@ -36,7 +34,7 @@
       if test `echo $XML2_VERSION | tr -d .` -ge `echo $LIBXML2_REQUIRED_VERSION | tr -d .`
       then
   	LIBXML2_LIBS=`$XML2_CONFIG --libs`
  -	LIBXML2_CLFAGS=`$XML2_CONFIG --cflags`
  +	LIBXML2_CFLAGS=`$XML2_CONFIG --cflags`
   	AC_MSG_RESULT($XML2_VERSION found)
       else
   	AC_MSG_ERROR(Version $XML2_VERSION found.  You need at least libxml2 $LIBXML2_REQUIRED VERSION for this version of halfling.)
  @@ -45,6 +43,9 @@
       AC_MSG_ERROR([Could not find libxml2 anywhere, download a copy from ftp://xmlsoft.org/.])
   fi
   
  +
  +AC_SUBST(LIBXML2_CFLAGS)
  +AC_SUBST(LIBXML2_LIBS)
   
   AC_CONFIG_FILES(Makefile src/Makefile)
   
  
  
  
  1.2       +6 -1      ALFS/halfling/src/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  RCS file: /home/cvsroot/ALFS/halfling/src/Makefile.am,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Makefile.am	17 Apr 2002 05:39:46 -0000	1.1
  +++ Makefile.am	17 Apr 2002 19:03:43 -0000	1.2
  @@ -1 +1,6 @@
  -SUBDIR =
  +AUTOMAKE_OPTIONS = foreign
  +
  +bin_PROGRAMS = halfling
  +halfling_CFLAGS = $(LIBXML2_CFLAGS)
  +halfling_LDADD = $(LIBXML2_LIBS)
  +halfling_SOURCES = main.c
  
  
  
  1.1                  ALFS/halfling/src/main.c
  
  Index: main.c
  ===================================================================
  /* Copyright (c) 2001, 2002, Jesse Tie-Ten-Quee
   * All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   *    o Redistributions of source code must retain the above copyright
   *      notice, this list of conditions and the following disclaimer.
   *
   *    o Redistributions in binary form must reproduce the above copyright
   *      notice, this list of conditions and the following disclaimer in
   *      the documentation and/or other materials provided with the
   *      distribution.
   *
   *    o Neither the name of "Automated Linux From Scratch" nor the names
   *      of its contributors may be used to endorse or promote products
   *      derived from this software without specific prior written
   *      permission.
   *
   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
   * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
   * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
   * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
   * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
   * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   * POSSIBILITY OF SUCH DAMAGE.
   */
  
  
  #include <stdio.h>
  #include <getopt.h>
  #include <libxml/tree.h>
  #include <libxml/parser.h>
  
  
  static struct option long_options[] = {
      {"help", no_argument, NULL, 'h'},
      {"version", no_argument, NULL, 'v'},
      {0, 0, NULL, 0}
  };
  
  
  void print_usage(void) {
      printf("Usage: halfling [options] profile...\n");
  }
  
  
  void print_help(void) {
      print_usage();
      printf("\
  Options:\n\
    -h,  --help       display this help and exit.\n\
    -v,  --version    print the version information and exit.\
  \n");
  }
  
  
  void print_version(void) {
      printf("halfling version CVS, by Jesse Tie-Ten-Quee.\n");
  
  }
  
  
  int parse_profile(const char *filename) {
      xmlDoc *doc = NULL;
      xmlNode *cur = NULL;
  
      doc = xmlParseFile(filename);
  
      if (doc == NULL) {
  	fprintf(stderr, "Document is not well-formed.\n");
  	return (-1);
      }
  
      cur = xmlDocGetRootElement(doc);
  
      if (cur = NULL) {
  	fprintf(stderr, "Empty root element.\n");
  	xmlFreeDoc(doc);
  	return (-1);
      }
  
      printf("So far so good.\n");
  
      xmlFreeDoc(doc);
  
      return (0);
  }
  
  
  int main(int argc, char **argv) {
      int c;
  
  
      while ((c = getopt_long(argc, argv, "hv", long_options, (int *)0)) != EOF) {
  	switch (c) {
  	    case 'h':
  		print_help();
  		exit(1);
  		break;
  	    case 'v':
  		print_version();
  		exit(1);
  		break;
  	}
      }
  
      if (optind < argc) {
  	while (optind < argc) {
  	    parse_profile(argv[optind++]);
  	}
      } else {
  	print_usage();
  	printf("\nTry 'halfing --help' for more information.\n");
      }
  
      return (0);
  }
  
  
  
-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe alfs-discuss' in the subject header of the message



More information about the alfs-discuss mailing list