fileext.h revision 9287223674afe3957d248ad51200c5abead6ec96
11dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* $OpenBSD: fileext.h,v 1.2 2005/06/17 20:40:32 espie Exp $ */ 21dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* $NetBSD: fileext.h,v 1.5 2003/07/18 21:46:41 nathanw Exp $ */ 31dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 41dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/*- 51dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Copyright (c)2001 Citrus Project, 61dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * All rights reserved. 71dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 81dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Redistribution and use in source and binary forms, with or without 91dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * modification, are permitted provided that the following conditions 101dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * are met: 111dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 1. Redistributions of source code must retain the above copyright 121dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * notice, this list of conditions and the following disclaimer. 131dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 2. Redistributions in binary form must reproduce the above copyright 141dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * notice, this list of conditions and the following disclaimer in the 151dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * documentation and/or other materials provided with the distribution. 161dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 171dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 181dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 191dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 201dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 211dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 221dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 231dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 241dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 251dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 261dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 271dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * SUCH DAMAGE. 281dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * 291dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * $Citrus$ 301dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project */ 311dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 329287223674afe3957d248ad51200c5abead6ec96Calin Juravle#ifndef _FILEEXT_H_ 339287223674afe3957d248ad51200c5abead6ec96Calin Juravle#define _FILEEXT_H_ 349287223674afe3957d248ad51200c5abead6ec96Calin Juravle 359831ad3ce6bd5b22da16a275ed67e7236eae3d1fDavid 'Digit' Turner#include <pthread.h> 369831ad3ce6bd5b22da16a275ed67e7236eae3d1fDavid 'Digit' Turner 371dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* 381dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * file extension 391dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project */ 401dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectstruct __sfileext { 411dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project struct __sbuf _ub; /* ungetc buffer */ 421dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project struct wchar_io_data _wcio; /* wide char io status */ 439831ad3ce6bd5b22da16a275ed67e7236eae3d1fDavid 'Digit' Turner pthread_mutex_t _lock; /* file lock */ 441dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project}; 451dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 469831ad3ce6bd5b22da16a275ed67e7236eae3d1fDavid 'Digit' Turner#define _FILEEXT_INITIALIZER {{NULL,0},{0},PTHREAD_RECURSIVE_MUTEX_INITIALIZER} 479831ad3ce6bd5b22da16a275ed67e7236eae3d1fDavid 'Digit' Turner 481dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define _EXT(fp) ((struct __sfileext *)((fp)->_ext._base)) 491dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define _UB(fp) _EXT(fp)->_ub 509831ad3ce6bd5b22da16a275ed67e7236eae3d1fDavid 'Digit' Turner#define _FLOCK(fp) _EXT(fp)->_lock 511dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 521dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define _FILEEXT_INIT(fp) \ 531dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectdo { \ 541dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project _UB(fp)._base = NULL; \ 551dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project _UB(fp)._size = 0; \ 561dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project WCIO_INIT(fp); \ 5753e43292aac91bf62995788cd5ca2ceb7caea283Elliott Hughes _FLOCK(fp).value = __PTHREAD_RECURSIVE_MUTEX_INIT_VALUE; \ 581dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project} while (0) 591dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 601dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define _FILEEXT_SETUP(f, fext) \ 611dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectdo { \ 621dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project (f)->_ext._base = (unsigned char *)(fext); \ 631dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project _FILEEXT_INIT(f); \ 641dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project} while (0) 659287223674afe3957d248ad51200c5abead6ec96Calin Juravle 669287223674afe3957d248ad51200c5abead6ec96Calin Juravle#endif /* _FILEEXT_H_ */ 67