Permalink
Browse files

Removed Windows-related code from masterbranch. Windows support has i…

…t's own branch.
  • Loading branch information...
1 parent 954afb9 commit ed91e8f4601bee4a2971fa52d4e3c78ce017e6ca @TacoSteemers committed Mar 21, 2013
View
2 code/backup.c
@@ -9,7 +9,7 @@
#include <errno.h>
#include <stdio.h> /* util.h uses FILE */
#include <dirent.h> /* util.h uses DIR */
-#include "logging.h"
+#include <syslog.h>
#include "global.h"
#include "util.h"
#include "bookKeeping.h"
View
2 code/bookKeeping.c
@@ -5,7 +5,7 @@
#include <stdlib.h> /* exit, malloc */
#include <string.h>
-#include "logging.h"
+#include <syslog.h>
#include "bookKeeping.h"
#include "global.h"
#include "backup.h"
View
2 code/daemon.c
@@ -16,7 +16,7 @@
#include <stdlib.h> /* exit */
#include <unistd.h> /* sleep */
#include <string.h>
-#include "logging.h"
+#include <syslog.h>
#include "processArguments.h"
#include "detection.h"
#include "bookKeeping.h"
View
82 code/daemonWindows.c
@@ -1,82 +0,0 @@
-/* USB Storage Backup Daemon
- Copyright 2012, Taco steemers. This program is distributed under the terms of
- the GNU General Public License. A version of this license should have been
- provided. It can also be found on: http://www.gnu.org/licenses/gpl-3.0.txt */
-
-#include <sys/stat.h> /* umask */
-#include <stdlib.h> /* exit */
-#include <unistd.h> /* sleep */
-#include <string.h>
-#include "logging.h"
-#include "processArguments.h"
-#include "detection.h"
-#include "bookKeeping.h"
-#include "global.h"
-#ifdef _WIN32
- #include "windowsAlternatives.h"
- #include <process.h> /* Required for _spawnv */
- #include <windows.h>
- /* We make getpid() work in a similar
- way on Windows as it does on Linux */
- #define getpid() GetCurrentProcessId()
-#endif
-
-int gCurrentRunId = 0; /* Declared in global.h */
-const int gModeSetting = DAEMONMODE; /* Declared in global.h */
-/* This program uses the 'daemon mode' of the code base. */
-
-int main(int argc, char *argv[]) {
- /* Our process ID and Session ID */
- pid_t pid;
-
- printf("Original pid: %ld", getpid());
-
-
- /* Fork off the parent process */
- _spawnv(_P_NOWAIT, argv[0], (const char * const *)argv);
-
- pid = getpid();
- if (pid < 0) {
- exit(EXIT_FAILURE);
- }
- /* If we got a good PID, then
- we can exit the parent process. */
- if (pid > 0) {
- exit(EXIT_SUCCESS);
- }
-
- /* Open any logs here */
- setlogmask (LOG_UPTO (LOG_DEBUG));
- openlog ("usbstoragebackup", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
- syslog(LOG_NOTICE, "Program started by User %d", getuid ());
-
- /* Change the current working directory */
- if ((chdir("/")) < 0) {
- syslog(LOG_ERR, "Exiting with failure: Program was unable to chdir");
- exit(EXIT_FAILURE);
- }
-
- /* Close out the standard file descriptors
- We won't need these, as such it is safer to close them */
- close(STDIN_FILENO);
- close(STDOUT_FILENO);
- close(STDERR_FILENO);
-
- /* Initialization of the daemon functionality */
- initializeDeviceBookKeeping();
- processArguments((const char * const *)argv, argc);
- if(gTargetDirectory == NULL)
- {
- syslog(LOG_ERR, "Exiting with failure: No target directory has been specified. Specifying a target directory is mandatory.");
- exit(EXIT_FAILURE);
- }
-
- /* The Big Loop */
- while (1) {
- doCheck();
-
- Sleep(30000); /* wait 30 seconds */
- }
-
- exit(EXIT_SUCCESS);
-}
View
2 code/detection.c
@@ -12,7 +12,7 @@
#include <stdio.h> /* fopen, feof, fgets, FILE */
#include <stdlib.h> /* exit */
#include <fcntl.h> /* File control options (contains open) */
-#include "logging.h"
+#include <syslog.h>
#include "detection.h"
#include "global.h"
#include "bookKeeping.h"
View
30 code/detectionWindows.c
@@ -1,30 +0,0 @@
-
-void doCheck()
-{
-
-}
-
-void processItem(char *devicePath, char* entryName)
-{
-
-}
-
-int checkIfItemMounted(char *devicePath)
-{
- return 0;
-}
-
-void getMountPoint(char *out, char *devicePath)
-{
-
-}
-
-void getDeviceInfo(char* out, int *pOutLen, const char device[])
-{
-
-}
-
-void addDeviceInfo(char *id, int *p_len, const char *source, const char *property)
-{
-
-}
View
49 code/loggingWindows.c
@@ -1,49 +0,0 @@
-/* USB Storage Backup Daemon
- Copyright 2012, Taco steemers. This program is distributed under the terms of
- the GNU General Public License. A version of this license should have been
- provided. It can also be found on: http://www.gnu.org/licenses/gpl-3.0.txt */
-
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <stdio.h>
-#include "logging.h"
-
-/* Sloppy partial implementation of syslog functionality.
- This allows the code that uses the syslog function to
- compile on a Windows platform. */
-
-int mode = 0;
-FILE *logFile;
-
-void syslog(int requestedMode, char *formatting, ...)
-{
- if(requestedMode > mode)
- return;
- va_list args;
- va_start(args,formatting);
- vfprintf(logFile, formatting, args);
- va_end(args);
-}
-
-int setlogmask(int newMode)
-{
- int oldMode = mode;
- mode = newMode;
- return oldMode;
-}
-
-int LOG_UPTO(int newMode)
-{
- return newMode;
-}
-
-void openlog(char* identifier, int unused_0, int unused_1)
-{
- char filePath[4096];
- filePath[0] = '\0';
- strcat(filePath, getenv("TEMP"));
- strcat(filePath, "\\");
- strcat(filePath, identifier);
- logFile = fopen(filePath, "r");
-}
View
2 code/processArguments.c
@@ -7,7 +7,7 @@
#include <string.h>
#include <stdio.h> /* util.h uses FILE */
#include <dirent.h> /* util.h uses DIR */
-#include "logging.h"
+#include <syslog.h>
#include "bookKeeping.h"
#include "global.h"
#include "processArguments.h"
View
2 code/util.c
@@ -13,7 +13,7 @@
#include <fcntl.h> /* File control options (contains open) */
#include <unistd.h> /* sleep, read, readlink */
#include <dirent.h>
-#include "logging.h"
+#include <syslog.h>
#include "global.h" /* MAXLISTLENGTH */
#include "util.h"
View
7 code/windowsAlternatives.c
@@ -1,7 +0,0 @@
-#include <windows.h>
-#include "logging.h"
-
-char *getuid()
-{
- return getenv("user");
-}
View
2 code/windowsAlternatives.h
@@ -1,2 +0,0 @@
-
-char *getuid(void);

0 comments on commit ed91e8f

Please sign in to comment.