]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
crypto-keygen-standalone: allow reading from file descriptors
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 26 Nov 2010 05:56:23 +0000 (05:56 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 26 Nov 2010 05:56:23 +0000 (05:56 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10636 d7cf8633-e32d-0410-b094-e92efae38249

crypto-keygen-standalone.c

index 17b825d214854499d0f6f0e37c5e7e8f77d251ec..1df9d6418931d2aeaba92300729fa78f733fea50 100644 (file)
@@ -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);