summaryrefslogtreecommitdiff
path: root/source3/web
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-10-14 12:10:29 +0000
committerAndrew Tridgell <tridge@samba.org>2001-10-14 12:10:29 +0000
commita689b24db14436ab1faa2f2f79b9f27b777b1fdb (patch)
tree7195ae4dc635d1f2e18b44ae57408b03e99e7c63 /source3/web
parent47a0b69029857e92703ca5b00022dcfcb179c9c7 (diff)
downloadsamba-a689b24db14436ab1faa2f2f79b9f27b777b1fdb.tar.gz
samba-a689b24db14436ab1faa2f2f79b9f27b777b1fdb.tar.bz2
samba-a689b24db14436ab1faa2f2f79b9f27b777b1fdb.zip
the next step in the intl changeover. This should get us compiling agian,
and also completes the switch to lang_tdb.c. SWAT should now work with a po file in the lib/ directory also removed useless SYSLOG defines in many files (This used to be commit 5296b20ad85d7519c870768455cb4d8df048c55a)
Diffstat (limited to 'source3/web')
-rw-r--r--source3/web/cgi.c39
-rw-r--r--source3/web/neg_lang.c274
-rw-r--r--source3/web/statuspage.c137
-rw-r--r--source3/web/swat.c32
4 files changed, 130 insertions, 352 deletions
diff --git a/source3/web/cgi.c b/source3/web/cgi.c
index caba28396f..e1b26d99b4 100644
--- a/source3/web/cgi.c
+++ b/source3/web/cgi.c
@@ -20,7 +20,6 @@
#include "includes.h"
#include "smb.h"
-#include "webintl.h"
#define MAX_VARIABLES 10000
@@ -138,7 +137,7 @@ void cgi_load_variables(void)
#ifdef DEBUG_COMMENTS
char dummy[100]="";
print_title(dummy);
- printf("<!== Start dump in cgi_load_variables() %s ==>\n",__FILE__);
+ d_printf("<!== Start dump in cgi_load_variables() %s ==>\n",__FILE__);
#endif
if (!content_length) {
@@ -270,7 +269,7 @@ static void cgi_setup_error(char *err, char *header, char *info)
}
}
- printf("HTTP/1.0 %s\r\n%sConnection: close\r\nContent-Type: text/html\r\n\r\n<HTML><HEAD><TITLE>%s</TITLE></HEAD><BODY><H1>%s</H1>%s<p></BODY></HTML>\r\n\r\n", err, header, err, err, info);
+ d_printf("HTTP/1.0 %s\r\n%sConnection: close\r\nContent-Type: text/html\r\n\r\n<HTML><HEAD><TITLE>%s</TITLE></HEAD><BODY><H1>%s</H1>%s<p></BODY></HTML>\r\n\r\n", err, header, err, err, info);
fclose(stdin);
fclose(stdout);
exit(0);
@@ -448,9 +447,7 @@ static void cgi_download(char *file)
char buf[1024];
int fd, l, i;
char *p;
-#if I18N_SWAT
- int nLangDesc;
-#endif
+ char *lang;
/* sanitise the filename */
for (i=0;file[i];i++) {
@@ -464,11 +461,8 @@ static void cgi_download(char *file)
cgi_setup_error("404 File Not Found","",
"The requested file was not found");
}
-#if I18N_SWAT
- fd = sys_open(ln_get_pref_file(file, &st, &nLangDesc),O_RDONLY,0);
-#else
- fd = sys_open(file,O_RDONLY,0);
-#endif
+
+ fd = web_open(file,O_RDONLY,0);
if (fd == -1) {
cgi_setup_error("404 File Not Found","",
"The requested file was not found");
@@ -486,10 +480,12 @@ static void cgi_download(char *file)
}
}
printf("Expires: %s\r\n", http_timestring(time(NULL)+EXPIRY_TIME));
-#if I18N_SWAT
- if(ln_get_lang(nLangDesc))
- printf("Content-Language: %s\r\n", ln_get_lang(nLangDesc));
-#endif
+
+ lang = lang_tdb_current();
+ if (lang) {
+ printf("Content-Language: %s\r\n", lang);
+ }
+
printf("Content-Length: %d\r\n\r\n", (int)st.st_size);
while ((l=read(fd,buf,sizeof(buf)))>0) {
fwrite(buf, 1, l, stdout);
@@ -511,6 +507,7 @@ void cgi_setup(char *rootdir, int auth_required)
char line[1024];
char *url=NULL;
char *p;
+ char *lang;
if (chdir(rootdir)) {
cgi_setup_error("400 Server Error", "",
@@ -520,10 +517,10 @@ void cgi_setup(char *rootdir, int auth_required)
/* Handle the possability we might be running as non-root */
sec_init();
-#if I18N_SWAT
- if(getenv("HTTP_ACCEPT_LANGUAGE")) /* if running as a cgi program */
- ln_negotiate_language(getenv("HTTP_ACCEPT_LANGUAGE"));
-#endif
+ if ((lang=getenv("HTTP_ACCEPT_LANGUAGE"))) {
+ /* if running as a cgi program */
+ web_set_lang(lang);
+ }
/* maybe we are running under a web server */
if (getenv("CONTENT_LENGTH") || getenv("REQUEST_METHOD")) {
@@ -559,10 +556,8 @@ void cgi_setup(char *rootdir, int auth_required)
authenticated = cgi_handle_authorization(&line[15]);
} else if (strncasecmp(line,"Content-Length: ", 16)==0) {
content_length = atoi(&line[16]);
-#if I18N_SWAT
} else if (strncasecmp(line,"Accept-Language: ", 17)==0) {
- ln_negotiate_language(&line[17]);
-#endif
+ web_set_lang(&line[17]);
}
/* ignore all other requests! */
}
diff --git a/source3/web/neg_lang.c b/source3/web/neg_lang.c
index 32f52aa473..8a5b60d99f 100644
--- a/source3/web/neg_lang.c
+++ b/source3/web/neg_lang.c
@@ -1,7 +1,7 @@
/*
Unix SMB/Netbios implementation.
- Version 1.9.
- Samba Web Administration Tool
+ Version 3.0
+ SWAT language handling
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,251 +21,47 @@
*/
#include "includes.h"
-/* #include "config.h" */
-#include "webintl.h"
-#if I18N_SWAT
-/* constants. */
-/* it is ok to make them bigger.*/
-#define LN_PREFLANG_MAX 10
-#define LN_LNAME_LENGTH 8+1+8
-
-#define LN_DEFAULT_LANG I18N_DEFAULT_LANG
-#define LN_LANGDESC_DEFAULT -1
-#define LN_NO_AVAILABLE_LANG -1
-
-/* ******************************************************************
- * macros for debugging.
- ***************************************************************** */
-#ifdef LN_R_NODEBUG
-
-#else
/*
- *#define LN_DEBUG_LOG "/tmp/lndebug.log"
- *void ln_debug_error(const char *info, int nLine)
- *{
- * FILE* fp;
- * fp = sys_fopen(LN_DEBUG_LOG, "a");
- * fprintf(fp, "%s at %d.\n", info, nLine);
- * fclose(fp);
- *}
- *void rassert_help(BOOL b, int l)
- *{
- * if(!b)
- * {
- * ln_debug_error("language negotiation error.", l);
- * exit(1);
- * }
- *}
- */
-#endif /* LN_R_NODEBUG */
-
-/* ****************************************************************
- LNNegotiator struct. It contains...
- [aPrefLang]
- the array of strings. each string is the name of
- languages ("ja", "ko"...), given by web browser.
- [nPrefLang]
- the number of the languages in aPrefLang.
- [lOriginalLang]
- == "en": indicates what language the default(original) files
- are written with.
-**************************************************************** */
-typedef char lnstring[LN_LNAME_LENGTH + 1];
-#define lnstrcpy(d,s) safe_strcpy((d),(s),sizeof(lnstring)-1)
-
-typedef struct tagLNNegotiator
-{
- lnstring aPrefLang[LN_PREFLANG_MAX];
- int nPrefLang;
- lnstring lOriginalLang;
-}LNNegotiator;
-
-/* **************************************************************
- * some access functions & macros for LNNegotiator struct.
- * ************************************************************ */
-#define ln_getPreflangCount(pLn) ((pLn)->nPrefLang)
-#define ln_getOriginalLang(pLn) ((pLn)->lOriginalLang)
-#define ln_getDefaultPrefLang(pLn) ((pLn)->lDefaultPrefLang)
-
-/* make it inline-expanded (or macro) to get better performance */
-static const char* ln_getPreflang(LNNegotiator* pLn, int i)
-{
- rassert(i == LN_LANGDESC_DEFAULT
- || (0 <= i && i < ln_getPreflangCount(pLn)));
-
- if(i == LN_LANGDESC_DEFAULT)
- return NULL;
- if(0 <= i && i < ln_getPreflangCount(pLn))
- return pLn->aPrefLang[i];
- return NULL;
-}
-/* initialize structures */
-static void ln_resetln(LNNegotiator* pLn)
-{
- pLn->nPrefLang = 0;
- /* using fixed memory.*/
-}
-static BOOL ln_addPreflang(LNNegotiator* pLn, const char* pLang)
-{
- int nPref = ln_getPreflangCount(pLn);
-
- if(nPref >= LN_PREFLANG_MAX)
- return False;
-
- lnstrcpy(pLn->aPrefLang[nPref], pLang);
- (pLn->nPrefLang)++;
- return True;
-}
-static void ln_initln_help(LNNegotiator* pLn)
-{
- ln_resetln(pLn);
- lnstrcpy(pLn->lOriginalLang, I18N_ORIGINAL_LANG);
- /* I18N_ORIGINAL_LANG = "en" is hardcoded in
- webintl.h. */
- if (I18N_DEFAULT_PREF_LANG[0] != '\0')
- ln_addPreflang(pLn, I18N_DEFAULT_PREF_LANG);
-
- /* this entry is used only when web browser didn't send
- ACCEPT-LANGUAGE header. */
-}
-/* ****************************************************************
- * store acceptable languages into LNNegotiator object.
- * [pstrLangarray] The arguments of "accept-language" http header,
- * which is like "en-GB, es;q=0.5, ja". "q=0.5" is called quality value,
- * but it is ignored now. wiled card "*" is also ignored.
- ***************************************************************** */
-static BOOL ln_negotiate_language_help( LNNegotiator* pLn, const char* pstrLangarray )
+ during a file download we first check to see if there is a language
+ specific file available. If there is then use that, otherwise
+ just open the specified file
+*/
+int web_open(const char *fname, int flags, mode_t mode)
{
- char* pToken;
- const char* pDelim = " \n\r\t,;";
- pstring strBuffer;
-
- rassert(pstrLangarray);
- rassert(pLn);
-
- ln_resetln(pLn);
- pstrcpy(strBuffer, pstrLangarray);
- pToken = strtok(strBuffer, pDelim);
- while(pToken != NULL)
- {
- if(strncmp(pToken, "q=", strlen("q=")) == 0)
- {
- pToken = strtok(NULL, pDelim);
- continue;
+ char *p = NULL;
+ char *lang = lang_tdb_current();
+ int fd;
+ if (lang) {
+ asprintf(&p, "lang/%s/%s", lang, fname);
+ if (p) {
+ fd = sys_open(p, flags, mode);
+ free(p);
+ if (fd != -1) {
+ return fd;
+ }
}
- if(!ln_addPreflang(pLn, pToken))
- break;
- pToken = strtok(NULL, pDelim);
}
- rassert(ln_getPreflangCount(pLn) != 0);
- return (ln_getPreflangCount(pLn) != 0);
-}
-
-/* **************************************************************
- initialize gettext. Before this, cgi_setup() should be done.
- cgi_setup() calls ln_negotiate_language() if the user specifies
- languages in web browser. Then, ln_set_pref_language() will work.
- ************************************************************* */
-static BOOL ln_init_lang_env_help(LNNegotiator* pLn)
-{
-#if I18N_GETTEXT
- int nLang;
- nLang = ln_set_pref_language(pLn);
- rstrace(getenv("LANGUAGE"));
-#endif /* I18N_GETTEXT */
- return True;
+ /* fall through to default name */
+ return sys_open(fname, flags, mode);
}
-/* *****************************************************************
- * This function searches for the "PrefLang" version of pFile.
- * if not available, returns pFile.
- * [pFile] the filename.
- * [pst] the address of a struct. it will be filled with the information
- * of the file.
- * [pLangDesc] The address of an integer. a value which indicates the
- * language of the returned value is written to the address. the value
- * is used in ln_get_lang().
- * [return value] address of the name of the language version of the file.
- * It is static object so it will be destroyed at the time ln_get_pref_file()
- * is called.
- **************************************************************** */
-static void ln_make_filename( pstring afname, const char* pFile, const char* pAdd )
-{
-#if LANG_PREFIX
- /* LANG_PREFIX is already undefined, maybe removed soon */
- /* maybe, foo.html.ja */
- pstrcpy(afname, pFile);
- pstrcat(afname, ".");
- pstrcat(afname, pAdd);
-#else
- /* maybe, lang/ja/foo.html */
- pstrcpy(afname, "lang/");
- pstrcat(afname, pAdd);
- pstrcat(afname, "/");
- pstrcat(afname, pFile);
-#endif
-}
-static const char* ln_get_pref_file_help(
- LNNegotiator* pLn, const char* pFile,
- SMB_STRUCT_STAT* pst, int* pLangDesc)
-{
- static pstring afname;
- int i;
- for(i = 0; i < ln_getPreflangCount(pLn); i++)
- {
- if(strcmp(ln_getPreflang(pLn, i), ln_getOriginalLang(pLn))
- == 0)
- break;
- ln_make_filename(afname, pFile, ln_getPreflang(pLn, i));
- if(file_exist(afname, pst))
- {
- *pLangDesc = i;
- return afname;
- }
- }
- pstrcpy(afname, pFile);
- file_exist(afname, pst);
- *pLangDesc = LN_LANGDESC_DEFAULT;
- return afname;
-}
-/* *******************************************************************
- * file scope variables. this variable is not locked.
- * (not multithread-safe)
- ******************************************************************** */
-static LNNegotiator lnLanguagenegotiator;
-/* *******************************************************************
- * interfaces to the outside of this file.
- ******************************************************************** */
-void ln_initln(void)
-{
- ln_initln_help(&lnLanguagenegotiator);
-}
-BOOL ln_init_lang_env(void)
-{
- return ln_init_lang_env_help(&lnLanguagenegotiator);
-}
-const char* ln_get_lang(int nLangDesc)
-{
- return ln_getPreflang(&lnLanguagenegotiator, nLangDesc);
-}
-const char* ln_get_pref_file(const char* pFile,
- SMB_STRUCT_STAT* pst, int* pLangDesc)
-{
- return ln_get_pref_file_help(
- &lnLanguagenegotiator, pFile, pst, pLangDesc);
-}
-BOOL ln_negotiate_language(const char* pstrLangarray)
-{
- return ln_negotiate_language_help(
- &lnLanguagenegotiator, pstrLangarray);
-}
-const char* ln_get_pref_file_n_o(const char* pFile)
+/*
+ choose from a list of languages. The list can be comma or space
+ separated
+ Keep choosing until we get a hit
+*/
+void web_set_lang(const char *lang_list)
{
- SMB_STRUCT_STAT st;
- int nLangDesc;
- return ln_get_pref_file(pFile, &st, &nLangDesc);
+ fstring lang;
+ char *p = (char *)lang_list;
+
+ while (next_token(&p, lang, ", \t\r\n", sizeof(lang))) {
+ if (lang_tdb_init(lang)) return;
+ }
+
+ /* it's not an error to not initialise - we just fall back to
+ the default */
}
-#endif /* I18N_SWAT */
diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c
index b49fc7b656..6af7674dc9 100644
--- a/source3/web/statuspage.c
+++ b/source3/web/statuspage.c
@@ -20,7 +20,6 @@
*/
#include "includes.h"
-#include "webintl.h"
#define PIDMAP struct PidMap
@@ -40,7 +39,7 @@ static void initPid2Machine (void)
{
/* show machine name rather PID on table "Open Files"? */
if (PID_or_Machine) {
- PIDMAP *p, *q;
+ PIDMAP *p;
for (p = pidmap; p != NULL; ) {
DLIST_REMOVE(pidmap, p);
@@ -105,41 +104,41 @@ static char *tstring(time_t t)
static void print_share_mode(share_mode_entry *e, char *fname)
{
- printf("<tr><td>%s</td>",_(mapPid2Machine(e->pid)));
- printf("<td>");
+ d_printf("<tr><td>%s</td>",_(mapPid2Machine(e->pid)));
+ d_printf("<td>");
switch ((e->share_mode>>4)&0xF) {
- case DENY_NONE: printf(_("DENY_NONE")); break;
- case DENY_ALL: printf(_("DENY_ALL ")); break;
- case DENY_DOS: printf(_("DENY_DOS ")); break;
- case DENY_READ: printf(_("DENY_READ ")); break;
- case DENY_WRITE:printf(_("DENY_WRITE ")); break;
+ case DENY_NONE: d_printf("DENY_NONE"); break;
+ case DENY_ALL: d_printf("DENY_ALL "); break;
+ case DENY_DOS: d_printf("DENY_DOS "); break;
+ case DENY_READ: d_printf("DENY_READ "); break;
+ case DENY_WRITE:d_printf("DENY_WRITE "); break;
}
- printf("</td>");
+ d_printf("</td>");
- printf("<td>");
+ d_printf("<td>");
switch (e->share_mode&0xF) {
- case 0: printf(_("RDONLY ")); break;
- case 1: printf(_("WRONLY ")); break;
- case 2: printf(_("RDWR ")); break;
+ case 0: d_printf("RDONLY "); break;
+ case 1: d_printf("WRONLY "); break;
+ case 2: d_printf("RDWR "); break;
}
- printf("</td>");
+ d_printf("</td>");
- printf("<td>");
+ d_printf("<td>");
if((e->op_type &
(EXCLUSIVE_OPLOCK|BATCH_OPLOCK)) ==
(EXCLUSIVE_OPLOCK|BATCH_OPLOCK))
- printf(_("EXCLUSIVE+BATCH "));
+ d_printf("EXCLUSIVE+BATCH ");
else if (e->op_type & EXCLUSIVE_OPLOCK)
- printf(_("EXCLUSIVE "));
+ d_printf("EXCLUSIVE ");
else if (e->op_type & BATCH_OPLOCK)
- printf(_("BATCH "));
+ d_printf("BATCH ");
else if (e->op_type & LEVEL_II_OPLOCK)
- printf(_("LEVEL_II "));
+ d_printf("LEVEL_II ");
else
- printf(_("NONE "));
- printf("</td>");
+ d_printf("NONE ");
+ d_printf("</td>");
- printf("<td>%s</td><td>%s</td></tr>\n",
+ d_printf("<td>%s</td><td>%s</td></tr>\n",
fname,tstring(e->time.tv_sec));
}
@@ -179,15 +178,15 @@ static int traverse_fn2(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st
addPid2Machine (crec.pid, crec.machine);
- printf("<tr><td>%d</td><td>%s</td><td>%s</td><td>%s</td>\n",
+ d_printf("<tr><td>%d</td><td>%s</td><td>%s</td><td>%s</td>\n",
(int)crec.pid,
crec.machine,crec.addr,
tstring(crec.start));
if (geteuid() == 0) {
- printf("<td><input type=submit value=\"X\" name=\"kill_%d\"></td>\n",
+ d_printf("<td><input type=submit value=\"X\" name=\"kill_%d\"></td>\n",
(int)crec.pid);
}
- printf("</tr>\n");
+ d_printf("</tr>\n");
return 0;
}
@@ -205,7 +204,7 @@ static int traverse_fn3(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void* st
if (crec.cnum == -1 || !process_exists(crec.pid))
return 0;
- printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td><td>%s</td><td>%s</td></tr>\n",
+ d_printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%d</td><td>%s</td><td>%s</td></tr>\n",
crec.name,uidtoname(crec.uid),
gidtoname(crec.gid),(int)crec.pid,
crec.machine,
@@ -270,22 +269,22 @@ void status_page(void)
initPid2Machine ();
- printf("<H2>%s</H2>\n", _("Server Status"));
+ d_printf("<H2>%s</H2>\n", _("Server Status"));
- printf("<FORM method=post>\n");
+ d_printf("<FORM method=post>\n");
if (!autorefresh) {
- printf("<input type=submit value=\"%s\" name=autorefresh>\n", _("Auto Refresh"));
- printf("<br>%s", _("Refresh Interval: "));
- printf("<input type=text size=2 name=\"refresh_interval\" value=%d>\n",
+ d_printf("<input type=submit value=\"%s\" name=autorefresh>\n", _("Auto Refresh"));
+ d_printf("<br>%s", _("Refresh Interval: "));
+ d_printf("<input type=text size=2 name=\"refresh_interval\" value=%d>\n",
refresh_interval);
} else {
- printf("<input type=submit value=\"%s\" name=norefresh>\n", _("Stop Refreshing"));
- printf("<br>%s%d\n", _("Refresh Interval: "), refresh_interval);
- printf("<input type=hidden name=refresh value=1>\n");
+ d_printf("<input type=submit value=\"%s\" name=norefresh>\n", _("Stop Refreshing"));
+ d_printf("<br>%s%d\n", _("Refresh Interval: "), refresh_interval);
+ d_printf("<input type=hidden name=refresh value=1>\n");
}
- printf("<p>\n");
+ d_printf("<p>\n");
if (!tdb) {
/* open failure either means no connections have been
@@ -293,83 +292,83 @@ void status_page(void)
}
- printf("<table>\n");
+ d_printf("<table>\n");
- printf("<tr><td>%s</td><td>%s</td></tr>", _("version:"), VERSION);
+ d_printf("<tr><td>%s</td><td>%s</td></tr>", _("version:"), VERSION);
fflush(stdout);
- printf("<tr><td>%s</td><td>%s</td>\n", _("smbd:"), smbd_running()?_("running"):_("not running"));
+ d_printf("<tr><td>%s</td><td>%s</td>\n", _("smbd:"), smbd_running()?_("running"):_("not running"));
if (geteuid() == 0) {
if (smbd_running()) {
- printf("<td><input type=submit name=\"smbd_stop\" value=\"%s\"></td>\n", _("Stop smbd"));
+ d_printf("<td><input type=submit name=\"smbd_stop\" value=\"%s\"></td>\n", _("Stop smbd"));
} else {
- printf("<td><input type=submit name=\"smbd_start\" value=\"%s\"></td>\n", _("Start smbd"));
+ d_printf("<td><input type=submit name=\"smbd_start\" value=\"%s\"></td>\n", _("Start smbd"));
}
- printf("<td><input type=submit name=\"smbd_restart\" value=\"%s\"></td>\n", _("Restart smbd"));
+ d_printf("<td><input type=submit name=\"smbd_restart\" value=\"%s\"></td>\n", _("Restart smbd"));
}
- printf("</tr>\n");
+ d_printf("</tr>\n");
fflush(stdout);
- printf("<tr><td>%s</td><td>%s</td>\n", _("nmbd:"), nmbd_running()?_("running"):_("not running"));
+ d_printf("<tr><td>%s</td><td>%s</td>\n", _("nmbd:"), nmbd_running()?_("running"):_("not running"));
if (geteuid() == 0) {
if (nmbd_running()) {
- printf("<td><input type=submit name=\"nmbd_stop\" value=\"%s\"></td>\n", _("Stop nmbd"));
+ d_printf("<td><input type=submit name=\"nmbd_stop\" value=\"%s\"></td>\n", _("Stop nmbd"));
} else {
- printf("<td><input type=submit name=\"nmbd_start\" value=\"%s\"></td>\n", _("Start nmbd"));
+ d_printf("<td><input type=submit name=\"nmbd_start\" value=\"%s\"></td>\n", _("Start nmbd"));
}
- printf("<td><input type=submit name=\"nmbd_restart\" value=\"%s\"></td>\n", _("Restart nmbd"));
+ d_printf("<td><input type=submit name=\"nmbd_restart\" value=\"%s\"></td>\n", _("Restart nmbd"));
}
- printf("</tr>\n");
+ d_printf("</tr>\n");
- printf("</table>\n");
+ d_printf("</table>\n");
fflush(stdout);
- printf("<p><h3>%s</h3>\n", _("Active Connections"));
- printf("<table border=1>\n");
- printf("<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th>\n", _("PID"), _("Client"), _("IP address"), _("Date"));
+ d_printf("<p><h3>%s</h3>\n", _("Active Connections"));
+ d_printf("<table border=1>\n");
+ d_printf("<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th>\n", _("PID"), _("Client"), _("IP address"), _("Date"));
if (geteuid() == 0) {
- printf("<th>%s</th>\n", _("Kill"));
+ d_printf("<th>%s</th>\n", _("Kill"));
}
- printf("</tr>\n");
+ d_printf("</tr>\n");
if (tdb) tdb_traverse(tdb, traverse_fn2, NULL);
- printf("</table><p>\n");
+ d_printf("</table><p>\n");
- printf("<p><h3>%s</h3>\n", _("Active Shares"));
- printf("<table border=1>\n");
- printf("<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr>\n\n",
+ d_printf("<p><h3>%s</h3>\n", _("Active Shares"));
+ d_printf("<table border=1>\n");
+ d_printf("<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr>\n\n",
_("Share"), _("User"), _("Group"), _("PID"), _("Client"), _("Date"));
if (tdb) tdb_traverse(tdb, traverse_fn3, NULL);
- printf("</table><p>\n");
+ d_printf("</table><p>\n");
- printf("<h3>%s</h3>\n", _("Open Files"));
- printf("<table border=1>\n");
- printf("<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr>\n", _("PID"), _("Sharing"), _("R/W"), _("Oplock"), _("File"), _("Date"));
+ d_printf("<h3>%s</h3>\n", _("Open Files"));
+ d_printf("<table border=1>\n");
+ d_printf("<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr>\n", _("PID"), _("Sharing"), _("R/W"), _("Oplock"), _("File"), _("Date"));
locking_init(1);
share_mode_forall(print_share_mode);
locking_end();
- printf("</table>\n");
+ d_printf("</table>\n");
if (tdb) tdb_close(tdb);
- printf("<br><input type=submit name=\"show_client_in_col_1\" value=\"Show Client in col 1\">\n");
- printf("<input type=submit name=\"show_pid_in_col_1\" value=\"Show PID in col 1\">\n");
+ d_printf("<br><input type=submit name=\"show_client_in_col_1\" value=\"Show Client in col 1\">\n");
+ d_printf("<input type=submit name=\"show_pid_in_col_1\" value=\"Show PID in col 1\">\n");
- printf("</FORM>\n");
+ d_printf("</FORM>\n");
if (autorefresh) {
/* this little JavaScript allows for automatic refresh
of the page. There are other methods but this seems
to be the best alternative */
- printf("<script language=\"JavaScript\">\n");
- printf("<!--\nsetTimeout('window.location.replace(\"%s/status?refresh_interval=%d&refresh=1\")', %d)\n",
+ d_printf("<script language=\"JavaScript\">\n");
+ d_printf("<!--\nsetTimeout('window.location.replace(\"%s/status?refresh_interval=%d&refresh=1\")', %d)\n",
cgi_baseurl(),
refresh_interval,
refresh_interval*1000);
- printf("//-->\n</script>\n");
+ d_printf("//-->\n</script>\n");
}
}
diff --git a/source3/web/swat.c b/source3/web/swat.c
index a6286dc93b..3deaafbc76 100644
--- a/source3/web/swat.c
+++ b/source3/web/swat.c
@@ -19,13 +19,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifdef SYSLOG
-#undef SYSLOG
-#endif
-
#include "includes.h"
-#include "smb.h"
-#include "webintl.h"
#define GLOBALS_SNUM -1
@@ -110,24 +104,22 @@ static char *make_parm_name(char *label)
****************************************************************************/
static int include_html(char *fname)
{
- FILE *f;
+ int fd;
char buf[1024];
int ret;
- f = sys_fopen((char*)LN_(fname), "r");
+ fd = web_open(fname, O_RDONLY, 0);
- if (!f) {
- d_printf(_("ERROR: Can't open %s\n"), fname);
+ if (fd == -1) {
+ d_printf("ERROR: Can't open %s\n", fname);
return 0;
}
- while (!feof(f)) {
- ret = fread(buf, 1, sizeof(buf), f);
- if (ret <= 0) break;
- fwrite(buf, 1, ret, stdout);
+ while ((ret = read(fd, buf, sizeof(buf))) > 0) {
+ write(1, buf, ret);
}
- fclose(f);
+ close(fd);
return 1;
}
@@ -475,7 +467,7 @@ static void commit_parameters(int snum)
/****************************************************************************
spit out the html for a link with an image
****************************************************************************/
-static void image_link(char *name,char *hlink, char *src)
+static void image_link(const char *name, const char *hlink, const char *src)
{
d_printf("<A HREF=\"%s/%s\"><img border=\"0\" src=\"/swat/%s\" alt=\"%s\"></A>\n",
cgi_baseurl(), hlink, src, name);
@@ -1045,6 +1037,8 @@ static void printers_page(void)
/* just in case it goes wild ... */
alarm(300);
+ setlinebuf(stdout);
+
/* we don't want any SIGPIPE messages */
BlockSignals(True,SIGPIPE);
@@ -1071,14 +1065,8 @@ static void printers_page(void)
iNumNonAutoPrintServices = lp_numservices();
load_printers();
-#if I18N_SWAT
- ln_initln();
- cgi_setup(SWATDIR, !demo_mode);
- ln_init_lang_env();
-#else
cgi_setup(SWATDIR, !demo_mode);
-#endif
print_header();
cgi_load_variables();