projects
/
mnenc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Implemented most of the protocol
[mnenc]
/
mnencd.cpp
diff --git
a/mnencd.cpp
b/mnencd.cpp
index
68be9a5
..
2573b47
100644
(file)
--- a/
mnencd.cpp
+++ b/
mnencd.cpp
@@
-26,7
+26,7
@@
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* */
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* */
-
+#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
@@
-68,9
+68,17
@@
int main(int argc, char** argv) {
/* Log the failure */
exit(EXIT_FAILURE);
}
/* Log the failure */
exit(EXIT_FAILURE);
}
-
+ std::string name, dirname;
+ name = getenv("USER");
+ dirname = "/home/" + name + "/.mnenc/";
+ if(mkdir(dirname.c_str(), S_IRWXU | S_IRWXG | S_IRWXO ) < 0) {
+ if(errno != EEXIST) {
+ exit(EXIT_FAILURE);
+ }
+ }
+
/* Change the current working directory */
/* Change the current working directory */
- if ((chdir("/home/micke/.fifo")) < 0) {
+ if ((chdir("/tmp/")) < 0) {
/* Log the failure */
exit(EXIT_FAILURE);
}
/* Log the failure */
exit(EXIT_FAILURE);
}
@@
-81,9
+89,11
@@
int main(int argc, char** argv) {
close(STDERR_FILENO);
/* Daemon-specific initialization goes here */
close(STDERR_FILENO);
/* Daemon-specific initialization goes here */
-
- mkfifo("./fife", 0777);
+ mkfifo("./mnencdfifo", 0777);
+ signal(SIGTERM, term); // register a SIGTERM handler
+ //raise(SIGTERM); // will cause term() to run
+
/* The Big Loop */
while (1) {
std::string request = m_read();
/* The Big Loop */
while (1) {
std::string request = m_read();
@@
-91,6
+101,5
@@
int main(int argc, char** argv) {
m_send(reply);
sleep(1); /* wait 1 second*/
}
m_send(reply);
sleep(1); /* wait 1 second*/
}
- unlink("fife");
exit(EXIT_SUCCESS);
}
exit(EXIT_SUCCESS);
}