Пример #1
0
Файл: io.c Проект: bhanug/harvey
static String*
Brdstring(Biobuf *b)
{
	int32_t len;
	String *s;
	Dir *d;

	d = dirfstat(Bfildes(b));
	if (d == nil)	/* shouldn't happen, we just opened it */
		len = 0;
	else
		len = d->length;
	free(d);
	s = s_newalloc(len);
	s_read(b, s, len);
	return s;
}
Пример #2
0
String *
s_dec64(String *sin)
{
	int lin, lout;
	String *sout;

	lin = s_len(sin);

	/*
	 * if the string is coming from smtpd.y, it will have no nl.
	 * if it is coming from getcrnl below, it will have an nl.
	 */
	if (*(s_to_c(sin)+lin-1) == '\n')
		lin--;
	sout = s_newalloc(lin+1);
	lout = dec64((uchar *)s_to_c(sout), lin, s_to_c(sin), lin);
	if (lout < 0) {
		s_free(sout);
		return nil;
	}
	sout->ptr = sout->base + lout;
	s_terminate(sout);
	return sout;
}