summaryrefslogtreecommitdiff
path: root/src/base
diff options
context:
space:
mode:
Diffstat (limited to 'src/base')
-rwxr-xr-xsrc/base/homeDirector.c6
-rwxr-xr-xsrc/base/modules.c2
-rw-r--r--src/base/path.h8
-rwxr-xr-xsrc/base/textFile.c17
4 files changed, 22 insertions, 11 deletions
diff --git a/src/base/homeDirector.c b/src/base/homeDirector.c
index 6abfb56..a3ae1d1 100755
--- a/src/base/homeDirector.c
+++ b/src/base/homeDirector.c
@@ -13,9 +13,11 @@ static char homeDirector[STR_PATH_SIZE];
void createHomeDirector()
{
char *envHome;
-
+#ifndef __WIN32__
envHome = getenv("HOME");
-
+#else
+ envHome = getenv("USERPROFILE");
+#endif
if( envHome == NULL )
{
fprintf(stderr, "Environment HOME not found !\n");
diff --git a/src/base/modules.c b/src/base/modules.c
index b42df8b..a45bfc6 100755
--- a/src/base/modules.c
+++ b/src/base/modules.c
@@ -4,8 +4,6 @@
#include <string.h>
#ifndef __WIN32__
#include <dlfcn.h>
-#else
-#include <windows.h>
#endif
#include <assert.h>
diff --git a/src/base/path.h b/src/base/path.h
index 8765ed5..d647710 100644
--- a/src/base/path.h
+++ b/src/base/path.h
@@ -6,7 +6,11 @@
#include "main.h"
#ifndef PREFIX
+#ifndef __WIN32__
#define PREFIX "/usr/local"
+#else
+#endif
+#define PREFIX ".."
#endif
#ifndef PUBLIC_SERVER
@@ -15,7 +19,11 @@
#else
#define PATH_DIR PREFIX "/share/tuxanci-ng-server/"
#define PATH_MODULES PREFIX "/lib/tuxanci-ng-server/"
+#ifndef __WIN32__
#define SERVER_CONFIG "/etc/tuxanci-ng-server/server.conf"
+#else
+ #define SERVER_CONFIG PREFIX "/etc/tuxanci-ng-server/server.conf"
+#endif
#endif
#define PATH_IMAGE PATH_DIR "image/"
diff --git a/src/base/textFile.c b/src/base/textFile.c
index e5636ae..a996ac8 100755
--- a/src/base/textFile.c
+++ b/src/base/textFile.c
@@ -13,10 +13,12 @@ textFile_t* newTextFile(char *s)
{
textFile_t *new;
char path[STR_PATH_SIZE];
-
assert( s != NULL );
-
+#ifndef __WIN32__
if( s[0] == '/' )
+#else
+ if( s[1] == ':' )
+#endif
{
strcpy(path, s);
}
@@ -26,7 +28,6 @@ textFile_t* newTextFile(char *s)
strcat(path, "/");
strcat(path, s);
}
-
new = malloc(sizeof(textFile_t));
new->file = strdup(path);
new->text = newList();
@@ -86,7 +87,7 @@ textFile_t* loadTextFile(char *s)
}
file_length = buf.st_size;
- if( (file = fopen(s, "rt")) == NULL )
+ if( (file = fopen(s, "rb")) == NULL )
{
fprintf(stderr, "ERROR: unable to open file %s for reading\n", s);
return NULL;
@@ -133,14 +134,16 @@ void saveTextFile(textFile_t *p)
{
int i;
FILE *file;
-
assert( p != NULL );
-
+
file = fopen(p->file, "wt");
-
for(i = 0; i < p->text->count; i++)
{
+#ifndef __WIN32__
fprintf(file, "%s\n", (char *)p->text->list[i]);
+#else
+ fprintf(file, "%s\r\n", (char *)p->text->list[i]);
+#endif
}
fclose(file);