This file is indexed.

/usr/include/scim-1.0/scim_transaction.h is in libscim-dev 1.4.18-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
/**
 * @file scim_transaction.h
 * @brief Transaction class.
 */

/* 
 * Smart Common Input Method
 * 
 * Copyright (c) 2002-2005 James Su <suzhe@tsinghua.org.cn>
 *
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA  02111-1307  USA
 *
 * $Id: scim_transaction.h,v 1.10 2005/05/24 12:22:51 suzhe Exp $
 */

#ifndef __SCIM_TRANSACTION_H
#define __SCIM_TRANSACTION_H

namespace scim {

/**
 * @addtogroup SocketCommunication
 * @{
 */

/**
 * @brief Signature of all valid data types which can be store into transaction.
 */
enum TransactionDataType
{
    SCIM_TRANS_DATA_UNKNOWN,        //!< Unknown transaction data type.
    SCIM_TRANS_DATA_COMMAND,        //!< Send/Receive command.
    SCIM_TRANS_DATA_RAW,            //!< Send/Receive raw buffer.
    SCIM_TRANS_DATA_UINT32,         //!< Send/Receive uint32.
    SCIM_TRANS_DATA_STRING,         //!< Send/Receive String.
    SCIM_TRANS_DATA_WSTRING,        //!< Send/Receive WideString.
    SCIM_TRANS_DATA_KEYEVENT,       //!< Send/Receive KeyEvent.
    SCIM_TRANS_DATA_ATTRIBUTE_LIST, //!< Send/Receive AttributeList.
    SCIM_TRANS_DATA_LOOKUP_TABLE,   //!< Send/Receive LookupTable.
    SCIM_TRANS_DATA_PROPERTY,       //!< Send/Receive Property.
    SCIM_TRANS_DATA_PROPERTY_LIST,  //!< Send/Receive PropertyList.
    SCIM_TRANS_DATA_VECTOR_UINT32,  //!< Send/Receive vector<uint32>.
    SCIM_TRANS_DATA_VECTOR_STRING,  //!< Send/Receive vector<String>.
    SCIM_TRANS_DATA_VECTOR_WSTRING, //!< Send/Receive vector<WideString>.
    SCIM_TRANS_DATA_TRANSACTION     //!< Send/Receive another Transaction.
};

/**
 * @brief An exception class to hold Transaction related errors.
 *
 * scim::Transaction and its related classes must throw
 * scim::TransactionError object when error.
 */
class TransactionError: public Exception
{
public:
    TransactionError (const String& what_arg)
        : Exception (String("scim::Transaction: ") + what_arg) { }
};

class TransactionHolder;
class TransactionReader;

/**
 * @brief This class is used to pack up many data and commands into one package
 *        and send them via socket.
 */
class Transaction
{
    friend class TransactionReader;

    TransactionHolder * m_holder;
    TransactionReader * m_reader;

    Transaction (const Transaction &);
    const Transaction & operator = (const Transaction &);
public:
    /**
     * @brief Constructor.
     *
     * @param bufsize the initial buffer size, maybe grow afterwards.
     */
    Transaction (size_t bufsize = 512);

    /**
     * @brief Destructor.
     */
    ~Transaction ();

    /**
     * @brief Check if the transaction is valid.
     *
     * @return true if this Transaction object is valid and ready to use.
     */
    bool valid () const;

    /**
     * @brief Get the size of this transaction.
     */
    size_t get_size () const;

    /**
     * @brief Write the transaction to a socket.
     *
     * @param socket the socket to be written to.
     * @param signature the leading signature to be written
     *        into the socket before the transaction itself,
     *        this signature maybe missing when receive the transaction.
     *        It's useful to check the connection before receiving
     *        a transaction by reading this signature.
     *
     * @return true if success.
     */
    bool write_to_socket (const Socket &socket, uint32 signature = 0) const;

