This file is indexed.

/usr/share/aolserver4/include/nsthread.h is in aolserver4-dev 4.5.1-15.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
/*
 * The contents of this file are subject to the AOLserver Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://aolserver.com/.
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 * the License for the specific language governing rights and limitations
 * under the License.
 *
 * The Original Code is AOLserver Code and related documentation
 * distributed by AOL.
 * 
 * The Initial Developer of the Original Code is America Online,
 * Inc. Portions created by AOL are Copyright (C) 1999 America Online,
 * Inc. All Rights Reserved.
 *
 * Alternatively, the contents of this file may be used under the terms
 * of the GNU General Public License (the "GPL"), in which case the
 * provisions of GPL are applicable instead of those above.  If you wish
 * to allow use of your version of this file only under the terms of the
 * GPL and not to allow others to use your version of this file under the
 * License, indicate your decision by deleting the provisions above and
 * replace them with the notice and other provisions required by the GPL.
 * If you do not delete the provisions above, a recipient may use your
 * version of this file under either the License or the GPL.
 */

/*
 * nsthread.h --
 *
 *	Core threading and system headers.
 *
 *	$Header: /cvsroot/aolserver/aolserver/include/nsthread.h,v 1.31 2005/08/23 21:41:31 jgdavidson Exp $
 */

#ifndef NSTHREAD_H
#define NSTHREAD_H


#include "nsattributes.h"


#ifdef _WIN32
#define NS_EXPORT		__declspec(dllexport)
#define NS_IMPORT		__declspec(dllimport)
#else
#define NS_EXPORT
#define NS_IMPORT
#ifndef _REENTRANT
#define _REENTRANT
#endif
#if defined(__sgi) && !defined(_SGI_MP_SOURCE)
#define _SGI_MP_SOURCE
#endif
#if defined(__sun) && !defined(_POSIX_PTHREAD_SEMANTICS)
#define _POSIX_PTHREAD_SEMANTICS
#endif
#endif

#ifdef NSTHREAD_EXPORTS
#define NS_STORAGE_CLASS	NS_EXPORT
#else
#define NS_STORAGE_CLASS	NS_IMPORT
#endif

#ifdef __cplusplus
#define NS_EXTERN		extern "C" NS_STORAGE_CLASS
#else
#define NS_EXTERN		extern NS_STORAGE_CLASS
#endif

#ifndef __linux
#ifdef FD_SETSIZE
#undef FD_SETSIZE
#endif
#define FD_SETSIZE 1024
#endif

#ifdef __OpenBSD__
#ifndef ENOTSUP
/*
 * Workaround until we have ENOTSUP in errno.h
 */
#define ENOTSUP         EOPNOTSUPP    
#endif
#endif

#ifndef _WIN32
#include <sys/types.h>
#include <dirent.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netdb.h>
#include <sys/uio.h>

#else

#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <winsock2.h>
#include <sys/timeb.h>
#include <sys/types.h>
#include <io.h>
#include <process.h>
#include <direct.h>
typedef struct DIR_ *DIR;
struct dirent {
    char *d_name;
};
NS_EXTERN DIR *opendir(char *pathname);
NS_EXTERN struct dirent *readdir(DIR *dp);
NS_EXTERN int closedir(DIR *dp);
#define sleep(n)	(Sleep((n)*1000))

#define HAVE_GETADDRINFO
#define HAVE_GETNAMEINFO
#include <ws2tcpip.h>

#endif

#include "tcl.h"
#include <limits.h>
#include <time.h>
#include <fcntl.h>
#include <signal.h>
#include <errno.h>
#include <ctype.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdio.h>
#include <stdarg.h>
#include <assert.h>
#ifndef PATH_MAX
#define PATH_MAX 1024
#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif

/*
 * Various constants.
 */

#define NS_OK              	0
#define NS_ERROR         	(-1)
#define NS_TIMEOUT       	(-2)
#define NS_BREAK	       	(-3)
#define NS_THREAD_DETACHED	1
#define NS_THREAD_JOINED	2
#define NS_THREAD_EXITED	4
#define NS_THREAD_NAMESIZE	64
#define NS_THREAD_MAXTLS	100

/*
 * The following objects are defined as pointers to dummy structures
 * to ensure proper type checking.  The actual objects underlying
 * objects are platform specific. 
 */

