浏览代码

Add bland check for the primes database file to exist.

This shitty primes file thing must be substituted asap with a truly accessible file.
Michele Orrù 11 年之前
父节点
当前提交
1238cc42c1
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      src/questions/primes.c

+ 5 - 1
src/questions/primes.c

@@ -4,6 +4,8 @@
  * \brief Fast access to a prime pool
  *
  */
+#include <errno.h>
+#include <error.h>
 #include <strings.h>
 
 #include <openssl/bn.h>
@@ -20,7 +22,9 @@ static const char *PRIME_POOL_FILE = "primes.txt";
  */
 pit_t *primes_init(void)
 {
-  return fopen(PRIME_POOL_FILE, "r");
+  pit_t *ret = fopen(PRIME_POOL_FILE, "r");
+  if (!ret) error(EXIT_FAILURE, errno, "Unable to open primes database.");
+  return ret;
 }