    /**
     * @brief Read a transaction from a socket.
     *
     * @param socket the socket to be read from.
     * @param timeout time out in millisecond (1/1000 second), -1 means infinity.
     *
     * @return true if success.
     */
    bool read_from_socket (const Socket &socket, int timeout = -1);

    /**
     * @brief Write the transaction into a buffer.
     *
     * @param buf A buffer to store the transaction data.
     * @param bufsize The size of this buffer.
     * @return true if success (the buf is large enough).
     */
    bool write_to_buffer (void *buf, size_t bufsize) const;

    /**
     * @brief Read a transaction from a buffer.
     * 
     * @param buf A buffer contains the transaction.
     * @param bufsize The size of this buffer.
     * @return true if success.
     */
    bool read_from_buffer (const void *buf, size_t bufsize);

    /**
     * @brief Store a command into this transaction.
     *
     * @param cmd the command code, like SCIM_TRANS_CMD_FOCUS_IN etc.
     */
    void put_command (int cmd);

    /**
     * @brief Store a uint32 value into this transaction.
     */
    void put_data (uint32 val);

    /**
     * @brief Store a String object into this transaction.
     */
    void put_data (const String &str);

    /**
     * @brief Store a WideString object into this transaction.
     */
    void put_data (const WideString &str);

    /**
     * @brief Store a KeyEvent object into this transaction.
     */
    void put_data (const KeyEvent &key);

    /**
     * @brief Store an AttributeList object into this transaction.
     */
    void put_data (const AttributeList &attrs);

    /**
     * @brief Store a Property object into this transaction.
     */
    void put_data (const Property &property);

    /**
     * @brief Store a PropertyList object into this transaction.
     */
    void put_data (const PropertyList &properties);

    /**
     * @brief Store a LookupTable object into this transaction.
     */
    void put_data (const LookupTable &table);

    /**
     * @brief Store a std::vector<uint32> object into this transaction.
     */
    void put_data (const std::vector<uint32> &vec);

    /**
     * @brief Store a std::vector<String> object into this transaction.
     */
    void put_data (const std::vector<String> &vec);

    /**
     * @brief Store a std::vector<WideString> object into this transaction.
     */
    void put_data (const std::vector<WideString> &vec);

    /**
     * @brief Store a raw buffer into this transaction.
     */
    void put_data (const char *raw, size_t bufsize);

    /**
     * @brief Store another Transaction object into this transaction.
     */
    void put_data (const Transaction &trans);

    /**
     * @brief Get the type of the data at current read position.
     *
     * @return The type of the data can be read currently.
     */
    TransactionDataType get_data_type () const;

    /**
     * @brief Get a command from current read position.
     */
    bool get_command (int &cmd);

    /**
     * @brief Get an uint32 value from current read position.
     */
    bool get_data (uint32 &val);

    /**
     * @brief Get a String from current read position.
     */
    bool get_data (String &str);

    /**
     * @brief Get a WideString from current read position.
     */
    bool get_data (WideString &str);

    /**
     * @brief Get a KeyEvent from current read position.
     */
    bool get_data (KeyEvent &key);

    /**
     * @brief Get an AttributeList from current read position.
     */
    bool get_data (AttributeList &attrs);

    /**
     * @brief Get a Property from current read position.
     */
    bool get_data (Property &property);

    /**
     * @brief Get a PropertyList from current read position.
     */
    bool get_data (PropertyList &properties);

    /**
     * @brief Get a CommonLookupTable from current read position.
     */
    bool get_data (CommonLookupTable &table);

    /**
     * @brief Get a std::vector<uint32> from current read position.
     */
    bool get_data (std::vector<uint32> &vec);

    /**
     * @brief Get a std::vector<String> from current read position.
     */
    bool get_data (std::vector<String> &vec);

    /**
     * @brief Get a std::vector<WideString> from current read position.
     */
    bool get_data (std::vector<WideString> &vec);

    /**
     * @brief Get a raw buffer from current read position.
     * 
     * if raw == NULL then return the bufsize and skip this data.
     * *raw should be deleted afterwards (do not use free!).
     */
    bool get_data (char **raw, size_t &bufsize);

