| 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 | #ifndef _XOS_R_H_ |
| 70 | # define _XOS_R_H_ |
| 71 | |
| 72 | # include <X11/Xos.h> |
| 73 | # include <X11/Xfuncs.h> |
| 74 | |
| 75 | # ifndef X_NOT_POSIX |
| 76 | # ifdef _POSIX_SOURCE |
| 77 | # include <limits.h> |
| 78 | # else |
| 79 | # define _POSIX_SOURCE |
| 80 | # include <limits.h> |
| 81 | # undef _POSIX_SOURCE |
| 82 | # endif |
| 83 | # ifndef LINE_MAX |
| 84 | # define X_LINE_MAX 2048 |
| 85 | # else |
| 86 | # define X_LINE_MAX LINE_MAX |
| 87 | # endif |
| 88 | # endif |
| 89 | #endif |
| 90 | |
| 91 | #ifndef WIN32 |
| 92 | |
| 93 | #ifdef __cplusplus |
| 94 | extern "C" { |
| 95 | #endif |
| 96 | |
| 97 | # if defined(XOS_USE_XLIB_LOCKING) |
| 98 | # ifndef XAllocIDs |
| 99 | typedef struct _LockInfoRec *LockInfoPtr; |
| 100 | extern LockInfoPtr _Xglobal_lock; |
| 101 | # endif |
| 102 | # ifndef _Xos_isThreadInitialized |
| 103 | # define _Xos_isThreadInitialized (_Xglobal_lock) |
| 104 | # endif |
| 105 | # if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) |
| 106 | # ifndef XAllocIDs |
| 107 | # include <X11/Xfuncproto.h> |
| 108 | extern void (*_XLockMutex_fn)( |
| 109 | # if NeedFunctionPrototypes |
| 110 | LockInfoPtr , char * , int |
| 111 | # endif |
| 112 | ); |
| 113 | extern void (*_XUnlockMutex_fn)( |
| 114 | # if NeedFunctionPrototypes |
| 115 | LockInfoPtr , char * , int |
| 116 | # endif |
| 117 | ); |
| 118 | # endif |
| 119 | # ifndef _Xos_processLock |
| 120 | # define _Xos_processLock \ |
| 121 | (_XLockMutex_fn ? (*_XLockMutex_fn)(_Xglobal_lock,__FILE__,__LINE__) : 0) |
| 122 | # endif |
| 123 | # ifndef _Xos_processUnlock |
| 124 | # define _Xos_processUnlock \ |
| 125 | (_XUnlockMutex_fn ? (*_XUnlockMutex_fn)(_Xglobal_lock,__FILE__,__LINE__) : 0) |
| 126 | # endif |
| 127 | # else |
| 128 | # ifndef XAllocIDs |
| 129 | # include <X11/Xfuncproto.h> |
| 130 | extern void (*_XLockMutex_fn)( |
| 131 | # if NeedFunctionPrototypes |
| 132 | LockInfoPtr |
| 133 | # endif |
| 134 | ); |
| 135 | extern void (*_XUnlockMutex_fn)( |
| 136 | # if NeedFunctionPrototypes |
| 137 | LockInfoPtr |
| 138 | # endif |
| 139 | ); |
| 140 | # endif |
| 141 | # ifndef _Xos_processLock |
| 142 | # define _Xos_processLock \ |
| 143 | (_XLockMutex_fn ? ((*_XLockMutex_fn)(_Xglobal_lock), 0) : 0) |
| 144 | # endif |
| 145 | # ifndef _Xos_processUnlock |
| 146 | # define _Xos_processUnlock \ |
| 147 | (_XUnlockMutex_fn ? ((*_XUnlockMutex_fn)(_Xglobal_lock), 0) : 0) |
| 148 | # endif |
| 149 | # endif |
| 150 | # elif defined(XOS_USE_XT_LOCKING) |
| 151 | # ifndef _XtThreadsI_h |
| 152 | extern void (*_XtProcessLock)(void); |
| 153 | # endif |
| 154 | # ifndef _XtintrinsicP_h |
| 155 | # include <X11/Xfuncproto.h> |
| 156 | extern void XtProcessLock( |
| 157 | # if NeedFunctionPrototypes |
| 158 | void |
| 159 | # endif |
| 160 | ); |
| 161 | extern void XtProcessUnlock( |
| 162 | # if NeedFunctionPrototypes |
| 163 | void |
| 164 | # endif |
| 165 | ); |
| 166 | # endif |
| 167 | # ifndef _Xos_isThreadInitialized |
| 168 | # define _Xos_isThreadInitialized _XtProcessLock |
| 169 | # endif |
| 170 | # ifndef _Xos_processLock |
| 171 | # define _Xos_processLock XtProcessLock() |
| 172 | # endif |
| 173 | # ifndef _Xos_processUnlock |
| 174 | # define _Xos_processUnlock XtProcessUnlock() |
| 175 | # endif |
| 176 | # elif defined(XOS_USE_NO_LOCKING) |
| 177 | # ifndef _Xos_isThreadInitialized |
| 178 | # define _Xos_isThreadInitialized 0 |
| 179 | # endif |
| 180 | # ifndef _Xos_processLock |
| 181 | # define _Xos_processLock 0 |
| 182 | # endif |
| 183 | # ifndef _Xos_processUnlock |
| 184 | # define _Xos_processUnlock 0 |
| 185 | # endif |
| 186 | # endif |
| 187 | |
| 188 | #endif |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | #if defined(__sun) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && \ |
| 196 | (_POSIX_C_SOURCE - 0 < 199506L) && !defined(_POSIX_PTHREAD_SEMANTICS) |
| 197 | # undef _POSIX_THREAD_SAFE_FUNCTIONS |
| 198 | #endif |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | #if defined(X_INCLUDE_PWD_H) && !defined(_XOS_INCLUDED_PWD_H) |
| 216 | # include <pwd.h> |
| 217 | # if defined(XUSE_MTSAFE_API) || defined(XUSE_MTSAFE_PWDAPI) |
| 218 | # define XOS_USE_MTSAFE_PWDAPI 1 |
| 219 | # endif |
| 220 | #endif |
| 221 | |
| 222 | #undef X_NEEDS_PWPARAMS |
| 223 | #if !defined(X_INCLUDE_PWD_H) || defined(_XOS_INCLUDED_PWD_H) |
| 224 | |
| 225 | |
| 226 | #elif !defined(XTHREADS) && !defined(X_FORCE_USE_MTSAFE_API) |
| 227 | |
| 228 | # if defined(X_NOT_POSIX) && !defined(__i386__) && !defined(SYSV) |
| 229 | extern struct passwd *getpwuid(), *getpwnam(); |
| 230 | # endif |
| 231 | typedef int _Xgetpwparams; |
| 232 | # define _XGetpwuid(u,p) getpwuid((u)) |
| 233 | # define _XGetpwnam(u,p) getpwnam((u)) |
| 234 | |
| 235 | #elif !defined(XOS_USE_MTSAFE_PWDAPI) || defined(XNO_MTSAFE_PWDAPI) |
| 236 | |
| 237 | # define X_NEEDS_PWPARAMS |
| 238 | typedef struct { |
| 239 | struct passwd pws; |
| 240 | char pwbuf[1024]; |
| 241 | struct passwd* pwp; |
| 242 | size_t len; |
| 243 | } _Xgetpwparams; |
| 244 | |
| 245 | |
| 246 | |
| 247 | |
| 248 | |
| 249 | |
| 250 | #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || \ |
| 251 | defined(__APPLE__) || defined(__DragonFly__) |
| 252 | static __inline__ void _Xpw_copyPasswd(_Xgetpwparams p) |
| 253 | { |
| 254 | memcpy(&(p).pws, (p).pwp, sizeof(struct passwd)); |
| 255 | |
| 256 | (p).pws.pw_name = (p).pwbuf; |
| 257 | (p).len = strlen((p).pwp->pw_name); |
| 258 | strcpy((p).pws.pw_name, (p).pwp->pw_name); |
| 259 | |
| 260 | (p).pws.pw_passwd = (p).pws.pw_name + (p).len + 1; |
| 261 | (p).len = strlen((p).pwp->pw_passwd); |
| 262 | strcpy((p).pws.pw_passwd,(p).pwp->pw_passwd); |
| 263 | |
| 264 | (p).pws.pw_class = (p).pws.pw_passwd + (p).len + 1; |
| 265 | (p).len = strlen((p).pwp->pw_class); |
| 266 | strcpy((p).pws.pw_class, (p).pwp->pw_class); |
| 267 | |
| 268 | (p).pws.pw_gecos = (p).pws.pw_class + (p).len + 1; |
| 269 | (p).len = strlen((p).pwp->pw_gecos); |
| 270 | strcpy((p).pws.pw_gecos, (p).pwp->pw_gecos); |
| 271 | |
| 272 | (p).pws.pw_dir = (p).pws.pw_gecos + (p).len + 1; |
| 273 | (p).len = strlen((p).pwp->pw_dir); |
| 274 | strcpy((p).pws.pw_dir, (p).pwp->pw_dir); |
| 275 | |
| 276 | (p).pws.pw_shell = (p).pws.pw_dir + (p).len + 1; |
| 277 | (p).len = strlen((p).pwp->pw_shell); |
| 278 | strcpy((p).pws.pw_shell, (p).pwp->pw_shell); |
| 279 | |
| 280 | (p).pwp = &(p).pws; |
| 281 | } |
| 282 | |
| 283 | #else |
| 284 | # define _Xpw_copyPasswd(p) \ |
| 285 | (memcpy(&(p).pws, (p).pwp, sizeof(struct passwd)), \ |
| 286 | ((p).pws.pw_name = (p).pwbuf), \ |
| 287 | ((p).len = strlen((p).pwp->pw_name)), \ |
| 288 | strcpy((p).pws.pw_name, (p).pwp->pw_name), \ |
| 289 | ((p).pws.pw_passwd = (p).pws.pw_name + (p).len + 1), \ |
| 290 | ((p).len = strlen((p).pwp->pw_passwd)), \ |
| 291 | strcpy((p).pws.pw_passwd,(p).pwp->pw_passwd), \ |
| 292 | ((p).pws.pw_age = (p).pws.pw_passwd + (p).len + 1), \ |
| 293 | ((p).len = strlen((p).pwp->pw_age)), \ |
| 294 | strcpy((p).pws.pw_age, (p).pwp->pw_age), \ |
| 295 | ((p).pws.pw_comment = (p).pws.pw_age + (p).len + 1), \ |
| 296 | ((p).len = strlen((p).pwp->pw_comment)), \ |
| 297 | strcpy((p).pws.pw_comment, (p).pwp->pw_comment), \ |
| 298 | ((p).pws.pw_gecos = (p).pws.pw_comment + (p).len + 1), \ |
| 299 | ((p).len = strlen((p).pwp->pw_gecos)), \ |
| 300 | strcpy((p).pws.pw_gecos, (p).pwp->pw_gecos), \ |
| 301 | ((p).pws.pw_dir = (p).pws.pw_comment + (p).len + 1), \ |
| 302 | ((p).len = strlen((p).pwp->pw_dir)), \ |
| 303 | strcpy((p).pws.pw_dir, (p).pwp->pw_dir), \ |
| 304 | ((p).pws.pw_shell = (p).pws.pw_dir + (p).len + 1), \ |
| 305 | ((p).len = strlen((p).pwp->pw_shell)), \ |
| 306 | strcpy((p).pws.pw_shell, (p).pwp->pw_shell), \ |
| 307 | ((p).pwp = &(p).pws), \ |
| 308 | 0 ) |
| 309 | #endif |
| 310 | # define _XGetpwuid(u,p) \ |
| 311 | ( (_Xos_processLock), \ |
| 312 | (((p).pwp = getpwuid((u))) ? _Xpw_copyPasswd(p), 0 : 0), \ |
| 313 | (_Xos_processUnlock), \ |
| 314 | (p).pwp ) |
| 315 | # define _XGetpwnam(u,p) \ |
| 316 | ( (_Xos_processLock), \ |
| 317 | (((p).pwp = getpwnam((u))) ? _Xpw_copyPasswd(p), 0 : 0), \ |
| 318 | (_Xos_processUnlock), \ |
| 319 | (p).pwp ) |
| 320 | |
| 321 | #elif !defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(__APPLE__) |
| 322 | # define X_NEEDS_PWPARAMS |
| 323 | typedef struct { |
| 324 | struct passwd pws; |
| 325 | char pwbuf[X_LINE_MAX]; |
| 326 | } _Xgetpwparams; |
| 327 | # if defined(_POSIX_REENTRANT_FUNCTIONS) || !defined(SVR4) |
| 328 | # define _XGetpwuid(u,p) \ |
| 329 | ((getpwuid_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf)) == -1) ? NULL : &(p).pws) |
| 330 | # define _XGetpwnam(u,p) \ |
| 331 | ((getpwnam_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf)) == -1) ? NULL : &(p).pws) |
| 332 | # else |
| 333 | # define _XGetpwuid(u,p) \ |
| 334 | ((getpwuid_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf)) == NULL) ? NULL : &(p).pws) |
| 335 | # define _XGetpwnam(u,p) \ |
| 336 | ((getpwnam_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf)) == NULL) ? NULL : &(p).pws) |
| 337 | # endif |
| 338 | |
| 339 | #else |
| 340 | # define X_NEEDS_PWPARAMS |
| 341 | typedef struct { |
| 342 | struct passwd pws; |
| 343 | char pwbuf[X_LINE_MAX]; |
| 344 | struct passwd* pwp; |
| 345 | } _Xgetpwparams; |
| 346 | typedef int _Xgetpwret; |
| 347 | # define _XGetpwuid(u,p) \ |
| 348 | ((getpwuid_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf),&(p).pwp) == 0) ? \ |
| 349 | (p).pwp : NULL) |
| 350 | # define _XGetpwnam(u,p) \ |
| 351 | ((getpwnam_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf),&(p).pwp) == 0) ? \ |
| 352 | (p).pwp : NULL) |
| 353 | #endif |
| 354 | |
| 355 | #if defined(X_INCLUDE_PWD_H) && !defined(_XOS_INCLUDED_PWD_H) |
| 356 | # define _XOS_INCLUDED_PWD_H |
| 357 | #endif |
| 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 | #undef XTHREADS_NEEDS_BYNAMEPARAMS |
| 384 | #if defined(X_INCLUDE_NETDB_H) && !defined(_XOS_INCLUDED_NETDB_H) \ |
| 385 | && !defined(WIN32) |
| 386 | # include <netdb.h> |
| 387 | # if defined(XUSE_MTSAFE_API) || defined(XUSE_MTSAFE_NETDBAPI) |
| 388 | # define XOS_USE_MTSAFE_NETDBAPI 1 |
| 389 | # endif |
| 390 | #endif |
| 391 | |
| 392 | #if !defined(X_INCLUDE_NETDB_H) || defined(_XOS_INCLUDED_NETDB_H) |
| 393 | |
| 394 | |
| 395 | #elif !defined(XTHREADS) && !defined(X_FORCE_USE_MTSAFE_API) |
| 396 | |
| 397 | typedef int _Xgethostbynameparams; |
| 398 | typedef int _Xgetservbynameparams; |
| 399 | # define _XGethostbyname(h,hp) gethostbyname((h)) |
| 400 | # define _XGethostbyaddr(a,al,t,hp) gethostbyaddr((a),(al),(t)) |
| 401 | # define _XGetservbyname(s,p,sp) getservbyname((s),(p)) |
| 402 | |
| 403 | #elif !defined(XOS_USE_MTSAFE_NETDBAPI) || defined(XNO_MTSAFE_NETDBAPI) |
| 404 | |
| 405 | |
| 406 | #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) |
| 407 | #include <sys/param.h> |
| 408 | #endif |
| 409 | |
| 410 | typedef struct { |
| 411 | struct hostent hent; |
| 412 | char h_name[MAXHOSTNAMELEN]; |
| 413 | struct hostent *hptr; |
| 414 | } _Xgethostbynameparams; |
| 415 | typedef struct { |
| 416 | struct servent sent; |
| 417 | char s_name[255]; |
| 418 | char s_proto[255]; |
| 419 | struct servent *sptr; |
| 420 | } _Xgetservbynameparams; |
| 421 | |
| 422 | # define XTHREADS_NEEDS_BYNAMEPARAMS |
| 423 | |
| 424 | # define _Xg_copyHostent(hp) \ |
| 425 | (memcpy(&(hp).hent, (hp).hptr, sizeof(struct hostent)), \ |
| 426 | strcpy((hp).h_name, (hp).hptr->h_name), \ |
| 427 | ((hp).hent.h_name = (hp).h_name), \ |
| 428 | ((hp).hptr = &(hp).hent), \ |
| 429 | 0 ) |
| 430 | # define _Xg_copyServent(sp) \ |
| 431 | (memcpy(&(sp).sent, (sp).sptr, sizeof(struct servent)), \ |
| 432 | strcpy((sp).s_name, (sp).sptr->s_name), \ |
| 433 | ((sp).sent.s_name = (sp).s_name), \ |
| 434 | strcpy((sp).s_proto, (sp).sptr->s_proto), \ |
| 435 | ((sp).sent.s_proto = (sp).s_proto), \ |
| 436 | ((sp).sptr = &(sp).sent), \ |
| 437 | 0 ) |
| 438 | # define _XGethostbyname(h,hp) \ |
| 439 | ((_Xos_processLock), \ |
| 440 | (((hp).hptr = gethostbyname((h))) ? _Xg_copyHostent(hp) : 0), \ |
| 441 | (_Xos_processUnlock), \ |
| 442 | (hp).hptr ) |
| 443 | # define _XGethostbyaddr(a,al,t,hp) \ |
| 444 | ((_Xos_processLock), \ |
| 445 | (((hp).hptr = gethostbyaddr((a),(al),(t))) ? _Xg_copyHostent(hp) : 0), \ |
| 446 | (_Xos_processUnlock), \ |
| 447 | (hp).hptr ) |
| 448 | # define _XGetservbyname(s,p,sp) \ |
| 449 | ((_Xos_processLock), \ |
| 450 | (((sp).sptr = getservbyname((s),(p))) ? _Xg_copyServent(sp) : 0), \ |
| 451 | (_Xos_processUnlock), \ |
| 452 | (sp).sptr ) |
| 453 | |
| 454 | #elif defined(XUSE_NETDB_R_API) |
| 455 | |
| 456 | |
| 457 | |
| 458 | |
| 459 | # ifdef _POSIX_REENTRANT_FUNCTIONS |
| 460 | # ifndef _POSIX_THREAD_SAFE_FUNCTIONS |
| 461 | # endif |
| 462 | # endif |
| 463 | # ifdef _POSIX_THREAD_SAFE_FUNCTIONS |
| 464 | # define X_POSIX_THREAD_SAFE_FUNCTIONS 1 |
| 465 | # endif |
| 466 | |
| 467 | # define XTHREADS_NEEDS_BYNAMEPARAMS |
| 468 | |
| 469 | # ifndef X_POSIX_THREAD_SAFE_FUNCTIONS |
| 470 | typedef struct { |
| 471 | struct hostent hent; |
| 472 | char hbuf[X_LINE_MAX]; |
| 473 | int herr; |
| 474 | } _Xgethostbynameparams; |
| 475 | typedef struct { |
| 476 | struct servent sent; |
| 477 | char sbuf[X_LINE_MAX]; |
| 478 | } _Xgetservbynameparams; |
| 479 | # define _XGethostbyname(h,hp) \ |
| 480 | gethostbyname_r((h),&(hp).hent,(hp).hbuf,sizeof((hp).hbuf),&(hp).herr) |
| 481 | # define _XGethostbyaddr(a,al,t,hp) \ |
| 482 | gethostbyaddr_r((a),(al),(t),&(hp).hent,(hp).hbuf,sizeof((hp).hbuf),&(hp).herr) |
| 483 | # define _XGetservbyname(s,p,sp) \ |
| 484 | getservbyname_r((s),(p),&(sp).sent,(sp).sbuf,sizeof((sp).sbuf)) |
| 485 | # else |
| 486 | typedef struct { |
| 487 | struct hostent hent; |
| 488 | struct hostent_data hdata; |
| 489 | } _Xgethostbynameparams; |
| 490 | typedef struct { |
| 491 | struct servent sent; |
| 492 | struct servent_data sdata; |
| 493 | } _Xgetservbynameparams; |
| 494 | # define _XGethostbyname(h,hp) \ |
| 495 | (bzero((char*)&(hp).hdata,sizeof((hp).hdata)), \ |
| 496 | ((gethostbyname_r((h),&(hp).hent,&(hp).hdata) == -1) ? NULL : &(hp).hent)) |
| 497 | # define _XGethostbyaddr(a,al,t,hp) \ |
| 498 | (bzero((char*)&(hp).hdata,sizeof((hp).hdata)), \ |
| 499 | ((gethostbyaddr_r((a),(al),(t),&(hp).hent,&(hp).hdata) == -1) ? NULL : &(hp).hent)) |
| 500 | # define _XGetservbyname(s,p,sp) \ |
| 501 | (bzero((char*)&(sp).sdata,sizeof((sp).sdata)), \ |
| 502 | ((getservbyname_r((s),(p),&(sp).sent,&(sp).sdata) == -1) ? NULL : &(sp).sent) ) |
| 503 | # endif |
| 504 | # ifdef X_POSIX_THREAD_SAFE_FUNCTIONS |
| 505 | # undef X_POSIX_THREAD_SAFE_FUNCTIONS |
| 506 | # endif |
| 507 | |
| 508 | #else |
| 509 | |
| 510 | typedef int _Xgethostbynameparams; |
| 511 | typedef int _Xgetservbynameparams; |
| 512 | # define _XGethostbyname(h,hp) gethostbyname((h)) |
| 513 | # define _XGethostbyaddr(a,al,t,hp) gethostbyaddr((a),(al),(t)) |
| 514 | # define _XGetservbyname(s,p,sp) getservbyname((s),(p)) |
| 515 | #endif |
| 516 | |
| 517 | #if defined(X_INCLUDE_NETDB_H) && !defined(_XOS_INCLUDED_NETDB_H) |
| 518 | # define _XOS_INCLUDED_NETDB_H |
| 519 | #endif |
| 520 | |
| 521 | |
| 522 | |
| 523 | |
| 524 | |
| 525 | |
| 526 | |
| 527 | |
| 528 | |
| 529 | |
| 530 | |
| 531 | |
| 532 | |
| 533 | |
| 534 | |
| 535 | |
| 536 | #if defined(X_INCLUDE_DIRENT_H) && !defined(_XOS_INCLUDED_DIRENT_H) |
| 537 | # include <sys/types.h> |
| 538 | # if !defined(X_NOT_POSIX) || defined(SYSV) |
| 539 | # include <dirent.h> |
| 540 | # else |
| 541 | # include <sys/dir.h> |
| 542 | # ifndef dirent |
| 543 | # define dirent direct |
| 544 | # endif |
| 545 | # endif |
| 546 | # if defined(XUSE_MTSAFE_API) || defined(XUSE_MTSAFE_DIRENTAPI) |
| 547 | # define XOS_USE_MTSAFE_DIRENTAPI 1 |
| 548 | # endif |
| 549 | #endif |
| 550 | |
| 551 | #if !defined(X_INCLUDE_DIRENT_H) || defined(_XOS_INCLUDED_DIRENT_H) |
| 552 | |
| 553 | |
| 554 | #elif !defined(XTHREADS) && !defined(X_FORCE_USE_MTSAFE_API) |
| 555 | |
| 556 | typedef int _Xreaddirparams; |
| 557 | # define _XReaddir(d,p) readdir(d) |
| 558 | |
| 559 | #elif !defined(XOS_USE_MTSAFE_DIRENTAPI) || defined(XNO_MTSAFE_DIRENTAPI) |
| 560 | |
| 561 | typedef struct { |
| 562 | struct dirent *result; |
| 563 | struct dirent dir_entry; |
| 564 | # ifdef _POSIX_PATH_MAX |
| 565 | char buf[_POSIX_PATH_MAX]; |
| 566 | # elif defined(NAME_MAX) |
| 567 | char buf[NAME_MAX]; |
| 568 | # else |
| 569 | char buf[255]; |
| 570 | # endif |
| 571 | } _Xreaddirparams; |
| 572 | |
| 573 | # define _XReaddir(d,p) \ |
| 574 | ( (_Xos_processLock), \ |
| 575 | (((p).result = readdir((d))) ? \ |
| 576 | (memcpy(&((p).dir_entry), (p).result, (p).result->d_reclen), \ |
| 577 | ((p).result = &(p).dir_entry), 0) : \ |
| 578 | 0), \ |
| 579 | (_Xos_processUnlock), \ |
| 580 | (p).result ) |
| 581 | |
| 582 | #else |
| 583 | typedef struct { |
| 584 | struct dirent *result; |
| 585 | struct dirent dir_entry; |
| 586 | # ifdef _POSIX_PATH_MAX |
| 587 | char buf[_POSIX_PATH_MAX]; |
| 588 | # elif defined(NAME_MAX) |
| 589 | char buf[NAME_MAX]; |
| 590 | # else |
| 591 | char buf[255]; |
| 592 | # endif |
| 593 | } _Xreaddirparams; |
| 594 | |
| 595 | # if defined(_POSIX_THREAD_SAFE_FUNCTIONS) || defined(__APPLE__) |
| 596 | |
| 597 | # define _XReaddir(d,p) \ |
| 598 | (readdir_r((d), &((p).dir_entry), &((p).result)) ? NULL : (p).result) |
| 599 | # elif defined(_POSIX_REENTRANT_FUNCTIONS) |
| 600 | |
| 601 | # define _XReaddir(d,p) \ |
| 602 | (readdir_r((d),&((p).dir_entry)) ? NULL : &((p).dir_entry)) |
| 603 | # elif defined(SVR4) |
| 604 | |
| 605 | # define _XReaddir(d,p) (readdir_r((d), &(p).dir_entry)) |
| 606 | # else |
| 607 | |
| 608 | # define _XReaddir(d,p) \ |
| 609 | ( (_Xos_processLock), \ |
| 610 | (((p).result = readdir((d))) ? \ |
| 611 | (memcpy(&((p).dir_entry), (p).result, (p).result->d_reclen), \ |
| 612 | ((p).result = &(p).dir_entry), 0) : \ |
| 613 | 0), \ |
| 614 | (_Xos_processUnlock), \ |
| 615 | (p).result ) |
| 616 | # endif |
| 617 | #endif |
| 618 | |
| 619 | #if defined(X_INCLUDE_DIRENT_H) && !defined(_XOS_INCLUDED_DIRENT_H) |
| 620 | # define _XOS_INCLUDED_DIRENT_H |
| 621 | #endif |
| 622 | |
| 623 | |
| 624 | |
| 625 | |
| 626 | |
| 627 | |
| 628 | |
| 629 | |
| 630 | |
| 631 | |
| 632 | |
| 633 | |
| 634 | |
| 635 | |
| 636 | |
| 637 | |
| 638 | |
| 639 | |
| 640 | #if defined(X_INCLUDE_UNISTD_H) && !defined(_XOS_INCLUDED_UNISTD_H) |
| 641 | |
| 642 | # if defined(XUSE_MTSAFE_API) || defined(XUSE_MTSAFE_UNISTDAPI) |
| 643 | # define XOS_USE_MTSAFE_UNISTDAPI 1 |
| 644 | # endif |
| 645 | #endif |
| 646 | |
| 647 | #if !defined(X_INCLUDE_UNISTD_H) || defined(_XOS_INCLUDED_UNISTD_H) |
| 648 | |
| 649 | |
| 650 | #elif !defined(XTHREADS) && !defined(X_FORCE_USE_MTSAFE_API) |
| 651 | |
| 652 | typedef int _Xgetloginparams; |
| 653 | typedef int _Xttynameparams; |
| 654 | # define _XGetlogin(p) getlogin() |
| 655 | # define _XTtyname(f) ttyname((f)) |
| 656 | |
| 657 | #elif !defined(XOS_USE_MTSAFE_UNISTDAPI) || defined(XNO_MTSAFE_UNISTDAPI) |
| 658 | |
| 659 | typedef struct { |
| 660 | char *result; |
| 661 | # if defined(MAXLOGNAME) |
| 662 | char buf[MAXLOGNAME]; |
| 663 | # elif defined(LOGIN_NAME_MAX) |
| 664 | char buf[LOGIN_NAME_MAX]; |
| 665 | # else |
| 666 | char buf[64]; |
| 667 | # endif |
| 668 | } _Xgetloginparams; |
| 669 | typedef struct { |
| 670 | char *result; |
| 671 | # ifdef TTY_NAME_MAX |
| 672 | char buf[TTY_NAME_MAX]; |
| 673 | # elif defined(_POSIX_TTY_NAME_MAX) |
| 674 | char buf[_POSIX_TTY_NAME_MAX]; |
| 675 | # elif defined(_POSIX_PATH_MAX) |
| 676 | char buf[_POSIX_PATH_MAX]; |
| 677 | # else |
| 678 | char buf[256]; |
| 679 | # endif |
| 680 | } _Xttynameparams; |
| 681 | |
| 682 | # define _XGetlogin(p) \ |
| 683 | ( (_Xos_processLock), \ |
| 684 | (((p).result = getlogin()) ? \ |
| 685 | (strncpy((p).buf, (p).result, sizeof((p).buf)), \ |
| 686 | ((p).buf[sizeof((p).buf)-1] = '\0'), \ |
| 687 | ((p).result = (p).buf), 0) : 0), \ |
| 688 | (_Xos_processUnlock), \ |
| 689 | (p).result ) |
| 690 | #define _XTtyname(f,p) \ |
| 691 | ( (_Xos_processLock), \ |
| 692 | (((p).result = ttyname(f)) ? \ |
| 693 | (strncpy((p).buf, (p).result, sizeof((p).buf)), \ |
| 694 | ((p).buf[sizeof((p).buf)-1] = '\0'), \ |
| 695 | ((p).result = (p).buf), 0) : 0), \ |
| 696 | (_Xos_processUnlock), \ |
| 697 | (p).result ) |
| 698 | |
| 699 | #elif defined(_POSIX_THREAD_SAFE_FUNCTIONS) || defined(_POSIX_REENTRANT_FUNCTIONS) |
| 700 | |
| 701 | |
| 702 | |
| 703 | |
| 704 | |
| 705 | typedef struct { |
| 706 | # if defined(MAXLOGNAME) |
| 707 | char buf[MAXLOGNAME]; |
| 708 | # elif defined(LOGIN_NAME_MAX) |
| 709 | char buf[LOGIN_NAME_MAX]; |
| 710 | # else |
| 711 | char buf[64]; |
| 712 | # endif |
| 713 | } _Xgetloginparams; |
| 714 | typedef struct { |
| 715 | # ifdef TTY_NAME_MAX |
| 716 | char buf[TTY_NAME_MAX]; |
| 717 | # elif defined(_POSIX_TTY_NAME_MAX) |
| 718 | char buf[_POSIX_TTY_NAME_MAX]; |
| 719 | # elif defined(_POSIX_PATH_MAX) |
| 720 | char buf[_POSIX_PATH_MAX]; |
| 721 | # else |
| 722 | char buf[256]; |
| 723 | # endif |
| 724 | } _Xttynameparams; |
| 725 | |
| 726 | # define _XGetlogin(p) (getlogin_r((p).buf, sizeof((p).buf)) ? NULL : (p).buf) |
| 727 | # define _XTtyname(f,p) \ |
| 728 | (ttyname_r((f), (p).buf, sizeof((p).buf)) ? NULL : (p).buf) |
| 729 | |
| 730 | #else |
| 731 | |
| 732 | |
| 733 | |
| 734 | |
| 735 | |
| 736 | typedef struct { |
| 737 | # if defined(MAXLOGNAME) |
| 738 | char buf[MAXLOGNAME]; |
| 739 | # elif defined(LOGIN_NAME_MAX) |
| 740 | char buf[LOGIN_NAME_MAX]; |
| 741 | # else |
| 742 | char buf[64]; |
| 743 | # endif |
| 744 | } _Xgetloginparams; |
| 745 | typedef struct { |
| 746 | # ifdef TTY_NAME_MAX |
| 747 | char buf[TTY_NAME_MAX]; |
| 748 | # elif defined(_POSIX_TTY_NAME_MAX) |
| 749 | char buf[_POSIX_TTY_NAME_MAX]; |
| 750 | # elif defined(_POSIX_PATH_MAX) |
| 751 | char buf[_POSIX_PATH_MAX]; |
| 752 | # else |
| 753 | char buf[256]; |
| 754 | # endif |
| 755 | } _Xttynameparams; |
| 756 | |
| 757 | # define _XGetlogin(p) getlogin_r((p).buf, sizeof((p).buf)) |
| 758 | # define _XTtyname(f,p) ttyname_r((f), (p).buf, sizeof((p).buf)) |
| 759 | #endif |
| 760 | |
| 761 | #if defined(X_INCLUDE_UNISTD_H) && !defined(_XOS_INCLUDED_UNISTD_H) |
| 762 | # define _XOS_INCLUDED_UNISTD_H |
| 763 | #endif |
| 764 | |
| 765 | |
| 766 | |
| 767 | |
| 768 | |
| 769 | |
| 770 | |
| 771 | |
| 772 | |
| 773 | |
| 774 | |
| 775 | |
| 776 | |
| 777 | |
| 778 | |
| 779 | |
| 780 | #if defined(X_INCLUDE_STRING_H) && !defined(_XOS_INCLUDED_STRING_H) |
| 781 | |
| 782 | # if defined(XUSE_MTSAFE_API) || defined(XUSE_MTSAFE_STRINGAPI) |
| 783 | # define XOS_USE_MTSAFE_STRINGAPI 1 |
| 784 | # endif |
| 785 | #endif |
| 786 | |
| 787 | #if !defined(X_INCLUDE_STRING_H) || defined(_XOS_INCLUDED_STRING_H) |
| 788 | |
| 789 | |
| 790 | #elif !defined(XTHREADS) && !defined(X_FORCE_USE_MTSAFE_API) |
| 791 | |
| 792 | typedef int _Xstrtokparams; |
| 793 | # define _XStrtok(s1,s2,p) \ |
| 794 | ( p = 0, (void)p, strtok((s1),(s2)) ) |
| 795 | |
| 796 | #elif !defined(XOS_USE_MTSAFE_STRINGAPI) || defined(XNO_MTSAFE_STRINGAPI) |
| 797 | |
| 798 | typedef char *_Xstrtokparams; |
| 799 | # define _XStrtok(s1,s2,p) \ |
| 800 | ( (_Xos_processLock), \ |
| 801 | ((p) = strtok((s1),(s2))), \ |
| 802 | (_Xos_processUnlock), \ |
| 803 | (p) ) |
| 804 | |
| 805 | #else |
| 806 | |
| 807 | typedef char * _Xstrtokparams; |
| 808 | # define _XStrtok(s1,s2,p) strtok_r((s1),(s2),&(p)) |
| 809 | #endif |
| 810 | |
| 811 | |
| 812 | |
| 813 | |
| 814 | |
| 815 | |
| 816 | |
| 817 | |
| 818 | |
| 819 | |
| 820 | |
| 821 | |
| 822 | |
| 823 | |
| 824 | |
| 825 | |
| 826 | |
| 827 | |
| 828 | |
| 829 | |
| 830 | |
| 831 | |
| 832 | #if defined(X_INCLUDE_TIME_H) && !defined(_XOS_INCLUDED_TIME_H) |
| 833 | # include <time.h> |
| 834 | # if defined(XUSE_MTSAFE_API) || defined(XUSE_MTSAFE_TIMEAPI) |
| 835 | # define XOS_USE_MTSAFE_TIMEAPI 1 |
| 836 | # endif |
| 837 | #endif |
| 838 | |
| 839 | #if !defined(X_INCLUDE_TIME_H) || defined(_XOS_INCLUDED_TIME_H) |
| 840 | |
| 841 | |
| 842 | #elif !defined(XTHREADS) && !defined(X_FORCE_USE_MTSAFE_API) |
| 843 | |
| 844 | typedef int _Xatimeparams; |
| 845 | # define _XAsctime(t,p) asctime((t)) |
| 846 | typedef int _Xctimeparams; |
| 847 | # define _XCtime(t,p) ctime((t)) |
| 848 | typedef int _Xgtimeparams; |
| 849 | # define _XGmtime(t,p) gmtime((t)) |
| 850 | typedef int _Xltimeparams; |
| 851 | # define _XLocaltime(t,p) localtime((t)) |
| 852 | |
| 853 | #elif !defined(XOS_USE_MTSAFE_TIMEAPI) || defined(XNO_MTSAFE_TIMEAPI) |
| 854 | |
| 855 | typedef struct { |
| 856 | # ifdef TIMELEN |
| 857 | char buf[TIMELEN]; |
| 858 | # else |
| 859 | char buf[26]; |
| 860 | # endif |
| 861 | char *result; |
| 862 | } _Xctimeparams, _Xatimeparams; |
| 863 | typedef struct { |
| 864 | struct tm buf; |
| 865 | struct tm *result; |
| 866 | } _Xgtimeparams, _Xltimeparams; |
| 867 | # define _XAsctime(t,p) \ |
| 868 | ( (_Xos_processLock), \ |
| 869 | (((p).result = asctime((t))) ? \ |
| 870 | (strncpy((p).buf, (p).result, sizeof((p).buf)), (p).result = &(p).buf) : \ |
| 871 | 0), \ |
| 872 | (_Xos_processUnlock), \ |
| 873 | (p).result ) |
| 874 | # define _XCtime(t,p) \ |
| 875 | ( (_Xos_processLock), \ |
| 876 | (((p).result = ctime((t))) ? \ |
| 877 | (strncpy((p).buf, (p).result, sizeof((p).buf)), (p).result = &(p).buf) : \ |
| 878 | 0), \ |
| 879 | (_Xos_processUnlock), \ |
| 880 | (p).result ) |
| 881 | # define _XGmtime(t,p) \ |
| 882 | ( (_Xos_processLock), \ |
| 883 | (((p).result = gmtime(t)) ? \ |
| 884 | (memcpy(&(p).buf, (p).result, sizeof((p).buf)), (p).result = &(p).buf) : \ |
| 885 | 0), \ |
| 886 | (_Xos_processUnlock), \ |
| 887 | (p).result ) |
| 888 | # define _XLocaltime(t,p) \ |
| 889 | ( (_Xos_processLock), \ |
| 890 | (((p).result = localtime(t)) ? \ |
| 891 | (memcpy(&(p).buf, (p).result, sizeof((p).buf)), (p).result = &(p).buf) : \ |
| 892 | 0), \ |
| 893 | (_Xos_processUnlock), \ |
| 894 | (p).result ) |
| 895 | |
| 896 | #elif !defined(_POSIX_THREAD_SAFE_FUNCTIONS) && defined(hpV4) |
| 897 | |
| 898 | |
| 899 | |
| 900 | |
| 901 | |
| 902 | |
| 903 | |
| 904 | # ifdef TIMELEN |
| 905 | typedef char _Xatimeparams[TIMELEN]; |
| 906 | typedef char _Xctimeparams[TIMELEN]; |
| 907 | # else |
| 908 | typedef char _Xatimeparams[26]; |
| 909 | typedef char _Xctimeparams[26]; |
| 910 | # endif |
| 911 | typedef struct tm _Xgtimeparams; |
| 912 | typedef struct tm _Xltimeparams; |
| 913 | # define _XAsctime(t,p) (asctime_r((t),(p),sizeof((p))) ? NULL : (p)) |
| 914 | # define _XCtime(t,p) (ctime_r((t),(p),sizeof((p))) ? NULL : (p)) |
| 915 | # define _XGmtime(t,p) (gmtime_r((t),&(p)) ? NULL : &(p)) |
| 916 | # define _XLocaltime(t,p) (localtime_r((t),&(p)) ? NULL : &(p)) |
| 917 | |
| 918 | #elif !defined(_POSIX_THREAD_SAFE_FUNCTIONS) && defined(__sun) |
| 919 | |
| 920 | |
| 921 | |
| 922 | |
| 923 | |
| 924 | |
| 925 | |
| 926 | # ifdef TIMELEN |
| 927 | typedef char _Xatimeparams[TIMELEN]; |
| 928 | typedef char _Xctimeparams[TIMELEN]; |
| 929 | # else |
| 930 | typedef char _Xatimeparams[26]; |
| 931 | typedef char _Xctimeparams[26]; |
| 932 | # endif |
| 933 | typedef struct tm _Xgtimeparams; |
| 934 | typedef struct tm _Xltimeparams; |
| 935 | # define _XAsctime(t,p) asctime_r((t),(p),sizeof((p))) |
| 936 | # define _XCtime(t,p) ctime_r((t),(p),sizeof((p))) |
| 937 | # define _XGmtime(t,p) gmtime_r((t),&(p)) |
| 938 | # define _XLocaltime(t,p) localtime_r((t),&(p)) |
| 939 | |
| 940 | #else |
| 941 | |
| 942 | |
| 943 | |
| 944 | |
| 945 | |
| 946 | |
| 947 | # ifdef TIMELEN |
| 948 | typedef char _Xatimeparams[TIMELEN]; |
| 949 | typedef char _Xctimeparams[TIMELEN]; |
| 950 | # else |
| 951 | typedef char _Xatimeparams[26]; |
| 952 | typedef char _Xctimeparams[26]; |
| 953 | # endif |
| 954 | typedef struct tm _Xgtimeparams; |
| 955 | typedef struct tm _Xltimeparams; |
| 956 | # define _XAsctime(t,p) asctime_r((t),(p)) |
| 957 | # define _XCtime(t,p) ctime_r((t),(p)) |
| 958 | # define _XGmtime(t,p) gmtime_r((t),&(p)) |
| 959 | # define _XLocaltime(t,p) localtime_r((t),&(p)) |
| 960 | #endif |
| 961 | |
| 962 | #if defined(X_INCLUDE_TIME_H) && !defined(_XOS_INCLUDED_TIME_H) |
| 963 | # define _XOS_INCLUDED_TIME_H |
| 964 | #endif |
| 965 | |
| 966 | |
| 967 | |
| 968 | |
| 969 | |
| 970 | |
| 971 | |
| 972 | |
| 973 | |
| 974 | |
| 975 | |
| 976 | |
| 977 | |
| 978 | |
| 979 | |
| 980 | |
| 981 | |
| 982 | |
| 983 | |
| 984 | |
| 985 | |
| 986 | |
| 987 | |
| 988 | #if defined(X_INCLUDE_GRP_H) && !defined(_XOS_INCLUDED_GRP_H) |
| 989 | # include <grp.h> |
| 990 | # if defined(XUSE_MTSAFE_API) || defined(XUSE_MTSAFE_GRPAPI) |
| 991 | # define XOS_USE_MTSAFE_GRPAPI 1 |
| 992 | # endif |
| 993 | #endif |
| 994 | |
| 995 | #if !defined(X_INCLUDE_GRP_H) || defined(_XOS_INCLUDED_GRP_H) |
| 996 | |
| 997 | |
| 998 | #elif !defined(XTHREADS) && !defined(X_FORCE_USE_MTSAFE_API) |
| 999 | |
| 1000 | typedef int _Xgetgrparams; |
| 1001 | #define _XGetgrgid(g,p) getgrgid((g)) |
| 1002 | #define _XGetgrnam(n,p) getgrnam((n)) |
| 1003 | |
| 1004 | #elif !defined(XOS_USE_MTSAFE_GRPAPI) || defined(XNO_MTSAFE_GRPAPI) |
| 1005 | |
| 1006 | typedef struct { |
| 1007 | struct group grp; |
| 1008 | char buf[X_LINE_MAX]; |
| 1009 | struct group *pgrp; |
| 1010 | size_t len; |
| 1011 | } _Xgetgrparams; |
| 1012 | #ifdef SVR4 |
| 1013 | |
| 1014 | # define _Xgrp_copyGroup(p) \ |
| 1015 | ( memcpy(&(p).grp, (p).pgrp, sizeof(struct group)), \ |
| 1016 | ((p).grp.gr_name = (p).buf), \ |
| 1017 | ((p).len = strlen((p).pgrp->gr_name)), \ |
| 1018 | strcpy((p).grp.gr_name, (p).pgrp->gr_name), \ |
| 1019 | ((p).grp.gr_passwd = (p).grp.gr_name + (p).len + 1), \ |
| 1020 | ((p).pgrp = &(p).grp), \ |
| 1021 | 0 ) |
| 1022 | #else |
| 1023 | # define _Xgrp_copyGroup(p) \ |
| 1024 | ( memcpy(&(p).grp, (p).pgrp, sizeof(struct group)), \ |
| 1025 | ((p).grp.gr_name = (p).buf), \ |
| 1026 | strcpy((p).grp.gr_name, (p).pgrp->gr_name), \ |
| 1027 | ((p).pgrp = &(p).grp), \ |
| 1028 | 0 ) |
| 1029 | #endif |
| 1030 | #define _XGetgrgid(g,p) \ |
| 1031 | ( (_Xos_processLock), \ |
| 1032 | (((p).pgrp = getgrgid((g))) ? _Xgrp_copyGroup(p) : 0), \ |
| 1033 | (_Xos_processUnlock), \ |
| 1034 | (p).pgrp ) |
| 1035 | #define _XGetgrnam(n,p) \ |
| 1036 | ( (_Xos_processLock), \ |
| 1037 | (((p).pgrp = getgrnam((n))) ? _Xgrp_copyGroup(p) : 0), \ |
| 1038 | (_Xos_processUnlock), \ |
| 1039 | (p).pgrp ) |
| 1040 | |
| 1041 | #elif !defined(_POSIX_THREAD_SAFE_FUNCTIONS) && defined(__sun) |
| 1042 | |
| 1043 | |
| 1044 | |
| 1045 | |
| 1046 | |
| 1047 | typedef struct { |
| 1048 | struct group grp; |
| 1049 | char buf[X_LINE_MAX]; |
| 1050 | } _Xgetgrparams; |
| 1051 | #define _XGetgrgid(g,p) getgrgid_r((g), &(p).grp, (p).buf, sizeof((p).buf)) |
| 1052 | #define _XGetgrnam(n,p) getgrnam_r((n), &(p).grp, (p).buf, sizeof((p).buf)) |
| 1053 | |
| 1054 | #elif !defined(_POSIX_THREAD_SAFE_FUNCTIONS) |
| 1055 | |
| 1056 | |
| 1057 | |
| 1058 | |
| 1059 | typedef struct { |
| 1060 | struct group grp; |
| 1061 | char buf[X_LINE_MAX]; |
| 1062 | } _Xgetgrparams; |
| 1063 | #define _XGetgrgid(g,p) \ |
| 1064 | ((getgrgid_r((g), &(p).grp, (p).buf, sizeof((p).buf)) ? NULL : &(p).grp)) |
| 1065 | #define _XGetgrnam(n,p) \ |
| 1066 | ((getgrnam_r((n), &(p).grp, (p).buf, sizeof((p).buf)) ? NULL : &(p).grp)) |
| 1067 | |
| 1068 | #else |
| 1069 | |
| 1070 | |
| 1071 | |
| 1072 | |
| 1073 | |
| 1074 | typedef struct { |
| 1075 | struct group grp; |
| 1076 | char buf[X_LINE_MAX]; |
| 1077 | struct group *result; |
| 1078 | } _Xgetgrparams; |
| 1079 | |
| 1080 | #define _XGetgrgid(g,p) \ |
| 1081 | ((getgrgid_r((g), &(p).grp, (p).buf, sizeof((p).buf), &(p).result) ? \ |
| 1082 | NULL : (p).result)) |
| 1083 | #define _XGetgrnam(n,p) \ |
| 1084 | ((getgrnam_r((n), &(p).grp, (p).buf, sizeof((p).buf), &(p).result) ? \ |
| 1085 | NULL : (p).result)) |
| 1086 | #endif |
| 1087 | |
| 1088 | #if defined(X_INCLUDE_GRP_H) && !defined(_XOS_INCLUDED_GRP_H) |
| 1089 | # define _XOS_INCLUDED_GRP_H |
| 1090 | #endif |
| 1091 | |
| 1092 | |
| 1093 | #ifdef __cplusplus |
| 1094 | } |
| 1095 | #endif |