This file is indexed.

/usr/include/gpsim/protocol.h is in gpsim-dev 0.27.0-6.

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
/*
   Copyright (C) 2004 T. Scott Dattalo

This file is part of the libgpsim library of gpsim

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.1 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 library; if not, see 
<http://www.gnu.org/licenses/lgpl-2.1.html>.
*/

//
// protocol.h
//

#include <glib.h>
#include <cstdio>

#ifndef __PROTCOL_H__
#define __PROTCOL_H__

#ifdef putc
#undef putc
#endif


/// gpsim protocol
///
/// gpsim's protocol interface is designed to provide a way for clients 
/// that are not linked with gpsim to interface with gpsim. 


/// Basic types
/// These are the fundamental types the protocol interface
/// supports.

enum eGPSIMObjectTypes
  {
    eGPSIM_TYPE_CHAR = 1,
    eGPSIM_TYPE_STRING,
    eGPSIM_TYPE_UINT32,
    eGPSIM_TYPE_UCHAR,
    eGPSIM_TYPE_BOOLEAN,
    eGPSIM_TYPE_INT32,
    eGPSIM_TYPE_INT64,
    eGPSIM_TYPE_UINT64,
    eGPSIM_TYPE_FLOAT,
    eGPSIM_TYPE_DOUBLE,
    eGPSIM_TYPE_OBJECT,
    eGPSIM_TYPE_CUSTOM,
  };

/// Socket Commands
/// FIXME - document how these are used.
/// 
enum eGPSIMSocketCommands
  {

    GPSIM_CMD_CREATE_NOTIFY_LINK    = 0xE0,
    GPSIM_CMD_CREATE_CALLBACK_LINK  = 0xE1,

    GPSIM_CMD_CREATE_SOCKET_LINK    = 0xF0,
    GPSIM_CMD_REMOVE_SOCKET_LINK    = 0xF1,
    GPSIM_CMD_QUERY_SOCKET_LINK     = 0xF2,
    GPSIM_CMD_WRITE_TO_SOCKET_LINK  = 0xF3,

    GPSIM_CMD_QUERY_SYMBOL          = 0xF4,
    GPSIM_CMD_WRITE_TO_SYMBOL       = 0xF5,

    GPSIM_CMD_RUN                   = 0xF6,
    GPSIM_CMD_RESET                 = 0xF7,

  };


/// PacketBuffer
/// A packet buffer is an area of memory that gpsim and a client
/// use to exchange information. The buffer consists of a sequence
/// encoded GPSIMObjectTypes. Member functions for encoding and 
/// decoding each type.

class PacketBuffer
{
public:
  PacketBuffer(unsigned int _size);
  ~PacketBuffer();


  char * getBuffer()
  {
    return &buffer[index];
  }

  unsigned int getSize()
  {
    return size-index;
  }

  void terminate();

  void putc(char c)
  {
    if(index < size)
      buffer[index++] = c;
  }
  void putAt(int pos, char c)
  {
    if(pos >=0 && pos < (int) size) 
      buffer[pos] = c;
  }

  void puts(const char *, int);

  /// advanceIndex() will move the index pointer forward

  void advanceIndex(unsigned int amount);

  bool bHasData() { return index!=0; }

  //private:
  char          *buffer;
  unsigned int   index;
  unsigned int   size;

};

class Packet
{
public:
  Packet(unsigned int rxsize, unsigned int txsize);

  bool DecodeHeader();
  bool DecodeObjectType(unsigned int &);
  bool DecodeChar(char);
  bool DecodeUInt32(unsigned int &);
  bool DecodeUInt64(guint64 &);
  bool DecodeString(char *, int);
  bool DecodeBool(bool &);
  bool DecodeFloat(double &);

  bool EncodeHeader();
  bool EncodeUInt32(unsigned int);
  bool EncodeUInt64(guint64);
  bool EncodeObjectType(unsigned int);
  bool EncodeString(const char *str, int len=-1);
  bool EncodeCustom(const char *str, int len);
  bool EncodeBool(bool);
  bool EncodeFloat(double);

  char *rxBuff()
  {
    return rxBuffer->getBuffer();
  }
  unsigned int rxSize()
  {
    return rxBuffer->getSize();
  }
  void rxTerminate(int pos)
  {
    rxBuffer->putAt(pos,0);
  }

  void rxAdvance(unsigned int amount)
  {
    rxBuffer->advanceIndex(amount);
  }
  bool brxHasData()
  { 
    return rxBuffer->bHasData(); 
  }

  char *txBuff()
  {
    return txBuffer->buffer;
  }
  unsigned int txBytesBuffered()
  {
    return txBuffer->index;
  }
  void txTerminate()
  {
    txBuffer->terminate();
  }
  void prepare()
  {
    rxBuffer->index = 0;
    txBuffer->index = 0;
  }

private:
  PacketBuffer *rxBuffer;
  PacketBuffer *txBuffer;

};


#endif