Merge branch 'master' of ssh://bitsetter.de:8090/netsl
This commit is contained in:
commit
9a0995dbd0
10
src/image.c
10
src/image.c
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user