source: lab/vendor/utvpn/utvpn-unix-v101-7101-public/src/Mayaqua/Unix.h @ 146

Last change on this file since 146 was 146, checked in by mitty, 12 years ago
  • tar xzf utvpn-src-unix-v101-7101-public-2010.06.27.tar.gz
File size: 9.8 KB
Line 
1// SoftEther UT-VPN SourceCode
2//
3// Copyright (C) 2004-2010 SoftEther Corporation.
4// Copyright (C) 2004-2010 University of Tsukuba, Japan.
5// Copyright (C) 2003-2010 Daiyuu Nobori.
6// All Rights Reserved.
7//
8// http://utvpn.tsukuba.ac.jp/
9//
10// This program is free software; you can redistribute it and/or
11// modify it under the terms of the GNU General Public License
12// version 2 as published by the Free Software Foundation.
13//
14// This program is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17// GNU General Public License for more details.
18//
19// You should have received a copy of the GNU General Public License version 2
20// along with this program; if not, write to the Free Software
21// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22//
23// このファイルは GPL バージョン 2 ライセンスで公開されています。
24// 誰でもこのファイルの内容を複製、改変したり、改変したバージョンを再配布
25// することができます。ただし、原著作物を改変した場合は、原著作物の著作権表示
26// を除去することはできません。改変した著作物を配布する場合は、改変実施者の
27// 著作権表示を原著作物の著作権表示に付随して記載するようにしてください。
28//
29// この SoftEther UT-VPN オープンソース・プロジェクトは、日本国の
30// ソフトイーサ株式会社 (SoftEther Corporation, http://www.softether.co.jp/ )
31// および筑波大学 (University of Tsukuba, http://www.tsukuba.ac.jp/ ) によって
32// ホストされています。
33// 本プログラムの配布者は、本プログラムを、業としての利用以外のため、
34// および、試験または研究のために利用が行われることを想定して配布
35// しています。
36// SoftEther UT-VPN プロジェクトの Web サイトは http://utvpn.tsukuba.ac.jp/ に
37// あります。
38// 本ソフトウェアの不具合の修正、機能改良、セキュリティホールの修復などのコード
39// の改変を行った場合で、その成果物を SoftEther UT-VPN プロジェクトに提出して
40// いただける場合は、 http://utvpn.tsukuba.ac.jp/ までソースコードを送付して
41// ください。SoftEther UT-VPN プロジェクトの本体リリースまたはブランチリリース
42// に組み込みさせていただきます。
43//
44// GPL に基づいて原著作物が提供される本ソフトウェアの改良版を配布、販売する
45// 場合は、そのソースコードを GPL に基づいて誰にでも開示する義務が生じます。
46//
47// 本ソフトウェアに関連する著作権、特許権、商標権はソフトイーサ株式会社
48// (SoftEther Corporation) およびその他の著作権保持者が保有しています。
49// ソフトイーサ株式会社等はこれらの権利を放棄していません。本ソフトウェアの
50// 二次著作物を配布、販売する場合は、これらの権利を侵害しないようにご注意
51// ください。
52//
53// お願い: どのような通信ソフトウェアにも通常は必ず未発見の
54// セキュリティホールが潜んでいます。本ソースコードをご覧いただいた結果、
55// UT-VPN にセキュリティホールを発見された場合は、当該セキュリティホールの
56// 情報を不特定多数に開示される前に、必ず、ソフトイーサ株式会社
57// および脆弱性情報の届出を受け付ける公的機関まで通報いただき、
58// 公益保護にご協力いただきますようお願い申し上げます。
59//
60// ソフトイーサ株式会社は、当該セキュリティホールについて迅速に対処を
61// 行い、UT-VPN および UT-VPN に関連するソフトウェアのユーザー・顧客
62// を保護するための努力を行います。
63//
64// ソフトイーサへの届出先: http://www.softether.co.jp/jp/contact/
65// 日本国内の脆弱性情報届出受付公的機関:
66//         独立行政法人 情報処理推進機構
67//         http://www.ipa.go.jp/security/vuln/report/
68//
69// 上記各事項について不明な点は、ソフトイーサ株式会社までご連絡ください。
70// 連絡先: http://www.softether.co.jp/jp/contact/
71
72// -----------------------------------------------
73// [ChangeLog]
74// 2010.05.20
75//  新規リリース by SoftEther
76// -----------------------------------------------
77
78// Unix.h
79// Unix.c のヘッダ
80
81#ifdef  OS_UNIX
82
83#ifndef UNIX_H
84#define UNIX_H
85
86// 定数
87#define UNIX_THREAD_STACK_SIZE          (200 * 1000)    // スタックサイズ
88#define UNIX_MAX_CHILD_PROCESSES        2000000         // 最大子プロセス数
89#define UNIX_LINUX_MAX_THREADS          200000000       // 最大スレッド数
90#define UNIX_MAX_LOCKS                  65536           // 最大ロック数
91#define UNIX_MAX_MEMORY                 (2147483648UL)  // 最大メモリ容量
92#define UNIX_MAX_FD                     (655360)        // 最大 FD 数
93#define MAXIMUM_WAIT_OBJECTS            64              // 最大 select 数
94
95#define UNIX_SERVICE_STOP_TIMEOUT_1     (600 * 1000)    // サービス停止までのタイムアウト
96#define UNIX_SERVICE_STOP_TIMEOUT_2     (900 * 1000)    // サービス停止までのタイムアウト (親プロセス)
97
98
99// サービス関係
100typedef void (SERVICE_FUNCTION)();
101
102#define SVC_NAME                    "SVC_%s_NAME"
103#define SVC_TITLE                   "SVC_%s_TITLE"
104
105#define UNIX_SVC_ARG_START              "start"
106#define UNIX_SVC_ARG_STOP               "stop"
107#define UNIX_SVC_ARG_EXEC_SVC           "execsvc"
108#define UNIX_ARG_EXIT                   "exit"
109
110#define UNIX_SVC_MODE_START             1
111#define UNIX_SVC_MODE_STOP              2
112#define UNIX_SVC_MODE_EXEC_SVC          3
113#define UNIX_SVC_MODE_EXIT              4
114
115
116// 関数プロトタイプ
117OS_DISPATCH_TABLE *UnixGetDispatchTable();
118void UnixInit();
119void UnixFree();
120void *UnixMemoryAlloc(UINT size);
121void *UnixMemoryReAlloc(void *addr, UINT size);
122void UnixMemoryFree(void *addr);
123UINT UnixGetTick();
124void UnixGetSystemTime(SYSTEMTIME *system_time);
125void UnixInc32(UINT *value);
126void UnixDec32(UINT *value);
127void UnixSleep(UINT time);
128LOCK *UnixNewLock();
129bool UnixLock(LOCK *lock);
130void UnixUnlock(LOCK *lock);
131void UnixUnlockEx(LOCK *lock, bool inner);
132void UnixDeleteLock(LOCK *lock);
133void UnixInitEvent(EVENT *event);
134void UnixSetEvent(EVENT *event);
135void UnixResetEvent(EVENT *event);
136bool UnixWaitEvent(EVENT *event, UINT timeout);
137void UnixFreeEvent(EVENT *event);
138bool UnixWaitThread(THREAD *t);
139void UnixFreeThread(THREAD *t);
140bool UnixInitThread(THREAD *t);
141UINT UnixThreadId();
142void *UnixFileOpen(char *name, bool write_mode, bool read_lock);
143void *UnixFileOpenW(wchar_t *name, bool write_mode, bool read_lock);
144void *UnixFileCreate(char *name);
145void *UnixFileCreateW(wchar_t *name);
146bool UnixFileWrite(void *pData, void *buf, UINT size);
147bool UnixFileRead(void *pData, void *buf, UINT size);
148void UnixFileClose(void *pData, bool no_flush);
149void UnixFileFlush(void *pData);
150UINT64 UnixFileSize(void *pData);
151bool UnixFileSeek(void *pData, UINT mode, int offset);
152bool UnixFileDelete(char *name);
153bool UnixFileDeleteW(wchar_t *name);
154bool UnixMakeDir(char *name);
155bool UnixMakeDirW(wchar_t *name);
156bool UnixDeleteDir(char *name);
157bool UnixDeleteDirW(wchar_t *name);
158CALLSTACK_DATA *UnixGetCallStack();
159bool UnixGetCallStackSymbolInfo(CALLSTACK_DATA *s);
160bool UnixFileRename(char *old_name, char *new_name);
161bool UnixFileRenameW(wchar_t *old_name, wchar_t *new_name);
162bool UnixRun(char *filename, char *arg, bool hide, bool wait);
163bool UnixRunW(wchar_t *filename, wchar_t *arg, bool hide, bool wait);
164bool UnixIsSupportedOs();
165void UnixGetOsInfo(OS_INFO *info);
166void UnixAlert(char *msg, char *caption);
167void UnixAlertW(wchar_t *msg, wchar_t *caption);
168char *UnixGetProductId();
169void UnixSetHighPriority();
170void UnixRestorePriority();
171void *UnixNewSingleInstance(char *instance_name);
172void UnixFreeSingleInstance(void *data);
173void UnixGetMemInfo(MEMINFO *info);
174void UnixYield();
175
176
177void UnixSetThreadPriorityRealtime();
178void UnixSetThreadPriorityLow();
179void UnixSetThreadPriorityHigh();
180void UnixSetThreadPriorityIdle();
181void UnixRestoreThreadPriority();
182void UnixSetResourceLimit(UINT id, UINT value);
183UINT64 UnixGetTick64();
184void UnixSigChldHandler(int sig);
185void UnixCloseIO();
186void UnixDaemon(bool debug_mode);
187void UnixGetCurrentDir(char *dir, UINT size);
188void UnixGetCurrentDirW(wchar_t *dir, UINT size);
189bool UnixCheckExecAccess(char *name);
190bool UnixCheckExecAccessW(wchar_t *name);
191DIRLIST *UnixEnumDirEx(char *dirname, COMPARE *compare);
192DIRLIST *UnixEnumDirExW(wchar_t *dirname, COMPARE *compare);
193bool UnixGetDiskFreeMain(char *path, UINT64 *free_size, UINT64 *used_size, UINT64 *total_size);
194bool UnixGetDiskFree(char *path, UINT64 *free_size, UINT64 *used_size, UINT64 *total_size);
195bool UnixGetDiskFreeW(wchar_t *path, UINT64 *free_size, UINT64 *used_size, UINT64 *total_size);
196void UnixInitSolarisSleep();
197void UnixFreeSolarisSleep();
198void UnixSolarisSleep(UINT msec);
199
200UINT UnixService(int argc, char *argv[], char *name, SERVICE_FUNCTION *start, SERVICE_FUNCTION *stop);
201void UnixServiceMain(int argc, char *argv[], char *name, SERVICE_FUNCTION *start, SERVICE_FUNCTION *stop);
202void UnixGenPidFileName(char *name, UINT size);
203void UnixStartService(char *name);
204void UnixStopService(char *name);
205void UnixExecService(char *name, SERVICE_FUNCTION *start, SERVICE_FUNCTION *stop);
206void UnixUsage(char *name);
207void UnixWritePidFile(UINT pid);
208UINT UnixReadPidFile();
209bool UnixIsProcess(UINT pid);
210bool UnixWaitProcessEx(UINT pid, UINT timeout);
211void UnixWaitProcess(UINT pid);
212void UnixDeletePidFile();
213void UnixStopThread(THREAD *t, void *param);
214
215
216#endif  // UNIX_H
217
218#endif  // OS_UNIX
219
Note: See TracBrowser for help on using the repository browser.