Beispiel #1
0
void wpc_out_device::send_output(int sid, int state)
{
	if(!handler_cb.isnull() && handler_cb(sid, state))
		return;

	char buffer[32];
	const char *name;
	if(names && names[sid-1] && strcmp(names[sid-1], "s:"))
		name = names[sid-1];
	else {
		sprintf(buffer, "u:output %02d", sid);
		name = buffer;
	}
	machine().output().set_value(name, state);

	if(sid == 41)
		machine().bookkeeping().coin_counter_w(0, state);
}
Beispiel #2
0
// Iterate records, calling factory_cb and handler_cb for each record.
void lsreg_iterate(lsreg_rec_factory_cb *factory_cb,
                   lsreg_rec_handler_cb *handler_cb,
                   void *something)
{
  FILE *f;
  size_t skip_lines;
  enum kLSRegParseStatus status;
  char *linebuf;
  const size_t linebufsize = 1024;
  
  if((f = lsreg_regdump_open()) == NULL) {
    return;
  }
  linebuf = (char *)malloc(sizeof(char)*linebufsize+1);
  skip_lines = 3;
  
  while(skip_lines--) {
    if(_readline(linebuf, linebufsize, f) == NULL) {
      // error occured
      free(linebuf);
      return;
    }
  }
  
  // Parse sections
  do {
    lsreg_rec_t *record = factory_cb(something);
    lsreg_rec_init(record);
    status = lsreg_parse_record(f, linebuf, linebufsize, record);
    //lsreg_rec_dump(&record, stdout);
    if(handler_cb(record, something)) {
      break;
    }
  } while(status == kLSRegParseStatusContinue);
  
  free(linebuf);
  lsreg_regdump_close(f);
}