summaryrefslogtreecommitdiff
path: root/src/io.c
diff options
context:
space:
mode:
authorFrederic Culot <calcurse@culot.org>2009-07-26 20:26:14 +0000
committerFrederic Culot <calcurse@culot.org>2009-07-26 20:26:14 +0000
commitbccd37ef968dc07c2e3435123deba3e541662e0c (patch)
treeae3db9b611497a9229f3624fdb910b81920cc1ca /src/io.c
parent3d23af73c0032ad08766d2375fd9827493a7d658 (diff)
downloadcalcurse-bccd37ef968dc07c2e3435123deba3e541662e0c.zip
--status flag added
Diffstat (limited to 'src/io.c')
-rwxr-xr-xsrc/io.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/io.c b/src/io.c
index 3cd765d..ed4266f 100755
--- a/src/io.c
+++ b/src/io.c
@@ -1,4 +1,4 @@
-/* $calcurse: io.c,v 1.73 2009/07/26 12:47:15 culot Exp $ */
+/* $calcurse: io.c,v 1.74 2009/07/26 20:26:15 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -2976,3 +2976,28 @@ io_dump_pid (char *file)
return 1;
}
+
+/*
+ * Return the pid number contained in a file previously created with
+ * io_dump_pid ().
+ * If no file was found, return 0.
+ */
+unsigned
+io_get_pid (char *file)
+{
+ FILE *fp;
+ unsigned pid;
+
+ if (!file)
+ return 0;
+
+ if ((fp = fopen (file, "r")) == 0)
+ return 0;
+
+ if (fscanf (fp, "%u", &pid) != 1)
+ return 0;
+
+ (void)fclose (fp);
+
+ return pid;
+}