2 * Implement some functions which are unknown to Solaris 10.
5 #include "compat_sun.h"
9 vasprintf(char **str
, const char *format
, va_list ap
)
14 if ((result
= vsnprintf(dummy
, 2, format
, ap
)) < 0) {
18 if ((*str
= malloc(result
+ 1)) == NULL
)
20 if ((result
= vsnprintf(*str
, result
+ 1, format
, ap
)) < 0) {
28 asprintf(char **str
, const char *format
, ...)
34 result
= vasprintf(str
, format
, ap
);
41 #include <sys/types.h>
47 MD5File(const char *filename
, char *buf
)
49 unsigned char dbuf
[8192];
54 if ((fd
= open(filename
, O_RDONLY
)) < 0)
57 while ((count
= read(fd
, dbuf
, sizeof(dbuf
))) > 0)
58 MD5Update(&ctx
, dbuf
, count
);
63 if ((buf
= malloc(33)) == NULL
)
66 for (count
= 0; count
< 16; count
++)
67 sprintf(buf
+ count
* 2, "%02x", dbuf
[count
]);
71 #endif /* ifndef NOMD5 */