aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.c15
-rw-r--r--src/misc.c2
-rw-r--r--src/misc.h3
-rw-r--r--src/modem.c3
-rw-r--r--src/modem.h9
5 files changed, 16 insertions, 16 deletions
diff --git a/src/main.c b/src/main.c
index cef7bb1..fbb8ee9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -10,11 +10,6 @@
int main(int argc, char* argv[])
{
log_init_stdout(_LOG_DEBUG);
-
- LOGPRINTF(_LOG_DEBUG, "debug");
- LOGPRINTF(_LOG_NOTE, "note");
- LOGPRINTF(_LOG_WARNING, "warn");
- LOGPRINTF(_LOG_ERROR, "Error");
signal(SIGCHLD,SIG_IGN); //Ignore sigchld
struct prog_params params = parse_args(argc, argv);
@@ -23,23 +18,23 @@ int main(int argc, char* argv[])
if(params.fork)
{
FILE* pidfile = fopen(params.pidfile, "w");
-
+
if(!pidfile)
{
- PRINT_ERROR("Unable to open pidfile for writing");
+ LOGPRINTF(_LOG_ERROR,"Unable to open pidfile\n");
exit(1);
}
pid_t pid = fork();
if(pid < 0)
{
- PRINT_ERROR("fork() failed");
+ LOGPRINTF(_LOG_ERROR,"fork failed\n");
exit(1);
}
else if(pid > 0)
{
fprintf(pidfile, "%i", pid);
- printf("Forked with PID %i\n", pid);
+ LOGPRINTF(_LOG_INFO,"Forked with PID %i\n\n", pid);
fclose (pidfile);
exit(0);
}
@@ -52,7 +47,7 @@ int main(int argc, char* argv[])
close (STDERR_FILENO);
}//if params.fork
- DEBUG_PRINTF("%s, %i\n", params.run_argv[0], params.run_argc);
+ LOGPRINTF(_LOG_DEBUG, "%s, %i\n", params.run_argv[0], params.run_argc);
if ( params.serial )
dialup_server(params);
diff --git a/src/misc.c b/src/misc.c
index c3cbf7b..ae6437e 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -25,7 +25,7 @@ pid_t fork_run(int _stdin, int _stdout, int _stderr, int argc, char* argv[])
execv(argv[0], arv);
- printf("EXEC ERROR %i: %s\r\n", errno, strerror(errno));
+ LOGPRINTF(_LOG_ERROR, "fork_run(): exec failed\n");
exit(1);
}
else {
diff --git a/src/misc.h b/src/misc.h
index 34ca3ec..61b1503 100644
--- a/src/misc.h
+++ b/src/misc.h
@@ -50,6 +50,9 @@ struct prog_params
char* pidfile;
};
+/*
+ * Parses input parameters, returns filled program parameter struct
+ * */
struct prog_params parse_args(int argc, char* argv[]);
/*
diff --git a/src/modem.c b/src/modem.c
index d8b09fc..f3c6594 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -86,7 +86,7 @@ int modem_command(int fd, char* cmd, int timeout_ms)
write(fd, cmd, strlen(cmd) );
- int ok = 1;
+ int ok = 1; //Return value of function
while(1) {
ret = poll(&fds, 1, timeout_ms);
usleep(5000); //Wait for data to fully come in
@@ -98,7 +98,6 @@ int modem_command(int fd, char* cmd, int timeout_ms)
if(cnt >= buffsize)
break;
-
if( strstr(buff, "OK") ) {
ok = 0;
break;
diff --git a/src/modem.h b/src/modem.h
index 31f9fee..544c4cc 100644
--- a/src/modem.h
+++ b/src/modem.h
@@ -26,20 +26,23 @@
#define _MODEM_WAIT_RING
-int modem_accept_wait(int fd);
/*
* Waits for RING (ifdef _MODEM_WAIT_RING), accepts incoming calls. Return is non-zero when cennection fails.
* */
+int modem_accept_wait(int fd);
-int modem_command(int fd, char* cmd, int timeout_ms);
/*
* Execute an AT command. return is non-zero if answer is not OK
* */
+int modem_command(int fd, char* cmd, int timeout_ms);
-int modem_run(int fd, int argc, char* argv[]);
/*
* Run a program with modem as STDIO. checks if connection is still alive & process is still active.
* will close fd on successful return
* */
+int modem_run(int fd, int argc, char* argv[]);
+/*
+ * Spawn a telnet server
+ * */
void dialup_server(struct prog_params params);