From: Philippe E. <ph...@us...> - 2001-12-01 21:16:52
|
Update of /cvsroot/oprofile/oprofile/util In directory usw-pr-cvs1:/tmp/cvs-serv25261/oprofile/util Modified Files: Makefile.in Added Files: op_popt.c op_popt.h Log Message: popt cleanup --- NEW FILE: op_popt.c --- /* COPYRIGHT (C) 2000 THE VICTORIA UNIVERSITY OF MANCHESTER and John Levon * 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 <stdlib.h> #include "op_popt.h" /** * opd_poptGetContext - wrapper for popt * * Use this instead of poptGetContext to cope with * different popt versions. This also handle unrecognized * options. All error are fatal */ poptContext opd_poptGetContext(const char * name, int argc, const char ** argv, const struct poptOption * options, int flags) { poptContext optcon; int c; #ifdef CONST_POPT optcon = poptGetContext(name, argc, argv, options, flags); #else optcon = poptGetContext((char *)name, argc, (char **)argv, options, flags); #endif c = poptGetNextOpt(optcon); if (c < -1) { fprintf(stderr, "%s: %s: %s\n", argv[0], poptBadOption(optcon, POPT_BADOPTION_NOALIAS), poptStrerror(c)); poptPrintHelp(optcon, stderr, 0); exit(EXIT_FAILURE); } return optcon; } --- NEW FILE: op_popt.h --- #ifndef OP_POPT_H #define OP_POPT_H #include <popt.h> #ifdef __cplusplus extern "C" { #endif /* wrapper around popt library: handle all non recognized options. all error * are fatal */ /* TODO: add version/help automatically, handle it here then remove it else * else where ? (need to put opd_malloc and related in the util directory) */ poptContext opd_poptGetContext(const char * name, int argc, const char ** argv, const struct poptOption * options, int flags); #ifdef __cplusplus } #endif #endif /* OP_POPT_H */ Index: Makefile.in =================================================================== RCS file: /cvsroot/oprofile/oprofile/util/Makefile.in,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Makefile.in 2001/11/26 21:44:35 1.4 +++ Makefile.in 2001/12/01 21:16:48 1.5 @@ -1,17 +1,21 @@ CXXFLAGS=@CXXFLAGS@ -Wall -pedantic -W -Wunused -Wmissing-prototypes +CFLAGS=-ansi -pedantic -Wall -O2 -pipe -Wstrict-prototypes -Wunused -W -Wshadow -Wmissing-prototypes -Winline @CFLAGS@ .PHONY: all clean install -all: string_manip.o child_reader.o file_manip.o +all: string_manip.o child_reader.o file_manip.o op_popt.o clean: rm -f *.o *.d install: all +%.o: %c + $(CC) -c $(CFLAGS) $(INCLUDE) -g $< -o $@ + %.o: %cpp $(CXX) -c $(CXXFLAGS) -g $< -o $@ -ALL_SOURCES = string_manip.cpp file_manip.cpp child_reader.cpp +ALL_SOURCES = string_manip.cpp file_manip.cpp child_reader.cpp op_popt.c include ../Rules.make |