Beispiel #1
0
/**
 *	* @brief Program entry point
 *	 * @param argc The argument counter
 *	  * @param argv The argument vector
 *	   * @return EXIT_SUCCESS on success, EXIT_ERROR in case of an error
 *	    */
int main(int argc, char** argv)
{
	/* Define a subroutine where the program jumps to if it exits gracefully */
	(void) atexit (cleanup);

	/* Input / Output Character Count */
	int in_ccount, out_ccount;	
	
	/* Save the name of the program */
	pgm_name = argv[0];
	

	/* Program is called with arguments */
	if (argc > 1)
	{	
		for (int i = 1; i < argc; i++)
		{
			char* out_name = malloc(sizeof(char)* (strlen(argv[i])+5));	//Allocate memory for the name of the output string
			(void) open_stream (argv[i], out_name);
			(void) compress (&in_ccount, &out_ccount);
			(void) output_summary (argv[i], out_name, in_ccount, out_ccount);
			free(out_name);
		}
	 }
	 else
	 {
		 char* out_name = malloc(sizeof(char)* (strlen("stdin.txt")+5));	//Allocate memory for the name of the output string
		 (void) open_stream ("stdin", out_name );
		 (void) compress (&in_ccount, &out_ccount);
		 (void) output_summary ("stdin", out_name, in_ccount, out_ccount);
		 free(out_name);
	 }

	 exit (EXIT_SUCCESS);
}
Beispiel #2
0
bool CFFMPEGLoader::CreateMovie(const char *filename, const AVOutputFormat *format, const AVCodecContext *VideoCon, const AVCodecContext *AudioCon) {
    if(!filename)
        return false;

    AVOutputFormat *fmt;
    //*fmt=*format;
    fmt = guess_format(NULL, filename, NULL);

    pFormatCon = av_alloc_format_context();
    if(!pFormatCon) {
        cout<<"Error while allocating format context\n";
        return false;
    }
    bOutput=true;
    strcpy(pFormatCon->filename,filename);

    pFormatCon->oformat=fmt;
    pAudioStream=pVideoStream=NULL;

    if (fmt->video_codec != CODEC_ID_NONE) {
        pVideoStream = add_video_stream(pFormatCon, fmt->video_codec,VideoCon);
    }
    if (fmt->audio_codec != CODEC_ID_NONE) {
        pAudioStream = add_audio_stream(pFormatCon, fmt->audio_codec,AudioCon);
    }

    if (av_set_parameters(pFormatCon, NULL) < 0) {
        cout<<"Invalid output format parameters\n";
        return false;
    }

    if (pVideoStream)
        open_stream(pFormatCon, pVideoStream);
    if (pAudioStream)
        open_stream(pFormatCon, pAudioStream);

    dump_format(pFormatCon, 0, filename, 1);

    if (!(fmt->flags & AVFMT_NOFILE)) {
        if (url_fopen(&pFormatCon->pb, filename, URL_WRONLY) < 0) {
            cout<<"Could not open '%s'"<<filename<<endl;
            return false;
        }
    }

    /* write the stream header, if any */
    av_write_header(pFormatCon);
    return true;
}
static void main_init(void) {

  TRACE(TRACE_DEBUG, "%s", "Starting initialization\n");

  /* Initalize the event library */
  event_init();

  /* Initalize our ô so accurate periodic timer */
  if (fms_periodic_init(main_periodic)) {
    TRACE(TRACE_ERROR, "%s", "failed to start periodic generator\n");
    return;
  }

  signal(SIGKILL, on_kill);
  signal(SIGINT,  on_kill);
  signal(SIGILL,  on_kill);
  signal(SIGHUP,  on_kill);
  signal(SIGQUIT, on_kill);
  signal(SIGTERM, on_kill);
  signal(SIGSEGV, on_kill);

  if(!open_stream()) {
    fprintf(stderr, "Could not open stream, sorry\n");
    exit(1);
  }

  TRACE(TRACE_DEBUG, "%s", "Initialization completed\n");
}
Beispiel #4
0
/* plain file access, no http! */
int attribute_align_arg mpg123_open(mpg123_handle *mh, const char *path)
{
	if(mh == NULL) return MPG123_ERR;

	mpg123_close(mh);
	return open_stream(mh, path, -1);
}
Beispiel #5
0
/* {{{ mysqlnd_net::connect_ex */
static enum_func_status
MYSQLND_METHOD(mysqlnd_net, connect_ex)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len,
										const zend_bool persistent,
										MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
{
	enum_func_status ret = FAIL;
	func_mysqlnd_net__open_stream open_stream = NULL;
	DBG_ENTER("mysqlnd_net::connect_ex");

	net->packet_no = net->compressed_envelope_packet_no = 0;

	net->data->m.close_stream(net, conn_stats, error_info);

	open_stream = net->data->m.get_open_stream(net, scheme, scheme_len, error_info);
	if (open_stream) {
		php_stream * net_stream = open_stream(net, scheme, scheme_len, persistent, conn_stats, error_info);
		if (net_stream) {
			(void) net->data->m.set_stream(net, net_stream);
			net->data->m.post_connect_set_opt(net, scheme, scheme_len, conn_stats, error_info);
			ret = PASS;
		}
	}

	DBG_RETURN(ret);
}
Beispiel #6
0
int attribute_align_arg mpg123_open_fd(mpg123_handle *mh, int fd)
{
	if(mh == NULL) return MPG123_ERR;

	mpg123_close(mh);
	return open_stream(mh, NULL, fd);
}
Beispiel #7
0
/*
 * Open both player and recorder.
 */
