.\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" Paul Vixie. .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#) bitstring. 3 8.1 (Berkeley) 7/19/93 .\" %FreeBSD: src/share/man/man3/bitstring. 3, v 1.6. 2.5 2001/12/17 11:30:11 ru Exp % .\" .\" $FreeBSD: doc/ja_JP.eucJP/man/man3/bitstring. 3, v 1.6 2002/05/18 07:12:52 horikawa Exp $ .\" .Dd July 19, 1993 .Dt BITSTRING 3 .Os .Sh ¸íĪ .Nm bit_alloc , .Nm bit_clear , .Nm bit_decl , .Nm bit_ffs , .Nm bit_nclear , .Nm bit_nset , .Nm bit_set , .Nm bitstr_size , .Nm bit_test .Nd ºñÆ®¿­Á¶ÀÛ ¸ÅÅ©·Î .Sh ¼­½Ä .In bitstring.h .Ft bitstr_t * .Fn bit_alloc "int nbits" .Ft void .Fn bit_decl "bitstr_t *name" "int nbits" .Ft void .Fn bit_clear "bitstr_t *name" "int bit" .Ft void .Fn bit_ffc "bitstr_t *name" "int nbits" "int *value" .Ft void .Fn bit_ffs "bitstr_t *name" "int nbits" "int *value" .Ft void .Fn bit_nclear "bitstr_t *name" "int start" "int stop" .Ft void .Fn bit_nset "bitstr_t *name" "int start" "int stop" .Ft void .Fn bit_set "bitstr_t *name" "int bit" .Ft int .Fn bitstr_size "int nbits" .Ft int .Fn bit_test "bitstr_t *name" "int bit" .Sh ÇØ¼³ ÀÌ·¯ÇÑ ¸ÅÅ©·Î´Â ºñÆ®¿­À» Á¶ÀÛÇÕ´Ï´Ù. .Pp ¸ÅÅ©·Î .Fn bit_alloc (Àº)´Â, .Fa nbits °³ÀÇ ºñÆ®¸¦ °Ý³³Çϴµ¥ ÃæºÐÇÑ °ø°£À» °¡¸®Å°´Â ÇüÅ .Dq Fa "bitstr_t *" ÀÇ Æ÷ÀÎÅ͸¦ µ¹·ÁÁÝ´Ï´Ù. ¶Ç´Â, °ø°£À» ÀÌ¿ëÇÒ ¼ö ¾ø´Â °æ¿ì´Â .Dv NULL (À»)¸¦ µ¹·ÁÁÝ´Ï´Ù. .Pp ¸ÅÅ©·Î .Fn bit_decl (Àº)´Â, .Fa nbits °³ÀÇ ºñÆ®¸¦ °Ý³³Çϴµ¥ ÃæºÐÇÑ °ø°£À» ½ºÅÿ¡ ÇÒ´çÇÕ´Ï´Ù. .Pp ¸ÅÅ©·Î .Fn bitstr_size (Àº)´Â, .Fa nbits °³ÀÇ ºñÆ®¸¦ °Ý³³Çϴµ¥ ÇÊ¿äÇÑ, ÇüÅ .Fa bitstr_t ÀÇ ¿ä¼ÒÀÇ ¼ö¸¦ µ¹·ÁÁÝ´Ï´Ù. À̰ÍÀº ºñÆ®¿­À» Ä«ÇÇÇϴµ¥ Æí¸®ÇÕ´Ï´Ù. .Pp ¸ÅÅ©·Î .Fn bit_clear (¿Í)°ú ¸ÅÅ©·Î .Fn bit_set (Àº)´Â, ºñÆ®¿­ .Ar name ¾ÈÀÇ, 0 À» ±âÁ¡À¸·Î¼­ .Fa bit ¹øÂ°ÀÇ ºñÆ®¸¦ Ŭ¸®¾î ¶Ç´Â ¼³Á¤ÇÕ´Ï´Ù. .Pp ¸ÅÅ©·Î .Fn bit_nset (¿Í)°ú ¸ÅÅ©·Î .Fn bit_nclear (Àº)´Â, ºñÆ®¿­ .Ar name ¾ÈÀÇ .Fa start (À¸)·ÎºÎÅÍ .Fa stop ±îÁöÀÇ (0 À» ±âÁ¡À¸·Î¼­ ¹øÈ£ ºÙÀ̰í ÇÑ) ºñÆ®¸¦ ¼¼Æ® ¶Ç´Â Ŭ¸®¾î ÇÕ´Ï´Ù. .Pp ¸ÅÅ©·Î .Fn bit_test (Àº)´Â, ºñÆ®¿­ .Ar name ¾È¿¡¼­, 0 À» ±âÁ¡À¸·Î¼­ .Fa bit ¹øÂ°ÀÇ ºñÆ®°¡ ¼¼Æ® µÇ°í ÀÖ´Â °æ¿ì, Æò°¡ °á°ú´Â 0 ÀÌ ¾Æ´Ñ °ªÀÌ µÇ¾î, ±× ÀÌ¿ÜÀÇ °æ¿ì´Â 0 À¸·Î Æò°¡µË´Ï´Ù. .Pp ¸ÅÅ©·Î .Fn bit_ffs (Àº)´Â, .Ar name ÇÏÁö¸¸ ÂüÁ¶ÇÑ´Ù .Fa nbits ºñÆ®ÀÇ ¹è¿­ ¼Ó¿¡¼­, ¼¼Æ® µÈ ºñÆ®°¡ ÃÖÃÊ·Î ³ªÅ¸³ª´Â À§Ä¡¸¦ 0 À» ±âÁ¡À¸·Î¼­ ¹øÈ£ ºÙÀ̰í ÇÑ °ªÀ», .Fa value ÇÏÁö¸¸ ÂüÁ¶ÇÏ´Â À§Ä¡¿¡ °Ý³³ÇÕ´Ï´Ù. ¾î´À ºñÆ®µµ ¼³Á¤µÇ¾î ÀÖÁö ¾ÊÀº °æ¿ì, .Fa value ÇÏÁö¸¸ ÂüÁ¶ÇÏ´Â À§Ä¡¿¡,\-1 °¡ ¼³Á¤µË´Ï´Ù. .Pp ¸ÅÅ©·Î .Fn bit_ffc (Àº)´Â, .Ar name ÇÏÁö¸¸ ÂüÁ¶ÇÑ´Ù .Fa nbits ºñÆ®ÀÇ ¹è¿­ ¼Ó¿¡¼­, ¼¼Æ®µÇ¾î ÀÖÁö ¾ÊÀº ºñÆ®°¡ ÃÖÃÊ·Î ³ªÅ¸³ª´Â À§Ä¡¸¦, 0 À» ±âÁ¡À¸·Î¼­ ¹øÈ£ ºÙÀ̰í ÇÑ °ªÀ», .Fa value ÇÏÁö¸¸ ÂüÁ¶ÇÏ´Â À§Ä¡¿¡ °Ý³³ÇÕ´Ï´Ù. ¾î´À ºñÆ®µµ ¼³Á¤µÇ¾î ÀÖ´Â °æ¿ì, .Fa value ÇÏÁö¸¸ ÂüÁ¶ÇÏ´Â À§Ä¡¿¡,\-1 °¡ ¼³Á¤µË´Ï´Ù. .Pp ÀÌ·¯ÇÑ ¸ÅÅ©·ÎÀÇ Àμö´Â, 1 ȸ¸¸ Æò°¡µÇ¾î ¾ÈÀüÇÑ ºÎÀÛ¿ëÀÌ ÀÖ´Ù °¡´É¼ºÀÌ ÀÖ½À´Ï´Ù. .Sh ¿¹ .Bd -literal -offset indent #include #include \&... #define LPR_BUSY_BIT 0 #define LPR_FORMAT_BIT 1 #define LPR_DOWNLOAD_BIT 2 \&... #define LPR_AVAILABLE_BIT 9 #define LPR_MAX_BITS 10 make_lpr_available() { bitstr_t bit_decl(bitlist, LPR_MAX_BITS); ... bit_nclear(bitlist, 0, LPR_MAX_BITS - 1); ... if (! bit_test(bitlist, LPR_BUSY_BIT)) { bit_clear(bitlist, LPR_FORMAT_BIT); bit_clear(bitlist, LPR_DOWNLOAD_BIT); bit_set(bitlist, LPR_AVAILABLE_BIT); } } .Ed .Sh °ü·Ã Ç׸ñ .Xr malloc 3 .Sh ¿ª»ç .Nm bitstring ÇÔ¼ö´Â .Bx 4.4 ±×¸®°í óÀ½ µîÀåÇß½À´Ï´Ù. .\" kuma