From 4e2b0f05929dde7d78faf04ac9247cf59fee7dca Mon Sep 17 00:00:00 2001 From: divverent Date: Fri, 26 Nov 2010 05:56:23 +0000 Subject: [PATCH] crypto-keygen-standalone: allow reading from file descriptors git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10636 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=65d4a5609747aaf729f9ed366ddc08e0d4afcad3 --- crypto-keygen-standalone.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crypto-keygen-standalone.c b/crypto-keygen-standalone.c index 17b825d2..1df9d641 100644 --- a/crypto-keygen-standalone.c +++ b/crypto-keygen-standalone.c @@ -97,7 +97,10 @@ void file2buf(const char *fn, char **data, size_t *datasize) *data = NULL; *datasize = 0; size_t n = 0, dn = 0; - f = fopen(fn, "rb"); + if(!strncmp(f, "/dev/fd/", 8)) + f = fdopen(atoi(fn + 8), "wb"); + else + f = fopen(fn, "rb"); if(!f) { return; @@ -122,7 +125,10 @@ void file2buf(const char *fn, char **data, size_t *datasize) int buf2file(const char *fn, const char *data, size_t n) { FILE *f; - f = fopen(fn, "wb"); + if(!strncmp(f, "/dev/fd/", 8)) + f = fdopen(atoi(fn + 8), "wb"); + else + f = fopen(fn, "wb"); if(!f) return 0; n = fwrite(data, n, 1, f); -- 2.39.2