summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Chernyakhovsky <alex@achernya.com>2023-07-30 18:10:08 -0400
committerAlex Chernyakhovsky <achernya@mit.edu>2023-07-30 19:02:51 -0400
commitcf542739cc6a11ae92404964fa3f246af4f89d0c (patch)
tree19b30e1f0aa5f21fffe4979e2ee2ad2463cebcd0
parent19ad493dcbc639e29ad07e5442ffc9f3e5af91d6 (diff)
Switch to C++ versions of standard C headers
-rw-r--r--src/crypto/base64.cc4
-rw-r--r--src/crypto/base64.h2
-rw-r--r--src/crypto/byteorder.h2
-rw-r--r--src/crypto/crypto.cc13
-rw-r--r--src/crypto/crypto.h9
-rw-r--r--src/crypto/ocb_internal.cc4
-rw-r--r--src/crypto/prng.h4
-rw-r--r--src/examples/benchmark.cc23
-rw-r--r--src/examples/decrypt.cc2
-rw-r--r--src/examples/encrypt.cc2
-rw-r--r--src/examples/ntester.cc4
-rw-r--r--src/examples/parse.cc21
-rw-r--r--src/examples/termemu.cc31
-rw-r--r--src/frontend/mosh-client.cc3
-rw-r--r--src/frontend/mosh-server.cc35
-rw-r--r--src/frontend/stmclient.cc19
-rw-r--r--src/frontend/stmclient.h5
-rw-r--r--src/frontend/terminaloverlay.cc4
-rw-r--r--src/frontend/terminaloverlay.h2
-rw-r--r--src/network/network.cc7
-rw-r--r--src/network/network.h15
-rw-r--r--src/network/networktransport.h7
-rw-r--r--src/network/transportfragment.cc2
-rw-r--r--src/network/transportfragment.h4
-rw-r--r--src/network/transportsender-impl.h9
-rw-r--r--src/statesync/completeterminal.cc7
-rw-r--r--src/statesync/completeterminal.h2
-rw-r--r--src/statesync/user.cc2
-rw-r--r--src/statesync/user.h2
-rw-r--r--src/terminal/parser.cc8
-rw-r--r--src/terminal/parser.h4
-rw-r--r--src/terminal/parseraction.cc4
-rw-r--r--src/terminal/parsertransition.h2
-rw-r--r--src/terminal/terminal.cc9
-rw-r--r--src/terminal/terminal.h6
-rw-r--r--src/terminal/terminaldispatcher.cc10
-rw-r--r--src/terminal/terminaldisplay.cc2
-rw-r--r--src/terminal/terminaldisplayinit.cc4
-rw-r--r--src/terminal/terminalframebuffer.cc6
-rw-r--r--src/terminal/terminalframebuffer.h7
-rw-r--r--src/terminal/terminalfunctions.cc5
-rw-r--r--src/terminal/terminaluserinput.cc3
-rw-r--r--src/tests/base64.cc6
-rw-r--r--src/tests/encrypt-decrypt.cc4
-rw-r--r--src/tests/inpty.cc11
-rw-r--r--src/tests/is-utf8-locale.cc2
-rw-r--r--src/tests/ocb-aes.cc6
-rw-r--r--src/tests/test_utils.cc2
-rw-r--r--src/util/dos_assert.h4
-rw-r--r--src/util/fatal_assert.h4
-rw-r--r--src/util/locale_utils.cc10
-rw-r--r--src/util/pty_compat.cc9
-rw-r--r--src/util/select.h9
-rw-r--r--src/util/swrite.cc5
-rw-r--r--src/util/timestamp.cc6
-rw-r--r--src/util/timestamp.h2
56 files changed, 205 insertions, 191 deletions
diff --git a/src/crypto/base64.cc b/src/crypto/base64.cc
index 6d8a9d1..ae38e3e 100644
--- a/src/crypto/base64.cc
+++ b/src/crypto/base64.cc
@@ -30,8 +30,8 @@
also delete it here.
*/
-#include <string.h>
-#include <stdlib.h>
+#include <cstdlib>
+#include <cstring>
#include "src/util/fatal_assert.h"
#include "src/crypto/base64.h"
diff --git a/src/crypto/base64.h b/src/crypto/base64.h
index e216dc0..80de7c6 100644
--- a/src/crypto/base64.h
+++ b/src/crypto/base64.h
@@ -30,7 +30,7 @@
also delete it here.
*/
-#include <stdint.h>
+#include <cstdint>
bool base64_decode( const char *b64, const size_t b64_len,
uint8_t *raw, size_t *raw_len );
diff --git a/src/crypto/byteorder.h b/src/crypto/byteorder.h
index 9148287..fe7e8cd 100644
--- a/src/crypto/byteorder.h
+++ b/src/crypto/byteorder.h
@@ -60,7 +60,7 @@
/* Use our fallback implementation, which is correct for any endianness. */
-#include <stdint.h>
+#include <cstdint>
/* Make sure they aren't macros */
#undef htobe64
diff --git a/src/crypto/crypto.cc b/src/crypto/crypto.cc
index b530ed9..62e04da 100644
--- a/src/crypto/crypto.cc
+++ b/src/crypto/crypto.cc
@@ -30,14 +30,15 @@
also delete it here.
*/
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <sys/resource.h>
+#include <cassert>
+#include <cerrno>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include <fstream>
+#include <sys/resource.h>
+
#include "src/crypto/byteorder.h"
#include "src/crypto/crypto.h"
#include "src/crypto/base64.h"
diff --git a/src/crypto/crypto.h b/src/crypto/crypto.h
index dfde2ba..a3c26a8 100644
--- a/src/crypto/crypto.h
+++ b/src/crypto/crypto.h
@@ -34,11 +34,12 @@
#define CRYPTO_HPP
#include "src/crypto/ae.h"
-#include <string>
-#include <string.h>
-#include <stdint.h>
-#include <stdlib.h>
+
+#include <cstdint>
+#include <cstdlib>
+#include <cstring>
#include <exception>
+#include <string>
long int myatoi( const char *str );
diff --git a/src/crypto/ocb_internal.cc b/src/crypto/ocb_internal.cc
index c25d7bd..0d4848c 100644
--- a/src/crypto/ocb_internal.cc
+++ b/src/crypto/ocb_internal.cc
@@ -87,8 +87,8 @@
#include "src/crypto/ae.h"
#include "src/crypto/crypto.h"
#include "src/util/fatal_assert.h"
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
#if defined(HAVE_STRINGS_H)
#include <strings.h>
#endif
diff --git a/src/crypto/prng.h b/src/crypto/prng.h
index 693080e..03e0b72 100644
--- a/src/crypto/prng.h
+++ b/src/crypto/prng.h
@@ -33,9 +33,9 @@
#ifndef PRNG_HPP
#define PRNG_HPP
-#include <string>
-#include <stdint.h>
+#include <cstdint>
#include <fstream>
+#include <string>
#include "src/crypto/crypto.h"
diff --git a/src/examples/benchmark.cc b/src/examples/benchmark.cc
index a52797a..1c60083 100644
--- a/src/examples/benchmark.cc
+++ b/src/examples/benchmark.cc
@@ -32,19 +32,20 @@
#include "src/include/config.h"
-#include <errno.h>
-#include <locale.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include <cerrno>
+#include <climits>
+#include <clocale>
+#include <csignal>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
+#include <exception>
+
+#include <pwd.h>
#include <sys/ioctl.h>
#include <sys/types.h>
-#include <pwd.h>
-#include <signal.h>
-#include <time.h>
-#include <limits.h>
-#include <exception>
+#include <unistd.h>
#if HAVE_PTY_H
#include <pty.h>
diff --git a/src/examples/decrypt.cc b/src/examples/decrypt.cc
index 384cf58..5f053a8 100644
--- a/src/examples/decrypt.cc
+++ b/src/examples/decrypt.cc
@@ -30,7 +30,7 @@
also delete it here.
*/
-#include <stdio.h>
+#include <cstdio>
#include <iostream>
#include <sstream>
diff --git a/src/examples/encrypt.cc b/src/examples/encrypt.cc
index b5afefe..bba0cc3 100644
--- a/src/examples/encrypt.cc
+++ b/src/examples/encrypt.cc
@@ -30,7 +30,7 @@
also delete it here.
*/
-#include <stdio.h>
+#include <cstdio>
#include <iostream>
#include <sstream>
diff --git a/src/examples/ntester.cc b/src/examples/ntester.cc
index bd26409..c1660c4 100644
--- a/src/examples/ntester.cc
+++ b/src/examples/ntester.cc
@@ -30,11 +30,11 @@
also delete it here.
*/
+#include <memory>
+
#include <termios.h>
#include <unistd.h>
-#include <memory>
-
#include "src/statesync/user.h"
#include "src/util/fatal_assert.h"
#include "src/util/pty_compat.h"
diff --git a/src/examples/parse.cc b/src/examples/parse.cc
index 26c4043..1883928 100644
--- a/src/examples/parse.cc
+++ b/src/examples/parse.cc
@@ -32,18 +32,19 @@
#include "src/include/config.h"
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <errno.h>
-#include <string.h>
-#include <locale.h>
-#include <wchar.h>
-#include <assert.h>
-#include <wctype.h>
+#include <cassert>
+#include <cerrno>
+#include <clocale>
+#include <csignal>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <cwchar>
+#include <cwctype>
#include <typeinfo>
+
#include <termios.h>
+#include <unistd.h>
#if HAVE_PTY_H
#include <pty.h>
diff --git a/src/examples/termemu.cc b/src/examples/termemu.cc
index e8dd3b5..8921ac7 100644
--- a/src/examples/termemu.cc
+++ b/src/examples/termemu.cc
@@ -32,25 +32,26 @@
#include "src/include/config.h"
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <errno.h>
-#include <string.h>
-#include <locale.h>
-#include <wchar.h>
-#include <assert.h>
-#include <wctype.h>
+#include <cassert>
+#include <cerrno>
+#include <clocale>
+#include <csignal>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <cwchar>
+#include <cwctype>
+#include <exception>
#include <typeinfo>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
+
#include <fcntl.h>
-#include <termios.h>
-#include <sys/types.h>
#include <pwd.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
#include <sys/time.h>
-#include <exception>
+#include <sys/types.h>
+#include <termios.h>
+#include <unistd.h>
#if HAVE_PTY_H
#include <pty.h>
diff --git a/src/frontend/mosh-client.cc b/src/frontend/mosh-client.cc
index 242aa48..5fa703d 100644
--- a/src/frontend/mosh-client.cc
+++ b/src/frontend/mosh-client.cc
@@ -33,7 +33,8 @@
#include "src/include/config.h"
#include "src/include/version.h"
-#include <stdlib.h>
+#include <cstdlib>
+
#include <unistd.h>
#include "stmclient.h"
diff --git a/src/frontend/mosh-server.cc b/src/frontend/mosh-server.cc
index 9324fdb..cfbd170 100644
--- a/src/frontend/mosh-server.cc
+++ b/src/frontend/mosh-server.cc
@@ -33,33 +33,34 @@
#include "src/include/config.h"
#include "src/include/version.h"
-#include <err.h>
-#include <errno.h>
-#include <locale.h>
-#include <string.h>
-#include <strings.h>
+#include <cerrno>
+#include <clocale>
+#include <csignal>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
#include <sstream>
-#include <termios.h>
-#include <unistd.h>
+#include <typeinfo>
+
+#include <err.h>
#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include <inttypes.h>
+#include <netdb.h>
+#include <pwd.h>
+#include <strings.h>
#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
#include <sys/types.h>
-#include <pwd.h>
-#include <typeinfo>
-#include <signal.h>
+#include <termios.h>
+#include <unistd.h>
#ifdef HAVE_UTEMPTER
#include <utempter.h>
#endif
#ifdef HAVE_SYSLOG
#include <syslog.h>
#endif
-#include <sys/socket.h>
-#include <netdb.h>
-#include <time.h>
-#include <sys/stat.h>
-#include <inttypes.h>
#ifdef HAVE_UTMPX_H
#include <utmpx.h>
diff --git a/src/frontend/stmclient.cc b/src/frontend/stmclient.cc
index 2a1a37a..8bec8a7 100644
--- a/src/frontend/stmclient.cc
+++ b/src/frontend/stmclient.cc
@@ -32,18 +32,19 @@
#include "src/include/config.h"
+#include <cerrno>
+#include <clocale>
+#include <csignal>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
+
#include <err.h>
-#include <errno.h>
-#include <locale.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include <pwd.h>
#include <sys/ioctl.h>
#include <sys/types.h>
-#include <pwd.h>
-#include <signal.h>
-#include <time.h>
+#include <unistd.h>
#if HAVE_PTY_H
#include <pty.h>
diff --git a/src/frontend/stmclient.h b/src/frontend/stmclient.h
index e811e26..09084dd 100644
--- a/src/frontend/stmclient.h
+++ b/src/frontend/stmclient.h
@@ -33,11 +33,12 @@
#ifndef STM_CLIENT_HPP
#define STM_CLIENT_HPP
-#include <sys/ioctl.h>
-#include <termios.h>
#include <string>
#include <memory>
+#include <sys/ioctl.h>
+#include <termios.h>
+
#include "src/statesync/completeterminal.h"
#include "src/network/networktransport.h"
#include "src/statesync/user.h"
diff --git a/src/frontend/terminaloverlay.cc b/src/frontend/terminaloverlay.cc
index 74dfeff..d8a3872 100644
--- a/src/frontend/terminaloverlay.cc
+++ b/src/frontend/terminaloverlay.cc
@@ -31,10 +31,10 @@
*/
#include <algorithm>
-#include <wchar.h>
+#include <climits>
+#include <cwchar>
#include <list>
#include <typeinfo>
-#include <limits.h>
#include "src/frontend/terminaloverlay.h"
diff --git a/src/frontend/terminaloverlay.h b/src/frontend/terminaloverlay.h
index 99bbc24..70c64e7 100644
--- a/src/frontend/terminaloverlay.h
+++ b/src/frontend/terminaloverlay.h
@@ -38,8 +38,8 @@
#include "src/network/transportsender.h"
#include "src/terminal/parser.h"
+#include <climits>
#include <vector>
-#include <limits.h>
namespace Overlay {
using namespace Terminal;
diff --git a/src/network/network.cc b/src/network/network.cc
index ea58bae..2b11fe7 100644
--- a/src/network/network.cc
+++ b/src/network/network.cc
@@ -32,6 +32,10 @@
#include "src/include/config.h"
+#include <cassert>
+#include <cerrno>
+#include <cstring>
+
#include <sys/types.h>
#include <sys/socket.h>
#ifdef HAVE_SYS_UIO_H
@@ -39,9 +43,6 @@
#endif
#include <netdb.h>
#include <netinet/in.h>
-#include <assert.h>
-#include <errno.h>
-#include <string.h>
#include <unistd.h>
#include "src/util/dos_assert.h"
diff --git a/src/network/network.h b/src/network/network.h
index 35042f7..56c37fb 100644
--- a/src/network/network.h
+++ b/src/network/network.h
@@ -33,16 +33,17 @@
#ifndef NETWORK_HPP
#define NETWORK_HPP
-#include <stdint.h>
+#include <cassert>
+#include <cmath>
+#include <cstdint>
+#include <cstring>
#include <deque>
-#include <sys/socket.h>
-#include <netinet/in.h>
+#include <exception>
#include <string>
-#include <math.h>
#include <vector>
-#include <assert.h>
-#include <exception>
-#include <string.h>
+
+#include <sys/socket.h>
+#include <netinet/in.h>
#include "src/crypto/crypto.h"
diff --git a/src/network/networktransport.h b/src/network/networktransport.h
index 11e00c4..55209d5 100644
--- a/src/network/networktransport.h
+++ b/src/network/networktransport.h
@@ -33,17 +33,16 @@
#ifndef NETWORK_TRANSPORT_HPP
#define NETWORK_TRANSPORT_HPP
-#include <string>
-#include <signal.h>
-#include <time.h>
+#include <csignal>
+#include <ctime>
#include <list>
+#include <string>
#include <vector>
#include "src/network/network.h"
#include "src/network/transportsender.h"
#include "transportfragment.h"
-
namespace Network {
template <class MyState, class RemoteState>
class Transport
diff --git a/src/network/transportfragment.cc b/src/network/transportfragment.cc
index 8870c3d..004e4d7 100644
--- a/src/network/transportfragment.cc
+++ b/src/network/transportfragment.cc
@@ -30,7 +30,7 @@
also delete it here.
*/
-#include <assert.h>
+#include <cassert>
#include "src/crypto/byteorder.h"
#include "transportfragment.h"
diff --git a/src/network/transportfragment.h b/src/network/transportfragment.h
index b9bf7fd..ff09542 100644
--- a/src/network/transportfragment.h
+++ b/src/network/transportfragment.h
@@ -33,9 +33,9 @@
#ifndef TRANSPORT_FRAGMENT_HPP
#define TRANSPORT_FRAGMENT_HPP
-#include <stdint.h>
-#include <vector>
+#include <cstdint>
#include <string>
+#include <vector>
#include "src/protobufs/transportinstruction.pb.h"
diff --git a/src/network/transportsender-impl.h b/src/network/transportsender-impl.h
index 90de4bc..3c8cf6f 100644
--- a/src/network/transportsender-impl.h
+++ b/src/network/transportsender-impl.h
@@ -34,16 +34,15 @@
#define TRANSPORT_SENDER_IMPL_HPP
#include <algorithm>
+#include <climits>
+#include <cstdio>
+#include <cstdlib>
+#include <ctime>
#include <list>
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
#include "src/network/transportsender.h"
#include "transportfragment.h"
-#include <limits.h>
-
using namespace Network;
template <class MyState>
diff --git a/src/statesync/completeterminal.cc b/src/statesync/completeterminal.cc
index 47a5c74..1f8fed7 100644
--- a/src/statesync/completeterminal.cc
+++ b/src/statesync/completeterminal.cc
@@ -30,12 +30,11 @@
also delete it here.
*/
-#include "src/statesync/completeterminal.h"
-#include "src/util/fatal_assert.h"
+#include <climits>
#include "src/protobufs/hostinput.pb.h"
-
-#include <limits.h>
+#include "src/statesync/completeterminal.h"
+#include "src/util/fatal_assert.h"
using namespace std;
using namespace Parser;
diff --git a/src/statesync/completeterminal.h b/src/statesync/completeterminal.h
index 2483ef4..e126462 100644
--- a/src/statesync/completeterminal.h
+++ b/src/statesync/completeterminal.h
@@ -33,8 +33,8 @@
#ifndef COMPLETE_TERMINAL_HPP
#define COMPLETE_TERMINAL_HPP
+#include <cstdint>
#include <list>
-#include <stdint.h>
#include "src/terminal/parser.h"
#include "src/terminal/terminal.h"
diff --git a/src/statesync/user.cc b/src/statesync/user.cc
index b1da825..0b1073e 100644
--- a/src/statesync/user.cc
+++ b/src/statesync/user.cc
@@ -30,7 +30,7 @@
also delete it here.
*/
-#include <assert.h>
+#include <cassert>
#include <typeinfo>
#include "src/statesync/user.h"
diff --git a/src/statesync/user.h b/src/statesync/user.h
index d98d23b..a3257b6 100644
--- a/src/statesync/user.h
+++ b/src/statesync/user.h
@@ -33,10 +33,10 @@
#ifndef USER_HPP
#define USER_HPP
+#include <cassert>
#include <deque>
#include <list>
#include <string>
-#include <assert.h>
#include "src/terminal/parseraction.h"
diff --git a/src/terminal/parser.cc b/src/terminal/parser.cc
index d1f00b7..7ab3ca4 100644
--- a/src/terminal/parser.cc
+++ b/src/terminal/parser.cc
@@ -30,11 +30,11 @@
also delete it here.
*/
-#include <assert.h>
+#include <cassert>
+#include <cerrno>
+#include <cstdint>
+#include <cwchar>
#include <typeinfo>
-#include <errno.h>
-#include <wchar.h>
-#include <stdint.h>
#include "src/terminal/parser.h"
diff --git a/src/terminal/parser.h b/src/terminal/parser.h
index f76096c..f1876c9 100644
--- a/src/terminal/parser.h
+++ b/src/terminal/parser.h
@@ -36,8 +36,8 @@
/* Based on Paul Williams's parser,
http://www.vt100.net/emu/dec_ansi_parser */
-#include <wchar.h>
-#include <string.h>
+#include <cstring>
+#include <cwchar>
#include "parsertransition.h"
#include "src/terminal/parseraction.h"
diff --git a/src/terminal/parseraction.cc b/src/terminal/parseraction.cc
index 531d2a9..4ca2b06 100644
--- a/src/terminal/parseraction.cc
+++ b/src/terminal/parseraction.cc
@@ -30,8 +30,8 @@
also delete it here.
*/
-#include <stdio.h>
-#include <wctype.h>
+#include <cstdio>
+#include <cwctype>
#include "src/terminal/parseraction.h"
#include "src/terminal/terminal.h"
diff --git a/src/terminal/parsertransition.h b/src/terminal/parsertransition.h
index cc2c6f5..aca909f 100644
--- a/src/terminal/parsertransition.h
+++ b/src/terminal/parsertransition.h
@@ -33,7 +33,7 @@
#ifndef PARSERTRANSITION_HPP
#define PARSERTRANSITION_H