File: pi-userland.h

package info (click to toggle)
pilot-link 0.12.5-dfsg-2
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 6,868 kB
  • ctags: 5,811
  • sloc: ansic: 53,153; sh: 10,459; java: 2,584; perl: 2,247; python: 1,044; makefile: 991; yacc: 662; cpp: 551; xml: 39
file content (186 lines) | stat: -rw-r--r-- 5,946 bytes parent folder | download | duplicates (5)
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
/*
 * $Id: pi-userland.h,v 1.8 2006/10/17 13:24:07 desrod Exp $
 *
 * userland.h: General definitions for userland conduits.
 *
 * Copyright (C) 2004 by Adriaan de Groot <groot@kde.org>
 *
 * 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.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */
#ifndef PALM_USERLAND_H
#define PALM_USERLAND_H

#include <popt.h>
#include "pi-appinfo.h"

/*
 * This file defines general stuff for conduits -- common option processing,
 * perhaps some utility functions, etc. It prescribes how some of the code
 * of a conduit should look like, so as to preserve uniformity of options
 * and handling.
 *
 * - Each conduit should start its options table with
 *   USERLAND_RESERVED_OPTIONS.  This sets up the standard options --port,
 *   --version, --quiet as well as popt autohelp.
 * - If an error is found while processing options, call plu_badoption. 
 *   This produces a standard error message.
 * - If no error is found, call plu_connect() instead of pilot_connect(). 
 *   This does the same as pilot_connect, but obeys --quiet and produces
 *   output on stderr only if there _is_ an error.
 */


/***********************************************************************
 *
 * Option-handling functions.
 *
 ***********************************************************************/

/*
 * These are definitions for popt support in userland. Every conduit's popt
 * table should start with USERLAND_RESERVED_OPTIONS to insert the standard
 * options into it. Also enables autohelp.
 */

#define USERLAND_RESERVED_OPTIONS \
	{NULL,0,POPT_ARG_INCLUDE_TABLE,plu_common_options,0,"Options common to all conduits.",NULL}, \
	POPT_AUTOHELP

/*
 * Complain about a bad (ie. nonexistent) option and exit();
 */

extern void plu_badoption(poptContext pc, int optc);


/*
 * Add an alias to a popt context; remember to use --bad-option in the alias
 * to add a complaint about deprecated options. Do not pass in both a long
 * and a short option in one go, use two calls for that.
 */
void plu_popt_alias(poptContext pc,
	const char *alias_long,
	char alias_short,
	const char *expansion);

/*
 * Set explanation of what options to use in response to an alias that
 * contains --bad-option.
 */
void plu_set_badoption_help(const char *help);

/***********************************************************************
 *
 * Connection functions.
 *
 ***********************************************************************/

/*
 * Connect to the Pilot specified by any --port option, respecting the quiet
 * flag as well. This is basically pilot_connect(), but marginally cleaner.
 */

extern int plu_connect(void);


/***********************************************************************
 *
 * Things to do once you're connected to the handheld.
 *
 ***********************************************************************/

/*
 * Look up a category name. Argument @p info is the category part of the
 * AppInfo block for the database, while @p name is the category to look up. 
 * Returns the index of the category if found (0..15) or -1 if not.
 *
 * The flags passed to findcategory are a bitwise or of enums; the meanings
 * are:
 *
 *   NOFLAGS          : Match case-sensitive, return -1 if not found, do not
 *                      match numbers as category numbers, do not complain.
 *   CASE_INSENSITIVE : Match in a case-insensitive fashion.
 *   DEFAULT_UNFILED  : Return 0 (unfiled) instead of -1 on no-match.
 *   MATCH_NUMBERS    : Match number strings 0 .. 15 as categories 0 .. 15.
 *   WARN_UNKNOWN     : Complain on stderr if category not found.
 */
typedef enum {
	PLU_CAT_NOFLAGS = 0,
	PLU_CAT_CASE_INSENSITIVE = 0x0001,
	PLU_CAT_DEFAULT_UNFILED = 0x0002,
	PLU_CAT_MATCH_NUMBERS = 0x0004,
	PLU_CAT_WARN_UNKNOWN = 0x0008
	} plu_findcategory_flags_t;

extern int plu_findcategory(const struct CategoryAppInfo *info, const char *name, int flags);

typedef struct {
	/* Numeric parts of the ROM version */
	int major,
		minor,
		bugfix,
		build,
		state;
	/* Textual representation of same: xxx.xx.xx-xxxxx */
	char name[16];
} plu_romversion_t;

/*
 * Retrieve the ROM version from the Palm; returns -1 on failure, 0
 * otherwise and fills the fields of the @p d structure.
 */
extern int plu_getromversion(int sd, plu_romversion_t *d);


/***********************************************************************
 *
 * File-handling functions on the PC.
 *
 ***********************************************************************/

/*
 * Function:	protect_files
 *
 * Summary:     Adjust output file name so as to not overwrite an exsisting
 *              file.
 *
 * Parameters:  name        <-> buffer for filename
 *              extension   --> file extension to add to name
 *              namelength  --> size of buffer
 *
 * Returns:     1 file name protected (and stored in buffer name)
 *              0 no alernate name found
 *             -1 other failure
 *
 */
int plu_protect_files(char *name, const char *extension, const size_t namelength);

/*
 * We need to be able to refer to the table of common options.
 */

extern struct poptOption plu_common_options[];
extern int plu_quiet;
extern char *plu_port;
extern int plu_timeout;


#endif

/* vi: set ts=8 sw=4 sts=4 noexpandtab: cin */
/* Local Variables: */
/* indent-tabs-mode: t */
/* c-basic-offset: 8 */
/* End: */