示例#1
0
文件: sshmitm.c 项目: IFGHou/dsniff
static void
sig_int(int signal)
{
	close(mitm_fd);
	record_close();
	exit(0);
}
void z_output_stream (void)
{

    flush_buffer ();

    switch ((short) zargs[0]) {

    case  1: ostream_screen = TRUE;
	     break;
    case -1: ostream_screen = FALSE;
	     break;
    case  2: if (!ostream_script) script_open ();
	     break;
    case -2: if (ostream_script) script_close ();
	     break;
    case  3: memory_open (zargs[1], zargs[2], zargc >= 3);
	     break;
    case -3: memory_close ();
	     break;
    case  4: if (!ostream_record) record_open ();
	     break;
    case -4: if (ostream_record) record_close ();
	     break;

    }

}/* z_output_stream */
示例#3
0
enum RECORD_RESULT record_write(struct record_t *record, const char *content, size_t size)
{
    if (NULL == record) {
        fprintf (stderr, "Invalid record in record_flush\n");
        return RECORD_ERROR;
    }

    record_open(record);

    writew_lock(record->fd, 0, SEEK_SET, 0);
    lseek(record->fd, 0, SEEK_END);

    int ret = write(record->fd, content, size);

    un_lock(record->fd, 0, SEEK_SET, 0);

    record_close(record);

    if (-1 == ret) {
        fprintf (stderr, "record_write failed\n");
        return RECORD_ERROR;
    }

