summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>1999-04-24 00:12:00 +0000
committerZeev Suraski <zeev@php.net>1999-04-24 00:12:00 +0000
commit0818d96c97ceec4dbb8251c5220a2fdcdf39f355 (patch)
treec56f529e445e4bee928e7c28e0ccbb7f67572f16 /win32
parent05d24c60223439b94d4100538331fb6749022ca3 (diff)
downloadphp-git-0818d96c97ceec4dbb8251c5220a2fdcdf39f355.tar.gz
A lot of cleanups... Removed old thread-safe code and other redundant code and files
Diffstat (limited to 'win32')
-rw-r--r--win32/pwd.c12
-rw-r--r--win32/sendmail.c55
-rw-r--r--win32/time.c15
-rw-r--r--win32/wsyslog.c19
4 files changed, 43 insertions, 58 deletions
diff --git a/win32/pwd.c b/win32/pwd.c
index 27194a7874..73c4b62c95 100644
--- a/win32/pwd.c
+++ b/win32/pwd.c
@@ -57,14 +57,12 @@ char *getlogin()
struct passwd *
getpwuid(int uid)
{
- TLS_VARS;
+ pw.pw_name = getlogin();
+ pw.pw_dir = home_dir;
+ pw.pw_shell = login_shell;
+ pw.pw_uid = 0;
- GLOBAL(pw).pw_name = getlogin();
- GLOBAL(pw).pw_dir = home_dir;
- GLOBAL(pw).pw_shell = login_shell;
- GLOBAL(pw).pw_uid = 0;
-
- return &GLOBAL(pw);
+ return &pw;
}
/*
diff --git a/win32/sendmail.c b/win32/sendmail.c
index 2889676a90..fbc76752ba 100644
--- a/win32/sendmail.c
+++ b/win32/sendmail.c
@@ -109,9 +109,8 @@ int TSendMail(char *host, int *error,
{
int ret;
char *RPath = NULL;
- TLS_VARS;
- GLOBAL(WinsockStarted) = FALSE;
+ WinsockStarted = FALSE;
if (host == NULL) {
*error = BAD_MAIL_HOST;
@@ -120,7 +119,7 @@ int TSendMail(char *host, int *error,
*error = BAD_MAIL_HOST;
return BAD_MAIL_HOST;
} else {
- strcpy(GLOBAL(MailHost), host);
+ strcpy(MailHost, host);
}
if (INI_STR("sendmail_from")){
@@ -155,8 +154,6 @@ int TSendMail(char *host, int *error,
//********************************************************************
void TSMClose()
{
- TLS_VARS;
-
Post("QUIT\n");
Ack();
// to guarantee that the cleanup is not made twice and
@@ -202,7 +199,6 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers
int res, i;
char *p;
- TLS_VARS;
// check for NULL parameters
if (data == NULL)
@@ -217,27 +213,27 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers
if (strchr(mailTo, '@') == NULL)
return (BAD_MSG_DESTINATION);
- sprintf(GLOBAL(Buffer), "HELO %s\n", GLOBAL(LocalHost));
+ sprintf(Buffer, "HELO %s\n", LocalHost);
// in the beggining of the dialog
// attempt reconnect if the first Post fail
- if ((res = Post(GLOBAL(Buffer))) != SUCCESS) {
+ if ((res = Post(Buffer)) != SUCCESS) {
MailConnect();
- if ((res = Post(GLOBAL(Buffer))) != SUCCESS)
+ if ((res = Post(Buffer)) != SUCCESS)
return (res);
}
if ((res = Ack()) != SUCCESS)
return (res);
- sprintf(GLOBAL(Buffer), "MAIL FROM:<%s>\n", RPath);
- if ((res = Post(GLOBAL(Buffer))) != SUCCESS)
+ sprintf(Buffer, "MAIL FROM:<%s>\n", RPath);
+ if ((res = Post(Buffer)) != SUCCESS)
return (res);
if ((res = Ack()) != SUCCESS)
return (res);
- sprintf(GLOBAL(Buffer), "RCPT TO:<%s>\n", mailTo);
- if ((res = Post(GLOBAL(Buffer))) != SUCCESS)
+ sprintf(Buffer, "RCPT TO:<%s>\n", mailTo);
+ if ((res = Post(Buffer)) != SUCCESS)
return (res);
if ((res = Ack()) != SUCCESS)
return (res);
@@ -272,12 +268,12 @@ int SendText(char *RPath, char *Subject, char *mailTo, char *data, char *headers
i = strlen(p);
// put next chunk in buffer
- strncpy(GLOBAL(Buffer), p, i);
- GLOBAL(Buffer)[i] = '\0';
+ strncpy(Buffer, p, i);
+ Buffer[i] = '\0';
p += i;
// send chunk
- if ((res = Post(GLOBAL(Buffer))) != SUCCESS)
+ if ((res = Post(Buffer)) != SUCCESS)
return (res);
}
}
@@ -315,9 +311,8 @@ int PostHeader(char *RPath, char *Subject, char *mailTo, char *xheaders)
int zoneh = abs(_timezone);
int zonem, res;
char *p;
- TLS_VARS;
- p = GLOBAL(Buffer);
+ p = Buffer;
zoneh /= (60 * 60);
zonem = (abs(_timezone) / 60) - (zoneh * 60);
@@ -342,7 +337,7 @@ int PostHeader(char *RPath, char *Subject, char *mailTo, char *xheaders)
p += sprintf(p, "%s\r\n", xheaders);
}
- if ((res = Post(GLOBAL(Buffer))) != SUCCESS)
+ if ((res = Post(Buffer)) != SUCCESS)
return (res);
if ((res = Post("\r\n")) != SUCCESS)
@@ -365,29 +360,27 @@ int MailConnect()
{
int res;
- TLS_VARS;
-
// Create Socket
- if ((GLOBAL(sc) = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
+ if ((sc = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
return (FAILED_TO_OBTAIN_SOCKET_HANDLE);
// Get our own host name
- if (gethostname(GLOBAL(LocalHost), HOST_NAME_LEN))
+ if (gethostname(LocalHost, HOST_NAME_LEN))
return (FAILED_TO_GET_HOSTNAME);
// Resolve the servers IP
- //if (!isdigit(GLOBAL(MailHost)[0])||!gethostbyname(GLOBAL(MailHost)))
+ //if (!isdigit(MailHost[0])||!gethostbyname(MailHost))
//{
// return (FAILED_TO_RESOLVE_HOST);
//}
// Connect to server
- GLOBAL(sock_in).sin_family = AF_INET;
- GLOBAL(sock_in).sin_port = htons(25);
- GLOBAL(sock_in).sin_addr.S_un.S_addr = GetAddr(GLOBAL(MailHost));
+ sock_in.sin_family = AF_INET;
+ sock_in.sin_port = htons(25);
+ sock_in.sin_addr.S_un.S_addr = GetAddr(MailHost);
- if (connect(GLOBAL(sc), (LPSOCKADDR) & GLOBAL(sock_in), sizeof(GLOBAL(sock_in))))
+ if (connect(sc, (LPSOCKADDR) & sock_in, sizeof(sock_in)))
return (FAILED_TO_CONNECT);
// receive Server welcome message
@@ -413,10 +406,9 @@ int Post(LPCSTR msg)
int len = strlen(msg);
int slen;
int index = 0;
- TLS_VARS;
while (len > 0) {
- if ((slen = send(GLOBAL(sc), msg + index, len, 0)) < 1)
+ if ((slen = send(sc, msg + index, len, 0)) < 1)
return (FAILED_TO_SEND);
len -= slen;
index += slen;
@@ -442,7 +434,6 @@ int Ack()
int rlen;
int Index = 0;
int Received = 0;
- TLS_VARS;
if (!buf)
if ((buf = (char *) malloc(1024 * 4)) == NULL)
@@ -450,7 +441,7 @@ int Ack()
again:
- if ((rlen = recv(GLOBAL(sc), buf + Index, ((1024 * 4) - 1) - Received, 0)) < 1)
+ if ((rlen = recv(sc, buf + Index, ((1024 * 4) - 1) - Received, 0)) < 1)
return (FAILED_TO_RECEIVE);
Received += rlen;
diff --git a/win32/time.c b/win32/time.c
index c48315e3e4..ea0e2d1acb 100644
--- a/win32/time.c
+++ b/win32/time.c
@@ -101,10 +101,9 @@ int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue
{
int timeout = value->it_value.tv_sec * 1000 + value->it_value.tv_usec;
int repeat = TIME_ONESHOT;
- TLS_VARS;
/*make sure the message queue is initialized */
- PeekMessage(GLOBAL(phpmsg), NULL, WM_USER, WM_USER, PM_NOREMOVE);
+ PeekMessage(phpmsg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
if (timeout > 0) {
struct timer_msg *msg = malloc(sizeof(struct timer_msg));
msg->threadid = GetCurrentThreadId();
@@ -114,15 +113,15 @@ int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue
switch (which) {
case ITIMER_REAL:
msg->signal = SIGALRM;
- GLOBAL(realtimer) = timeSetEvent(timeout, 100, (LPTIMECALLBACK) setitimer_timeout, (UINT) msg, repeat);
+ realtimer = timeSetEvent(timeout, 100, (LPTIMECALLBACK) setitimer_timeout, (UINT) msg, repeat);
break;
case ITIMER_VIRT:
msg->signal = SIGVTALRM;
- GLOBAL(virttimer) = timeSetEvent(timeout, 100, (LPTIMECALLBACK) setitimer_timeout, (UINT) msg, repeat);
+ virttimer = timeSetEvent(timeout, 100, (LPTIMECALLBACK) setitimer_timeout, (UINT) msg, repeat);
break;
case ITIMER_PROF:
msg->signal = SIGPROF;
- GLOBAL(proftimer) = timeSetEvent(timeout, 100, (LPTIMECALLBACK) setitimer_timeout, (UINT) msg, repeat);
+ proftimer = timeSetEvent(timeout, 100, (LPTIMECALLBACK) setitimer_timeout, (UINT) msg, repeat);
break;
default:
errno = EINVAL;
@@ -132,13 +131,13 @@ int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue
} else {
switch (which) {
case ITIMER_REAL:
- timeKillEvent(GLOBAL(realtimer));
+ timeKillEvent(realtimer);
break;
case ITIMER_VIRT:
- timeKillEvent(GLOBAL(virttimer));
+ timeKillEvent(virttimer);
break;
case ITIMER_PROF:
- timeKillEvent(GLOBAL(proftimer));
+ timeKillEvent(proftimer);
break;
default:
errno = EINVAL;
diff --git a/win32/wsyslog.c b/win32/wsyslog.c
index 701eeed913..616b6f8a07 100644
--- a/win32/wsyslog.c
+++ b/win32/wsyslog.c
@@ -63,9 +63,8 @@ static HANDLE loghdl = NULL; /* handle of event source */
void closelog(void)
{
- TLS_VARS;
- DeregisterEventSource(GLOBAL(loghdl));
- efree(GLOBAL(loghdr));
+ DeregisterEventSource(loghdl);
+ efree(loghdr);
}
/* Emulator for BSD syslog() routine
@@ -80,10 +79,9 @@ void syslog(int priority, const char *message,...)
LPTSTR strs[2];
char tmp[1024]; /* callers must be careful not to pop this */
unsigned short etype;
- TLS_VARS;
/* default event source */
- if (!GLOBAL(loghdl))
+ if (!loghdl)
openlog("c-client", LOG_PID, LOG_MAIL);
switch (priority) { /* translate UNIX type into NT type */
case LOG_ALERT:
@@ -97,10 +95,10 @@ void syslog(int priority, const char *message,...)
}
va_start(args, message); /* initialize vararg mechanism */
vsprintf(tmp, message, args); /* build message */
- strs[0] = GLOBAL(loghdr); /* write header */
+ strs[0] = loghdr; /* write header */
strs[1] = tmp; /* then the message */
/* report the event */
- ReportEvent(GLOBAL(loghdl), etype, (unsigned short) priority, 2000, NULL, 2, 0, strs, NULL);
+ ReportEvent(loghdl, etype, (unsigned short) priority, 2000, NULL, 2, 0, strs, NULL);
va_end(args);
}
@@ -114,12 +112,11 @@ void syslog(int priority, const char *message,...)
void openlog(const char *ident, int logopt, int facility)
{
char tmp[1024];
- TLS_VARS;
- if (GLOBAL(loghdl)) {
+ if (loghdl) {
closelog();
}
- GLOBAL(loghdl) = RegisterEventSource(NULL, ident);
+ loghdl = RegisterEventSource(NULL, ident);
sprintf(tmp, (logopt & LOG_PID) ? "%s[%d]" : "%s", ident, getpid());
- GLOBAL(loghdr) = estrdup(tmp); /* save header for later */
+ loghdr = estrdup(tmp); /* save header for later */
}