File: ttyrec.h

package info (click to toggle)
termrec 0.19-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,148 kB
  • sloc: ansic: 8,430; makefile: 181; perl: 16; sh: 15
file content (89 lines) | stat: -rw-r--r-- 4,440 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef _TTYREC_H
#define _TTYREC_H
#include <sys/time.h>
#include <tty.h>

#ifndef _TTYREC_H_NO_TYPES
typedef struct TTYRecRecorder *recorder;
typedef struct TTYRec *ttyrec;
typedef struct
{
    struct timeval t;
    int len;
    char *data;
} *ttyrec_frame;
#endif

#define SM_READ         0
#define SM_WRITE        1
#define SM_REPREAD      2
#define SM_APPEND       3

int             open_stream(int fd, const char* url, int mode, const char **error);

const char*     ttyrec_w_find_format(const char *format, const char *filename,
                    const char *fallback);
recorder        ttyrec_w_open(int fd, const char *format, const char *filename,
                    const struct timeval *ts);
int             ttyrec_w_write(recorder r, const struct timeval *tm,
                    const char *data, int len);
int             ttyrec_w_close(recorder r);
const char*     ttyrec_w_get_format_name(int i);
const char*     ttyrec_w_get_format_ext(const char *format);

const char*     ttyrec_r_find_format(const char *format, const char *filename,
                    const char *fallback);
const char*     ttyrec_r_get_format_name(int i);
const char*     ttyrec_r_get_format_ext(const char *format);
int             ttyrec_r_play(int fd, const char *format, const char *filename,
                    void (*synch_init_wait)(const struct timeval *ts, void *arg),
                    void (*synch_wait)(const struct timeval *delay, void *arg),
                    void (*synch_print)(const char *data, int len, void *arg),
                    void *arg);

ttyrec          ttyrec_init(tty vt);
ttyrec          ttyrec_load(int fd, const char *format, const char *filename, tty vt);
void            ttyrec_free(ttyrec tr);
ttyrec_frame    ttyrec_seek(ttyrec tr, const struct timeval *t, tty *vt);
ttyrec_frame    ttyrec_next_frame(ttyrec tr, ttyrec_frame tfv);
void            ttyrec_add_frame(ttyrec tr, const struct timeval *delay,
                    const char *data, int len);
int             ttyrec_save(ttyrec tr, int fd, const char *format,
                    const char *filename, const struct timeval *selstart,
                    const struct timeval *selend);


#define tadd(t, d)      do                                              \
                        {if (((t).tv_usec+=(d).tv_usec)>=1000000)       \
                            (t).tv_usec-=1000000, (t).tv_sec++;         \
                         (t).tv_sec+=(d).tv_sec;                        \
                        } while (0)
#define tsub(t, d)      do                                              \
                        {if ((signed)((t).tv_usec-=(d).tv_usec)<0)      \
                            (t).tv_usec+=1000000, (t).tv_sec--;         \
                         (t).tv_sec-=(d).tv_sec;                        \
                        } while (0)
#define tmul1000(t, m)  do                                              \
                        {long long v;                                   \
                         v=((long long)(t).tv_usec)*(m)/1000+           \
                             ((long long)(t).tv_sec)*(m)*1000;          \
                         (t).tv_usec=v%1000000;                         \
                         (t).tv_sec=v/1000000;                          \
                         if ((t).tv_usec<0)                             \
                             (t).tv_usec+=1000000, (t).tv_sec--;        \
                        } while (0)
#define tdiv1000(t, m)  do                                              \
                        {long long v;                                   \
                         v=((long long)(t).tv_sec)*1000000+(t).tv_usec; \
                         v*=1000;                                       \
                         v/=m;                                          \
                         (t).tv_usec=v%1000000;                         \
                         (t).tv_sec=v/1000000;                          \
                         if ((t).tv_usec<0)                             \
                             (t).tv_usec+=1000000, (t).tv_sec--;        \
                        } while (0)
#define tcmp(t1, t2)    (((t1).tv_sec>(t2).tv_sec)?1:           \
                         ((t1).tv_sec<(t2).tv_sec)?-1:          \
                         ((t1).tv_usec>(t2).tv_usec)?1:         \
                         ((t1).tv_usec<(t2).tv_usec)?-1:0)
#endif