annotate osdep/strl.c @ 13394:455a5056801f

New generic 'portable anymap' video output driver. It supports portable pixmaps and graymaps in both raw and ASCII mode. Besides PPM and PGM, it can also output PGMYUV files which are PGM files with the U and V plane appended to the bottom of the Y image (bottom left and bottom right). All files can be written to the current directory, to a specified output directory or to multiple subdirectories if the filesystem can't handle the amount of files in one directory anymore. Note: This driver is not yet activated and will not be compiled and linked to libvo. A separate patch will take care of that. This is just for adding the file to the repository.
author ivo
date Mon, 20 Sep 2004 00:54:57 +0000
parents 9a495bdc3a1e
children f48dc20c9185
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12646
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
1 /* strl(cat|cpy) implementation for systems that do not have it in libc */
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
2 /* strl.c - strlcpy/strlcat implementation
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
3 * Time-stamp: <2004-03-14 njk>
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
4 * (C) 2003-2004 Nicholas J. Kain <njk@aerifal.cx>
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
5 */
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
6
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
7 #include "../config.h"
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
8
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
9 #ifndef HAVE_STRLCPY
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
10 unsigned int strlcpy (char *dest, char *src, unsigned int size)
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
11 {
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
12 register unsigned int i;
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
13
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
14 for (i=0; size > 0 && src[i] != '\0'; ++i, size--)
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
15 dest[i] = src[i];
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
16
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
17 dest[i] = '\0';
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
18
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
19 return i;
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
20 }
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
21 #endif
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
22
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
23 #ifndef HAVE_STRLCAT
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
24 unsigned int strlcat (char *dest, char *src, unsigned int size)
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
25 {
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
26 #if 0
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
27 register unsigned int i, j;
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
28
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
29 for(i=0; size > 0 && dest[i] != '\0'; size--, i++);
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
30 for(j=0; size > 0 && src[j] != '\0'; size--, i++, j++)
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
31 dest[i] = src[j];
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
32
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
33 dest[i] = '\0';
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
34 return i;
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
35 #else
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
36 register char *d = dest, *s = src;
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
37
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
38 for (; size > 0 && *d != '\0'; size--, d++);
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
39 for (; size > 0 && *s != '\0'; size--, d++, s++)
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
40 *d = *s;
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
41
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
42 *d = '\0';
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
43 return (d - dest) + (s - src);
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
44 #endif
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
45 }
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
46 #endif
9a495bdc3a1e string handling security fixes
diego
parents:
diff changeset
47