    /**
     * @brief Get a Transaction object from current read position.
     */
    bool get_data (Transaction &trans);

    /**
     * @brief Skip one data from current read position.
     */
    bool skip_data ();

    /**
     * @brief Rewind the current read position, then the data can be read again.
     */
    void rewind ();

    /**
     * @brief Clear the transaction, all data in this transaction will be freed.
     */
    void clear ();
};

/**
 * @brief This class is used to read data from a transaction without changing it.
 */
class TransactionReader
{
    class TransactionReaderImpl;

    TransactionReaderImpl *m_impl;

public:
    /**
     * @brief Default constructor.
     *
     * Construct an empty TransactionReader object.
     */
    TransactionReader ();

    /**
     * @brief Constructor.
     *
     * Construct a TransactionReader object and attach to a Transaction object.
     *
     * @param trans The Transaction to be read.
     */
    TransactionReader (const Transaction &trans);

    /**
     * @brief Destructor.
     */
    ~TransactionReader ();

    /**
     * @brief Copy constructor.
     */
    TransactionReader (const TransactionReader &);

    /**
     * @brief Copy operator.
     */
    const TransactionReader & operator = (const TransactionReader &);

    /**
     * @brief Attach this TransactionReader object to a Transaction.
     *
     * An empty TransactionReader object must be attached to a
     * Transaction object before reading.
     *
     * @param trans The Transaction object to be read.
     */
    void attach (const Transaction &trans);

    /**
     * @brief Detach this TransactionReader object from
     * currently attached Transaction object.
     */
    void detach ();

    /**
     * @brief Check if the transaction reader is valid.
     *
     * @return true if this TransactionReader object
     * is attached to a Transaction object and ready to be read.
     */
    bool valid () const;

    /**
     * @brief Get the type of the data at current read position.
     *
     * @return The type of the data can be read currently.
     */
    TransactionDataType get_data_type () const;

    /**
     * @brief Get a command from current read position.
     */
    bool get_command (int &cmd);

    /**
     * @brief Get an uint32 value from current read position.
     */
    bool get_data (uint32 &val);

    /**
     * @brief Get a String from current read position.
     */
    bool get_data (String &str);

    /**
     * @brief Get a WideString from current read position.
     */
    bool get_data (WideString &str);

    /**
     * @brief Get a KeyEvent from current read position.
     */
    bool get_data (KeyEvent &key);

    /**
     * @brief Get an AttributeList from current read position.
     */
    bool get_data (AttributeList &attrs);

    /**
     * @brief Get a Property from current read position.
     */
    bool get_data (Property &property);

    /**
     * @brief Get a PropertyList from current read position.
     */
    bool get_data (PropertyList &properties);

    /**
     * @brief Get a CommonLookupTable from current read position.
     */
    bool get_data (CommonLookupTable &table);

    /**
     * @brief Get a std::vector<uint32> from current read position.
     */
    bool get_data (std::vector<uint32> &vec);

    /**
     * @brief Get a std::vector<String> from current read position.
     */
    bool get_data (std::vector<String> &vec);

    /**
     * @brief Get a std::vector<WideString> from current read position.
     */
    bool get_data (std::vector<WideString> &vec);

    /**
     * @brief Get a raw buffer from current read position.
     * 
     * if raw == NULL then return the bufsize and skip this data.
     * *raw should be deleted afterwards (do not use free!).
     */
    bool get_data (char **raw, size_t &bufsize);

    /**
     * @brief Get a Transaction object from current read position.
     */
    bool get_data (Transaction &trans);

    /**
     * @brief Skip one data from current read position.
     */
    bool skip_data ();

    /**
     * @brief Rewind the current read position, then the data can be read again.
     */
    void rewind ();
};

/** @} */

} // namespace scim

#endif //__SCIM_TRANSACTION_H

/*
vi:ts=4:nowrap:ai:expandtab
*/