Merge branch 'master' of ssh://bitsetter.de:8090/netsl

This commit is contained in:
tkarrass 2013-11-02 23:39:50 +01:00
commit 9a0995dbd0
4 changed files with 17 additions and 10 deletions

View File

@ -46,7 +46,7 @@ statisch nichts print_current_image(konstant struktur message* msg, zahl start,
void prntscreen(const struct message *msg, const struct prog_info *pinfo); void prntscreen(const struct message *msg, const struct prog_info *pinfo);
void callback(const struct message *msg, const struct prog_info *pinfo) { void callback(const struct message *msg, const struct prog_info *pinfo) {
// printf("in callback, tst=%d\n", msg->timestamp); //printf("in callback, tst=%d\n", msg->timestamp);
// calculate the actual offset to use // calculate the actual offset to use
//int start = msg->timestamp % msg->width + pinfo->client_offset; //int start = msg->timestamp % msg->width + pinfo->client_offset;

View File

@ -1,5 +1,12 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/param.h> // MAX
#include "image.h" #include "image.h"
#define LINELEN 20000
char *readImage(const char* filename, int *cols, int *rows) { char *readImage(const char* filename, int *cols, int *rows) {
printf("fopen\n"); printf("fopen\n");
@ -13,7 +20,7 @@ char *readImage(const char* filename, int *cols, int *rows) {
if (f) { if (f) {
while (fgets(linebuf, LINELEN, f)) { while (fgets(linebuf, LINELEN, f)) {
int len = strlen(linebuf); int len = strlen(linebuf);
*cols = len>*cols?len:*cols; *cols = MAX(len, *cols);
(*rows)++; (*rows)++;
} }
@ -31,3 +38,4 @@ char *readImage(const char* filename, int *cols, int *rows) {
return ret; return ret;
} }

View File

@ -1,12 +1,6 @@
#ifndef __IMAGE #ifndef __IMAGE
#define __IMAGE #define __IMAGE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LINELEN 20000
char *readImage(const char* filename, int *cols, int *rows); char *readImage(const char* filename, int *cols, int *rows);
#endif #endif

View File

@ -13,6 +13,10 @@
#define MODE_SERVER 0 #define MODE_SERVER 0
#define MODE_CLIENT 1 #define MODE_CLIENT 1
void die() {
cleanup_display();
exit(1);
}
int parseArgs(struct prog_info *pinfo, int argc, char **argv) { int parseArgs(struct prog_info *pinfo, int argc, char **argv) {
pinfo->mode = MODE_SERVER; pinfo->mode = MODE_SERVER;
@ -128,8 +132,9 @@ int main(int argc, char **argv) {
prog_info.width = prog_info.width>(w*2)?prog_info.width:(w*2); prog_info.width = prog_info.width>(w*2)?prog_info.width:(w*2);
ret = run_server(&prog_info, image, w, h); ret = run_server(&prog_info, image, w, h);
} else { } else {
printf("running in CLIENT mode, using client number %d\n", prog_info.client_offset); printf("running in CLIENT mode, using client offset %d\n", prog_info.client_offset);
signal(SIGINT,&cleanup_display); signal(SIGINT,&die);
signal(SIGTERM,&die);
ret = run_client(&prog_info, callback); ret = run_client(&prog_info, callback);
} }