bin/tests/dst/t_dst.c
/*
 * Write a sig in buf to file at path.
 */
Write a sig in buf to file at path.
Write a sig in buf to file at path .
static int
sig_tofile(char *path, isc_buffer_t *buf) {
	int		rval;
	int		fd;
	int		len;
	int		nprobs;
	int		cnt;
	unsigned char	c;
	unsigned char	val;
	cnt = 0;
	nprobs = 0;
	len = buf->used - buf->current;
	t_info("buf: current %d used %d len %d\n",
	       buf->current, buf->used, len);
	fd = open(path, O_CREAT|O_TRUNC|O_WRONLY, S_IRWXU|S_IRWXO|S_IRWXG);
	if (fd < 0) {
		t_info("open %s failed %d\n", path, errno);
		return(1);
	}
	while (len) {
		c = (unsigned char) isc_buffer_getuint8(buf);
		val = ((c >> 4 ) & 0x0f);
		if ((0 <= val) && (val <= 9))
			val = '0' + val;
		else
			val = 'A' + val - 10;
		rval = write(fd, &val, 1);
		if (rval != 1) {
			++nprobs;
			t_info("write failed %d %d\n", rval, errno);
			break;
		}
		val = (c & 0x0f);
		if ((0 <= val) && (val <= 9))
			val = '0' + val;
		else
			val = 'A' + val - 10;
		rval = write(fd, &val, 1);
		if (rval != 1) {
			++nprobs;
			t_info("write failed %d %d\n", rval, errno);
			break;
		}
		--len;
		++cnt;
		if ((cnt % 16) == 0) {
			val = '\n';
			rval = write(fd, &val, 1);
			if (rval != 1) {
				++nprobs;
				t_info("write failed %d %d\n", rval, errno);
				break;
			}
		}
	}
	val = '\n';
	rval = write(fd, &val, 1);
	if (rval != 1) {
		++nprobs;
		t_info("write failed %d %d\n", rval, errno);
	}
	(void) close(fd);
	return(nprobs);
}
static int sig_tofile ( char * path , isc_buffer_t * buf ) { int rval ; int fd ; int len ; int nprobs ; int cnt ; unsigned char c ; unsigned char val ; cnt = 0 ; nprobs = 0 ; len = buf -> used - buf -> current ; t_info ( " \n " , buf -> current , buf -> used , len ) ; fd = open ( path , O_CREAT | O_TRUNC | O_WRONLY , S_IRWXU | S_IRWXO | S_IRWXG ) ; if ( fd < 0 ) { t_info ( " \n " , path , errno ) ; return ( 1 ) ; } while ( len ) { c = ( unsigned char ) isc_buffer_getuint8 ( buf ) ; val = ( ( c >> 4 ) & 0x0f ) ; if ( ( 0 <= val ) && ( val <= 9 ) ) val = ' ' + val ; else val = ' ' + val - 10 ; rval = write ( fd , & val , 1 ) ; if ( rval != 1 ) { ++ nprobs ; t_info ( " \n " , rval , errno ) ; break ; } val = ( c & 0x0f ) ; if ( ( 0 <= val ) && ( val <= 9 ) ) val = ' ' + val ; else val = ' ' + val - 10 ; rval = write ( fd , & val , 1 ) ; if ( rval != 1 ) { ++ nprobs ; t_info ( " \n " , rval , errno ) ; break ; } -- len ; ++ cnt ; if ( ( cnt % 16 ) == 0 ) { val = ' \n ' ; rval = write ( fd , & val , 1 ) ; if ( rval != 1 ) { ++ nprobs ; t_info ( " \n " , rval , errno ) ; break ; } } } val = ' \n ' ; rval = write ( fd , & val , 1 ) ; if ( rval != 1 ) { ++ nprobs ; t_info ( " \n " , rval , errno ) ; } ( void ) close ( fd ) ; return ( nprobs ) ; }
Write a sig in buf to file at path.
Write a sig in buf to file at path .