mirror of https://github.com/nginx/nginx
parent
b533e98252
commit
bd91999ea5
|
Before Width: | Height: | Size: 198 B |
@ -1,24 +0,0 @@ |
||||
/* XPM */ |
||||
static char * nginx_xpm[] = { |
||||
"16 16 2 2", |
||||
/* colors */ |
||||
" c none", |
||||
"GG c #008000", |
||||
/* pixels */ |
||||
" ", |
||||
" GGGGGGGGGGGGGGGG ", |
||||
" GGGGGGGGGGGGGGGG ", |
||||
" GGGGGGGGGGGGGGGGGGGG ", |
||||
" GGGGGG GGGGGG ", |
||||
" GGGGGG GGGGGG ", |
||||
" GGGGGG ", |
||||
" GGGGGG GGGGGGGGGGGGGGGG ", |
||||
" GGGGGG GGGGGGGGGGGGGGGGGG ", |
||||
" GGGGGG GGGGGGGGGGGGGG ", |
||||
" GGGGGG GGGGGG ", |
||||
" GGGGGG GGGGGG ", |
||||
" GGGGGGGGGGGGGGGGGGGG ", |
||||
" GGGGGGGGGGGGGGGG ", |
||||
" GGGGGGGGGGGGGGGG ", |
||||
" " |
||||
}; |
||||
@ -0,0 +1,116 @@ |
||||
/*
|
||||
* Copyright (C) Igor Sysoev |
||||
*/ |
||||
|
||||
|
||||
#include <ngx_config.h> |
||||
#include <ngx_core.h> |
||||
|
||||
|
||||
#define NGX_MAX_ERROR_STR 2048 |
||||
|
||||
|
||||
void ngx_cdecl |
||||
ngx_event_log(ngx_err_t err, const char *fmt, ...) |
||||
{ |
||||
u_char *p, *last; |
||||
long types; |
||||
HKEY key; |
||||
HANDLE ev; |
||||
va_list args; |
||||
u_char text[NGX_MAX_ERROR_STR]; |
||||
const char *msgarg[9]; |
||||
static u_char netmsg[] = "%SystemRoot%\\System32\\netmsg.dll"; |
||||
|
||||
p = text + GetModuleFileName(NULL, (char *) text, NGX_MAX_ERROR_STR - 50); |
||||
|
||||
*p++ = ':'; |
||||
ngx_linefeed(p); |
||||
|
||||
va_start(args, fmt); |
||||
p = ngx_vsnprintf(p, NGX_MAX_ERROR_STR, fmt, args); |
||||
va_end(args); |
||||
|
||||
last = text + NGX_MAX_ERROR_STR; |
||||
|
||||
if (err) { |
||||
|
||||
if (p > last - 50) { |
||||
|
||||
/* leave a space for an error code */ |
||||
|
||||
p = last - 50; |
||||
*p++ = '.'; |
||||
*p++ = '.'; |
||||
*p++ = '.'; |
||||
} |
||||
|
||||
p = ngx_snprintf(p, last - p, ((unsigned) err < 0x80000000) |
||||
? " (%d: " : " (%Xd: ", err); |
||||
p = ngx_strerror_r(err, p, last - p); |
||||
|
||||
if (p < last) { |
||||
*p++ = ')'; |
||||
} |
||||
} |
||||
|
||||
if (p > last - NGX_LINEFEED_SIZE - 1) { |
||||
p = last - NGX_LINEFEED_SIZE - 1; |
||||
} |
||||
|
||||
ngx_linefeed(p); |
||||
|
||||
*p = '\0'; |
||||
|
||||
/*
|
||||
* we do not log errors here since we use |
||||
* Event Log only to log our own logs open errors |
||||
*/ |
||||
|
||||
if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, |
||||
"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\nginx", |
||||
0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &key, NULL) |
||||
!= 0) |
||||
{ |
||||
return; |
||||
} |
||||
|
||||
if (RegSetValueEx(key, "EventMessageFile", 0, REG_EXPAND_SZ, |
||||
netmsg, sizeof(netmsg) - 1) |
||||
!= 0) |
||||
{ |
||||
return; |
||||
} |
||||
|
||||
types = EVENTLOG_ERROR_TYPE; |
||||
|
||||
if (RegSetValueEx(key, "TypesSupported", 0, REG_DWORD, |
||||
(u_char *) &types, sizeof(long)) |
||||
!= 0) |
||||
{ |
||||
return; |
||||
} |
||||
|
||||
RegCloseKey(key); |
||||
|
||||
ev = RegisterEventSource(NULL, "nginx"); |
||||
|
||||
msgarg[0] = (char *) text; |
||||
msgarg[1] = NULL; |
||||
msgarg[2] = NULL; |
||||
msgarg[3] = NULL; |
||||
msgarg[4] = NULL; |
||||
msgarg[5] = NULL; |
||||
msgarg[6] = NULL; |
||||
msgarg[7] = NULL; |
||||
msgarg[8] = NULL; |
||||
|
||||
/*
|
||||
* the 3299 event id in netmsg.dll has the generic message format: |
||||
* "%1 %2 %3 %4 %5 %6 %7 %8 %9" |
||||
*/ |
||||
|
||||
ReportEvent(ev, EVENTLOG_ERROR_TYPE, 0, 3299, NULL, 9, 0, msgarg, NULL); |
||||
|
||||
DeregisterEventSource(ev); |
||||
} |
||||
@ -1,81 +0,0 @@ |
||||
|
||||
/*
|
||||
* Copyright (C) Igor Sysoev |
||||
*/ |
||||
|
||||
|
||||
#include <ngx_config.h> |
||||
#include <ngx_core.h> |
||||
|
||||
|
||||
#define NGX_MAX_TEXT 2048 |
||||
|
||||
|
||||
void __cdecl |
||||
ngx_message_box(char *title, ngx_uint_t type, ngx_err_t err, |
||||
const char *fmt, ...) |
||||
{ |
||||
va_list args; |
||||
u_char text[NGX_MAX_TEXT], *p, *last; |
||||
|
||||
last = text + NGX_MAX_TEXT; |
||||
|
||||
va_start(args, fmt); |
||||
p = ngx_vsnprintf(text, NGX_MAX_TEXT, fmt, args); |
||||
va_end(args); |
||||
|
||||
if (err) { |
||||
|
||||
if (p > last - 50) { |
||||
|
||||
/* leave a space for an error code */ |
||||
|
||||
p = last - 50; |
||||
*p++ = '.'; |
||||
*p++ = '.'; |
||||
*p++ = '.'; |
||||
} |
||||
|
||||
p = ngx_snprintf(p, last - p, ((unsigned) err < 0x80000000) |
||||
? " (%d: " : " (%Xd: ", err); |
||||
p = ngx_strerror_r(err, p, last - p); |
||||
|
||||
if (p < last) { |
||||
*p++ = ')'; |
||||
} |
||||
} |
||||
|
||||
if (p == last) { |
||||
p--; |
||||
} |
||||
|
||||
*p = '\0'; |
||||
|
||||
MessageBox(NULL, (char *) text, title, type); |
||||
} |
||||
|
||||
|
||||
ngx_int_t |
||||
ngx_system_tray_icon(HWND window, u_long action, HICON icon, u_char *tip) |
||||
{ |
||||
NOTIFYICONDATA ni; |
||||
|
||||
ni.cbSize = sizeof(NOTIFYICONDATA); |
||||
ni.hWnd = window; |
||||
ni.uID = 0; |
||||
ni.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP; |
||||
ni.uCallbackMessage = NGX_WM_TRAY; |
||||
ni.hIcon = icon; |
||||
|
||||
if (tip) { |
||||
ngx_cpystrn((u_char *) ni.szTip, tip, 64); |
||||
} else { |
||||
ni.szTip[0] = '\0'; |
||||
} |
||||
|
||||
if (Shell_NotifyIcon(action, &ni) == 0) { |
||||
return NGX_ERROR; |
||||
} |
||||
|
||||
return NGX_OK; |
||||
} |
||||
@ -1,23 +0,0 @@ |
||||
|
||||
/*
|
||||
* Copyright (C) Igor Sysoev |
||||
*/ |
||||
|
||||
|
||||
#ifndef _NGX_GUI_H_INCLUDED_ |
||||
#define _NGX_GUI_H_INCLUDED_ |
||||
|
||||
|
||||
#include <ngx_config.h> |
||||
#include <ngx_core.h> |
||||
#include <ngx_gui_resources.h> |
||||
|
||||
|
||||
void ngx_cdecl ngx_message_box(char *title, ngx_uint_t type, ngx_err_t err, |
||||
const char *fmt, ...); |
||||
|
||||
ngx_int_t ngx_system_tray_icon(HWND window, u_long action, |
||||
HICON icon, u_char *tip); |
||||
|
||||
|
||||
#endif /* _NGX_GUI_H_INCLUDED_ */ |
||||
@ -1,19 +0,0 @@ |
||||
|
||||
/*
|
||||
* Copyright (C) Igor Sysoev |
||||
*/ |
||||
|
||||
|
||||
#ifndef _NGX_GUI_RESOURCES_H_INCLUDED_ |
||||
#define _NGX_GUI_RESOURCES_H_INCLUDED_ |
||||
|
||||
|
||||
#include <winuser.h> |
||||
|
||||
|
||||
#define NGX_WM_TRAY WM_USER |
||||
#define NGX_WM_EXIT WM_USER + 1 |
||||
#define NGX_WM_ABOUT WM_USER + 2 |
||||
|
||||
|
||||
#endif /* _NGX_GUI_RESOURCES_H_INCLUDED_ */ |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,183 @@ |
||||
|
||||
/*
|
||||
* Copyright (C) Igor Sysoev |
||||
*/ |
||||
|
||||
|
||||
#include <ngx_config.h> |
||||
#include <ngx_core.h> |
||||
#include <ngx_event.h> |
||||
|
||||
|
||||
ssize_t |
||||
ngx_wsasend(ngx_connection_t *c, u_char *buf, size_t size) |
||||
{ |
||||
int n; |
||||
u_long sent; |
||||
ngx_err_t err; |
||||
ngx_event_t *wev; |
||||
WSABUF wsabuf; |
||||
|
||||
wev = c->write; |
||||
|
||||
if (!wev->ready) { |
||||
return NGX_AGAIN; |
||||
} |
||||
|
||||
/*
|
||||
* WSABUF must be 4-byte aligned otherwise |
||||
* WSASend() will return undocumented WSAEINVAL error. |
||||
*/ |
||||
|
||||
wsabuf.buf = (char *) buf; |
||||
wsabuf.len = size; |
||||
|
||||
sent = 0; |
||||
|
||||
n = WSASend(c->fd, &wsabuf, 1, &sent, 0, NULL, NULL); |
||||
|
||||
ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0, |
||||
"WSASend: fd:%d, %d, %ul of %uz", c->fd, n, sent, size); |
||||
|
||||
if (n == 0) { |
||||
if (sent < size) { |
||||
wev->ready = 0; |
||||
} |
||||
|
||||
c->sent += sent; |
||||
|
||||
return sent; |
||||
} |
||||
|
||||
err = ngx_socket_errno; |
||||
|
||||
if (err == WSAEWOULDBLOCK) { |
||||
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err, "WSASend() not ready"); |
||||
return NGX_AGAIN; |
||||
} |
||||
|
||||
wev->error = 1; |
||||
ngx_connection_error(c, err, "WSASend() failed"); |
||||
|
||||
return NGX_ERROR; |
||||
} |
||||
|
||||
|
||||
ssize_t |
||||
ngx_overlapped_wsasend(ngx_connection_t *c, u_char *buf, size_t size) |
||||
{ |
||||
int n; |
||||
u_long sent; |
||||
ngx_err_t err; |
||||
ngx_event_t *wev; |
||||
LPWSAOVERLAPPED ovlp; |
||||
WSABUF wsabuf; |
||||
|
||||
wev = c->write; |
||||
|
||||
if (!wev->ready) { |
||||
return NGX_AGAIN; |
||||
} |
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
||||
"wev->complete: %d", wev->complete); |
||||
|
||||
if (!wev->complete) { |
||||
|
||||
/* post the overlapped WSASend() */ |
||||
|
||||
/*
|
||||
* WSABUFs must be 4-byte aligned otherwise |
||||
* WSASend() will return undocumented WSAEINVAL error. |
||||
*/ |
||||
|
||||
wsabuf.buf = (char *) buf; |
||||
wsabuf.len = size; |
||||
|
||||
sent = 0; |
||||
|
||||
ovlp = (LPWSAOVERLAPPED) &c->write->ovlp; |
||||
ngx_memzero(ovlp, sizeof(WSAOVERLAPPED)); |
||||
|
||||
n = WSASend(c->fd, &wsabuf, 1, &sent, 0, ovlp, NULL); |
||||
|
||||
ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0, |
||||
"WSASend: fd:%d, %d, %ul of %uz", c->fd, n, sent, size); |
||||
|
||||
wev->complete = 0; |
||||
|
||||
if (n == 0) { |
||||
if (ngx_event_flags & NGX_USE_IOCP_EVENT) { |
||||
|
||||
/*
|
||||
* if a socket was bound with I/O completion port then |
||||
* GetQueuedCompletionStatus() would anyway return its status |
||||
* despite that WSASend() was already complete |
||||
*/ |
||||
|
||||
wev->active = 1; |
||||
return NGX_AGAIN; |
||||
} |
||||
|
||||
if (sent < size) { |
||||
wev->ready = 0; |
||||
} |
||||
|
||||
c->sent += sent; |
||||
|
||||
return sent; |
||||
} |
||||
|
||||
err = ngx_socket_errno; |
||||
|
||||
if (err == WSA_IO_PENDING) { |
||||
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err, |
||||
"WSASend() posted"); |
||||
wev->active = 1; |
||||
return NGX_AGAIN; |
||||
} |
||||
|
||||
wev->error = 1; |
||||
ngx_connection_error(c, err, "WSASend() failed"); |
||||
|
||||
return NGX_ERROR; |
||||
} |
||||
|
||||
/* the overlapped WSASend() complete */ |
||||
|
||||
wev->complete = 0; |
||||
wev->active = 0; |
||||
|
||||
if (ngx_event_flags & NGX_USE_IOCP_EVENT) { |
||||
|
||||
if (wev->ovlp.error) { |
||||
ngx_connection_error(c, wev->ovlp.error, "WSASend() failed"); |
||||
return NGX_ERROR; |
||||
} |
||||
|
||||
sent = wev->available; |
||||
|
||||
} else { |
||||
if (WSAGetOverlappedResult(c->fd, (LPWSAOVERLAPPED) &wev->ovlp, |
||||
&sent, 0, NULL) |
||||
== 0) |
||||
{ |
||||
ngx_connection_error(c, ngx_socket_errno, |
||||
"WSASend() or WSAGetOverlappedResult() failed"); |
||||
|
||||
return NGX_ERROR; |
||||
} |
||||
} |
||||
|
||||
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
||||
"WSAGetOverlappedResult: fd:%d, %ul of %uz", |
||||
c->fd, sent, size); |
||||
|
||||
if (sent < size) { |
||||
wev->ready = 0; |
||||
} |
||||
|
||||
c->sent += sent; |
||||
|
||||
return sent; |
||||
} |
||||
Loading…
Reference in new issue