typedef struct Ns_Thread_	*Ns_Thread;
typedef struct Ns_Tls_		*Ns_Tls;
typedef struct Ns_Mutex_	*Ns_Mutex;
typedef struct Ns_Cond_		*Ns_Cond;
typedef struct Ns_Cs_		*Ns_Cs;
typedef struct Ns_Sema_		*Ns_Sema;
typedef struct Ns_RWLock_	*Ns_RWLock;

typedef struct Ns_Time {
    time_t	sec;
    long	usec;
} Ns_Time;

typedef void (Ns_ThreadProc) (void *arg);
typedef void (Ns_TlsCleanup) (void *arg);
typedef void (Ns_ThreadArgProc) (Tcl_DString *, void *proc, void *arg);

/*
 * fork.c:
 */

NS_EXTERN int ns_fork(void);

/*
 * master.c:
 */

NS_EXTERN void Ns_MasterLock(void);
NS_EXTERN void Ns_MasterUnlock(void);

/*
 * memory.c:
 */

NS_EXTERN void *ns_malloc(size_t size) _nsmalloc;
NS_EXTERN void *ns_calloc(size_t num, size_t size) _nsmalloc;
NS_EXTERN void ns_free(void *buf);
NS_EXTERN void *ns_realloc(void *buf, size_t size);
NS_EXTERN char *ns_strdup(const char *string) _nsmalloc;
NS_EXTERN char *ns_strcopy(const char *string) _nsmalloc;

/*
 * mutex.c:
 */

NS_EXTERN void Ns_MutexInit(Ns_Mutex *mutexPtr);
NS_EXTERN void Ns_MutexDestroy(Ns_Mutex *mutexPtr);
NS_EXTERN void Ns_MutexLock(Ns_Mutex *mutexPtr);
NS_EXTERN int  Ns_MutexTryLock(Ns_Mutex *mutexPtr);
NS_EXTERN void Ns_MutexUnlock(Ns_Mutex *mutexPtr);
NS_EXTERN void Ns_MutexSetName(Ns_Mutex *mutexPtr, char *name);
NS_EXTERN void Ns_MutexSetName2(Ns_Mutex *mutexPtr, char *prefix, char *name);
NS_EXTERN void Ns_MutexList(Tcl_DString *dsPtr);

/*
 * rwlock.c:
 */

NS_EXTERN void Ns_RWLockInit(Ns_RWLock *lockPtr);
NS_EXTERN void Ns_RWLockDestroy(Ns_RWLock *lockPtr);
NS_EXTERN void Ns_RWLockRdLock(Ns_RWLock *lockPtr);
NS_EXTERN void Ns_RWLockWrLock(Ns_RWLock *lockPtr);
NS_EXTERN void Ns_RWLockUnlock(Ns_RWLock *lockPtr);

/*
 * cslock.c;
 */

NS_EXTERN void Ns_CsInit(Ns_Cs *csPtr);
NS_EXTERN void Ns_CsDestroy(Ns_Cs *csPtr);
NS_EXTERN void Ns_CsEnter(Ns_Cs *csPtr);
NS_EXTERN void Ns_CsLeave(Ns_Cs *csPtr);

/*
 * cond.c:
 */

NS_EXTERN void Ns_CondInit(Ns_Cond *condPtr);
NS_EXTERN void Ns_CondDestroy(Ns_Cond *condPtr);
NS_EXTERN void Ns_CondSignal(Ns_Cond *condPtr);
NS_EXTERN void Ns_CondBroadcast(Ns_Cond *condPtr);
NS_EXTERN void Ns_CondWait(Ns_Cond *condPtr, Ns_Mutex *lockPtr);
NS_EXTERN int Ns_CondTimedWait(Ns_Cond *condPtr, Ns_Mutex *lockPtr,
			    Ns_Time *timePtr);

/*
 * reentrant.c:
 */

NS_EXTERN struct dirent *ns_readdir(DIR * pDir);
NS_EXTERN struct tm *ns_localtime(const time_t * clock);
NS_EXTERN struct tm *ns_gmtime(const time_t * clock);
NS_EXTERN char *ns_ctime(const time_t * clock);
NS_EXTERN char *ns_asctime(const struct tm *tmPtr);
NS_EXTERN char *ns_strtok(char *s1, const char *s2);
NS_EXTERN char *ns_inet_ntoa(struct in_addr addr);

/*
 * sema.c:
 */

