This file is indexed.

/usr/include/hphp/util/afdt-util.h is in hhvm-dev 3.11.1+dfsg-1ubuntu1.

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
/*
   +----------------------------------------------------------------------+
   | HipHop for PHP                                                       |
   +----------------------------------------------------------------------+
   | Copyright (c) 2010-2015 Facebook, Inc. (http://www.facebook.com)     |
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
   | http://www.php.net/license/3_01.txt                                  |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
   +----------------------------------------------------------------------+
*/

#ifndef incl_HPHP_AFDT_UTIL_H_
#define incl_HPHP_AFDT_UTIL_H_

#ifdef _MSC_VER
# error AFDT is not currently supported for MSVC!
#endif

#include <sys/socket.h>
#include <vector>
#include <string>
#include <stdexcept>
#include <cstring>

namespace HPHP {
namespace afdt {
///////////////////////////////////////////////////////////////////////////////

namespace detail {

typedef void (*SrFunc)(int afdt_fd, std::vector<iovec>& iov);

void sappend(int afdt_fd,
             std::vector<iovec>& iov, const void* addr, size_t size);
void rappend(int afdt_fd,
             std::vector<iovec>& iov, void* addr, size_t size);

template<class T>
typename std::enable_if<std::is_fundamental<T>::value, void>::type
sappend(int afdt_fd, std::vector<iovec>& iov, const T& elm) {
  sappend(afdt_fd, iov, &elm, sizeof elm);
}

template<class T>
typename std::enable_if<std::is_fundamental<T>::value, void>::type
rappend(int afdt_fd, std::vector<iovec>& iov, T* elm) {
  rappend(afdt_fd, iov, elm, sizeof *elm);
}

void send(int afdt_fd, std::vector<iovec>& iov);

template<class... Tail>
void send(int afdt_fd, std::vector<iovec>& iov,
          const std::vector<std::string>& h, Tail&&... args);

template<class... Tail>
void send(int afdt_fd, std::vector<iovec>& iov,
          const std::string& h, Tail&&... args);

template<class... Tail>
void send(int afdt_fd, std::vector<iovec>& iov,
          const char* h, Tail&&... args);

template<class T, class... Tail>
typename std::enable_if<std::is_fundamental<T>::value, void>::type
send(int afdt_fd, std::vector<iovec>& iov,
     const std::vector<T>& h, Tail&&... args);

template<class... Tail>
void send(int afdt_fd, std::vector<iovec>& iov,
          const std::vector<std::string>& h, Tail&&... args);


template<class Head, class... Tail>
void send(int afdt_fd, std::vector<iovec>& iov,
          const Head& h, Tail&&... args) {
  sappend(afdt_fd, iov, h);
  send(afdt_fd, iov, std::forward<Tail>(args)...);
}

template<class... Tail>
void send(int afdt_fd, std::vector<iovec>& iov,
          const std::string& h, Tail&&... args) {
  size_t s = h.size();
  sappend(afdt_fd, iov, s);
  sappend(afdt_fd, iov, &h[0], s);
  send(afdt_fd, iov, std::forward<Tail>(args)...);
}

template<class... Tail>
void send(int afdt_fd, std::vector<iovec>& iov,
          const char* h, Tail&&... args) {
  size_t s = std::strlen(h);
  sappend(afdt_fd, iov, s);
  sappend(afdt_fd, iov, &h[0], s);
  send(afdt_fd, iov, std::forward<Tail>(args)...);
}

template<class T, class... Tail>
typename std::enable_if<std::is_fundamental<T>::value, void>::type
send(int afdt_fd, std::vector<iovec>& iov,
     const std::vector<T>& h, Tail&&... args) {
  size_t s = h.size();
  sappend(afdt_fd, iov, s);
  sappend(afdt_fd, iov, &h[0], s * sizeof(T));
  send(afdt_fd, iov, std::forward<Tail>(args)...);
}

template<class... Tail>
void send(int afdt_fd, std::vector<iovec>& iov,
          const std::vector<std::string>& h, Tail&&... args) {
  size_t s = h.size();
  sappend(afdt_fd, iov, s);
  std::vector<size_t> sizes;
  sizes.reserve(s);
  for (auto& e : h) {
    auto strsz = e.size();
    sizes.push_back(strsz);
    sappend(afdt_fd, iov, sizes.back());
    sappend(afdt_fd, iov, &e[0], strsz);
  }
  send(afdt_fd, iov, std::forward<Tail>(args)...);
}

void recv(int afdt_fd, std::vector<iovec>& iov);

template<class... Tail>
void recv(int afdt_fd, std::vector<iovec>& iov,
          std::string& h, Tail&... args);

template<class T, class... Tail>
typename std::enable_if<std::is_fundamental<T>::value, void>::type
recv(int afdt_fd, std::vector<iovec>& iov,
     std::vector<T>& h, Tail&... args);

template<class... Tail>
void recv(int afdt_fd, std::vector<iovec>& iov,
          std::vector<std::string>& h, Tail&... args);


template<class Head, class... Tail>
void recv(int afdt_fd, std::vector<iovec>& iov,
          Head& h, Tail&... args) {
  rappend(afdt_fd, iov, &h);
  recv(afdt_fd, iov, args...);
}

template<class... Tail>
void recv(int afdt_fd, std::vector<iovec>& iov,
          std::string& h, Tail&... args) {
  size_t sz;
  rappend(afdt_fd, iov, &sz);
  recv(afdt_fd, iov);
  iov.clear();
  h.resize(sz);
  rappend(afdt_fd, iov, &h[0], sz);
  recv(afdt_fd, iov, args...);
}

template<class T, class... Tail>
typename std::enable_if<std::is_fundamental<T>::value, void>::type
recv(int afdt_fd, std::vector<iovec>& iov,
     std::vector<T>& h, Tail&... args) {
  size_t sz;
  rappend(afdt_fd, iov, &sz);
  recv(afdt_fd, iov);
  iov.clear();
  h.resize(sz);
  rappend(afdt_fd, iov, &h[0], sz * sizeof(h[0]));
  recv(afdt_fd, iov, args...);
}

template<class... Tail>
void recv(int afdt_fd, std::vector<iovec>& iov,
          std::vector<std::string>& h, Tail&... args) {
  size_t sz;
  rappend(afdt_fd, iov, &sz);
  recv(afdt_fd, iov);
  iov.clear();
  h.resize(sz);
  for (auto& e : h) {
    size_t strsz;
    rappend(afdt_fd, iov, &strsz);
    recv(afdt_fd, iov);
    iov.clear();
    e.resize(strsz);
    rappend(afdt_fd, iov, &e[0], strsz);
  }
  recv(afdt_fd, iov, args...);
}

}

template<class Head, class... Tail>
int sendRaw(int afdt_fd, const Head& h, Tail&&... args) {
  std::vector<iovec> iov;
  try {
    detail::send(afdt_fd, iov, h, std::forward<Tail>(args)...);
    return 0;
  } catch (const std::runtime_error& e) {
    return -1;
  }
}

template<class Head, class... Tail>
int recvRaw(int afdt_fd, Head& h, Tail&... args) {
  std::vector<iovec> iov;
  try {
    detail::recv(afdt_fd, iov, h, args...);
    return 0;
  } catch (const std::runtime_error& e) {
    return -1;
  }
}

bool send_fd(int afdt_fd, int fd);
int recv_fd(int afdt_fd);

///////////////////////////////////////////////////////////////////////////////
}
}
#endif