forked from agalakhov/captdriver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
printer.h
71 lines (60 loc) · 2.29 KB
/
printer.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
/*
* Copyright (C) 2013 Alexey Galakhov <agalakhov@gmail.com>
*
* Licensed under the GNU General Public License Version 3
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "std.h"
enum printer_support {
UNSUPPORTED,
BROKEN,
EXPERIMENTAL,
WORKS,
FULLY,
};
struct page_dims_s;
struct printer_state_s {
const struct printer_ops_s *ops;
unsigned ipage;
unsigned iband;
unsigned isend;
};
struct printer_ops_s {
struct printer_state_s * (*alloc_state) (void);
void (*free_state) (struct printer_state_s *state);
void (*job_prologue) (struct printer_state_s *state);
void (*job_epilogue) (struct printer_state_s *state);
void (*page_setup) (struct printer_state_s *state,
struct page_dims_s *dims, unsigned width, unsigned height);
bool (*page_prologue) (struct printer_state_s *state, const struct page_dims_s *dims);
bool (*page_epilogue) (struct printer_state_s *state, const struct page_dims_s *dims);
size_t (*compress_band) (struct printer_state_s *state,
void *band, size_t size,
const void *pixels, unsigned line_size, unsigned num_lines);
void (*send_band) (struct printer_state_s *state, const void *band, size_t size);
void (*wait_user) (struct printer_state_s *state);
};
const struct printer_ops_s *printer_detect(void);
void __printer_register_ops(const char *name, const struct printer_ops_s *ops,
enum printer_support status);
#define ___concat(text, line) text##line
#define __printer_register_func(line) \
___concat(static void __register_printer_, line)(void)
#define register_printer(mdl, ops, status) \
__attribute__((constructor(150))) \
__printer_register_func(__LINE__) \
{ __printer_register_ops(mdl, &ops, status); } \
__printer_register_func(__LINE__)