[ci] Fix netbsd job to upgrade existing packages
[xapian.git] / xapian-applications / omega / worker_comms.h
blob598c6b51d3f7f70df2e9e00d79a9aeb3e4200424
1 /** @file
2 * @brief Communication with worker processes
3 */
4 /* Copyright (C) 2011,2022 Olly Betts
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
19 * USA
22 #include <cstdio>
23 #include <string>
25 /// Read a string from the file descriptor @a f and storage it in @a s.
26 bool read_string(std::FILE* f, std::string& s);
28 /// Write the string @a p of length @a len to the file descriptor @a f.
29 bool write_string(std::FILE* f, const char* p, size_t len);
31 /// Write the string @a p of length @a len to the file descriptor @a f.
32 inline bool write_string(std::FILE* f, const std::string& s) {
33 return write_string(f, s.data(), s.size());
36 bool read_unsigned(std::FILE* f, unsigned& v);
38 bool read_unsigned(std::FILE* f, unsigned long& v);
40 bool write_unsigned(std::FILE* f, unsigned v);
42 bool write_unsigned(std::FILE* f, unsigned long v);
44 // Exit codes for situations not enumerated by <sysexits.h>.
45 enum {
46 OMEGA_EX_SOCKET_READ_ERROR = 10,
47 OMEGA_EX_SOCKET_WRITE_ERROR