This file is indexed.

/usr/include/qgis/qextserialport.h is in libqgis-dev 2.8.6+dfsg-1build1.

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
#ifndef _QEXTSERIALPORT_H_
#define _QEXTSERIALPORT_H_


/*if all warning messages are turned off, flag portability warnings to be turned off as well*/
#ifdef _TTY_NOWARN_
#define _TTY_NOWARN_PORT_
#endif

/*macros for warning and debug messages*/
#ifdef _TTY_NOWARN_PORT_
#define TTY_PORTABILITY_WARNING(s)
#else
#define TTY_PORTABILITY_WARNING(s) qWarning(s)
#endif /*_TTY_NOWARN_PORT_*/
#ifdef _TTY_NOWARN_
#define TTY_WARNING(s)
#else
#define TTY_WARNING(s) qWarning(s)
#endif /*_TTY_NOWARN_*/


/*line status constants*/
#define LS_CTS  0x01
#define LS_DSR  0x02
#define LS_DCD  0x04
#define LS_RI   0x08
#define LS_RTS  0x10
#define LS_DTR  0x20
#define LS_ST   0x40
#define LS_SR   0x80

/*error constants*/
#define E_NO_ERROR                   0
#define E_INVALID_FD                 1
#define E_NO_MEMORY                  2
#define E_CAUGHT_NON_BLOCKED_SIGNAL  3
#define E_PORT_TIMEOUT               4
#define E_INVALID_DEVICE             5
#define E_BREAK_CONDITION            6
#define E_FRAMING_ERROR              7
#define E_IO_ERROR                   8
#define E_BUFFER_OVERRUN             9
#define E_RECEIVE_OVERFLOW          10
#define E_RECEIVE_PARITY_ERROR      11
#define E_TRANSMIT_OVERFLOW         12
#define E_READ_FAILED               13
#define E_WRITE_FAILED              14

enum BaudRateType
{
    BAUD50,                //POSIX ONLY
    BAUD75,                //POSIX ONLY
    BAUD110,
    BAUD134,               //POSIX ONLY
    BAUD150,               //POSIX ONLY
    BAUD200,               //POSIX ONLY
    BAUD300,
    BAUD600,
    BAUD1200,
    BAUD1800,              //POSIX ONLY
    BAUD2400,
    BAUD4800,
    BAUD9600,
    BAUD14400,             //WINDOWS ONLY
    BAUD19200,
    BAUD38400,
    BAUD56000,             //WINDOWS ONLY
    BAUD57600,
    BAUD76800,             //POSIX ONLY
    BAUD115200,
    BAUD128000,            //WINDOWS ONLY
    BAUD256000             //WINDOWS ONLY
};

enum DataBitsType
{
    DATA_5,
    DATA_6,
    DATA_7,
    DATA_8
};

enum ParityType
{
    PAR_NONE,
    PAR_ODD,
    PAR_EVEN,
    PAR_MARK,               //WINDOWS ONLY
    PAR_SPACE
};

enum StopBitsType
{
    STOP_1,
    STOP_1_5,               //WINDOWS ONLY
    STOP_2
};

enum FlowType
{
    FLOW_OFF,
    FLOW_HARDWARE,
    FLOW_XONXOFF
};

/**
 * structure to contain port settings
 */
struct PortSettings
{
    BaudRateType BaudRate;
    DataBitsType DataBits;
    ParityType Parity;
    StopBitsType StopBits;
    FlowType FlowControl;
    long Timeout_Millisec;
};

#include <QIODevice>
#include <QMutex>
#ifdef Q_OS_UNIX
#include <stdio.h>
#include <termios.h>
#include <errno.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include <QSocketNotifier>
typedef int HANDLE; // unused
#elif defined (Q_OS_WIN)
#include <windows.h>
#include <QThread>
#include <QReadWriteLock>
#endif

/*!
Encapsulates a serial port on both POSIX and Windows systems.

\note
Be sure to check the full list of members, as QIODevice provides quite a lot of
functionality for QextSerialPort.

\section Usage
QextSerialPort offers both a polling and event driven API.  Event driven is typically easier
to use, since you never have to worry about checking for new data.

\b Example
\code
QextSerialPort* port = new QextSerialPort("COM1", QextSerialPort::EventDriven);
connect(port, SIGNAL(readyRead()), myClass, SLOT(onDataAvailable()));
port->open();

void MyClass::onDataAvailable() {
    int avail = port->bytesAvailable();
    if( avail > 0 ) {
        QByteArray usbdata;
        usbdata.resize(avail);
        int read = port->read(usbdata.data(), usbdata.size());
        if( read > 0 ) {
            processNewData(usbdata);
        }
    }
}
\endcode

\section Compatibility
The user will be notified of errors and possible portability conflicts at run-time
by default - this behavior can be turned off by defining _TTY_NOWARN_
(to turn off all warnings) or _TTY_NOWARN_PORT_ (to turn off portability warnings) in the project.

On Windows NT/2000/XP this class uses Win32 serial port functions by default.  The user may
select POSIX behavior under NT, 2000, or XP ONLY by defining Q_OS_UNIX in the project.
No guarantees are made as to the quality of POSIX support under NT/2000 however.

\author Stefan Sander, Michal Policht, Brandon Fosdick, Liam Staskawicz
*/

