This commit is contained in:
R. Eric Wheeler 2015-07-01 15:17:12 -07:00
parent 2747d87a1f
commit 15a430c93a
12 changed files with 38 additions and 70 deletions

3
.gitignore vendored
View File

@ -29,6 +29,9 @@ stamp-h1
# Ignore output files
libpipecolors.o
libpipecolors.so
.libs/
libpipecolors.la
libpipecolors.lo
# Ignore backup files
*~

26
Makefile.am Executable file → Normal file
View File

@ -1,19 +1,17 @@
pkgconfig_DATA = pipecolors.pc
VERSION = 0.1.0
AM_CXXFLAGS = -std=c++11
ACLOCAL_AMFLAGS = -I m4 -I config
LIBTOOL_DEPS = @LIBTOOL_DEPS@
AM_CXXFLAGS += -std=c++11 -fPIC -pipe
ACLOCAL_AMFLAGS = -I m4
LIBTOOL_DEPS += @LIBTOOL_DEPS@
libtool: $(LIBTOOL_DEPS)
$(SHELL) ./config.status libtool
pkginclude_HEADERS = pipecolors.h
soinclude_HEADERS = pipecolors.h
soincludedir = $(prefix)/include
sodir=$(libdir)
so_PROGRAMS = libpipecolors.so
libpipecolors_so_SOURCES = libpipecolors.cpp
libpipecolors_so_LDFLAGS = \
-shared \
-fPIC \
-Wl,-soname,libpipecolors.so.0.1 \
-ltermcap
lib_LTLIBRARIES = libpipecolors.la
libpipecolors_la_SOURCES = libpipecolors.cpp
libpipecolors_la_LIBADD = -ltermcap
libpipecolors_la_CFLAGS = -fPIC -DPIC -pthread
libpipecolors_la_LDFLAGS = -module \
-release ${PIPECOLORS_VERSION}
include_HEADERS = pipecolors.h

View File

@ -3,7 +3,7 @@
set -x
test -d autom4te.cache && rm -rf autom4te.cache
test -d config && rm -rf config || exit 1
test -d config && rm -rf config
mkdir config || exit 1
libtoolize --install --copy || exit 1
aclocal -I config || exit 1

41
configure.ac Executable file → Normal file
View File