NS_EXTERN void Ns_SemaInit(Ns_Sema *semaPtr, int initCount);
NS_EXTERN void Ns_SemaDestroy(Ns_Sema *semaPtr);
NS_EXTERN void Ns_SemaWait(Ns_Sema *semaPtr);
NS_EXTERN void Ns_SemaPost(Ns_Sema *semaPtr, int count);

/*
 * signal.c:
 */

#ifndef _WIN32
NS_EXTERN int ns_sigmask(int how, sigset_t * set, sigset_t * oset);
NS_EXTERN int ns_sigwait(sigset_t * set, int *sig);
NS_EXTERN int ns_signal(int sig, void (*proc)(int));
#endif

/*
 * thread.c:
 */

NS_EXTERN void NsThreads_LibInit(void);
NS_EXTERN void Ns_ThreadCreate(Ns_ThreadProc *proc, void *arg, long stackSize,
			    Ns_Thread *resultPtr);
NS_EXTERN void Ns_ThreadExit(void *arg);
NS_EXTERN void Ns_ThreadJoin(Ns_Thread *threadPtr, void **argPtr);
NS_EXTERN void Ns_ThreadYield(void);
NS_EXTERN void Ns_ThreadSetName(char *name);
NS_EXTERN int Ns_ThreadId(void);
NS_EXTERN void Ns_ThreadSelf(Ns_Thread *threadPtr);
NS_EXTERN char *Ns_ThreadGetName(void);
NS_EXTERN char *Ns_ThreadGetParent(void);
NS_EXTERN long Ns_ThreadStackSize(long size);
NS_EXTERN void Ns_ThreadList(Tcl_DString *dsPtr, Ns_ThreadArgProc *proc);
NS_EXTERN int Ns_CheckStack(void);

/*
 * time.c:
 */

NS_EXTERN void Ns_GetTime(Ns_Time *timePtr);
NS_EXTERN void Ns_AdjTime(Ns_Time *timePtr);
NS_EXTERN int  Ns_DiffTime(Ns_Time *t1, Ns_Time *t0, Ns_Time *resultPtr);
NS_EXTERN void Ns_IncrTime(Ns_Time *timePtr, time_t sec, long usec);

/*
 * tls.c:
 */

NS_EXTERN void Ns_TlsAlloc(Ns_Tls *tlsPtr, Ns_TlsCleanup *cleanup);
NS_EXTERN void Ns_TlsSet(Ns_Tls *tlsPtr, void *value);
NS_EXTERN void *Ns_TlsGet(Ns_Tls *tlsPtr);


#ifndef NS_NOCOMPAT

/*
 * Unsupported legacy API's and macros.
 */

/*
 * compat.c:
 */

typedef struct Ns_Semaphore_		*Ns_Semaphore;
typedef struct Ns_CriticalSection_ 	*Ns_CriticalSection;
typedef struct Ns_ThreadLocalStorage_ 	*Ns_ThreadLocalStorage;
typedef struct Ns_Event_		*Ns_Event;

NS_EXTERN int Ns_InitializeMutex(Ns_Mutex *mutexPtr);
NS_EXTERN int Ns_DestroyMutex(Ns_Mutex *mutexPtr);
NS_EXTERN int Ns_LockMutex(Ns_Mutex *mutexPtr);
NS_EXTERN int Ns_UnlockMutex(Ns_Mutex *mutexPtr);
NS_EXTERN int Ns_InitializeCriticalSection(Ns_CriticalSection *cs);
NS_EXTERN int Ns_DestroyCriticalSection(Ns_CriticalSection *cs);
NS_EXTERN int Ns_EnterCriticalSection(Ns_CriticalSection *cs);
NS_EXTERN int Ns_LeaveCriticalSection(Ns_CriticalSection *cs);
NS_EXTERN int Ns_InitializeEvent(Ns_Event *event);
NS_EXTERN int Ns_DestroyEvent(Ns_Event *event);
NS_EXTERN int Ns_SetEvent(Ns_Event *event);
NS_EXTERN int Ns_BroadcastEvent(Ns_Event *event);
NS_EXTERN int Ns_WaitForEvent(Ns_Event *event, Ns_Mutex *lock);
NS_EXTERN int Ns_TimedWaitForEvent(Ns_Event *event, Ns_Mutex *lock, int timeout);
NS_EXTERN int Ns_AbsTimedWaitForEvent(Ns_Event *event, Ns_Mutex *lock,
				   time_t abstime);
NS_EXTERN int Ns_UTimedWaitForEvent(Ns_Event *event, Ns_Mutex *lock, int seconds,
				 int microseconds);
