OSDN Git Service

Add C++ support
authora <a@b.c>
Fri, 23 Jun 2017 14:41:12 +0000 (16:41 +0200)
committera <a@b.c>
Fri, 23 Jun 2017 14:41:12 +0000 (16:41 +0200)
README.md
configure.ac
doc/pinkybar.1
doc/pinkybar.texi
m4/extend.m4
src/Makefail.skel
src/c++.cpp [new file with mode: 0644]
src/options.c
src/prototypes/cpp.hpp [new file with mode: 0644]

index 29180d1..ccbb436 100644 (file)
--- a/README.md
+++ b/README.md
@@ -45,7 +45,7 @@ Please note that the program won't detect fans connected via molex connetor(s) o
 
 The program is smart enough to detect whether some of your fan(s) blades are spinning, or the particular fan have been removed. Hold down some of your fan blades and you'll see that the program won't include this fan and it's RPM, release the blades and you'll see the fan and it's RPM in the statusbar. Try simulating real fan hardware failure by holding down all system fan blades and watch what the program will show you, just try not to slice your cheesy fingers open in the process.
 
-You can extend pinky-bar with your own crafted perl/python/ruby/lua/R/assembly/lisp/ocaml/rust/go script.
+You can extend pinky-bar with your own crafted perl/python/ruby/lua/R/assembly/lisp/ocaml/rust/go/c++ script.
 
 If you compile your kernel from source code make sure to include your cpu and motherboard sensors as **modules** and not inlined.
 
@@ -102,8 +102,9 @@ The order of supplied options will dictate how, where and what system informatio
 |              | --asm       | Extend pinkybar with assembly, learn more from the Opt-in section. |
 |              | --lisp      | Extend pinkybar with your scripts written in lisp, learn more from the Opt-in section.     |
 |              | --ocaml     | Extend pinkybar with your scripts written in ocaml, learn more from the Opt-in section.     |
-|              | --rust     | Extend pinkybar with your scripts written in rust, learn more from the Opt-in section.     |
-|              | --go     | Extend pinkybar with your scripts written in go, learn more from the Opt-in section.     |
+|              | --rust      | Extend pinkybar with your scripts written in rust, learn more from the Opt-in section.     |
+|              | --go        | Extend pinkybar with your scripts written in go, learn more from the Opt-in section.     |
+|              | --cpp       | Extend pinkybar with your  cpp, learn more from the Opt-in section.  |
 | -q           | --weather   | Show the temperature outside [argument - London,uk]                |
 | -U           | --uptime    | The system uptime                                                  |
 | -w           | --loadavg   | The system average load for past 1, 5 and 15 minutes               |
@@ -183,6 +184,7 @@ It's up to you to decide which features suit you best.
 | --with-ocaml   | --without-ocaml     | Extend pinkybar with your own crafted scripts written in ocaml                             |
 | --with-rust    | --without-rust      | Extend pinkybar with your own crafted scripts written in rust                              |
 | --with-go      | --without-go        | Extend pinkybar with your own crafted scripts written in go                                |
+| --with-cpp     | --without-cpp       | Extend pinkybar with c++ program                                                           |
 | --with-weather | --without-weather   | The temperature outside  (some details must be provided)                                   |
 | api\_key='123458976'               | | API key obtained after registering yourself in the weather website, must be combined **--with-weather**  |
 | --with-smartemp | --without-smartemp   | Read the drive temperature from S.M.A.R.T cross-platform available                       |
@@ -591,7 +593,7 @@ frost ALL=NOPASSWD:/usr/sbin/smartctl
 
 Copy the code from extra/scripts/drive-temperature.sh or `exec` it from **xinitrc** or the script used to start your DE/WM.
 
-To extend pinkybar with your own crafted perl/python/ruby/lua/assembly/R/ocaml/lisp/rust/go script:
+To extend pinkybar with your own crafted perl/python/ruby/lua/assembly/R/ocaml/lisp/rust/go/c++ script:
 
 * perl
 * python == 2.7 (--with-python2)
@@ -605,7 +607,7 @@ To extend pinkybar with your own crafted perl/python/ruby/lua/assembly/R/ocaml/l
 * rust
 * go
 
-Have a look at extra/scripts/pinky.{py,pl,ruby,lua,R,s,lisp}, they serve as examples how to write the most basic scripts in order to extend pinkybar in python/perl/ruby/lua/R/assembly/lisp/ocaml/rust/go. You can use all languages simultaneously.
+Have a look at extra/scripts, the examples there will teach you how to write the most basic scripts in order to extend pinkybar in python/perl/ruby/lua/R/assembly/lisp/ocaml/rust/go/c++. You can use all languages simultaneously.
 
 Please, please do **NOT** export or set PYTHONPATH on it's own line.
 
@@ -709,6 +711,14 @@ The source code resides in the **src** folder under the name of **pinky.go**
 ~/pinkbar --go
 ```
 
+**--with-cpp**
+
+The source code resides in the **src** folder under the name of **c++.cpp**
+
+```bash
+~/pinkbar --cpp
+```
+
 -----
 
 To get the sound volume level:
index 3df49e0..cfd6b5d 100644 (file)
@@ -7,7 +7,7 @@ AC_CONFIG_HEADERS([src/config.h])
 AM_INIT_AUTOMAKE([1.13 -Wall no-define foreign subdir-objects dist-xz no-dist-gzip std-options])
 
 AM_SILENT_RULES([yes])
-{perl will replace this line}
+m4_define([cuRos],[GENTOO]) m4_define([LINUKS], [cryMeAriver])
 
 # With the addition of more runtime compile and
 # link tests, this option is no longer necessary.
@@ -23,6 +23,7 @@ AC_C_CONST
 AC_HEADER_STDC
 AM_PROG_CC_C_O
 AM_PROG_AS
+AC_PROG_CXX
 
 # AM_EXTRA_RECURSIVE_TARGETS([ncurses])
 
@@ -48,6 +49,7 @@ TEST_ECL
 TEST_OCAML
 TEST_RUST
 TEST_GO
+TEST_CPP
 
 AC_CONFIG_FILES([
   Makefile
@@ -58,4 +60,4 @@ AC_OUTPUT
 
 echo
 echo 'Now type \"make\" and \"make install\" afterwards'
-echo
+echo
\ No newline at end of file
index 63003e5..a5a3260 100644 (file)
@@ -32,7 +32,7 @@ blades and watch what the program will show you, just try not to slice
 your cheesy fingers open in the process.
 .PP
 You can extend pinky\-bar with your own crafted
-perl/python/ruby/lua/R/assembly/lisp/ocaml/rust/go script.
+perl/python/ruby/lua/R/assembly/lisp/ocaml/rust/go/c++ script.
 .PP
 If you compile your kernel from source code make sure to include your
 cpu and motherboard sensors as \f[B]modules\f[] and not inlined.
@@ -349,6 +349,12 @@ Extend pinkybar with your scripts written in go, learn more from the
 Opt\-in section.
 T}
 T{
+T}@T{
+\[en]cpp
+T}@T{
+Extend pinkybar with your cpp, learn more from the Opt\-in section.
+T}
+T{
 \-q
 T}@T{
 \[en]weather
@@ -771,6 +777,13 @@ T}@T{
 Extend pinkybar with your own crafted scripts written in go
 T}
 T{
+\[en]with\-cpp
+T}@T{
+\[en]without\-cpp
+T}@T{
+Extend pinkybar with c++ program
+T}
+T{
 \[en]with\-weather
 T}@T{
 \[en]without\-weather
@@ -1385,7 +1398,7 @@ Copy the code from extra/scripts/drive\-temperature.sh or \f[C]exec\f[]
 it from \f[B]xinitrc\f[] or the script used to start your DE/WM.
 .PP
 To extend pinkybar with your own crafted
-perl/python/ruby/lua/assembly/R/ocaml/lisp/rust/go script:
+perl/python/ruby/lua/assembly/R/ocaml/lisp/rust/go/c++ script:
 .IP \[bu] 2
 perl
 .IP \[bu] 2
@@ -1409,9 +1422,9 @@ rust
 .IP \[bu] 2
 go
 .PP
-Have a look at extra/scripts/pinky.{py,pl,ruby,lua,R,s,lisp}, they serve
-as examples how to write the most basic scripts in order to extend
-pinkybar in python/perl/ruby/lua/R/assembly/lisp/ocaml/rust/go.
+Have a look at extra/scripts, the examples there will teach you how to
+write the most basic scripts in order to extend pinkybar in
+python/perl/ruby/lua/R/assembly/lisp/ocaml/rust/go/c++.
 You can use all languages simultaneously.
 .PP
 Please, please do \f[B]NOT\f[] export or set PYTHONPATH on it's own
@@ -1546,6 +1559,17 @@ The source code resides in the \f[B]src\f[] folder under the name of
 \f[]
 .fi
 .PP
+\f[B]\[en]with\-cpp\f[]
+.PP
+The source code resides in the \f[B]src\f[] folder under the name of
+\f[B]c++.cpp\f[]
+.IP
+.nf
+\f[C]
+~/pinkbar\ \-\-cpp
+\f[]
+.fi
+.PP
    *   *   *   *   *
 .PP
 To get the sound volume level:
index ed64ef4..3ef6531 100644 (file)
@@ -62,7 +62,7 @@ all system fan blades and watch what the program will show you, just try
 not to slice your cheesy fingers open in the process.
 
 You can extend pinky-bar with your own crafted
-perl/python/ruby/lua/R/assembly/lisp/ocaml/rust/go script.
+perl/python/ruby/lua/R/assembly/lisp/ocaml/rust/go/c++ script.
 
 If you compile your kernel from source code make sure to include your
 cpu and motherboard sensors as @strong{modules} and not inlined.
@@ -280,6 +280,9 @@ the Opt-in section.
  @tab Extend pinkybar with your scripts written in go, learn more from
 the Opt-in section.
 @item 
+--cpp
+ @tab Extend pinkybar with your cpp, learn more from the Opt-in section.
+@item 
 -q
  @tab --weather
  @tab Show the temperature outside [argument - London,uk]
@@ -535,6 +538,10 @@ colorized
  @tab --without-go
  @tab Extend pinkybar with your own crafted scripts written in go
 @item 
+--with-cpp
+ @tab --without-cpp
+ @tab Extend pinkybar with c++ program
+@item 
 --with-weather
  @tab --without-weather
  @tab The temperature outside (some details must be provided)
@@ -1155,7 +1162,7 @@ Copy the code from extra/scripts/drive-temperature.sh or @code{exec} it
 from @strong{xinitrc} or the script used to start your DE/WM.
 
 To extend pinkybar with your own crafted
-perl/python/ruby/lua/assembly/R/ocaml/lisp/rust/go script:
+perl/python/ruby/lua/assembly/R/ocaml/lisp/rust/go/c++ script:
 
 @itemize
 @item
@@ -1182,10 +1189,10 @@ rust
 go
 @end itemize
 
-Have a look at extra/scripts/pinky.@{py,pl,ruby,lua,R,s,lisp@}, they
-serve as examples how to write the most basic scripts in order to extend
-pinkybar in python/perl/ruby/lua/R/assembly/lisp/ocaml/rust/go. You can
-use all languages simultaneously.
+Have a look at extra/scripts, the examples there will teach you how to
+write the most basic scripts in order to extend pinkybar in
+python/perl/ruby/lua/R/assembly/lisp/ocaml/rust/go/c++. You can use all
+languages simultaneously.
 
 Please, please do @strong{NOT} export or set PYTHONPATH on it's own
 line.
@@ -1293,6 +1300,15 @@ The source code resides in the @strong{src} folder under the name of
 ~/pinkbar --go
 @end verbatim
 
+@strong{--with-cpp}
+
+The source code resides in the @strong{src} folder under the name of
+@strong{c++.cpp}
+
+@verbatim
+~/pinkbar --cpp
+@end verbatim
+
 @iftex
 @bigskip@hrule@bigskip
 @end iftex
index 4d75c67..ec30ddb 100644 (file)
@@ -466,11 +466,11 @@ AC_DEFUN([TEST_RUST],[
 ])
 
 
-dnl TEST_RUST() function in configure.ac
+dnl TEST_GO() function in configure.ac
 dnl
 dnl Substitute ECL related linker flags
 dnl to the variable ECL_LIBS if
-dnl the user enabled the --with-rust switch
+dnl the user enabled the --with-go switch
 AC_DEFUN([TEST_GO],[
   GO_LIBS=""
   WITH_GO=0
@@ -479,7 +479,7 @@ AC_DEFUN([TEST_GO],[
     AS_HELP_STRING([--with-go],
       [Extend the program via go scripts]),
     [],
-    [with_rust=no]
+    [with_go=no]
   )
 
   AS_IF([test "x$with_go" = "xyes"], [
@@ -493,3 +493,27 @@ AC_DEFUN([TEST_GO],[
   AC_SUBST(GO_LIBS)
   AC_DEFINE_UNQUOTED([WITH_GO],[$WITH_GO],[Extend the program via go scripts])
 ])
+
+
+dnl TEST_C++() function in configure.ac
+dnl
+dnl Substitute ECL related linker flags
+dnl to the variable ECL_LIBS if
+dnl the user enabled the --with-c++ switch
+AC_DEFUN([TEST_CPP],[
+  WITH_CPP=0
+
+  AC_ARG_WITH([cpp],
+    AS_HELP_STRING([--with-cpp],
+      [Extend the program via c++]),
+    [],
+    [with_cpp=no]
+  )
+
+  AS_IF([test "x$with_cpp" = "xyes"], [
+    WITH_CPP=1
+
+  ])
+
+  AC_DEFINE_UNQUOTED([WITH_CPP],[$WITH_CPP],[Extend the program via c++])
+])
index 682e6d5..911f3b7 100644 (file)
@@ -21,6 +21,7 @@ pinkybar_SOURCES = main.c           \
     python.c                        \
     R.c                             \
     go.c                            \
+    c++.cpp                         \
     ../extra/scripts/pinky.s        \
     prototypes/ecl.h                \
     prototypes/common.h             \
@@ -38,6 +39,7 @@ pinkybar_SOURCES = main.c           \
     prototypes/R.h                  \
     prototypes/go.h                 \
     prototypes/ocaml.h              \
+    prototypes/cpp.hpp              \
     include/headers.h               \
     include/options_constants.h     \
     include/functions_constants.h   \
diff --git a/src/c++.cpp b/src/c++.cpp
new file mode 100644 (file)
index 0000000..694edac
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+   06/23/2017
+
+   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., 51 Franklin Street, Fifth Floor, Boston,
+   MA 02110-1301, USA.
+*/
+
+#include <string>
+using std::string;
+
+#include "config.h" /* Auto-generated */
+
+#if WITH_CPP == 1
+#include "include/headers.h"
+#endif /* WITH_CPP */
+
+#include "prototypes/cpp.hpp"
+
+#if WITH_CPP == 1
+void get_cpp(char *str1) {
+  const string str("Hello World");
+  FILL_STR_ARR(1, str1, str.c_str());
+}
+#else
+char *cpp9;
+#endif /* WITH_CPP */
index d77eef3..0f208e9 100644 (file)
@@ -37,6 +37,7 @@
 #include "prototypes/ocaml.h"
 #include "prototypes/rust.h"
 #include "prototypes/go.h"
+#include "prototypes/cpp.hpp"
 
 /* Because we ran out of a-z A-Z options,
  * only long ones will be supported from now on.
@@ -56,6 +57,7 @@ enum {
   OCAML,
   RUST,
   GO,
+  CPP,
   BULLSHIFT
 };
 const char *argp_program_version = PACKAGE_STRING;
@@ -148,6 +150,10 @@ static const struct argp_option options[] = {
   { .name = "go",         .key = GO,                           .doc = "Extend the program with go, read README."         },
 #endif /* WITH_GO */
 
+#if WITH_CPP == 1
+  { .name = "cpp",         .key = CPP,                        .doc = "Extend the program with c++, read README."         },
+#endif /* WITH_CPP */
+
 #if WITH_WEATHER == 1
   { .name = "weather", .key = 'q', .arg = "London,uk", .doc = "The temperature outside."                                 },
 #endif /* WITH_WEATHER */
@@ -332,6 +338,11 @@ parse_opt(int key, char *arg, struct argp_state *state) {
 #endif /* WITH_GO */
 
 
+#if WITH_CPP == 1
+    NEW_LABEL(CPP, char cpp[VLA], cpp, FMT_KERN);
+#endif /* WITH_CPP */
+
+
 #if WITH_WEATHER == 1
     NEW_ARG_LABEL('q', char weather[VLA], weather, OUT_STR YELLOW STR_SPEC" ");
 #endif /* WITH_WEATHER */
diff --git a/src/prototypes/cpp.hpp b/src/prototypes/cpp.hpp
new file mode 100644 (file)
index 0000000..f654644
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+   06/16/2017
+
+   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., 51 Franklin Street, Fifth Floor, Boston,
+   MA 02110-1301, USA.
+*/
+
+#ifndef CPP_H_
+#define CPP_H_
+
+#if WITH_CPP == 1
+#ifdef __cplusplus
+  extern "C" {
+#endif /* __cplusplus */
+
+void get_cpp(char *);
+#ifdef __cplusplus
+  }
+#endif /* __cplusplus */
+
+#endif /* WITH_CPP */
+
+#endif /* CPP_H_ */