This file is indexed.

/usr/include/gnelib/Packet.h is in libgnelib-dev 0.75+svn20091130-1.

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

/* GNE - Game Networking Engine, a portable multithreaded networking library.
 * Copyright (C) 2001-2006 Jason Winnebeck 
 * Project website: http://www.gillius.org/gne/
 *
 * 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, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <gnelib/SmartPtr.h>
#include <gnelib/WeakPtr.h>

namespace GNE {
class Buffer;

/**
 * @ingroup midlevel
 *
 * The base packet class, used for dealing with all types of packets at a
 * fundamental level.  All types of packets must inherit from this class to
 * be recognized by %GNE.  %GNE already implements some types of packets.
 *
 * When you create a new packet you MUST define your own versions of all
 * virtual functions or the program will fail.
 *
 * See the example expacket on how to properly derive from a Packet class, or
 * look at the code for the other %GNE packets.
 */
class Packet {
public: //typedefs
  typedef SmartPtr<Packet> sptr;
  typedef WeakPtr<Packet> wptr;

public:
  virtual ~Packet();

  /**
   * Returns a newly allocated exact copy of this packet, using the
   * PacketParser::clonePacket function.
   */
  Packet* makeClone() const;

  /**
   * Returns the type of this instance.  This allows you to identify the type
   * of packet you have when you only have a Packet*.
   */
  int getType() const;

  /**
   * Returns the current size of this packet in bytes.  When overloading this
   * function, call getSize on the parent class then add the sizes of your
   * additional variables.  If the size cannot be determined, then getSize
   * should return a value <= Buffer::RAW_PACKET_LEN but >= its possible
   * size -- so in other words if the size cannot be determined, it should
   * return the largest possible size that given packet could be.  This is
   * discouraged as much as possible since GNE allocates packets in the data
   * stream based on this value, and large values will hinder performance.
   */
  virtual int getSize() const;

  /**
   * Writes the packet to the given Buffer.  You can continue writing more
   * packets to the Buffer after this method.  You must make sure there
   * is enough space in the Buffer to fit this new packet.  When
   * overloading this function, call writePacket on the parent class then
   * write your own variables.
   *
   * No more than getSize() bytes may be written to the Buffer.
   *
   * This method is allowed to throw any subclass of Error.  Typically this
   * only happens if accesses to Packet case a buffer overflow.
   */
  virtual void writePacket(Buffer& raw) const;

  /**
   * Reads this packet from the given Buffer.  When overloading this
   * function, call readPacket on the parent class then read your own
   * variables.
   *
   * This method is allowed to throw any subclass of Error.  This can happen
   * if accessing the Packet causes a buffer underflow, but an error might
   * occur in the format or consistency of the data for the user's derived
   * class.  If you cannot construct a proper Packet of your type from the
   * data in raw, then you should throw a subclass of Error.
   */
  virtual void readPacket(Buffer& raw);

protected:
  /**
   * Constructs a packet with the given ID.  If you pass no ID, the ID for an
   * empty packet is assumed.  Normally sending blank packets are not useful,
   * however.  If you are wanting to use a blank packet for some purpose such
   * as a end-of-data marker or for sending some message that requires no
   * data, it is suggested that you simply derive a class from Packet that
   * adds no data, but has a unique ID so it can be "recognized" easier.
   *
   * @param id a number from PacketParser::MIN_USER_ID to
   *   PacketParser::MAX_USER_ID, inclusive.  %GNE packet id's are less than
   *   MIN_USER_ID.
   */
  explicit Packet( int id );

  /**
   * Copy constructor.  If your Packet is using the default packet clone
   * function in registration, remember that it uses the copy constructor so
   * if you need to override the default implementation, you must do it.
   */
  Packet( const Packet& o );

  /**
   * Copy operator you can use to help you in creating your own.
   * There is a debug assert in this function that checks to make sure the
   * types match.  Call this operator first from your copy operator.  Many
   * GNE packets may not support this operation, so check the documentation
   * first -- if no operator = exists, then assume you cannot copy packets
   * this way, unless the documentation says otherwise.
   *
   * If you can't use operator= on a packet, you can use makeClone to
   * achieve a nearly equivalent result.
   */
  Packet& operator = (const Packet& rhs);

private:
  /**
   * The type ID for this Packet.
   */
  const guint8 type;
};

}
#endif /* PACKET_H_INCLUDED_C51B374A */