Get some of the last remaining C files into C++
They still need to be fixed up, but they now build with C++.
This commit is contained in:
@ -14,17 +14,17 @@ dpidc_LDADD = \
|
||||
EXTRA_DIST = dpidrc.in
|
||||
|
||||
dpid_SOURCES = \
|
||||
dpi.h \
|
||||
dpi_socket_dir.h \
|
||||
dpid.h \
|
||||
dpid_common.h \
|
||||
misc_new.h \
|
||||
dpi.hh \
|
||||
dpi_socket_dir.hh \
|
||||
dpid.hh \
|
||||
dpid_common.hh \
|
||||
misc_new.hh \
|
||||
dpi.cc \
|
||||
dpi_socket_dir.c \
|
||||
dpi_socket_dir.cc \
|
||||
dpid.cc \
|
||||
dpid_common.c \
|
||||
main.c \
|
||||
misc_new.c
|
||||
dpid_common.cc \
|
||||
main.cc \
|
||||
misc_new.cc
|
||||
|
||||
dpidc_SOURCES = dpidc.cc
|
||||
|
||||
|
@ -23,9 +23,9 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h> /* for exit */
|
||||
#include "dpid_common.h"
|
||||
#include "dpi.h"
|
||||
#include "misc_new.h"
|
||||
#include "dpid_common.hh"
|
||||
#include "dpi.hh"
|
||||
#include "misc_new.hh"
|
||||
|
||||
/*! \Return
|
||||
* Returns path to the dpi_socket_dir file
|
||||
|
@ -21,10 +21,10 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "dpid_common.h"
|
||||
#include "dpi.h"
|
||||
#include "misc_new.h"
|
||||
#include "dpi_socket_dir.h" /* for function prototypes */
|
||||
#include "dpid_common.hh"
|
||||
#include "dpi.hh"
|
||||
#include "misc_new.hh"
|
||||
#include "dpi_socket_dir.hh" /* for function prototypes */
|
||||
|
||||
/*! Save socket directory name in ~/.dillo/dpi_socket_dir
|
||||
* \Return
|
||||
@ -76,17 +76,18 @@ int tst_dir(char *dir)
|
||||
*/
|
||||
char *mk_sockdir(void)
|
||||
{
|
||||
char *template, *logname;
|
||||
char *template_;
|
||||
const char *logname;
|
||||
|
||||
logname = getenv("LOGNAME") ? getenv("LOGNAME") : "flenser";
|
||||
template = dStrconcat("/tmp/", logname, "-", "XXXXXX", NULL);
|
||||
if (a_Misc_mkdtemp(template) == NULL) {
|
||||
template_ = dStrconcat("/tmp/", logname, "-", "XXXXXX", NULL);
|
||||
if (a_Misc_mkdtemp(template_) == NULL) {
|
||||
ERRMSG("mk_sockdir", "a_Misc_mkdtemp", 0);
|
||||
MSG_ERR(" - %s\n", template);
|
||||
dFree(template);
|
||||
MSG_ERR(" - %s\n", template_);
|
||||
dFree(template_);
|
||||
return (NULL);
|
||||
}
|
||||
return template;
|
||||
return template_;
|
||||
}
|
||||
|
||||
/*! Create socket directory if it does not exist and save its name in
|
12
dpid/dpid.cc
12
dpid/dpid.cc
@ -31,13 +31,13 @@
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include "dpid_common.h"
|
||||
#include "dpid.h"
|
||||
#include "dpi.h"
|
||||
#include "dpi_socket_dir.h"
|
||||
#include "misc_new.h"
|
||||
#include "dpid_common.hh"
|
||||
#include "dpid.hh"
|
||||
#include "dpi.hh"
|
||||
#include "dpi_socket_dir.hh"
|
||||
#include "misc_new.hh"
|
||||
|
||||
#include "../dpip/dpip.h"
|
||||
#include "../dpip/dpip.hh"
|
||||
|
||||
using namespace std::literals::string_literals;
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "dpid_common.h"
|
||||
#include "dpid_common.hh"
|
||||
|
||||
/*
|
||||
* Send a verbose error message.
|
@ -9,16 +9,17 @@
|
||||
* the next patch
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <dirent.h>
|
||||
#include <stddef.h> /* size_t */
|
||||
#include <sys/types.h> /* ssize_t */
|
||||
|
||||
#include "../dlib/dlib.h"
|
||||
#include "../dlib/dlib.hh"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Debugging macros
|
@ -20,8 +20,8 @@
|
||||
#include <netdb.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "../dlib/dlib.h"
|
||||
#include "../dpip/dpip.h"
|
||||
#include "../dlib/dlib.hh"
|
||||
#include "../dpip/dpip.hh"
|
||||
|
||||
#define MSG_ERR(...) printf("** ERROR **: " __VA_ARGS__);
|
||||
|
||||
|
@ -24,14 +24,14 @@
|
||||
#include <assert.h> /* for assert */
|
||||
#include <sys/stat.h> /* for umask */
|
||||
|
||||
#include "dpid_common.h"
|
||||
#include "dpid.h"
|
||||
#include "dpi.h"
|
||||
#include "dpi_socket_dir.h"
|
||||
#include "misc_new.h"
|
||||
#include "dpid_common.hh"
|
||||
#include "dpid.hh"
|
||||
#include "dpi.hh"
|
||||
#include "dpi_socket_dir.hh"
|
||||
#include "misc_new.hh"
|
||||
|
||||
#include "../dlib/dlib.h"
|
||||
#include "../dpip/dpip.h"
|
||||
#include "../dlib/dlib.hh"
|
||||
#include "../dpip/dpip.hh"
|
||||
|
||||
sigset_t mask_sigchld;
|
||||
|
@ -15,9 +15,9 @@
|
||||
#include <sys/stat.h> /* stat */
|
||||
#include <stdlib.h> /* rand, srand */
|
||||
|
||||
#include "../dlib/dlib.h"
|
||||
#include "dpid_common.h"
|
||||
#include "misc_new.h" /* for function prototypes */
|
||||
#include "../dlib/dlib.hh"
|
||||
#include "dpid_common.hh"
|
||||
#include "misc_new.hh" /* for function prototypes */
|
||||
|
||||
/*! Reads a dpi tag from a socket
|
||||
* \li Continues after a signal interrupt
|
||||
@ -128,30 +128,30 @@ int a_Misc_nohang_rdtag(int socket, int timeout, Dstr **tag)
|
||||
* Alternative to mkdtemp().
|
||||
* Not as strong as mkdtemp, but enough for creating a directory.
|
||||
*/
|
||||
char *a_Misc_mkdtemp(char *template)
|
||||
char *a_Misc_mkdtemp(char *template_)
|
||||
{
|
||||
for (;;) {
|
||||
if (a_Misc_mkfname(template) && mkdir(template, 0700) == 0)
|
||||
if (a_Misc_mkfname(template_) && mkdir(template_, 0700) == 0)
|
||||
break;
|
||||
if (errno == EEXIST)
|
||||
continue;
|
||||
return 0;
|
||||
}
|
||||
return template;
|
||||
return template_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a new, nonexistent file name from a template.
|
||||
* (adapted from dietlibc; alternative to mkdtemp())
|
||||
*/
|
||||
char *a_Misc_mkfname(char *template)
|
||||
char *a_Misc_mkfname(char *template_)
|
||||
{
|
||||
char *tmp = template + strlen(template) - 6;
|
||||
char *tmp = template_ + strlen(template_) - 6;
|
||||
int i;
|
||||
uint_t random;
|
||||
struct stat stat_buf;
|
||||
|
||||
if (tmp < template)
|
||||
if (tmp < template_)
|
||||
goto error;
|
||||
for (i = 0; i < 6; ++i)
|
||||
if (tmp[i] != 'X') {
|
||||
@ -168,10 +168,10 @@ char *a_Misc_mkfname(char *template)
|
||||
|
||||
tmp[i] = hexdigit > 9 ? hexdigit + 'a' - 10 : hexdigit + '0';
|
||||
}
|
||||
if (stat(template, &stat_buf) == -1 && errno == ENOENT)
|
||||
return template;
|
||||
if (stat(template_, &stat_buf) == -1 && errno == ENOENT)
|
||||
return template_;
|
||||
|
||||
MSG_ERR("a_Misc_mkfname: another round for %s \n", template);
|
||||
MSG_ERR("a_Misc_mkfname: another round for %s \n", template_);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user