strcstr man page on DragonFly

Man page or keyword search:  
man Server   44335 pages
apropos Keyword Search (all sections)
Output format
DragonFly logo
[printable version]

STRCSTR(3)		     C Programmer's Manual		    STRCSTR(3)

NAME
       strcstr - convert memory block to printable C string notation

SYNOPSIS
       #include <publib.h>
       void strcstr(char *str, size_t max, const void *block, size_t n);

DESCRIPTION
       strcstr	converts the contents of an arbitrary memory block (which need
       not be a zero terminated string) into a printable notation using normal
       C  string literal syntax.  This can be used for example to store poten‐
       tially binary data in a file, or in debugging outputs.

       All characters for which there is a simple  shorthand  escape  sequence
       (',  ",	?,  \, \a, \b, \f, \n, \r, \t, \v) are stored using that nota‐
       tion.  \0 is stored as \0.   All	 other	non-printable  characters  are
       stored  using a hexadecimal escape sequence.  All other printable char‐
       acters are stored as is.

       The isprint(3) macro is used to determine whether a character is print‐
       able  (i.e.,  whether  it is printed as is, or using special notation).
       Therefore, the output depends on the locale.

RETURN VALUE
       strcstr returns nothing.

EXAMPLE
       The following code dumps input to the standard output in	 a  guaranteed
       (modulo locale bugs) printable format.  It might be used for debugging.

	    #include <stdio.h>
	    #include <publib.h>

	    int main(void) {
		 char line[512];
		 char cstr[512*(CHAR_BIT/4+1+2)+1];  /* +2 for \x, +1 for \0,
					  the rest to be able to
					  store the hex code for
					  512 chars.  */

		 while (fgets(line, sizeof(line), stdin) != NULL) {
		      strcstr(cstr, sizeof(cstr), line, strlen(line));
		      printf("%s0, cstr);
		 }
		 return 0;
	    }

SEE ALSO
       publib(3), strins(3)

AUTHOR
       Lars Wirzenius (lars.wirzenius@helsinki.fi)

Publib			     C Programmer's Manual		    STRCSTR(3)
[top]

List of man pages available for DragonFly

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net