ReactOS 0.4.15-dev-7924-g5949c20
Strnpcpy.c File Reference
#include <sys/types.h>
#include <string.h>
#include "Strn.h"
Include dependency graph for Strnpcpy.c:

Go to the source code of this file.

Functions

charStrnpcpy (char *const dst, const char *const src, size_t n)
 

Function Documentation

◆ Strnpcpy()

char * Strnpcpy ( char *const  dst,
const char *const  src,
size_t  n 
)

Definition at line 12 of file Strnpcpy.c.

13{
14 register char *d;
15 register const char *s;
16 register char c;
17 char *ret;
18 register size_t i;
19
20 d = dst;
21 if (n != 0) {
22 s = src;
23 /* If they specified a maximum of n characters, use n - 1 chars to
24 * hold the copy, and the last character in the array as a NUL.
25 * This is the difference between the regular strncpy routine.
26 * strncpy doesn't guarantee that your new string will have a
27 * NUL terminator, but this routine does.
28 */
29 for (i=1; i<n; i++) {
30 c = *s++;
31 if (c == '\0') {
32 ret = d; /* Return ptr to end byte. */
33 *d++ = c;
34#if (STRNP_ZERO_PAD == 1)
35 /* Pad with zeros. */
36 for (; i<n; i++)
37 *d++ = 0;
38#endif /* STRNP_ZERO_PAD */
39 return ret;
40 }
41 *d++ = c;
42 }
43 /* If we get here, then we have a full string, with n - 1 characters,
44 * so now we NUL terminate it and go home.
45 */
46 *d = '\0';
47 return (d); /* Return ptr to end byte. */
48 } else {
49 *d = 0;
50 }
51 return (d); /* Return ptr to end byte. */
52} /* Strnpcpy */
GLdouble s
Definition: gl.h:2039
GLdouble n
Definition: glext.h:7729
GLenum src
Definition: glext.h:6340
const GLubyte * c
Definition: glext.h:8905
GLenum GLenum dst
Definition: glext.h:6340
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
#define c
Definition: ke_i.h:80
int ret

Referenced by main(), and PathCat().