-
Notifications
You must be signed in to change notification settings - Fork 1
/
stag.h
193 lines (165 loc) · 4.83 KB
/
stag.h
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/* stag.h */
/*
* This file is public domain as declared by Sturm Mabie.
*/
#include <sys/ioctl.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <libgen.h>
#include <locale.h>
#include <regex.h>
#include <signal.h>
#include <unistd.h>
#include <ctype.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <setjmp.h>
#ifdef NCURSESW_WIDE
#include <ncursesw/curses.h>
#include <ncursesw/form.h>
#include <ncursesw/menu.h>
#else
#include <curses.h>
#include <form.h>
#include <menu.h>
#endif /* NCURSESW_WIDE */
#include <taglib/tag_c.h>
/*
* sys/queue from OpenBSD. We use our own because not all queue's are created
* equal.
*/
#include "queue.h"
#define ENTRY(x) ((struct entry *) \
(item_userptr(current_item((const MENU *)(x)))))
#define PROG_NAME "stag"
#define INFO_LEN 9 /* Height of the bottom info window. */
/*
* These flags are used by the make_active function and control its behavior
* and what files to add to the list of active files. Active files are files
* that can be viewed and edited. It might be a dubious design to group the
* recurse, clear, and hide functions with the rest.
*/
#define AFLG_REC 0x0001 /* recursively add files? */
#define AFLG_CLR 0x0002 /* clear active structure? */
#define AFLG_HID 0x0004 /* include hidden files and directories? */
#define AFLG_MP3 0x0008 /* mp3 files */
#define AFLG_OGG 0x0010 /* ogg vorbis */
#define AFLG_FLC 0x0020 /* flac */
#define AFLG_MPC 0x0040 /* musepack */
#define AFLG_OGF 0x0080 /* ogg flac */
#define AFLG_WPK 0x0100 /* wavpack */
#define AFLG_SPX 0x0200 /* speex */
#define AFLG_TAO 0x0400 /* true audio */
#define AFLG_MP4 0x0800 /* mpeg4 */
#define AFLG_ASF 0x1000 /* ms asf */
LIST_HEAD(h, entry);
extern struct h active;
extern char wtfbuf[];
extern char cwd[];
extern const char *ext[];
extern struct textbox edit;
extern struct frame dir, file, info;
extern enum mode { DIR_MODE, FILE_MODE, INFO_MODE, EDIT_MODE } state;
extern jmp_buf env;
struct entry {
char dir[PATH_MAX]; /* set by dirname(3) */
char name[NAME_MAX]; /* set by basename(3) */
int mark; /* is the file selected? */
int mod; /* the tags been changed? */
TagLib_File *filep;
TagLib_Tag *tagp;
LIST_ENTRY(entry) entries;
};
struct frame {
WINDOW *win;
MENU *menu;
int idx;
};
struct textbox {
WINDOW *win;
FORM *form;
FIELD *field[2];
};
#ifdef __GLIBC__
#undef basename
#undef dirname
#define basename bsd_basename
#define dirname bsd_dirname
char *bsd_basename(const char *);
char *bsd_dirname(const char *);
size_t strlcat(char *, const char *, size_t);
size_t strlcpy(char *, const char *, size_t);
#endif /* __GLIBC__ */
WINDOW *make_win(int, int, int, int);
MENU *make_menu(ITEM **, WINDOW *);
void init_screen();
void destroy_screen();
void print_state();
int any_marked();
void nth_item(MENU *, int);
unsigned int all_equal_int(unsigned int (*)(const TagLib_Tag *));
char *all_equal_str(char *(*)(const TagLib_Tag *));
char *str_cleanup(char *);
char *clean_xstrdup(char *);
const char *make_regex_str(TagLib_Tag *);
void resize(int);
void stag_warnx(const char *, ...);
void stag_warn(const char *, ...);
ITEM **path_make_items(const char *, int);
ITEM **list_make_items(void);
ITEM **info_make_items(const struct entry *, int);
void free_items(ITEM **);
void free_item_strings(ITEM **);
void draw_info(const struct entry *, WINDOW *);
struct entry *make_entry(const char *);
void free_entry(struct entry *);
void clear_active(void);
int populate_active(const char *, unsigned int);
void kb_add();
void kb_enter(int);
void kb_hide(int *);
void kb_file_mode();
void kb_toggle();
void kb_edit(int *);
void kb_regex1(int *);
void kb_regex2(regex_t *, char *);
void kb_toggle_all();
void kb_clear();
void kb_remove();
void kb_multi_edit(int *);
void kb_move(int);
void kb_reload();
void kb_write();
void kb_unmark();
void kb_write_marked();
void kb_edit_field();
void kb_other();
void kb_left();
void set_title(struct entry *, const char *);
void set_artist(struct entry *, const char *);
void set_album(struct entry *, const char *);
void set_comment(struct entry *, const char *);
void set_genre(struct entry *, const char *);
void set_year(struct entry *, unsigned int);
void set_track(struct entry *, unsigned int);
void write_entry(struct entry *);
void revert_entry(struct entry *);
void remove_entry(struct entry *);
void write_marked(void);
void revert_marked(void);
void remove_marked(void);
void set_marked_title(const char *);
void set_marked_artist(const char *);
void set_marked_album(const char *);
void set_marked_comment(const char *);
void set_marked_genre(const char *);
void set_marked_year(unsigned int);
void set_marked_track(unsigned int);