PJ_DEF(pj_status_t) pjmedia_snd_open(int rec_id,
				     int play_id,
				     unsigned clock_rate,
				     unsigned channel_count,
				     unsigned samples_per_frame,
				     unsigned bits_per_sample,
				     pjmedia_snd_rec_cb rec_cb,
				     pjmedia_snd_play_cb play_cb,
				     void *user_data,
				     pjmedia_snd_stream **p_snd_strm)
{
    PJ_ASSERT_RETURN(rec_cb && play_cb && p_snd_strm, PJ_EINVAL);

    return open_stream( PJMEDIA_DIR_CAPTURE_PLAYBACK,
			rec_id,
			play_id,
			clock_rate,
			channel_count,
			samples_per_frame,
			bits_per_sample,
			rec_cb,
			play_cb,
			user_data,
			p_snd_strm);
}
Beispiel #8
0
static void
print_trace(void)
{
  void *array[MAX_BACKTRACE];
  size_t size;
  char **strings;
  size_t i;

  if (backtrace_mode == 0)
    return;

  if (!mb_stream) {
    init_env();
    mb_stream = open_stream();
  }

  size = backtrace(array, backtrace_mode);
  strings = backtrace_symbols(array, size);

  fprintf(mb_stream, "# Obtained %zd stack frames.\n", size);

  for (i = 0; i < size; i++)
    fprintf(mb_stream, "# [BT] %d: %s\n", i, strings[i]);

  free (strings);
}
Beispiel #9
0
int main(int argc, char *argv[]) {
  if (argc < 3) {
    fprintf(stderr, "usage: backend-test <input-file> <output-file>\n");
    return 1;
  }
  FILE *src = fopen(argv[1], "r");
  if (src == NULL) {
    fprintf(stderr, "backend-test: no such file or directory\n");
    return 1;
  }
  stream *in = open_stream(src);
  block_statement *block = parse(in);
  close_stream(in);
  fclose(src);

  analyze(block);
  code_system *system = generate(block);
  optimize(system);

  FILE *out = fopen(argv[2], "w");
  if (out == NULL) {
    fprintf(stderr, "backend-test: error opening output-file\n");
    return 1;
  }

  backend_write(system, out);

  fflush(out);
  fclose(out);

  exit(0);
}
Beispiel #10
0
static void asx_parse_entryref(ASX_Parser_t* parser,char* buffer,char** _attribs) {
    char *href;
    stream_t* stream;
    int f=DEMUXER_TYPE_UNKNOWN;

    if(parser->deep > 0)
        return;

    href = asx_get_attrib("HREF",_attribs);
    if(href == NULL) {
        asx_warning_attrib_required(parser,"ENTRYREF" ,"HREF" );
        return;
    }
    stream=open_stream(href,0,&f);
    if(!stream) {
        mp_msg(MSGT_PLAYTREE,MSGL_WARN,"Can't open playlist %s\n",href);
        free(href);
        return;
    }

    mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Not recursively loading playlist %s\n",href);

    free_stream(stream);
    free(href);
    //mp_msg(MSGT_PLAYTREE,MSGL_INFO,"Need to implement entryref\n");
}
static int net_stream_open(client_t* cl,char* url) {
  int file_format=DEMUXER_TYPE_UNKNOWN;
  mp_net_stream_opened_t ret;

  if(cl->stream) {
    if(!write_error(cl->fd,"A stream is currently opened\n"))
      return 0;
    return 1;
  }

  mp_msg(MSGT_NETST,MSGL_V,"Open stream %s\n",url);
  cl->stream = open_stream(url,NULL,&file_format);
  if(!cl->stream) {
    if(!write_error(cl->fd,"Open failed\n"))
      return 0;
    return 1;
  }
  stream_reset(cl->stream);
  stream_seek(cl->stream,cl->stream->start_pos);
  ret.file_format = file_format;
  ret.flags = cl->stream->flags;
  ret.sector_size = cl->stream->sector_size;
  ret.start_pos = cl->stream->start_pos;
  ret.end_pos = cl->stream->end_pos;
  net_stream_opened_2_me(&ret);

  if(!write_packet(cl->fd,NET_STREAM_OK,(char*)&ret,sizeof(mp_net_stream_opened_t)))
    return 0;
  return 1;
}
Beispiel #12
0
static int start_file(char *name)
{
    char buf[MAXFILENAME+20];
    int fd;

    if (play_f!=-1)
    {
        replay_abort();
        close(play_f);
        play_f=-1;
        CancelWaitableTimer(timer);
        replay_pause();
        set_buttons(0);
    }
    fd=open_stream(-1, name, SM_READ, 0);
    if (fd==-1)
        return 0;
    play_f=fd;
    play_format=ttyrec_r_find_format(0, name, "baudrate");
    play_filename=name;
    replay_start();
    snprintf(buf, sizeof(buf), "Termplay: %s (%s)", filename, play_format);
    SetWindowText(wndMain, buf);
    set_toolbar_state(1);
    play_state=2;
    do_replay();
    return 1;
}
Beispiel #13
0
ASS_Track *mp_ass_read_stream(ASS_Library *library, const char *fname,
                              char *charset)
{
    ASS_Track *track;

    struct stream *s = open_stream(fname, NULL, NULL);
    if (!s)
        // Stream code should have printed an error already
        return NULL;
    struct bstr content = stream_read_complete(s, NULL, 100000000, 1);
    if (content.start == NULL)
        mp_tmsg(MSGT_ASS, MSGL_ERR, "Refusing to load subtitle file "
                "larger than 100 MB: %s\n", fname);
    free_stream(s);
    if (content.len == 0) {
        talloc_free(content.start);
        return NULL;
    }
    content.start[content.len] = 0;
    track = ass_read_memory(library, content.start, content.len, charset);
    if (track) {
        free(track->name);
        track->name = strdup(fname);
    }
    talloc_free(content.start);
    return track;
}
Beispiel #14
0
void print_group(Group *group, int expand, struct Redir *rd)
{
  if (group && open_stream(rd, group->my_corpus->corpus->charset)) {

    switch (GlobalPrintMode) {
    
    case PrintSGML:
      sgml_print_group(group, expand, rd->stream);
      break;
      
    case PrintHTML:
      html_print_group(group, expand, rd->stream);
      break;
      
    case PrintLATEX:
      latex_print_group(group, expand, rd->stream);
      break;
      
    case PrintASCII:
      ascii_print_group(group, expand, rd->stream);
      break;
    
    default:
      cqpmessage(Error, "Unknown print mode");
      break;
    }

    close_stream(rd);
    
  }
}
Beispiel #15
0
void
mb_log(const char *fmt, ...)
{
  va_list ap;
  struct timeval tv;

  if (!mb_stream) {
    init_env();
    mb_stream = open_stream();
  }

  va_start(ap, fmt);

  if (gettimeofday(&tv, NULL) < 0)
    fprintf(stderr, "gettimeofday(2) failed: %s", strerror(errno));
  else {
    fprintf(mb_stream,
#if 0
            "%10lu:%06u.%06u:%10zu:",
            ++seq,
#else
            "%06u.%06u:%10zu:",
#endif  /* 0 */
            (unsigned)tv.tv_sec, (unsigned)tv.tv_usec, mb_allocated);
  }

  vfprintf(mb_stream, fmt, ap);
  fputc('\n', mb_stream);
  fflush(mb_stream);
  va_end(ap);
}
Beispiel #16
0
/**
 * Prints the contents of a ContextDescriptor either to stdout or a pager
 * (NB this uses its own internal stream).
 */
