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... */
};
/*
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));
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(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;
}
/*
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();
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
lprintf(2, "master shutdown exiting!.\n");
exit(0);
}