12c393a42Smrg/* 2a6844aabSmrg * fontconfig/doc/fcatomic.fncs 32c393a42Smrg * 42c393a42Smrg * Copyright © 2003 Keith Packard 52c393a42Smrg * 62c393a42Smrg * Permission to use, copy, modify, distribute, and sell this software and its 72c393a42Smrg * documentation for any purpose is hereby granted without fee, provided that 82c393a42Smrg * the above copyright notice appear in all copies and that both that 92c393a42Smrg * copyright notice and this permission notice appear in supporting 10ca08ab68Smrg * documentation, and that the name of the author(s) not be used in 112c393a42Smrg * advertising or publicity pertaining to distribution of the software without 12ca08ab68Smrg * specific, written prior permission. The authors make no 132c393a42Smrg * representations about the suitability of this software for any purpose. It 142c393a42Smrg * is provided "as is" without express or implied warranty. 152c393a42Smrg * 16a6844aabSmrg * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 172c393a42Smrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 18a6844aabSmrg * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR 192c393a42Smrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 202c393a42Smrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 212c393a42Smrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 222c393a42Smrg * PERFORMANCE OF THIS SOFTWARE. 232c393a42Smrg */ 242c393a42Smrg 252c393a42Smrg@RET@ FcAtomic * 262c393a42Smrg@FUNC@ FcAtomicCreate 271cc69409Smrg@TYPE1@ const FcChar8 * @ARG1@ file 281cc69409Smrg@PURPOSE@ create an FcAtomic object 292c393a42Smrg@DESC@ 302c393a42SmrgCreates a data structure containing data needed to control access to <parameter>file</parameter>. 312c393a42SmrgWriting is done to a separate file. Once that file is complete, the original 322c393a42Smrgconfiguration file is atomically replaced so that reading process always see 332c393a42Smrga consistent and complete file without the need to lock for reading. 342c393a42Smrg@@ 352c393a42Smrg 362c393a42Smrg@RET@ FcBool 372c393a42Smrg@FUNC@ FcAtomicLock 382c393a42Smrg@TYPE1@ FcAtomic * @ARG1@ atomic 391cc69409Smrg@PURPOSE@ lock a file 402c393a42Smrg@DESC@ 412c393a42SmrgAttempts to lock the file referenced by <parameter>atomic</parameter>. 422c393a42SmrgReturns FcFalse if the file is already locked, else returns FcTrue and 432c393a42Smrgleaves the file locked. 442c393a42Smrg@@ 452c393a42Smrg 462c393a42Smrg@RET@ FcChar8 * 472c393a42Smrg@FUNC@ FcAtomicNewFile 482c393a42Smrg@TYPE1@ FcAtomic * @ARG1@ atomic 491cc69409Smrg@PURPOSE@ return new temporary file name 502c393a42Smrg@DESC@ 512c393a42SmrgReturns the filename for writing a new version of the file referenced 522c393a42Smrgby <parameter>atomic</parameter>. 532c393a42Smrg@@ 542c393a42Smrg 552c393a42Smrg@RET@ FcChar8 * 562c393a42Smrg@FUNC@ FcAtomicOrigFile 572c393a42Smrg@TYPE1@ FcAtomic * @ARG1@ atomic 581cc69409Smrg@PURPOSE@ return original file name 592c393a42Smrg@DESC@ 60ca08ab68SmrgReturns the file referenced by <parameter>atomic</parameter>. 612c393a42Smrg@@ 622c393a42Smrg 632c393a42Smrg@RET@ FcBool 642c393a42Smrg@FUNC@ FcAtomicReplaceOrig 652c393a42Smrg@TYPE1@ FcAtomic * @ARG1@ atomic 661cc69409Smrg@PURPOSE@ replace original with new 672c393a42Smrg@DESC@ 682c393a42SmrgReplaces the original file referenced by <parameter>atomic</parameter> with 692c393a42Smrgthe new file. Returns FcFalse if the file cannot be replaced due to 702c393a42Smrgpermission issues in the filesystem. Otherwise returns FcTrue. 712c393a42Smrg@@ 722c393a42Smrg 732c393a42Smrg@RET@ void 742c393a42Smrg@FUNC@ FcAtomicDeleteNew 752c393a42Smrg@TYPE1@ FcAtomic * @ARG1@ atomic 761cc69409Smrg@PURPOSE@ delete new file 772c393a42Smrg@DESC@ 782c393a42SmrgDeletes the new file. Used in error recovery to back out changes. 792c393a42Smrg@@ 802c393a42Smrg 812c393a42Smrg@RET@ void 822c393a42Smrg@FUNC@ FcAtomicUnlock 832c393a42Smrg@TYPE1@ FcAtomic * @ARG1@ atomic 841cc69409Smrg@PURPOSE@ unlock a file 852c393a42Smrg@DESC@ 862c393a42SmrgUnlocks the file. 872c393a42Smrg@@ 882c393a42Smrg 892c393a42Smrg@RET@ void 902c393a42Smrg@FUNC@ FcAtomicDestroy 912c393a42Smrg@TYPE1@ FcAtomic * @ARG1@ atomic 921cc69409Smrg@PURPOSE@ destroy an FcAtomic object 932c393a42Smrg@DESC@ 942c393a42SmrgDestroys <parameter>atomic</parameter>. 952c393a42Smrg@@ 96