void
PrintContextDescriptor(ContextDescriptor *cdp)
{
  FILE *fd;
  struct Redir rd = { NULL, NULL, NULL, 0, 0 };        /* for paging (with open_stream()) */
  int stream_ok;

  if (cdp) {
    stream_ok = open_stream(&rd, ascii);
    fd = (stream_ok) ? rd.stream : NULL; /* use pager, or simply print to stdout if it fails */

    if (pretty_print) {
      fprintf(fd, "===Context Descriptor=======================================\n");
      fprintf(fd, "\n");
      fprintf(fd, "left context:     %d ", cdp->left_width);
      switch (cdp->left_type) {
      case CHAR_CONTEXT: 
        fprintf(fd, "characters\n"); break;
      case WORD_CONTEXT: 
        fprintf(fd, "tokens\n"); break;
      case STRUC_CONTEXT: 
      case ALIGN_CONTEXT:
        fprintf(fd, "%s\n",
                cdp->left_structure_name ? cdp->left_structure_name : "???");
      }
      fprintf(fd, "right context:    %d ", cdp->right_width);
      switch (cdp->right_type) {
      case CHAR_CONTEXT: 
        fprintf(fd, "characters\n"); break;
      case WORD_CONTEXT: 
        fprintf(fd, "tokens\n"); break;
      case STRUC_CONTEXT: 
      case ALIGN_CONTEXT:
        fprintf(fd, "%s\n",
                cdp->right_structure_name ? cdp->right_structure_name : "???");
      }
      fprintf(fd, "corpus position:  %s\n", cdp->print_cpos ? "shown" : "not shown");
      fprintf(fd, "target anchors:   %s\n", show_targets ? "shown" : "not shown");
      fprintf(fd, "\n");
      PrintAttributes(fd, "Positional Attributes:", cdp->attributes, 0);
      fprintf(fd, "\n");
      PrintAttributes(fd, "Structural Attributes:", cdp->strucAttributes, 1);
      fprintf(fd, "\n");
      /*     PrintAttributes(fd, "Structure Values:     ", cdp->printStructureTags); */
      /*     fprintf(fd, "\n"); */
      PrintAttributes(fd, "Aligned Corpora:      ", cdp->alignedCorpora, 0);
      fprintf(fd, "\n");
      fprintf(fd, "============================================================\n");
    }
    else {
      PrintAttributesSimple(fd, "p-Att", cdp->attributes, 0);
      PrintAttributesSimple(fd, "s-Att", cdp->strucAttributes, 1);
      PrintAttributesSimple(fd, "a-Att", cdp->alignedCorpora, 0);
    }

    if (stream_ok) 
      close_stream(&rd);        /* close pipe to pager if we were using it */
  }
}
Beispiel #17
0
void
Email::sendExit( ClassAd* ad, int exit_reason )
{
	open_stream( ad, exit_reason );
	writeExit( ad, exit_reason );
    writeCustom( ad );
	send();
}
Beispiel #18
0
// This method sucks.  As soon as we have a real solution for storing
// all 4 of these values in the job classad, it should be removed.
void
Email::sendExitWithBytes( ClassAd* ad, int exit_reason,
						  float run_sent, float run_recv,
						  float tot_sent, float tot_recv )
{
	open_stream( ad, exit_reason );
	writeExit( ad, exit_reason );
	writeBytes( run_sent, run_recv, tot_sent, tot_recv );
    writeCustom( ad );
	send();
}
Beispiel #19
0
static void coco_print_byte(struct MC6809 *cpu) {
	int byte;
	/* Open stream for output if it's not already */
	if (!stream_dest) return;
	if (!stream) open_stream();
	/* Print byte */
	byte = MC6809_REG_A(cpu);
	if (stream) {
		fputc(byte, stream);
	}
}
Beispiel #20
0
int i2c_open(const char *path, int *error) {
    int i2c_fd;
    int errsv = 0;
    if((i2c_fd = open_stream(path, &errsv)) < 0) {
        perror("error: i2c_open() failure");
        if(errsv == EACCES) {
            *error = E_ACCESS_DENIED;
        }
        return -1;
    }
    return i2c_fd;
}
Beispiel #21
0
PJ_DEF(pj_status_t) pjmedia_snd_open_player( int index,
					unsigned clock_rate,
					unsigned channel_count,
					unsigned samples_per_frame,
					unsigned bits_per_sample,
					pjmedia_snd_play_cb play_cb,
					void *user_data,
					pjmedia_snd_stream **p_snd_strm )
{
    return open_stream(PJMEDIA_DIR_PLAYBACK, PJMEDIA_AUD_INVALID_DEV, index, 
		       clock_rate, channel_count, samples_per_frame,
		       bits_per_sample, NULL, play_cb,
		       user_data, p_snd_strm);
}
Beispiel #22
0
PJ_DEF(pj_status_t) pjmedia_snd_open_rec( int index,
					  unsigned clock_rate,
					  unsigned channel_count,
					  unsigned samples_per_frame,
					  unsigned bits_per_sample,
					  pjmedia_snd_rec_cb rec_cb,
					  void *user_data,
					  pjmedia_snd_stream **p_snd_strm)
{
    return open_stream(PJMEDIA_DIR_CAPTURE, index, PJMEDIA_AUD_INVALID_DEV,
		       clock_rate, channel_count, samples_per_frame,
		       bits_per_sample, rec_cb, NULL,
		       user_data, p_snd_strm);
}
Beispiel #23
0
ASS_Track *mp_ass_read_stream(ASS_Library *library, const char *fname,
                              char *charset)
{
    int i;
    char *buf = NULL;
    ASS_Track *track;
    size_t sz = 0;
    size_t buf_alloc = 0;
    stream_t *fd;

    fd = open_stream(fname, NULL, NULL);
    if (!fd)
        // Stream code should have printed an error already
        return NULL;
    if (fd->end_pos > STREAM_BUFFER_SIZE)
        /* read entire file if size is known */
        buf_alloc = fd->end_pos;
    else
        buf_alloc = 1000;
    for (;;) {
        if (sz > 100000000) {
            mp_tmsg(MSGT_ASS, MSGL_ERR, "Refusing to load subtitle file "
                    "larger than 100 MB: %s\n", fname);
            sz = 0;
            break;
        }
        buf_alloc = FFMAX(buf_alloc, sz + (sz >> 1));
        buf_alloc = FFMIN(buf_alloc, 100000001);
        buf = realloc(buf, buf_alloc + 1);
        i = stream_read(fd, buf + sz, buf_alloc - sz);
        if (i <= 0)
            break;
        sz += i;
    }
    free_stream(fd);
    if (!sz) {
        free(buf);
        return NULL;
    }
    buf[sz] = 0;
    buf = realloc(buf, sz + 1);
    track = ass_read_memory(library, buf, sz, charset);
    if (track) {
        free(track->name);
        track->name = strdup(fname);
    }
    free(buf);
    return track;
}
Beispiel #24
0
PJ_DEF(pj_status_t) pjmedia_snd_open_player( int index,
					unsigned clock_rate,
					unsigned channel_count,
					unsigned samples_per_frame,
					unsigned bits_per_sample,
					pjmedia_snd_play_cb play_cb,
					void *user_data,
					pjmedia_snd_stream **p_snd_strm)
{
    PJ_ASSERT_RETURN(play_cb && p_snd_strm, PJ_EINVAL);

    return open_stream( PJMEDIA_DIR_PLAYBACK, -1, index,
			clock_rate, channel_count, samples_per_frame,
			bits_per_sample, NULL, play_cb, user_data,
			p_snd_strm);
}
Beispiel #25
0
/*
 * Open stream.
 */
