Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=fw32.git;a=commitdiff;h=42b3b0f8633079b58fcf67344451d624afba67a5

commit 42b3b0f8633079b58fcf67344451d624afba67a5
Author: Marius Cirsta <[email protected]>
Date:   Fri Mar 6 17:28:09 2015 +0200

* begin changing code to c++

diff --git a/Makefile b/Makefile
index 538f9f5..156e3bc 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
-CFLAGS ?= -O2
-CFLAGS += -D_GNU_SOURCE -DNDEBUG -Wall -Wextra
+CXXFLAGS ?= -O2
+CXXFLAGS += -D_GNU_SOURCE -DNDEBUG -Wall -Wextra

all: fw32

diff --git a/VERSION b/VERSION
index 3eefcb9..78bc1ab 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.0.0
+0.10.0
diff --git a/fw32.c b/fw32.cpp
similarity index 97%
rename from fw32.c
rename to fw32.cpp
index b98d48c..e15e03c 100644
--- a/fw32.c
+++ b/fw32.cpp
@@ -30,6 +30,9 @@
#include <assert.h>
#include <pwd.h>

+#include <string>
+#include <vector>
+
typedef struct
{
const char *dir;
@@ -90,21 +93,20 @@ static const char *FW32_DEF_PKGS[] =
};

static bool
-is_cmd(const char *s,const char *cmd)
+is_cmd(const std::string& s,const std::string cmd)
{
-  char buf[PATH_MAX];
-
-  if(!strcmp(s,cmd))
+  if(s == cmd)
return true;

-  snprintf(buf,sizeof buf,"/usr/sbin/%s",cmd);
+  std::string temp;
+  temp = "/usr/sbin/" + cmd;

-  if(!strcmp(s,buf))
+  if(s == temp)
return true;

-  snprintf(buf,sizeof buf,"/usr/bin/%s",cmd);
+  temp = "/usr/bin/" + cmd;

-  if(!strcmp(s,buf))
+  if(s == temp)
return true;

return false;
@@ -653,7 +655,7 @@ fw32_upgrade(void)
}

static void
-fw32_merge(const char **args1)
+fw32_merge(std::vector<const std::string> args1)
{
const char *args2[] =
{
@@ -763,12 +765,16 @@ fw32_umount_all(void)
extern int
main(int argc,const char **argv)
{
-  const char *cmd, **args;
int i;
+  const std::string cmd;

cmd = argv[0];

-  args = argv + 1;
+  std::vector<const std::string> args;
+
+  if (argc > 1) {
+    args.assign(argv + 1, argv + argc);
+  }

i = argc - 1;
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to