added examples

This commit is contained in:
= 2015-07-06 06:59:54 -07:00
parent 68aaadeb45
commit 4513387026
5 changed files with 46 additions and 40 deletions

View File

@ -1,5 +1,5 @@
pkgconfig_DATA = libpipecolors.pc
AM_CXXFLAGS = -std=c++11
ACLOCAL_AMFLAGS = -I m4 -I config
LIBTOOL_DEPS = @LIBTOOL_DEPS@
@ -8,7 +8,7 @@ libtool: $(LIBTOOL_DEPS)
lib_LTLIBRARIES = libpipecolors.la
libpipecolors_la_SOURCES = libpipecolors.cpp
libpipecolors_la_LIBADD = -lboost_regex
libpipecolors_la_LIBS = -lboost_regex
libpipecolors_la_CFLAGS = -fPIC -DPIC -pthread
libpipecolors_la_LDFLAGS = -module \
-release ${PIPECOLORS_VERSION}

View File

@ -44,7 +44,7 @@ LT_INIT
AC_LANG_CPLUSPLUS
AC_PREFIX_DEFAULT([/usr])
#AC_CHECK_LIB([pipecolors], [cprintf])
AC_CHECK_LIB([boost_regex], [main])
# Checks for programs.
AC_CONFIG_MACRO_DIR([m4])
@ -57,7 +57,7 @@ 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_CHECK_CXX_ARGUMENT([-std=c++11], [], [AC_MSG_ERROR([C++11 support is required.])])
AC_MSG_CHECKING([${CXX-c++} version])
if test "${gcc_minor_vers}" -lt 9; then
@ -69,7 +69,8 @@ fi
# Checks for libraries.
AC_CHECK_HEADERS([stdarg.h stdlib.h unistd.h string iostream map boost/regex.hpp],[],[AC_MSG_ERROR([We couldn't find some of the headers.])])
AC_CHECK_HEADERS([stdarg.h stdlib.h unistd.h string iostream map],[],[AC_MSG_ERROR([We couldn't find some of the headers.])])
AC_CHECK_HEADER([boost/regex.hpp],[],[AC_MSG_ERROR([Please install the libboost-regex header library.])])
AC_CHECK_FUNCS([vprintf vsprintf vasprintf printf])
AC_CHECK_TYPE([size_t])

15
examples/test.c Normal file
View File

@ -0,0 +1,15 @@
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <pipecolors.h>
main() {
int a,b;
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";
a = pcprintf("\n%s\n\n", name);
b = pcprintf("%s\n", str);
}

19
examples/test.cpp Normal file
View File

@ -0,0 +1,19 @@
#include <stdio.h>
#include <iostream>
#include <unistd.h>
#include <pipecolors.h>
using namespace pipecolors;
int main(void) {
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";
pcprintf("\n%s\n\n", name);
pcprintf("%s\n", str);
int size = pcprintf("%s", str);
std::cout << std::endl << "Size : " << size << std::endl;
return 0;
}

View File

@ -31,47 +31,18 @@
.\" 2000-07-26 jsm28@hermes.cam.ac.uk - three small fixes
.\" 2000-10-16 jsm28@hermes.cam.ac.uk - more fixes
.\"
.TH PRINTF 3 2014-07-08 "GNU" "Linux Programmer's Manual"
.TH CPPRINTF 3 2015-07-01 "GNU" "Linux Programmer's Manual"
.SH NAME
printf, fprintf, sprintf, snprintf, vprintf, vfprintf, vsprintf,
vsnprintf \- formatted output conversion
cpprintf,
cpsprintf \- formatted output conversion
.SH SYNOPSIS
.B #include <stdio.h>
.B #include <pipecolors.h>
.sp
.BI "int printf(const char *" format ", ...);"
.BI "int cpprintf(const char *" format ", ...);"
.br
.BI "int fprintf(FILE *" stream ", const char *" format ", ...);"
.br
.BI "int sprintf(char *" str ", const char *" format ", ...);"
.br
.BI "int snprintf(char *" str ", size_t " size ", const char *" format ", ...);"
.sp
.B #include <stdarg.h>
.sp
.BI "int vprintf(const char *" format ", va_list " ap );
.br
.BI "int vfprintf(FILE *" stream ", const char *" format ", va_list " ap );
.br
.BI "int vsprintf(char *" str ", const char *" format ", va_list " ap );
.br
.BI "int vsnprintf(char *" str ", size_t " size ", const char *" format \
", va_list " ap );
.BI "int cpsprintf(char *" str ", const char *" format ", ...);"
.sp
.in -4n
Feature Test Macro Requirements for glibc (see
.BR feature_test_macros (7)):
.in
.sp
.ad l
.BR snprintf (),
.BR vsnprintf ():
.RS 4
_BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _ISOC99_SOURCE ||
_POSIX_C_SOURCE\ >=\ 200112L;
.br
or
.I "cc -std=c99"
.RE
.ad
.SH DESCRIPTION
The functions in the