summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jobcontrol.h3
-rw-r--r--jobs.c23
2 files changed, 26 insertions, 0 deletions
diff --git a/jobcontrol.h b/jobcontrol.h
new file mode 100644
index 0000000..b80f792
--- /dev/null
+++ b/jobcontrol.h
@@ -0,0 +1,3 @@
+#include <sys/types.h>
+
+pid_t pidfrom(const char *s);
diff --git a/jobs.c b/jobs.c
index 5fe1c6e..9cf7854 100644
--- a/jobs.c
+++ b/jobs.c
@@ -1,5 +1,28 @@
#define _XOPEN_SOURCE 700
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "jobcontrol.h"
+
+pid_t pidfrom(const char *s)
+{
+ if (*s == '%') {
+ if (!strcmp(s, "%%") || !strcmp(s, "%+")) {
+ /* return current_job; */
+ } else if (!strcmp(s, "%-")) {
+ /* return previous_job; */
+ }
+
+ /* %digits => job # */
+ /* %string => command begins with string */
+ /* %?string => command contains string */
+
+ return -1;
+ }
+
+ return atoi(s);
+}
int jobs_main(int argc, char *argv[])
{