From: divverent Date: Fri, 26 Nov 2010 05:56:23 +0000 (+0000) Subject: crypto-keygen-standalone: allow reading from file descriptors X-Git-Tag: xonotic-v0.5.0~438^2~205 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=65d4a5609747aaf729f9ed366ddc08e0d4afcad3;p=xonotic%2Fdarkplaces.git crypto-keygen-standalone: allow reading from file descriptors git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10636 d7cf8633-e32d-0410-b094-e92efae38249 --- 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);