⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 atoul.3

📁 This a good VPN source
💻 3
字号:
.TH IPSEC_ATOUL 3 "11 June 2001".\" RCSID $Id: atoul.3,v 1.10 2004/04/09 18:00:39 mcr Exp $.SH NAMEipsec atoul, ultoa \- convert unsigned-long numbers to and from ASCII.SH SYNOPSIS.B "#include <freeswan.h>.sp.B "const char *atoul(const char *src, size_t srclen,".ti +1c.B "int base, unsigned long *n);".br.B "size_t ultoa(unsigned long n, int base, char *dst,".ti +1c.B "size_t dstlen);".SH DESCRIPTIONThese functions are obsolete; see.IR ipsec_ttoul (3)for their replacements..PP.I Atoulconverts an ASCII number into a binary.B "unsigned long"value..I Ultoadoes the reverse conversion, back to an ASCII version..PPNumbers are specified in ASCII asdecimal (e.g..BR 123 ),octal with a leading zero (e.g..BR 012 ,which has value 10),or hexadecimal with a leading.B 0x(e.g..BR 0x1f ,which has value 31)in either upper or lower case..PPThe.I srclenparameter of.I atoulspecifies the length of the ASCII string pointed to by.IR src ;it is an error for there to be anything else(e.g., a terminating NUL) within that length.As a convenience for cases where an entire NUL-terminated string isto be converted,a.I srclenvalue of.B 0is taken to mean.BR strlen(src) ..PPThe.I baseparameter of.I atoulcan be.BR 8 ,.BR 10 ,or.BR 16 ,in which case the number supplied is assumed to be of that form(and in the case of.BR 16 ,to lack any.B 0xprefix).It can also be.BR 0 ,in which case the number is examined for a leading zeroor a leading.B 0xto determine its base,or.B 13(halfway between 10 and 16),which has the same effect as.B 0except that a non-hexadecimalnumber is considered decimal regardless of any leading zero..PPThe.I dstlenparameter of.I ultoaspecifies the size of the.I dstparameter;under no circumstances are more than.I dstlenbytes written to.IR dst .A result which will not fit is truncated..I Dstlencan be zero, in which case.I dstneed not be valid and no result is written,but the return value is unaffected;in all other cases, the (possibly truncated) result is NUL-terminated..PPThe.I baseparameter of.I ultoamust be.BR 8 ,.BR 10 ,or.BR 16 ..PP.I Atoulreturns NULL for success anda pointer to a string-literal error message for failure;see DIAGNOSTICS..I Ultoareturns the size of buffer which would be needed toaccommodate the full conversion result, including terminating NUL;it is the caller's responsibility to check this against the size ofthe provided buffer to determine whether truncation has occurred..SH SEE ALSOatol(3), strtoul(3).SH DIAGNOSTICSFatal errors in.I atoulare:empty input;unknown.IR base ;non-digit character found;number too large for an.BR "unsigned long" ..SH HISTORYWritten for the FreeS/WAN project by Henry Spencer..SH BUGSThere is no provision for reporting an invalid.I baseparameter given to.IR ultoa ..PPThe restriction of error reports to literal strings(so that callers don't need to worry about freeing them or copying them)does limit the precision of error reporting..PPThe error-reporting convention lends itself to slightly obscure code,because many readers will not think of NULL as signifying success.A good way to make it clearer is to write something like:.PP.RS.nf.B "const char *error;".sp.B "error = atoul( /* ... */ );".B "if (error != NULL) {".B "        /* something went wrong */".fi.RE

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -