copystr(9r)copystr(9r)NAME
copystr - General: Copies a null-terminated character string with a specified limit
SYNOPSIS
int copystr(
char *s1,
char *s2,
u_int maxlength,
u_int *ncopiedaddr );
ARGUMENTS
Specifies a pointer to a string (an array of characters terminated by a null character). Specifies a pointer to a buffer of at least
maxlength characters. Specifies the maximum number of characters to copy. Specifies the address of an integer to receive the number of
copied characters.
DESCRIPTION
The copystr routine copies string s1 to the buffer pointed to by s2. The routine stops after copying a null character or after copying
maxlength characters, whichever comes first. The s2 buffer is not padded with null characters to maxlength.
The copystr routine returns the number of characters copied in the location pointed to by ncopiedaddr. Note that the character size is 1
byte.
RETURN VALUES
Upon successful completion, copystr returns the value 0 (zero). Otherwise, it can return the following error: The string length, s1,
exceeds the maximum number of characters, maxlength.
SEE ALSO
Routines: bcopy(9r), blkclr(9r), ovbcopy(9r), strcpy(9r), strncpy(9r)copystr(9r)
Check Out this Related Man Page
COPY(9) BSD Kernel Developer's Manual COPY(9)NAME
copy, copyin, copyinstr, copyout, copystr -- kernel copy functions
SYNOPSIS
#include <sys/types.h>
#include <sys/systm.h>
int
copyin(const void *uaddr, void *kaddr, size_t len);
int
copyinstr(const void *uaddr, void *kaddr, size_t len, size_t *done);
int
copyout(const void *kaddr, void *uaddr, size_t len);
int
copystr(const void *kfaddr, void *kdaddr, size_t len, size_t *done);
DESCRIPTION
The copy functions are designed to copy contiguous data from one address to another. All but copystr() copy data from user-space to kernel-
space or vice-versa.
The copy routines provide the following functionality:
copyin() Copies len bytes of data from the user-space address uaddr to the kernel-space address kaddr.
copyinstr() Copies a NUL-terminated string, at most len bytes long, from user-space address uaddr to kernel-space address kaddr. The num-
ber of bytes actually copied, including the terminating NUL, is returned in *done.
copyout() Copies len bytes of data from the kernel-space address kaddr to the user-space address uaddr.
copystr() Copies a NUL-terminated string, at most len bytes long, from kernel-space address kfaddr to kernel-space address kdaddr. The
number of bytes actually copied, including the terminating NUL, is returned in *done.
RETURN VALUES
The copy functions return 0 on success or the following error on failure:
[EFAULT] If a bad address is encountered. When this error is returned, the contents of the destination buffer ( *kaddr for
copyin(), copyinstr(), and copystr(); *uaddr for copyout()) are undefined. For copyinstr() and copystr(), the contents of
the *done parameter are also undefined on a return of EFAULT.
In addition to EFAULT, copystr() and copyinstr() on failure will return:
[ENAMETOLONG] When the string is longer than len bytes. On this error return, the destination buffer is not null-terminated, but the
*done parameter is maintained.
SEE ALSO fetch(9), store(9)BSD October 2, 2008 BSD
I'm trying to remove the null characters from a file and copy it to std output.
I'm using emacs and I create the following one line bash file (followed by the error messages):
sed -e 's/^@//' <ConfigItemReplicator.install.log
/usr/bin/bash: -c: line 0: unexpected EOF while looking for... (1 Reply)
Hi all,
Any help on how to do the following? :eek:
I have an infile as follows:
_thisishowyouwritehelloworld
_thisisalsohowyouwritehelloworld2
I want to delete the characters from "_" to "how" and be left with:
youwritehelloworld
youwritehelloworld2
I am able to do delete from a... (2 Replies)
Hi,
I have a text file with a very long string of characters, like "ACGCTTGCAA...", and I want to make another file with 36 characters from this string file every 4 lines like:
character of position 1 to position 36 of the string file, position 2-37, position 3-38 ... position... (2 Replies)
As bash cannot cope with a byte value of zero inside a variable then this is a workaround.
This code is a DEMO to show how to create a _string_variable_ containing all of the values of 1 to 255 as single characters and 0, (zero), as a two byte character set of \0.
The real binary files are 512... (20 Replies)
Hello,
I would like to copy the first and third char on each line of a file and place them in the 14h and 17th char positions. The file name is listed first and is 6 char's and the dir name is second and also same char size on each line.
The file has thousands of lines.
Initial... (6 Replies)