OSDN Git Service

Update README
[linuxjm/LDP_man-pages.git] / draft / man3 / strtoul.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" References consulted:
26 .\"     Linux libc source code
27 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
28 .\"     386BSD man pages
29 .\" Modified Sun Jul 25 10:54:03 1993 by Rik Faith (faith@cs.unc.edu)
30 .\" Fixed typo, aeb, 950823
31 .\" 2002-02-22, joey, mihtjel: Added strtoull()
32 .\"
33 .\"*******************************************************************
34 .\"
35 .\" This file was generated with po4a. Translate the source file.
36 .\"
37 .\"*******************************************************************
38 .\"
39 .\" Japanese Version Copyright (c) 1999 AKAMATSU, Kazuo
40 .\"                            and 2006 Akihiro MOTOKI
41 .\"         all rights reserved.
42 .\" Translated Thu Jan 31 18:00:00 JST 1999
43 .\"         by AKAMATSU, Kazuo
44 .\" Updated & Modified 2006-07-20,
45 .\"         Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.36
46 .\"
47 .TH STRTOUL 3 2014\-03\-18 GNU "Linux Programmer's Manual"
48 .SH 名前
49 strtoul, strtoull, strtouq \- 文字列を unsigned long int に変換する
50 .SH 書式
51 .nf
52 \fB#include <stdlib.h>\fP
53 .sp
54 \fBunsigned long int strtoul(const char *\fP\fInptr\fP\fB, char **\fP\fIendptr\fP\fB, int \fP\fIbase\fP\fB);\fP
55 .sp
56 \fBunsigned long long int strtoull(const char *\fP\fInptr\fP\fB, char **\fP\fIendptr\fP\fB,\fP
57 \fB                                int \fP\fIbase\fP\fB);\fP
58 .fi
59 .sp
60 .in -4n
61 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
62 .in
63 .sp
64 .ad l
65 \fBstrtoull\fP():
66 .RS 4
67 XOPEN_SOURCE\ >=\ 600 || _BSD_SOURCE || _SVID_SOURCE || _ISOC99_SOURCE
68 || _POSIX_C_SOURCE\ >=\ 200112L;
69 .br
70 または \fIcc\ \-std=c99\fP
71 .RE
72 .ad
73 .SH 説明
74 \fBstrtoul\fP()  関数は、 \fInptr\fP の文字列の最初の部分を、 \fIbase\fP を基数として \fIunsigned long int\fP
75 に変換する。 この \fIbase\fP は 2 から 36 までの値 あるいは特別な意味を持つ値 0 でなければならない。
76 .PP
77 文字列の先頭には、任意の数の空白があってもよく (空白は \fBisspace\fP(3) で判定される)、また数字の直前には \(aq+\(aq か
78 \(aq\-\(aq の 符号があってもよい。 \fIbase\fP が 0 または 16 の場合には、文字列の先頭に "0x" を置くことが
79 でき、その場合には文字列は 16進数として扱われる。 これ以外の文字列で \fIbase\fP が 0 の場合は、 文字列が \(aq0\(aq
80 で始まるときは 8進数として、 それ以外のときは 10進数として扱われる。
81 .PP
82 文字列の残りの部分は \fIunsigned long int\fP に変換されるが、基数に対して
83 有効でない数字が現れた時点で変換は終了する。(11進数以上では \(aqA\(aq は 大文字・小文字に関わらず 10 を表し、 \(aqB\(aq は
84 11 を表現し, 以下同様に、 \(aqZ\(aq は 35 を表す。)
85 .PP
86 \fIendptr\fP がヌル値 (NULL) でない場合、 \fBstrtoul\fP()  は最初に不正な文字が現れたアドレスを \fI*endptr\fP
87 に格納している。 文字列に有効な数字がひとつもなければ、 \fBstrtoul\fP()  は \fInptr\fP の元の値を \fI*endptr\fP
88 に代入する(そして 0 を返す)。 特に、 \fI*nptr\fP が \(aq\e0\(aq 以外で、返された \fI**endptr\fP が
89 \(aq\e0\(aq ならば、文字列全体が有効だったことになる。
90 .PP
91 \fBstrtoull\fP()  関数は \fBstrtoul\fP()  関数と同様だが、 \fIunsigned long long int\fP 型の値を返す。
92 .SH 返り値
93 \fBstrtoul\fP()  関数は変換結果を返す。文字列がマイナス符号から始まっていた場 合は、(符号反転前の値がオーバーフローしていなければ)
94 変換結果を符号反転した 値を unsigned 型で返す。変換でオーバーフローが発生した場合は \fBULONG_MAX\fP を返し、 \fIerrno\fP に
95 \fBERANGE\fP を設定する。 (\fBULONG_MAX\fP を \fBULLONG_MAX\fP と読み替えれば)  \fBstrtoull\fP()  は
96 \fBstrtoul\fP()  と全く同じである。
97 .SH エラー
98 .TP 
99 \fBEINVAL\fP
100 (C99 にはない) 指定された \fIbase\fP がサポートされていない値である。
101 .TP 
102 \fBERANGE\fP
103 結果の値が範囲外である。
104 .LP
105 実装によっては、変換が行われなかった場合 (数字がなく、0 を返した場合)、 \fIerrno\fP に \fBEINVAL\fP が設定される場合がある。
106 .SH 属性
107 .SS "マルチスレッディング (pthreads(7) 参照)"
108 関数 \fBstrtoul\fP(), \fBstrtoull\fP(), \fBstrtouq\fP() は、例外付きのスレッドセーフである。実行中に
109 \fBsetlocale\fP(3) を呼び出してロケールを変更しない限り、マルチスレッドアプリケーションで安全に使用することができる。
110 .SH 準拠
111 \fBstrtoul\fP()  は SVr4, C89, C99 と POSIX\-2001 に準拠している。 \fBstrtoull\fP()  は C99 と
112 POSIX.1\-2001 に準拠している。
113 .SH 注意
114 \fBstrtoul ()\fP からは成功、失敗どちらの場合でも 0 や \fBULONG_MAX\fP (\fBstrtoull\fP()  では
115 \fBULLONG_MAX\fP)  が返る可能性があるので、 プログラムは関数を呼び出す前に \fIerrno\fP を 0 に設定し、呼び出し後に
116 \fIerrno\fP が 0 以外の値かどうかを確認しエラーが発生したかどうかを判断する 必要がある。
117
118 "C" 以外のロケールの場合、その他の文字列も受け付けられるかもしれない。 (例えば、現在のロケールの 1000
119 毎の区切り文字に対応しているかもしれない。)
120 .LP
121 BSD には、
122 .sp
123 .in +4n
124 .nf
125 \fBu_quad_t strtouq(const char *\fP\fInptr\fP\fB, char **\fP\fIendptr\fP\fB, int \fP\fIbase\fP\fB);\fP
126 .sp
127 .in -4n
128 .fi
129 という完全に同様の定義を持つ関数がある。 使用中のアーキテクチャーのワード長次第であるが、この関数は \fBstrtoull\fP()  や
130 \fBstroul\fP()  と等価な場合もありえる。
131
132 負の値も正当な入力とみなされ、エラーもなく、 対応する \fIunsigned long int\fP 型の値に変換される。
133 .SH 例
134 \fBstrtol\fP(3)  のマニュアルページの例を参照。 このページで説明した関数の使用方法も同様である。
135 .SH 関連項目
136 \fBatof\fP(3), \fBatoi\fP(3), \fBatol\fP(3), \fBstrtod\fP(3), \fBstrtol\fP(3)
137 .SH この文書について
138 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部
139 である。プロジェクトの説明とバグ報告に関する情報は
140 http://www.kernel.org/doc/man\-pages/ に書かれている。