summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authordeva <deva>2006-07-25 16:35:32 +0000
committerdeva <deva>2006-07-25 16:35:32 +0000
commitbad686c6eba0d6afc39b8fcdd78f5069ec4d2cb8 (patch)
tree5af7bb7561ec08460503f6487341838898a78d38 /server
parentdffe8d4a8ce470d315639331bdc1f45f25244618 (diff)
Moved the ETC and PIXMAPS symbols to config.h.
Moved the ETC and PIXMAPS symbols to config.h. Moved the ETC and PIXMAPS symbols to config.h.
Diffstat (limited to 'server')
-rw-r--r--server/Makefile.am4
-rw-r--r--server/miav_server.cc66
-rw-r--r--server/miav_server.h7
-rw-r--r--server/mov_encoder_writer.cc4
-rw-r--r--server/server.cc26
5 files changed, 74 insertions, 33 deletions
diff --git a/server/Makefile.am b/server/Makefile.am
index fb667dd..7d0ae05 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -1,6 +1,4 @@
-AM_CXXFLAGS := -I../lib -L../lib \
- $(CXXFLAGS) $(EXTRA_CXXFLAGS) \
- -DETC=\"$(prefix)/etc/miav\"
+AM_CXXFLAGS :=
bin_PROGRAMS = miav_server
diff --git a/server/miav_server.cc b/server/miav_server.cc
index b1dfcac..28c45b6 100644
--- a/server/miav_server.cc
+++ b/server/miav_server.cc
@@ -24,7 +24,8 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
+// For ETC
+#include "config.h"
#include "miav_server.h"
#include "miav_config.h"
@@ -36,6 +37,7 @@
#include "server.h"
#include "socket.h"
+#include "network.h"
#include <signal.h>
#include <errno.h>
@@ -56,24 +58,27 @@
static const char usage_str[] =
"Usage: %s [options]\n"
"Options:\n"
-" -c file Read configfile from 'file'\n"
-" -i Run in interactive mode (non-background mode)\n"
-" -h This message\n"
+" -c file Read configfile from 'file'\n"
+" -f Run in foreground mode (non-background mode)\n"
+" -u user Run as 'user' (overrides the configfile)\n"
+" -g group Run as 'group' (overrides the configfile)\n"
+" -h This message\n"
;
-static char *config_file = ETC"/miav.conf";
-/**
- * This function starts the MIaV server.
- */
int main(int argc, char *argv[])
{
+ char *config_file = ETC"/miav.conf";
+
int optc;
int lose = 0;
- bool interactive = false;
+ bool foreground = false;
+
+ char *user_opt = NULL;
+ char *group_opt = NULL;
// Parse the commandline
- while((optc = getopt(argc, argv, "c:ih")) != EOF) {
+ while((optc = getopt(argc, argv, "c:fhu:g:")) != EOF) {
switch(optc) {
case 'c':
config_file = strdup(optarg);
@@ -82,8 +87,22 @@ int main(int argc, char *argv[])
return 1;
}
break;
- case 'i':
- interactive = true;
+ case 'u':
+ user_opt = strdup(optarg);
+ if(!user_opt) {
+ fprintf(stderr, "Fatal: out of memory\n");
+ return 1;
+ }
+ break;
+ case 'g':
+ group_opt = strdup(optarg);
+ if(!group_opt) {
+ fprintf(stderr, "Fatal: out of memory\n");
+ return 1;
+ }
+ break;
+ case 'f':
+ foreground = true;
break;
case 'h':
fprintf(stdout, usage_str, argv[0]);
@@ -107,39 +126,44 @@ int main(int argc, char *argv[])
InfoConsole info;
MIaV::initInfo(&info);
- string *user = cfg.readString("server_user");
- string *group = cfg.readString("server_group");
-
+ string user;
+ if(user_opt) user = string(user_opt);
+ else user = *cfg.readString("server_user");
+
+ string group;
+ if(group_opt) group = string(group_opt);
+ else group = *cfg.readString("server_group");
+
// Fetch user id
int uid = -1;
struct passwd *p = getpwent();
while(p) {
- if(strcmp(p->pw_name, user->c_str()) == 0) uid = p->pw_uid;
+ if(strcmp(p->pw_name, user.c_str()) == 0) uid = p->pw_uid;
p = getpwent();
}
if(uid == -1) {
- fprintf(stderr, "Could not find user \"%s\" in /etc/passwd file.\n", user->c_str());
+ fprintf(stderr, "Could not find user \"%s\" in /etc/passwd file.\n", user.c_str());
}
// Fetch group id
int gid = -1;
struct group *g = getgrent();
while(g) {
- if(strcmp(g->gr_name, group->c_str()) == 0) gid = g->gr_gid;
+ if(strcmp(g->gr_name, group.c_str()) == 0) gid = g->gr_gid;
g = getgrent();
}
if(gid == -1) {
- fprintf(stderr, "Could not find group \"%s\" in /etc/group file.\n", group->c_str());
+ fprintf(stderr, "Could not find group \"%s\" in /etc/group file.\n", group.c_str());
}
- if(!interactive) {
+ if(!foreground) {
fprintf(stderr, "Entering daemon mode\n");
daemon(0,0);
signal (SIGTERM, SIG_IGN);
signal (SIGINT, SIG_IGN);
signal (SIGHUP, SIG_IGN);
} else {
- fprintf(stderr, "Running interactive\n");
+ fprintf(stderr, "Running in foreground mode.\n");
}
int port = MIaV::config->readInt("server_port");
diff --git a/server/miav_server.h b/server/miav_server.h
index 6d5068a..eeeccf6 100644
--- a/server/miav_server.h
+++ b/server/miav_server.h
@@ -24,14 +24,7 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "config.h"
#ifndef __LIBMIAV_H__
#define __LIBMIAV_H__
-#include "util.h"
-
-#include "network.h"
-#include "socket.h"
-#include "queue.h"
-
#endif/*__LIBMIAV_H__*/
diff --git a/server/mov_encoder_writer.cc b/server/mov_encoder_writer.cc
index a8eb190..8f432ee 100644
--- a/server/mov_encoder_writer.cc
+++ b/server/mov_encoder_writer.cc
@@ -24,7 +24,9 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
+// For ETC
+#include "config.h"
+
#include "mov_encoder_writer.h"
#include <sys/types.h>
diff --git a/server/server.cc b/server/server.cc
index 9af22d9..27e5eef 100644
--- a/server/server.cc
+++ b/server/server.cc
@@ -25,7 +25,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#include "server.h"
-#include "miav_server.h"
+
+#include "network.h"
#include <stdio.h>
#include <stdlib.h>
@@ -57,6 +58,28 @@
void newConnection(Socket *socket)
{
+ Network network(socket);
+
+ MIaV::info->info("CONNECTION OPENED");
+ MIaV::info->info("New connection (%s)", inet_ntoa(socket->socketaddr.sin_addr));
+
+ Frame *frame;
+ while((frame = network.recvFrame())) {
+
+ sleep(1);
+
+ if(frame->vframe) delete frame->vframe;
+ if(frame->aframe) delete frame->aframe;
+ delete frame;
+ }
+
+ MIaV::info->info("CONNECTION CLOSED");
+}
+
+
+/*
+void newConnection(Socket *socket)
+{
char cpr[256];
char clientip[64];
bool hasCpr = false;
@@ -135,3 +158,4 @@ void newConnection(Socket *socket)
MIaV::info->info("CONNECTION CLOSED");
}
+*/