    if (debug) fprintf (stderr, "record_write: %s %s\n", record->filename, content);
    return RECORD_SUCCESS;
}
示例#4
0
void record_write_key (zchar key)
{

    record_char (key);

    if (fputc ('\n', rfp) == EOF)
	record_close ();

}/* record_write_key */
示例#5
0
void record_write_input (const zchar *buf, zchar key)
{
    zchar c;

    while ((c = *buf++) != 0)
	record_char (c);

    record_char (key);

    if (fputc ('\n', rfp) == EOF)
	record_close ();

}/* record_write_input */
示例#6
0
int bbsfdel_main(void)
{
	if (!loginok)
		return BBS_ELGNREQ;
	char *user = getparm("u");
	if (*user != '\0') {
		char file[HOMELEN];
		sethomefile(file, currentuser.userid, "friends");
		record_t r;
		if (record_open(file, O_RDWR, &r) < 0)
			return BBS_EINTNL;
		override_t key;
		strlcpy(key.id, user, sizeof(key.id));
		override_t *ptr =
				record_search(&r, &key, sizeof(key), lsearch, cmp_override);
		if (ptr != NULL)
			record_delete(&r, ptr, sizeof(*ptr));
		record_close(&r);
	}
	printf("Location: fall\n\n");
	return 0;
}
示例#7
0
void active_board_init(bool force)
{
	fb_time_t now = fb_time();
	if (!force) {
		fb_time_t last = mdb_integer(0, "GET", ACTIVE_BOARD_UPTIME_KEY);
		if (now - last < ACTIVE_BOARD_INIT_INTERVAL)
			return;
	}
	mdb_cmd("SET", ACTIVE_BOARD_UPTIME_KEY" %"PRIdFBT, now);

	board_t board;
	if (get_board(ACTIVE_BOARD_NAME, &board) <= 0)
		return;

	record_t record;
	if (post_record_open(board.id, &record) < 0)
		return;

	active_board_clear();
	record_foreach(&record, NULL, 0, active_board_init_callback, NULL);

	record_close(&record);
}
示例#8
0
void Processor::z_output_stream() {
	flush_buffer();

	switch ((short) zargs[0]) {
	case  1: ostream_screen = true;
		 break;
	case -1: ostream_screen = false;
		 break;
	case  2: if (!ostream_script) script_open();
		 break;
	case -2: if (ostream_script) script_close();
		 break;
	case  3: memory_open(zargs[1], zargs[2], zargc >= 3);
		 break;
	case -3: memory_close();
		 break;
	case  4: if (!ostream_record) record_open();
		 break;
	case -4: if (ostream_record) record_close();
		 break;
	default:
		break;
	}
}
示例#9
0
文件: main.c 项目: 4nykey/rockbox
int cdecl frotz_main (void)
{

    os_init_setup ();

    init_buffer ();

    init_err ();

    init_memory ();

    init_process ();

    init_sound ();

    os_init_screen ();

    init_undo ();

    z_restart ();

    interpret ();

    script_close ();

    record_close ();

    replay_close ();

    reset_memory ();

    os_reset_screen ();

    return 0;

}/* main */
示例#10
0
文件: dsniff.c 项目: IFGHou/dsniff
int
main(int argc, char *argv[])
{
	int c;
	char *services, *savefile, *triggers;

	services = savefile = triggers = NULL;
	
	while ((c = getopt(argc, argv, "cdf:i:mnr:s:t:w:h?V")) != -1) {
		switch (c) {
		case 'c':
			Opt_client = 1;
			break;
		case 'd':
			Opt_debug++;
			break;
		case 'f':
			services = optarg;
			break;
		case 'i':
			nids_params.device = optarg;
			break;
		case 'm':
			Opt_magic = 1;
			break;
		case 'n':
			Opt_dns = 0;
			break;
		case 'r':
			Opt_read = 1;
			savefile = optarg;
			break;
		case 's':
			if ((Opt_snaplen = atoi(optarg)) == 0)
				usage();
			break;
		case 't':
			triggers = optarg;
			break;
		case 'w':
			Opt_write = 1;
			savefile = optarg;
			break;
		default:
			usage();
		}
	}
	argc -= optind;
	argv += optind;
	
	if (Opt_read && Opt_write)
		usage();
	
	if (!record_init(savefile))
		err(1, "record_init");
	
	signal(SIGHUP, sig_hup);
	signal(SIGINT, sig_die);
	signal(SIGTERM, sig_die);
	
	if (Opt_read) {
		record_dump();
		record_close();
		exit(0);
	}

	if (argc != 0)
		nids_params.pcap_filter = copy_argv(argv);
	nids_params.scan_num_hosts = 0;
	nids_params.syslog = null_syslog;
	
	if (!nids_init()) {
		record_close();
		errx(1, "nids_init: %s", nids_errbuf);
	}
	if (Opt_magic) {
		trigger_init_magic(DSNIFF_LIBDIR DSNIFF_MAGIC);
	}
	if (triggers) {
		trigger_init_list(triggers);
	}
	if (services == NULL) {
		services = DSNIFF_LIBDIR DSNIFF_SERVICES;
	}
	trigger_init_services(services);
	
	nids_register_ip(trigger_ip);
	nids_register_ip(trigger_udp);
		
	if (Opt_client) {
		nids_register_ip(trigger_tcp_raw);
		signal(SIGALRM, trigger_tcp_raw_timeout);
		alarm(TRIGGER_TCP_RAW_TIMEOUT);
	}
	else nids_register_tcp(trigger_tcp);
	
	if (nids_params.pcap_filter != NULL) {
		warnx("listening on %s [%s]", nids_params.device,
		      nids_params.pcap_filter);
	}
	else warnx("listening on %s", nids_params.device);
	
	nids_run();
	
	/* NOTREACHED */
	
	exit(0);
}
示例#11
0
文件: dsniff.c 项目: IFGHou/dsniff
void
sig_die(int sig)
{
	record_close();
	exit(0);
}
示例#12
0
文件: io.c 项目: jabahiro/bonanse
int
open_history( const char *str_name1, const char *str_name2 )
{
#if defined(NO_LOGGING)
  int iret;

  iret = record_close( &record_game );
  if ( iret < 0 ) { return -1; }

  iret = record_open( &record_game, "game.csa", mode_read_write,
		      str_name1, str_name2 );
  if ( iret < 0 ) { return -1; }

  return 1;
#else
  FILE *pf;
  int i, iret;
  char str_file[SIZE_FILENAME];
  
  if ( record_game.pf != NULL && ! record_game.moves )
    {
      record_game.str_name1[0] = '\0';
      record_game.str_name2[0] = '\0';

      if ( str_name1 )
	{
	  strncpy( record_game.str_name1, str_name1, SIZE_PLAYERNAME-1 );
	  record_game.str_name1[SIZE_PLAYERNAME-1] = '\0';
	}
      
      if ( str_name2 )
	{
	  strncpy( record_game.str_name2, str_name2, SIZE_PLAYERNAME-1 );
	  record_game.str_name2[SIZE_PLAYERNAME-1] = '\0';
	}
      return 1;
    }

  if ( ( ( game_status & flag_nonewlog )
#  if defined(USI)
	 ||  usi_mode != usi_off
#  endif
	 ) && 0 <= record_num )
    {
      iret = record_close( &record_game );
      if ( iret < 0 ) { return -1; }
      
      snprintf( str_file, SIZE_FILENAME, "%s/game%03d.csa",
		str_dir_logs, record_num );
      iret = record_open( &record_game, str_file, mode_read_write,
			  str_name1, str_name2 );
      if ( iret < 0 ) { return -1; }
    }
  else
    {
      iret = file_close( pf_log );
      if ( iret < 0 ) { return -1; }
      
      iret = record_close( &record_game );
      if ( iret < 0 ) { return -1; }
      
      for ( i = 0; i < 999; i++ )
	{
	  snprintf( str_file, SIZE_FILENAME, "%s/game%03d.csa",
		    str_dir_logs, i );
	  pf = file_open( str_file, "r" );
	  if ( pf == NULL ) { break; }
	  iret = file_close( pf );
	  if ( iret < 0 ) { return -1; }
	}
      record_num = i;
      
      snprintf( str_file, SIZE_FILENAME, "%s/n%03d.log",
		str_dir_logs, i );
      pf_log = file_open( str_file, "w" );
      if ( pf_log == NULL ) { return -1; }
      
      snprintf( str_file, SIZE_FILENAME, "%s/game%03d.csa",
		str_dir_logs, i );
      iret = record_open( &record_game, str_file, mode_read_write,
			  str_name1, str_name2 );
      if ( iret < 0 ) { return -1; }
    }
  
  return 1;
#endif
}