1 |
kusanagi |
1.1 |
|
2 |
|
|
#include "cmdgenerator.h" |
3 |
|
|
|
4 |
|
|
void abort(const char* msg1,const char *msg2) { |
5 |
|
|
fprintf(stderr,"%s %s\n",msg1,msg2); |
6 |
|
|
exit(1); |
7 |
|
|
} |
8 |
|
|
|
9 |
|
|
int write_buf(const char *filename,DAQ_CMD_BUF *b) { |
10 |
|
|
FILE *F; |
11 |
|
|
int f,i; |
12 |
|
|
char s[100]; |
13 |
|
|
sprintf(s,"../commands/%s.cmg",filename); |
14 |
|
|
f=creat(s,S_IRUSR|S_IWUSR); |
15 |
|
|
if(f == -1) |
16 |
|
|
abort("cannot open file ",filename); |
17 |
|
|
printf("writing %d Byte into %s ...\n",b->len,filename); |
18 |
|
|
if(write(f,b->buf,b->len) != b->len) |
19 |
|
|
abort("write error file %s",filename); |
20 |
|
|
close(f); |
21 |
|
|
} |
22 |
|
|
|
23 |
|
|
|