logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

strlen.3p (3296B)


  1. '\" et
  2. .TH STRLEN "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. strlen, strnlen
  12. \(em get length of fixed size string
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <string.h>
  17. .P
  18. size_t strlen(const char *\fIs\fP);
  19. size_t strnlen(const char *\fIs\fP, size_t \fImaxlen\fP);
  20. .fi
  21. .SH DESCRIPTION
  22. For
  23. \fIstrlen\fR():
  24. The functionality described on this reference page is aligned with the
  25. ISO\ C standard. Any conflict between the requirements described here and the
  26. ISO\ C standard is unintentional. This volume of POSIX.1\(hy2017 defers to the ISO\ C standard.
  27. .P
  28. The
  29. \fIstrlen\fR()
  30. function shall compute the number of bytes in the string to which
  31. .IR s
  32. points, not including the terminating NUL character.
  33. .P
  34. The
  35. \fIstrnlen\fR()
  36. function shall compute the smaller of the number of bytes in the array
  37. to which
  38. .IR s
  39. points, not including any terminating NUL character, or the value of the
  40. .IR maxlen
  41. argument. The
  42. \fIstrnlen\fR()
  43. function shall never examine more than
  44. .IR maxlen
  45. bytes of the array pointed to by
  46. .IR s .
  47. .SH "RETURN VALUE"
  48. The
  49. \fIstrlen\fR()
  50. function shall return the length of
  51. .IR s ;
  52. no return value shall be reserved to indicate an error.
  53. .P
  54. The
  55. \fIstrnlen\fR()
  56. function shall return the number of bytes preceding the first null
  57. byte in the array to which
  58. .IR s
  59. points, if
  60. .IR s
  61. contains a null byte within the first
  62. .IR maxlen
  63. bytes; otherwise, it shall return
  64. .IR maxlen .
  65. .SH ERRORS
  66. No errors are defined.
  67. .LP
  68. .IR "The following sections are informative."
  69. .SH EXAMPLES
  70. .SS "Getting String Lengths"
  71. .P
  72. The following example sets the maximum length of
  73. .IR key
  74. and
  75. .IR data
  76. by using
  77. \fIstrlen\fR()
  78. to get the lengths of those strings.
  79. .sp
  80. .RS 4
  81. .nf
  82. #include <string.h>
  83. \&...
  84. struct element {
  85. char *key;
  86. char *data;
  87. };
  88. \&...
  89. char *key, *data;
  90. int len;
  91. .P
  92. *keylength = *datalength = 0;
  93. \&...
  94. if ((len = strlen(key)) > *keylength)
  95. *keylength = len;
  96. if ((len = strlen(data)) > *datalength)
  97. *datalength = len;
  98. \&...
  99. .fi
  100. .P
  101. .RE
  102. .SH "APPLICATION USAGE"
  103. None.
  104. .SH RATIONALE
  105. None.
  106. .SH "FUTURE DIRECTIONS"
  107. None.
  108. .SH "SEE ALSO"
  109. .IR "\fIwcslen\fR\^(\|)"
  110. .P
  111. The Base Definitions volume of POSIX.1\(hy2017,
  112. .IR "\fB<string.h>\fP"
  113. .\"
  114. .SH COPYRIGHT
  115. Portions of this text are reprinted and reproduced in electronic form
  116. from IEEE Std 1003.1-2017, Standard for Information Technology
  117. -- Portable Operating System Interface (POSIX), The Open Group Base
  118. Specifications Issue 7, 2018 Edition,
  119. Copyright (C) 2018 by the Institute of
  120. Electrical and Electronics Engineers, Inc and The Open Group.
  121. In the event of any discrepancy between this version and the original IEEE and
  122. The Open Group Standard, the original IEEE and The Open Group Standard
  123. is the referee document. The original Standard can be obtained online at
  124. http://www.opengroup.org/unix/online.html .
  125. .PP
  126. Any typographical or formatting errors that appear
  127. in this page are most likely
  128. to have been introduced during the conversion of the source files to
  129. man page format. To report such errors, see
  130. https://www.kernel.org/doc/man-pages/reporting_bugs.html .