Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
#include "ssh2.h"
4
 
5
void
6
freeptr(void **vpp)
7
{
8
	char **cpp;
9
 
10
	cpp = vpp;
11
	free(*cpp);
12
	*cpp = nil;
13
}
14
 
15
int
16
readfile(char *file, char *buf, int size)
17
{
18
	int n, fd;
19
 
20
	fd = open(file, OREAD);
21
	if (fd < 0)
22
		return -1;
23
	n = readn(fd, buf, size - 1);
24
	if (n < 0)
25
		buf[0] = '\0';
26
	else
27
		buf[n] = '\0';
28
	close(fd);
29
	return n;
30
}