class QWinEventNotifier;

class QextSerialPort: public QIODevice
{
    Q_OBJECT
    public:
        enum QueryMode {
            Polling,
            EventDriven
        };

        QextSerialPort(QueryMode mode = EventDriven);
        QextSerialPort(const QString & name, QueryMode mode = EventDriven);
        QextSerialPort(PortSettings const& s, QueryMode mode = EventDriven);
        QextSerialPort(const QString & name, PortSettings const& s, QueryMode mode = EventDriven);
        ~QextSerialPort();

        void setPortName(const QString & name);
        QString portName() const;

        /**!
         * Get query mode.
         * \return query mode.
         */
        inline QueryMode queryMode() const { return _queryMode; }

        /*!
         * Set desired serial communication handling style. You may choose from polling
         * or event driven approach. This function does nothing when port is open; to
         * apply changes port must be reopened.
         *
         * In event driven approach read() and write() functions are acting
         * asynchronously. They return immediately and the operation is performed in
         * the background, so they doesn't freeze the calling thread.
         * To determine when operation is finished, QextSerialPort runs separate thread
         * and monitors serial port events. Whenever the event occurs, adequate signal
         * is emitted.
         *
         * When polling is set, read() and write() are acting synchronously. Signals are
         * not working in this mode and some functions may not be available. The advantage
         * of polling is that it generates less overhead due to lack of signals emissions
         * and it doesn't start separate thread to monitor events.
         *
         * Generally event driven approach is more capable and friendly, although some
         * applications may need as low overhead as possible and then polling comes.
         *
         * \param mode query mode.
         */
        void setQueryMode(QueryMode mode);

        void setBaudRate(BaudRateType);
        BaudRateType baudRate() const;

        void setDataBits(DataBitsType);
        DataBitsType dataBits() const;

        void setParity(ParityType);
        ParityType parity() const;

        void setStopBits(StopBitsType);
        StopBitsType stopBits() const;

        void setFlowControl(FlowType);
        FlowType flowControl() const;

        void setTimeout(long);

        bool open(OpenMode mode) override;
        bool isSequential() const override;
        void close() override;
        void flush();

        qint64 size() const override;
        qint64 bytesAvailable() const override;
        QByteArray readAll();

        void ungetChar(char c);

        ulong lastError() const;
        void translateError(ulong error);

        void setDtr(bool set=true);
        void setRts(bool set=true);
        ulong lineStatus();
        QString errorString();

#ifdef Q_OS_WIN
        virtual bool waitForReadyRead(int msecs);  ///< @todo implement.
        virtual qint64 bytesToWrite() const;
        static QString fullPortNameWin(const QString & name);
#endif

    protected:
        QMutex* mutex;
        QString port;
        PortSettings Settings;
        ulong lastErr;
        QueryMode _queryMode;

        // platform specific members
#ifdef Q_OS_UNIX
        int fd;
        QSocketNotifier *readNotifier;
        struct termios Posix_CommConfig;
        struct termios old_termios;
        struct timeval Posix_Timeout;
        struct timeval Posix_Copy_Timeout;
#elif (defined Q_OS_WIN)
        HANDLE Win_Handle;
        OVERLAPPED overlap;
        COMMCONFIG Win_CommConfig;
        COMMTIMEOUTS Win_CommTimeouts;
        QWinEventNotifier *winEventNotifier;
        DWORD eventMask;
        QList<OVERLAPPED*> pendingWrites;
        QReadWriteLock* bytesToWriteLock;
        qint64 _bytesToWrite;
#endif

        void construct(); // common construction
        void platformSpecificDestruct();
        void platformSpecificInit();
        qint64 readData(char * data, qint64 maxSize) override;
        qint64 writeData(const char * data, qint64 maxSize) override;

    private slots:
        void onWinEvent(HANDLE h);

    private:
        Q_DISABLE_COPY(QextSerialPort)

    signals:
//        /**
//         * This signal is emitted whenever port settings are updated.
//         * 	\param valid \p true if settings are valid, \p false otherwise.
//         *
//         * 	@todo implement.
//         */
//        // void validSettings(bool valid);

        /*!
         * This signal is emitted whenever dsr line has changed its state. You may
         * use this signal to check if device is connected.
         * 	\param status \p true when DSR signal is on, \p false otherwise.
         *
         * 	\see lineStatus().
         */
        void dsrChanged(bool status);

};

#endif