multiprogress.c: Probe termcap/info for newline sequence.
[dvdrip] / lib.h
CommitLineData
dc53ebfa
MW
1#ifndef LIB_H
2#define LIB_H
3
4#define _GNU_SOURCE
5#define _FILE_OFFSET_BITS 64
6
7#include <assert.h>
8#include <ctype.h>
9#include <errno.h>
10#include <float.h>
11#include <inttypes.h>
12#include <limits.h>
13#include <locale.h>
14#include <math.h>
15#include <stdarg.h>
16#include <stdint.h>
17#include <stdio.h>
18#include <stdlib.h>
19#include <string.h>
20#include <time.h>
21
22#include <unistd.h>
23#include <fcntl.h>
24#include <sys/ioctl.h>
25#include <sys/select.h>
26#include <sys/stat.h>
27#include <sys/time.h>
28
29#include <getopt.h>
30
31#include <linux/fs.h>
32
33#include <dvdread/dvd_reader.h>
34#include <dvdread/dvd_udf.h>
35#include <dvdread/ifo_read.h>
36#include <dvdread/ifo_types.h>
37
38#include "multiprogress.h"
39
40#define CTYPE_HACK(fn, ch) fn((unsigned char)(ch))
41#define ISDIGIT(ch) CTYPE_HACK(isdigit, ch)
42#define ISSPACE(ch) CTYPE_HACK(isspace, ch)
43
44#define STRCMP(a, op, b) (strcmp((a), (b)) op 0)
45#define STRNCMP(a, op, b, n) (strncmp((a), (b), (n)) op 0)
46
47#ifdef DEBUG
48# define D(x) x
49#else
50# define D(x)
51#endif
52
53#define N(v) (sizeof(v)/sizeof((v)[0]))
54
55#define SECTORSZ 2048
56#define SECTORS(n) (((n) + (SECTORSZ - 1))/SECTORSZ)
57typedef uint_least32_t secaddr;
58#define PRIuSEC PRIuLEAST32
59#define SECLIMIT 0x00400000
60
61#define PRINTF_LIKE(fmt, dots) __attribute__((format(printf, fmt, dots)))
62#define NORETURN __attribute__((noreturn))
63
64extern const char *prog;
65
66extern void set_prog(const char *p);
67extern void vmoan(const char *fmt, va_list ap);
68extern PRINTF_LIKE(1, 2) void moan(const char *fmt, ...);
69extern PRINTF_LIKE(1, 2) NORETURN void bail(const char *fmt, ...);
70extern PRINTF_LIKE(2, 3) NORETURN
71 void bail_syserr(int err, const char *fmt, ...);
72
73extern void sit(double t);
74
75enum { RAW, IFO, VOB, BUP };
76typedef uint_least32_t ident;
77
78static inline ident mkident(unsigned kind, unsigned title, unsigned part)
79 { return (((ident)kind << 0) | ((ident)title << 8) | ((ident)part << 16)); }
80static inline unsigned id_kind(ident id) { return ((id >> 0)&0x0ff); }
81static inline unsigned id_title(ident id) { return ((id >> 8)&0x0ff); }
82static inline unsigned id_part(ident id) { return ((id >> 16)&0x0ff); }
83
84#define MAXFNSZ (1 + 8 + 1 + 12 + 1)
85extern void store_filename(char *buf, ident id);
86
87struct banner_progress_item {
88 struct progress_item _base;
89 const char *msg;
90};
91
92extern struct progress_state progress;
93
94extern void show_banner(const char *msg);
95extern void hide_banner(void);
96
97extern void open_dvd(const char *device,
98 int *fd_out, dvd_reader_t **dvd_out);
99
100#endif