PJ_DEF(pj_status_t) pjmedia_snd_open_rec( int index,
					  unsigned clock_rate,
					  unsigned channel_count,
					  unsigned samples_per_frame,
					  unsigned bits_per_sample,
					  pjmedia_snd_rec_cb rec_cb,
					  void *user_data,
					  pjmedia_snd_stream **p_snd_strm)
{
    PJ_ASSERT_RETURN(rec_cb && p_snd_strm, PJ_EINVAL);

    return open_stream( PJMEDIA_DIR_CAPTURE, index, -1,
			clock_rate, channel_count, samples_per_frame,
			bits_per_sample, rec_cb, NULL, user_data,
			p_snd_strm);
}
Beispiel #26
0
/* Called when the PIA bus containing STROBE is changed */
void printer_strobe(_Bool strobe, int data) {
	/* Ignore if this is not a transition to high */
	if (strobe == strobe_state) return;
	strobe_state = strobe;
	if (!strobe_state) return;
	/* Open stream for output if it's not already */
	if (!stream_dest) return;
	if (!stream) open_stream();
	/* Print byte */
	if (stream) {
		fputc(data, stream);
	}
	/* ACK, and schedule !ACK */
	DELEGATE_SAFE_CALL1(printer_signal_ack, 1);
	ack_clear_event.at_tick = event_current_tick + (OSCILLATOR_RATE / 150000);
	event_queue(&MACHINE_EVENT_LIST, &ack_clear_event);
}
Beispiel #27
0
ASS_Track* ass_read_stream(ASS_Library* library, const char *fname, char *charset) {
	char *buf = NULL;
	ASS_Track *track;
	size_t sz = 0;
	size_t buf_alloc = 0;
	stream_t *fd;

	fd = open_stream(fname, NULL, NULL);
	if (!fd) {
		mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FopenFailed, fname);
		return NULL;
	}
	if (fd->end_pos > STREAM_BUFFER_SIZE)
		/* read entire file if size is known */
		buf_alloc = fd->end_pos;
	for (;;) {
		int i;
		if (buf_alloc >= 100*1024*1024) {
			mp_msg(MSGT_ASS, MSGL_INFO, MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan100M, fname);
			sz = 0;
			break;
		}
		if (buf_alloc < sz + STREAM_BUFFER_SIZE)
			buf_alloc += STREAM_BUFFER_SIZE;
		buf = realloc(buf, buf_alloc + 1);
		i = stream_read(fd, buf + sz, buf_alloc - sz);
		if (i <= 0) break;
		sz += i;
	}
	free_stream(fd);
	if (!sz) {
		free(buf);
		return NULL;
	}
	buf[sz] = 0;
	buf = realloc(buf, sz + 1);
	track = ass_read_memory(library, buf, sz, charset);
	if (track) {
		free(track->name);
		track->name = strdup(fname);
	}
	free(buf);
	return track;
}
static void main_init(void) {
  uint8_t byte_idx;

  TRACE(TRACE_DEBUG, "%s", "Starting initialization\n");

  /* Initalize our SPI link to IO processor */
  if (spi_link_init()) {
    TRACE(TRACE_ERROR, "%s", "failed to open SPI link \n");
    return;
  }

  spistream_init(&on_spistream_msg_received,
                 &on_spistream_msg_sent);

  for(byte_idx=1; byte_idx < 123; byte_idx++) {
    spistream_msg[byte_idx] = byte_idx;
  }
  /* Initalize the event library */
  event_init();

  /* Initalize our ô so accurate periodic timer */
  if (fms_periodic_init(main_periodic)) {
    TRACE(TRACE_ERROR, "%s", "failed to start periodic generator\n");
    return;
  }

	signal(SIGKILL, on_kill);
	signal(SIGINT,  on_kill);
	signal(SIGILL,  on_kill);
	signal(SIGHUP,  on_kill);
	signal(SIGQUIT, on_kill);
	signal(SIGTERM, on_kill);
	signal(SIGSEGV, on_kill);
	signal(SIGPIPE, on_dead_pipe);

	if(!open_stream()) {
		fprintf(LOG_OUT, "Could not open stream, sorry\n");
		exit(1);
	}

  TRACE(TRACE_DEBUG, "%s", "Initialization completed\n");
}
Beispiel #29
0
static void export_file(void)
{
    char fn[MAXFILENAME],errmsg[MAXFILENAME+20+128];
    OPENFILENAME dlg;
    int record_f;
    const char *format;
    struct timeval sel1, sel2;

    memset(&dlg, 0, sizeof(dlg));
    dlg.lStructSize=sizeof(dlg);
    dlg.hwndOwner=wndMain;
    dlg.lpstrFilter=
                    "ttyrec videos (*.ttyrec, *.ttyrec.[gz|bz2|xz])\000*.ttyrec;*.ttyrec.gz;*.ttyrec.bz2;*.ttyrec.xz\000"
                    "nh-recorder videos (*.nh, *.nh.[gz|bz2|xz])\000*.nh;*.nh.gz;*.nh.bz2;*.nh.xz\000"
                    "RealLogs videos (*.rl, *.rl.[gz|bz2|xz])\000*.rl;*.rl.gz;*.rl.bz2;*.rl.xz\000"
                    "ANSI logs (*.txt, *.txt.[gz|bz2|xz])\000*.txt;*.txt.gz;*.txt.bz2;*.txt.xz\000"
                    "all files\000*\000"
                    "\000\000";
    dlg.nFilterIndex=1;
    dlg.lpstrFile=fn;
    dlg.nMaxFile=MAXFILENAME;
    dlg.Flags=OFN_HIDEREADONLY|OFN_LONGNAMES;
    dlg.lpstrDefExt="ttyrec.bz2";
    *fn=0;

    if (!GetSaveFileName(&dlg))
        return;

    format=ttyrec_w_find_format(0, fn, "ansi");
    if ((record_f=open(fn, O_WRONLY|O_CREAT|O_TRUNC, 0666))==-1)
    {
        sprintf(errmsg, "Can't write to %s: %s", fn, strerror(errno));
        MessageBox(wndMain, errmsg, "Write error", MB_ICONERROR);
        return;
    }
    record_f=open_stream(record_f, fn, SM_WRITE, 0);
    sel1=selstart;
    tadd(sel1, tdate);
    sel2=selend;
    tadd(sel2, tdate);
    ttyrec_save(ttr, record_f, format, filename, &sel1, &sel2);
}
Beispiel #30
0
void
Email::sendAction( ClassAd* ad, const char* reason,
						const char* action )
{
	if( ! ad ) {
		EXCEPT( "Email::sendAction() called with NULL ad!" );
	}

	if( ! open_stream(ad, -1, action) ) {
			// nothing to do
		return;
	}

	writeJobId( ad );

	fprintf( fp, "\nis being %s.\n\n", action );
	fprintf( fp, "%s", reason );

	send();
}