@ -6,7 +6,7 @@ AC_PREREQ([2.69])
m4_define([pipecolors_version_major],[0])
m4_define([pipecolors_version_minor],[1])
m4_define([pipecolors_version_micro],[0])
m4_define([pipecolors_version_beta], [b])
m4_define([pipecolors_version_beta], [])
m4_define([pipecolors_version_base], [pipecolors_version_major.pipecolors_version_minor.pipecolors_version_micro])
m4_define([pipecolors_version],
@ -36,12 +36,12 @@ AC_CANONICAL_HOST
AC_PROG_CXX
AC_PROG_CXX_C_O
AC_PROG_CXXCPP
AM_PROG_AR
AC_PROG_LIBTOOL
LT_INIT
AC_DISABLE_SHARED
AC_ENABLE_STATIC
AC_LANG_CPLUSPLUS
LT_INIT
AC_LANG_CPLUSPLUS
AC_PREFIX_DEFAULT([/usr])
#AC_CHECK_LIB([pipecolors], [cprintf])
#PKG_CHECK_MODULES([LIBPIPECOLORS], [pipecolors])
# Checks for programs.
@ -57,8 +57,6 @@ gcc_micro_vers=`echo ${gcc_full_vers} | cut -f3 -d.`
# Checks for functions
AC_CHECK_CXX_ARGUMENT([-std=c++11], [], [AC_MSG_ERROR([C++11 support is required.])])
AC_SUBST([ACLOCAL_AMFLAGS])
AC_SUBST([AM_CXXFLAGS])
AC_MSG_CHECKING([if ${CXX-c++} supports nullptr])
AC_LINK_IFELSE(
@ -95,38 +93,11 @@ AC_CHECK_TYPES([std::string], [], [], [[
#include <iostream>
]])
AC_ARG_WITH(arch,
AS_HELP_STRING([--with-arch=ARCH],
[On x86_64 systems, compile with -fno-omit-frame-pointer (see INSTALL)]))
if test z${with_arch} = "z"; then
AC_CHECK_PROG(ARCH_PROG, arch, "found", "no")
if test $ARCH_PROG = "no"; then
AC_CHECK_PROG(UNAME_PROG, uname, "found", "no")
if test $UNAME_PROG = "no"; then
AC_MSG_ERROR([Could not detect your architecture, please set --with-arch=ARCH.])
else
with_arch=`uname -i`
fi
else
with_arch=`arch`
fi
fi
AC_MSG_NOTICE([building for ${with_arch} platform])
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_ARG_ENABLE([the-force],
[AC_HELP_STRING([--enable-the-force], [use the force [default=no]])],
[], [enable_the_force=no])
AM_CONDITIONAL([ENABLE_THE_FORCE], [test "x$enable_the_force" = "xyes"])
AC_CONFIG_FILES([Makefile pipecolors.pc:pipecolors.pc.in],[],[API_VERSION='0.1'])
AC_CONFIG_FILES([Makefile pipecolors.pc:pipecolors.pc.in],[],[APIVERSION=PIPECOLORS_VERSION])
AC_CONFIG_COMMANDS([default],[[]],[[]])
AC_OUTPUT

BIN
examples/test Executable file

Binary file not shown.

View File

@ -1,12 +1,15 @@
#include <stdio.h>
#include <pipecolors/pipecolors.h>
#include <unistd.h>
#include <pipecolors.h>
int main(void) {
const char* str = "|0101|0202|0303|0404|0505|0606|0707|0808|0909|1010|1111|1212|1313|1414|1515";
const char* str = "|0101|0202|0303|0404|0505|0606|0707|0808|0909|1010|1111|1212|1313|1414|1515|07";
const char* name = "|01P|02i|03p|04e|05c|06ol|07o|08r|09s |10l|11i|12b|13r|14a|15r|14y |130|12.|111|07";
cprintf("\n%s\n\n", name);
cprintf("%s\n", str);
if( isatty(fileno(stdout)) ) {
cprintf("Awesome!");
}
}

19
libpipecolors.cpp Executable file → Normal file
View File

@ -18,16 +18,15 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
//#include <cstdio>
//#include <stdio.h>
#include <iostream>
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
#include <string>
#include <map>
#include <regex>
#include <termcap.h>
#include "pipecolors.h"
#define C_DEFAULT 0
@ -98,13 +97,8 @@
}
bool has_colors(void) {
char buffer[1024];
int c;
tgetent(buffer, getenv("TERM"));
c = tgetnum("Co");
if(c > 0 || c == -1) {
if( isatty(fileno(stdout)) ) {
return true;
} else {
return false;
@ -138,8 +132,3 @@ void cprintf( const char * format, ... ) {
std::cout << s;
}
int main(void) {
cprintf("\n%s\n\n", "|01P|02i|03p|04e|05c|06ol|07o|08r|09s |10l|11i|12b|13r|14a|15r|14y |130|12.|111|07");
return 0;
}

View File

@ -1,5 +1,8 @@
#ifndef __PIPECOLORS_H
#define __PIPECOLORS_H
#ifdef _PIPECOLORS_H
#undef _PIPECOLORS_H
#endif
#ifndef _PIPECOLORS_H
#define _PIPECOLORS_H
#endif
#ifdef __cplusplus
@ -7,6 +10,7 @@ extern "C" {
#endif
void cprintf(const char* format, ...);
void csprintf(void);
#ifdef __cplusplus
}

0
pipecolors.pc.in Executable file → Normal file
View File

Binary file not shown.

Binary file not shown.

Binary file not shown.