Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
xt_strlupper(3)		   Library Functions Manual	       xt_strlupper(3)

NAME
       xt_redirect()  -	Redirect stdin,	stdout and stderr if corresponding ar-
       gument isn't NULL xt_strlupper()	- Copy string and convert  lower  case
       to uppper

LIBRARY
       #include	<xtend/string.h>
       -lxtend

SYNOPSIS
       size_t  xt_strlupper(char *dest,	const char *src, size_t	dest_size)

ARGUMENTS
       src	   Pointer to null-terminated string to	be copied
       dest	   Pointer to a	character array	to receive the copy
       dest_size   Size	of the destination array

DESCRIPTION
       This  function  redirects  the stdin, stdout, and stderr	of the current
       process to the files named by the corresponding arguments.  The	origi-
       nal  file  streams  are	not  preserved.	 If you	need to	restore	any of
       these streams to	their original state, they must	be saved  (e.g.	 using
       dup(), dup2(), or ttyname()) prior to calling xt_redirect().

       Author:			Jason		      W.		 Bacon
       ***************************************************************************/

       void    xt_redirect( char    *infile,	/* If not NULL,	stdin is redi-
       rected from this	file */	char	*outfile,   /* If not NULL, stdout  is
       redirected  to  this file */ char    *errfile	/* If not NULL,	stderr
       is redirected to	this file */ )

       { if (infile != NULL) { close(0); if ( open(infile, O_RDONLY) ==	 -1  )
       fprintf(stderr,"xt_redirect():  Cannot open infile: %s.n",infile); } if
       (outfile	!= NULL) { close(1); if	( open(outfile,	O_WRONLY |  O_CREAT  |
       O_TRUNC,	 0600) == -1 ) fprintf(stderr,"xt_redirect(): Cannot open out-
       file: %s.n",outfile); } if (errfile != NULL)  {	close(2);  if  (  str-
       cmp(errfile,outfile)    ==    0	 )   {	 if   (	  dup(1)   ==	-1   )
       fprintf(stderr,"xt_redirect(): Cannot open errfile:  %s.n",errfile);  }
       else  {	if ( open(errfile, O_WRONLY | O_CREAT |	O_TRUNC, 0600) == -1 )
       fprintf(stderr,"xt_redirect(): Cannot open errfile: %s.n",errfile); } }
       }

       xt_strlupper(3) copies a	string from src	to dest, up to	a  maximum  of
       dest_size  -  1 characters.  It behaves exactly like strlcpy(3),	except
       that any	lower case characters in the string  are  converted  to	 upper
       case.

RETURN VALUES
       Size  of	the src	string.	 If this differs from dest_size, then we knoiw
       the copy	is truncated.

EXAMPLES
       char    src[] = "Some text",
       dest    [DEST_SIZE + 1];

       if ( xt_strlupper(dest, src, DEST_SIZE +	1) != DEST_SIZE	+ 1 )
	   fputs("Warning: String truncated.n",	stderr);

SEE ALSO
       xt_strllower(3),	strlcpy(3), strlcat(3)

							       xt_strlupper(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=xt_strlupper&sektion=3&manpath=FreeBSD+Ports+14.3.quarterly>

home | help