
#include "cmdgenerator.h"

void abort(const char* msg1,const char *msg2) {
  fprintf(stderr,"%s %s\n",msg1,msg2);
  exit(1);
}

int write_buf(const char *filename,DAQ_CMD_BUF *b) {
  FILE *F;
  int f,i;
  char s[100];
  sprintf(s,"../commands/%s.cmg",filename);
  f=creat(s,S_IRUSR|S_IWUSR);
  if(f == -1)
    abort("cannot open file ",filename);
  printf("writing %d Byte into %s ...\n",b->len,filename);
  if(write(f,b->buf,b->len) != b->len)
    abort("write error file %s",filename);
  close(f);
}