NS_EXTERN int Ns_InitializeRWLock(Ns_RWLock *lock);
NS_EXTERN int Ns_DestroyRWLock(Ns_RWLock *lock);
NS_EXTERN int Ns_ReadLockRWLock(Ns_RWLock *lock);
NS_EXTERN int Ns_ReadUnlockRWLock(Ns_RWLock *lock);
NS_EXTERN int Ns_WriteLockRWLock(Ns_RWLock *lock);
NS_EXTERN int Ns_WriteUnlockRWLock(Ns_RWLock *lock);
NS_EXTERN int Ns_InitializeSemaphore(Ns_Semaphore *sema, int initCount);
NS_EXTERN int Ns_DestroySemaphore(Ns_Semaphore *sema);
NS_EXTERN int Ns_WaitForSemaphore(Ns_Semaphore *sema);
NS_EXTERN int Ns_ReleaseSemaphore(Ns_Semaphore *sema, int count);
NS_EXTERN int Ns_AllocThreadLocalStorage(Ns_ThreadLocalStorage *tls,
				      Ns_TlsCleanup *cleanup);
NS_EXTERN int Ns_SetThreadLocalStorage(Ns_ThreadLocalStorage *tls, void *p);
NS_EXTERN int Ns_GetThreadLocalStorage(Ns_ThreadLocalStorage *tls, void **p);
NS_EXTERN int Ns_WaitForThread(Ns_Thread *threadPtr);
NS_EXTERN int Ns_WaitThread(Ns_Thread *threadPtr, int *exitCodePtr);
NS_EXTERN void Ns_ExitThread(int exitCode);
NS_EXTERN int Ns_BeginDetachedThread(Ns_ThreadProc *proc, void *arg);
NS_EXTERN int Ns_BeginThread(Ns_ThreadProc *proc, void *arg, Ns_Thread *thrPtr);
NS_EXTERN int Ns_GetThreadId(void);
NS_EXTERN void Ns_GetThread(Ns_Thread *threadPtr);

/*
 * pool.c:
 */

typedef struct Ns_Pool_		*Ns_Pool;

NS_EXTERN int nsMemNumBuckets;
NS_EXTERN Ns_Pool *Ns_PoolCreate(char *name);
NS_EXTERN void Ns_PoolFlush(Ns_Pool *pool);
NS_EXTERN void Ns_PoolDestroy(Ns_Pool *pool);
NS_EXTERN void *Ns_PoolAlloc(Ns_Pool *pool, size_t size);
NS_EXTERN void Ns_PoolFree(Ns_Pool *pool, void *cp);
NS_EXTERN void *Ns_PoolRealloc(Ns_Pool *pool, void *ptr, size_t size);
NS_EXTERN void *Ns_PoolCalloc(Ns_Pool *pool, size_t elsize, size_t nelem);
NS_EXTERN char *Ns_PoolStrDup(Ns_Pool *pool, char *old);
NS_EXTERN char *Ns_PoolStrCopy(Ns_Pool *pool, char *old);
NS_EXTERN void *Ns_ThreadMalloc(size_t size);
NS_EXTERN void *Ns_ThreadAlloc(size_t size);
NS_EXTERN void *Ns_ThreadRealloc(void *ptr, size_t size);
NS_EXTERN void Ns_ThreadFree(void *ptr);
NS_EXTERN void *Ns_ThreadCalloc(size_t nelem, size_t elsize);
NS_EXTERN char *Ns_ThreadStrDup(char *old);
NS_EXTERN char *Ns_ThreadStrCopy(char *old);

#define Ns_Readdir ns_readdir
#define Ns_Localtime ns_localtime
#define Ns_Gmtime ns_gmtime
#define Ns_Ctime ns_ctime
#define Ns_Asctime ns_asctime
#define Ns_Strtok ns_strtok
#define Ns_InetNtoa ns_inet_ntoa
#define Ns_Signal ns_signal
#define Ns_Sigmask ns_sigmask
#define Ns_Sigwait ns_sigwait
#define Ns_Malloc ns_malloc
#define Ns_Realloc ns_realloc
#define Ns_Free ns_free
#define Ns_Calloc ns_calloc
#define Ns_StrDup ns_strdup
#define Ns_StrCopy ns_strcopy
#define Ns_ThreadAlloc Ns_ThreadMalloc
#define Ns_Fork ns_fork

#endif	/* NS_NOCOMPAT */

#endif /* NSTHREAD_H */