ReactOS  0.4.13-dev-479-gec9c8fd
Strncpy.c
Go to the documentation of this file.
1 #include <sys/types.h>
2 #include <string.h>
3 #include "Strn.h"
4 
5 
6 /*
7  * Copy src to dst, truncating or null-padding to always copy n-1 bytes.
8  * Return dst.
9  */
10 char *
11 Strncpy(char *const dst, const char *const src, const size_t n)
12 {
13  register char *d;
14  register const char *s;
15  register size_t i;
16 
17  d = dst;
18  *d = 0;
19  if (n != 0) {
20  s = src;
21  /* If they specified a maximum of n characters, use n - 1 chars to
22  * hold the copy, and the last character in the array as a NUL.
23  * This is the difference between the regular strncpy routine.
24  * strncpy doesn't guarantee that your new string will have a
25  * NUL terminator, but this routine does.
26  */
27  for (i=1; i<n; i++) {
28  if ((*d++ = *s++) == 0) {
29 #if (STRN_ZERO_PAD == 1)
30  /* Pad with zeros. */
31  for (; i<n; i++)
32  *d++ = 0;
33 #endif /* STRN_ZERO_PAD */
34  return dst;
35  }
36  }
37  /* If we get here, then we have a full string, with n - 1 characters,
38  * so now we NUL terminate it and go home.
39  */
40  *d = 0;
41  }
42  return (dst);
43 } /* Strncpy */
44 
45 /* eof Strn.c */
GLdouble n
Definition: glext.h:7729
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define d
Definition: ke_i.h:81
GLdouble s
Definition: gl.h:2039
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
char * Strncpy(char *const dst, const char *const src, const size_t n)
Definition: Strncpy.c:11