[go: up one dir, main page]

Menu

[r89]: / trunk / scanbd.h  Maximize  Restore  History

Download this file

162 lines (120 with data), 3.8 kB

  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
/*
* $Id$
*
* scanbd - KMUX scanner button daemon
*
* Copyright (C) 2008 - 2012 Wilhelm Meier (wilhelm.meier@fh-kl.de)
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef SCANBD_H
#define SCANBD_H
#ifndef USE_SANE
#ifndef USE_SCANBUTTOND
#define USE_SCANBUTTOND
#endif
#endif
#define _GNU_SOURCE
#include "common.h"
#include <getopt.h>
#include <confuse.h>
#ifdef USE_SANE
#include <sane/sane.h>
#else
#include "scanbuttond/include/scanbuttond/libusbi.h"
#endif
#include "slog.h"
#include "scanbd_dbus.h"
#include "udev.h"
#define SANE_REINIT_TIMEOUT 3 // TODO: don't know if this is really neccessary
#define SCANBUTTOND_ALARM_TIMEOUT 5 // reconfigure after this amount of seconds if
// device was busy
#define C_FROM_VALUE "from-value"
#define C_FROM_VALUE_DEF_INT 0
#define C_FROM_VALUE_DEF_STR ""
#define C_TO_VALUE "to-value"
#define C_TO_VALUE_DEF_INT 1
#define C_TO_VALUE_DEF_STR ".+"
#define C_FILTER "filter"
#define C_ACTION_DEF "^scan.*"
#define C_FUNCTION_DEF "^function.*"
#define C_NUMERICAL_TRIGGER "numerical-trigger"
#define C_STRING_TRIGGER "string-trigger"
#define C_DESC "desc"
#define C_DESC_DEF "The description goes here"
#define C_SCRIPT "script"
#define C_SCRIPT_DEF ""
#define C_ENV "env"
#define C_ENV_FUNCTION "SCANBD_FUNCTION"
#define C_ENV_FUNCTION_DEF "SCANBD_FUNCTION"
#define C_ENV_DEVICE "device"
#define C_ENV_DEVICE_DEF "SCANBD_DEVIVCE"
#define C_ENV_ACTION "action"
#define C_ENV_ACTION_DEF "SCANBD_ACTION"
#define C_DEBUG "debug"
#define C_DEBUG_DEF false
#define C_MULTIPLE_ACTIONS "multiple_actions"
#define C_MULTIPLE_ACTIONS_DEF true
#define C_DEBUG_LEVEL "debug-level"
#define C_DEBUG_LEVEL_DEF 1
#define C_USER "user"
#define C_USER_DEF "saned"
#define C_GROUP "group"
#define C_GROUP_DEF "scanner"
#define C_SANED "saned"
#define C_SANED_DEF "/usr/sbin/saned"
#define C_SANED_OPTS "saned_opt"
#define C_SANED_OPTS_DEF "{}"
#define C_SCANBUTTONS_BACKENDS_DIR "scanbuttond_backends_dir"
#ifdef CFG_DIR
#define C_SCANBUTTONS_BACKENDS_DIR_DEF CFG_DIR
#else
#ifndef USE_SANE
#warning "Using predefined directory: /usr/local/etc/scanbd/scanbuttond/backends"
#endif
#define C_SCANBUTTONS_BACKENDS_DIR_DEF "/usr/local/etc/scanbd/scanbuttond/backends"
#endif
#define C_SANED_ENVS "saned_env"
#define C_SANED_ENVS_DEF "{}"
#define C_TIMEOUT "timeout"
#define C_TIMEOUT_DEF 500
#define C_PIDFILE "pidfile"
#define C_PIDFILE_DEF "/var/run/scanbd.pid"
#define C_ENVIRONMENT "environment"
#define C_FUNCTION "function"
#define C_ACTION "action"
#define C_GLOBAL "global"
#define C_DEVICE "device"
#define SCANBD_NULL_STRING "(null)"
struct scanbdOptions {
bool managerMode;
bool foreground;
bool signal;
const char* config_file_name;
};
// command-line options
extern struct scanbdOptions scanbd_options;
// config from the config-file
extern cfg_t* cfg;
// functions
#ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
extern void sane_init_mutex();
#endif
extern void get_sane_devices(void);
extern void sane_trigger_action(int, int);
extern void stop_sane_threads(void);
extern void start_sane_threads(void);
extern void daemonize(void);
#endif