basic structure and client process chain done
This commit is contained in:
parent
77657c7078
commit
83bd6fb796
21 changed files with 313 additions and 7 deletions
30
src/djumbai_enqueue/djumbai_enqueue.c
Normal file
30
src/djumbai_enqueue/djumbai_enqueue.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include "djumbai_enqueue.h"
|
||||
|
||||
int main() {
|
||||
//Change the root of the djumbai_enqueue process so it doesn't have access to anything else.
|
||||
chroot("/opt/djumbai/queue/");
|
||||
const char *message_queue_path =
|
||||
"mailqueue"; // Replace this with the path to your FIFO
|
||||
|
||||
// Open the FIFO for writing
|
||||
int queue_fd;
|
||||
queue_fd = open(message_queue_path, O_WRONLY);
|
||||
if (queue_fd == -1) {
|
||||
if (errno == ENOENT) {
|
||||
// FIFO does not exist
|
||||
printf("FIFO '%s' does not exist. Exiting...\n", message_queue_path);
|
||||
return 1;
|
||||
} else {
|
||||
perror("open");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Read message from stdin
|
||||
unsigned char buffer[MESSAGE_SIZE];
|
||||
read(0, buffer, MESSAGE_SIZE);
|
||||
|
||||
// Write message to message queue
|
||||
write(queue_fd, buffer, MESSAGE_SIZE);
|
||||
close(queue_fd);
|
||||
}
|
12
src/djumbai_enqueue/djumbai_enqueue.h
Normal file
12
src/djumbai_enqueue/djumbai_enqueue.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#ifndef DJUMBAI_ENQUEUE_H
|
||||
#define DJUMBAI_ENQUEUE_H
|
||||
|
||||
#include "../../libs/protocol/protocol.h"
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main();
|
||||
|
||||
#endif // !DJUMBAI_ENQUEUE_H
|
Loading…
Add table
Add a link
Reference in a new issue