summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2008-05-27 22:37:08 +0200
committerJim Meyering <meyering@redhat.com>2008-05-28 00:03:40 +0200
commitf96625f99593a5d6477915cccc2f1e5268541563 (patch)
treef53e32813eb11b07704e6c4a5b6c6d237ede0d8a /src
parent3719e8d5de121e950a285825bb702564c2853ff1 (diff)
downloadidutils-f96625f99593a5d6477915cccc2f1e5268541563.tar.gz
idutils-f96625f99593a5d6477915cccc2f1e5268541563.tar.bz2
idutils-f96625f99593a5d6477915cccc2f1e5268541563.zip
build aid, eid, and gid as binaries (were scripts)
* src/lid.c: Include "lid.h". (main): Set defaults based on new global, lid_mode. * src/Makefile.am (bin_PROGRAMS): Add aid, eid, gid. (dist_bin_SCRIPTS): Remove them from this list. (noinst_HEADERS, aid_SOURCES, eid_SOURCES): Define. (gid_SOURCES, lid_SOURCES): Define. * src/aid, src/eid, src/gid: Remove scripts. * src/lid-aid.c, src/lid-eid.c, src/lid-gid.c, src/lid-lid.c: * src/lid.h: New files. * man/Makefile.am (aid.1, eid.1, gid.1): Adjust dependencies. * .gitignore: Add src/aid, src/eid, src/gid.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am9
-rwxr-xr-xsrc/aid3
-rwxr-xr-xsrc/eid3
-rwxr-xr-xsrc/gid3
-rw-r--r--src/lid-aid.c2
-rw-r--r--src/lid-eid.c2
-rw-r--r--src/lid-gid.c2
-rw-r--r--src/lid-lid.c2
-rw-r--r--src/lid.c24
-rw-r--r--src/lid.h9
10 files changed, 48 insertions, 11 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 8b2201b..597f572 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,6 +1,11 @@
+bin_PROGRAMS = mkid lid fid fnid xtokid aid eid gid
+dist_bin_SCRIPTS = defid
-bin_PROGRAMS = mkid lid fid fnid xtokid
-dist_bin_SCRIPTS = eid aid gid defid
+noinst_HEADERS = lid.h
+aid_SOURCES = lid.c lid-aid.c
+eid_SOURCES = lid.c lid-eid.c
+gid_SOURCES = lid.c lid-gid.c
+lid_SOURCES = lid.c lid-lid.c
AM_CPPFLAGS = -I$(top_builddir)/intl \
-I$(top_srcdir)/lib \
diff --git a/src/aid b/src/aid
deleted file mode 100755
index 3578bf2..0000000
--- a/src/aid
+++ /dev/null
@@ -1,3 +0,0 @@
-#! /bin/sh
-
-exec lid -ils "$@"
diff --git a/src/eid b/src/eid
deleted file mode 100755
index d5cfcf6..0000000
--- a/src/eid
+++ /dev/null
@@ -1,3 +0,0 @@
-#! /bin/sh
-
-exec lid -R edit "$@"
diff --git a/src/gid b/src/gid
deleted file mode 100755
index 6854bb7..0000000
--- a/src/gid
+++ /dev/null
@@ -1,3 +0,0 @@
-#! /bin/sh
-
-exec lid -R grep "$@"
diff --git a/src/lid-aid.c b/src/lid-aid.c
new file mode 100644
index 0000000..317f297
--- /dev/null
+++ b/src/lid-aid.c
@@ -0,0 +1,2 @@
+#include "lid.h"
+enum lid_mode lid_mode = LID_MODE_AID;
diff --git a/src/lid-eid.c b/src/lid-eid.c
new file mode 100644
index 0000000..b9e2ad7
--- /dev/null
+++ b/src/lid-eid.c
@@ -0,0 +1,2 @@
+#include "lid.h"
+enum lid_mode lid_mode = LID_MODE_EID;
diff --git a/src/lid-gid.c b/src/lid-gid.c
new file mode 100644
index 0000000..ba04770
--- /dev/null
+++ b/src/lid-gid.c
@@ -0,0 +1,2 @@
+#include "lid.h"
+enum lid_mode lid_mode = LID_MODE_GID;
diff --git a/src/lid-lid.c b/src/lid-lid.c
new file mode 100644
index 0000000..bb7b08d
--- /dev/null
+++ b/src/lid-lid.c
@@ -0,0 +1,2 @@
+#include "lid.h"
+enum lid_mode lid_mode = LID_MODE_LID;
diff --git a/src/lid.c b/src/lid.c
index 2ea305c..a97529b 100644
--- a/src/lid.c
+++ b/src/lid.c
@@ -42,6 +42,7 @@
#include "xnls.h"
#include "idfile.h"
#include "iduglobal.h"
+#include "lid.h"
typedef void (*report_func_t) (char const *name, struct file_link **flinkv);
typedef int (*query_func_t) (char const *arg, report_func_t);
@@ -307,6 +308,29 @@ main (int argc, char **argv)
atexit (close_stdout);
+ switch (lid_mode)
+ {
+ case LID_MODE_AID: /* -ils */
+ ignore_case_flag = REG_ICASE;
+ pattern_style = ps_literal;
+ delimiter_style = ds_substring;
+ break;
+
+ case LID_MODE_EID: /* -R edit */
+ result_style = rs_edit;
+ break;
+
+ case LID_MODE_GID: /* -R grep */
+ result_style = rs_grep;
+ break;
+
+ case LID_MODE_LID:
+ break;
+
+ default:
+ abort ();
+ }
+
for (;;)
{
int optc = getopt_long (argc, argv, "f:F:a:k:R:S:ilrwsxdo",
diff --git a/src/lid.h b/src/lid.h
new file mode 100644
index 0000000..d778b66
--- /dev/null
+++ b/src/lid.h
@@ -0,0 +1,9 @@
+enum lid_mode
+ {
+ LID_MODE_AID,
+ LID_MODE_EID,
+ LID_MODE_GID,
+ LID_MODE_LID
+ };
+
+extern enum lid_mode lid_mode;