Example #1
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);
}
Example #2
0
void get_rec_parms(int argc, char **argv)
{
    format=0;
    command=0;
    record_name=0;
    raw=0;
    append=0;
#if (defined HAVE_LIBBZ2) || (defined SHIPPED_LIBBZ2)
    comp_ext=".bz2";
#elif (defined HAVE_LIBZ) || (defined SHIPPED_LIBZ)
    comp_ext=".gz";
#elif (defined HAVE_LIBLZMA) || (defined SHIPPED_LIBLZMA)
    comp_ext=".xz";
#else
    comp_ext="";
#endif

    while (1)
    {
#ifdef HAVE_GETOPT_LONG
        switch (getopt_long(argc, argv, "f:e:rah", rec_opts, 0))
#else
        switch (getopt(argc, argv, "f:e:rah"))
#endif
        {
        case -1:
            goto finish_args;
        case ':':
        case '?':
            exit(1);
        case 'f':
            get_w_format(&format);
            break;
        case 'e':
            if (command)
                die(_("You can specify -e only once.\n"));
            command=optarg;
            break;
        case 'r':
            raw=1;
            break;
        case 'a':
            append=1;
            break;
        case 'h':
            printf(
                "%stermrec [-f format] [-e command] [file]\n"
                "    %s"
                "-f, --format X        %s\n"
                "-e, --exec X          %s\n"
                "-r, --raw             %s\n"
                "-a, --append          %s\n"
                "-h, --help            %s\n"
                "%s%s%s",
                _("Usage: "),
                _("Records the output of a console session to a file, including timing data.\n"),
                _("set output format to X (-f whatever for the list)"),
                _("execute command X instead of spawning a shell"),
                _("don't record UTFness or terminal size"),
                _("append to an existing file"),
                _("show this usage message"),
                _("If no filename is given, a name will be generated using the current date\n"
                  "    and the given format.\n"),
                _("If no format is given, it will be set according to the extension of the\n"
                  "    filename, or default to ttyrec if nothing is given.\n"),
                _("You can specify compression by appending .gz, .xz or .bz2 to the file name.\n"));
            exit(0);
        }
    }
finish_args:
    if (optind<argc)
        record_name=argv[optind++];
    if (optind<argc)
        die(_("You can specify at most one file to record to.\n"));

    if (!format)
        format=ttyrec_w_find_format(0, record_name, "ttyrec");
    if (!(format_ext=ttyrec_w_get_format_ext(format)))
        format_ext="";
}