#if HAVE_BACKTRACE
#include <execinfo.h>
#endif
-
+#include "modules_init.h"
#ifndef HAVE_SNPRINTF
int vsnprintf(char *buf, size_t max, const char *fmt, va_list argp);
#endif
static const char editor_absolut_dir[PATH_MAX]=EDITORDIR; /* nailed to what configure gives us. */
static char static_dir[PATH_MAX]; /* calculated on startup */
static char static_local_dir[PATH_MAX]; /* calculated on startup */
+static char static_icon_dir[PATH_MAX]; /* where should we find our mime icons? */
char *static_dirs[]={ /* needs same sort order as the web mapping */
(char*)static_dir, /* our templates on disk */
(char*)static_local_dir, /* user provided templates disk */
- (char*)editor_absolut_dir /* the editor on disk */
+ (char*)editor_absolut_dir, /* the editor on disk */
+ (char*)static_icon_dir /* our icons... */
};
/*
* (If you add more, remember to increment 'ndirs' below)
*/
char *static_content_dirs[] = {
- "static", /** static templates */
- "static.local", /** site local static templates */
- "tiny_mce" /** rich text editor */
+ "static", /* static templates */
+ "static.local", /* site local static templates */
+ "tiny_mce" /* rich text editor */
};
int ndirs=3;
i = 1;
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(i));
- fcntl(s, F_SETFL, O_NONBLOCK);/// TODO
+ fcntl(s, F_SETFL, O_NONBLOCK); /* maide: this statement is incorrect
+ there should be a preceding F_GETFL
+ and a bitwise OR with the previous
+ fd flags */
if (bind(s, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
lprintf(1, "Can't bind: %s\n", strerror(errno));
/*
- * \brief Create a Unix domain socket and listen on it
- * \param sockpath file name of the unix domain socket
- * \param queue_len Number of incoming connections to allow in the queue
+ * Create a Unix domain socket and listen on it
+ * sockpath - file name of the unix domain socket
+ * queue_len - Number of incoming connections to allow in the queue
*/
int ig_uds_server(char *sockpath, int queue_len)
{
i = unlink(sockpath);
if (i != 0) if (errno != ENOENT) {
- lprintf(1, "webserver: can't unlink %s: %s\n",
+ lprintf(1, "webcit: can't unlink %s: %s\n",
sockpath, strerror(errno));
exit(WC_EXIT_BIND);
}
s = socket(AF_UNIX, SOCK_STREAM, 0);
if (s < 0) {
- lprintf(1, "webserver: Can't create a socket: %s\n",
+ lprintf(1, "webcit: Can't create a socket: %s\n",
strerror(errno));
exit(WC_EXIT_BIND);
}
if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
- lprintf(1, "webserver: Can't bind: %s\n",
+ lprintf(1, "webcit: Can't bind: %s\n",
strerror(errno));
exit(WC_EXIT_BIND);
}
if (listen(s, actual_queue_len) < 0) {
- lprintf(1, "webserver: Can't listen: %s\n",
+ lprintf(1, "webcit: Can't listen: %s\n",
strerror(errno));
exit(WC_EXIT_BIND);
}
*/
ssize_t client_write(const void *buf, size_t count)
{
- char *newptr;
- size_t newalloc;
+ char *newptr;
+ size_t newalloc;
+ size_t bytesWritten = 0;
+ ssize_t res;
+ fd_set wset;
+ int fdflags;
if (WC->burst != NULL) {
if ((WC->burst_len + count) >= WC->burst_alloc) {
write(2, buf, count);
write(2, "\033[30m", 5);
#endif
- return (write(WC->http_sock, buf, count));
+ fdflags = fcntl(WC->http_sock, F_GETFL);
+
+ while (bytesWritten < count) {
+ if ((fdflags & O_NONBLOCK) == O_NONBLOCK) {
+ FD_ZERO(&wset);
+ FD_SET(WC->http_sock, &wset);
+ if (select(WC->http_sock + 1, NULL, &wset, NULL, NULL) == -1) {
+ lprintf(2, "client_write: Socket select failed (%s)\n", strerror(errno));
+ return -1;
+ }
+ }
+
+ if ((res = write(WC->http_sock, (char*)buf + bytesWritten,
+ count - bytesWritten)) == -1) {
+ lprintf(2, "client_write: Socket write failed (%s)\n", strerror(errno));
+ return res;
+ }
+ bytesWritten += res;
+ }
+
+ return bytesWritten;
}
/*
if (current_child < 0) {
perror("fork");
+ ShutDownLibCitadel ();
exit(errno);
}
if (pid_file) {
unlink(pid_file);
}
+ ShutDownLibCitadel ();
exit(WEXITSTATUS(status));
}
pthread_attr_destroy(&attr);
}
+const char foobuf[32];
+const char *nix(void *vptr) {snprintf(foobuf, 32, "%0x", (long) vptr); return foobuf;}
/*
* \brief Here's where it all begins.
* \param argc number of commandline args
#endif /* ENABLE_NLS */
char uds_listen_path[PATH_MAX]; /*< listen on a unix domain socket? */
+ HandlerHash = NewHash(1, NULL);
+ initialise_modules();
+ dbg_PrintHash(HandlerHash, nix, NULL);
+
/* Ensure that we are linked to the correct version of libcitadel */
if (libcitadel_version_number() < LIBCITADEL_VERSION_NUMBER) {
fprintf(stderr, " You are running libcitadel version %d.%02d\n",
strcpy(uds_listen_path, "");
- if (getenv("TZ") == NULL)
- putenv("TZ=UTC");
-
/* Parse command line */
#ifdef HAVE_OPENSSL
while ((a = getopt(argc, argv, "h:i:p:t:x:dD:cfs")) != EOF)
is_https = 1;
break;
default:
- fprintf(stderr, "usage: webserver "
+ fprintf(stderr, "usage: webcit "
"[-i ip_addr] [-p http_port] "
"[-t tracefile] [-c] [-f] "
"[-d] "
/* initialize the International Bright Young Thing */
#ifdef ENABLE_NLS
initialize_locales();
+
locale = setlocale(LC_ALL, "");
+
mo = malloc(strlen(webcitdir) + 20);
lprintf(9, "Message catalog directory: %s\n", bindtextdomain("webcit", LOCALEDIR"/locale"));
free(mo);
lprintf(9, "Text domain: %s\n", textdomain("webcit"));
lprintf(9, "Text domain Charset: %s\n", bind_textdomain_codeset("webcit","UTF8"));
+ preset_locale();
#endif
COMPUTE_DIRECTORY(socket_dir);
basedir=WWWDIR "/static";
COMPUTE_DIRECTORY(static_dir);
+ basedir=WWWDIR "/static/icons";
+ COMPUTE_DIRECTORY(static_icon_dir);
basedir=WWWDIR "/static.local";
COMPUTE_DIRECTORY(static_local_dir);
lprintf(9, "Changing directory to %s\n", socket_dir);
if (chdir(webcitdir) != 0) {
perror("chdir");
- }
- CtdlInitBase64Table();
+ }
+ LoadIconDir(static_icon_dir);
initialize_viewdefs();
initialize_axdefs();
/* now the original thread becomes another worker */
worker_entry();
+ ShutDownLibCitadel ();
return 0;
}
sleeeeeeeeeep(1); // wait so some others might finish...
lprintf(2, "master shutdown: cleaning up sessions\n");
do_housekeeping();
-#ifdef WEBCIT_WITH_CALENDAR_SERVICE
lprintf(2, "master shutdown: cleaning up libical\n");
free_zone_directory ();
icaltimezone_release_zone_tab ();
icalmemory_free_ring ();
-#endif
+ ShutDownLibCitadel ();
lprintf(2, "master shutdown exiting!.\n");
exit(0);
}