summaryrefslogtreecommitdiffstats
path: root/abs/core-testing/udev/resolve-modalias.c
diff options
context:
space:
mode:
authorCecil Hugh Watson <knoppmyth@gmail.com>2008-12-01 23:48:10 (GMT)
committerCecil Hugh Watson <knoppmyth@gmail.com>2008-12-01 23:48:10 (GMT)
commit575bd0829fce6f7582aefca086e1894b63812ef8 (patch)
tree1b66d798131ebd448034b30a2d7d6111aabf4c52 /abs/core-testing/udev/resolve-modalias.c
parent466412d4bdf5beb0645eced2d064df5e15f9b76b (diff)
downloadlinhes_pkgbuild-575bd0829fce6f7582aefca086e1894b63812ef8.zip
linhes_pkgbuild-575bd0829fce6f7582aefca086e1894b63812ef8.tar.gz
linhes_pkgbuild-575bd0829fce6f7582aefca086e1894b63812ef8.tar.bz2
Emulators and deps.
Signed-off-by: Cecil Hugh Watson <knoppmyth@gmail.com>
Diffstat (limited to 'abs/core-testing/udev/resolve-modalias.c')
-rw-r--r--abs/core-testing/udev/resolve-modalias.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/abs/core-testing/udev/resolve-modalias.c b/abs/core-testing/udev/resolve-modalias.c
new file mode 100644
index 0000000..d1680b1
--- /dev/null
+++ b/abs/core-testing/udev/resolve-modalias.c
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <fnmatch.h>
+#include <string.h>
+#include <malloc.h>
+
+static char *getline(FILE *file) {
+ static size_t size = 1024;
+ static char *buf = NULL;
+ static unsigned int i = 0, r = 0;;
+
+ if(buf == NULL)
+ buf = (char*)malloc(size);
+
+ if(i) {
+ memmove(buf, buf+i, size-i);
+ r -= i;
+ i = 0;
+ }
+
+ while(1) {
+ if(i == size) {
+ size *= 2;
+ buf = (char*)realloc(buf, size);
+ }
+
+ if(i==r)
+ r += fread(buf+i, 1, size-i, file);
+
+ if(i==r && i == 0) {
+ free(buf);
+ buf = NULL;
+ r = 0;
+ return NULL;
+ }
+
+ if(i==r || buf[i] == '\n') {
+ buf[i++] = '\0';
+ return buf;
+ }
+ i++;
+ }
+}
+
+int main(int argc, char *argv[]) {
+ FILE *f=fopen(argv[1], "r");
+ char *line, *pattern, *module;
+ char *pos1, *pos2;
+
+ while((line=getline(f))!=NULL) {
+ if(!strncmp(line, "alias", strlen("alias"))) {
+ pos1 = index(line, ' ');
+ pos2 = index(pos1+1, ' ');
+ pattern = pos1+1;
+ *pos2 = '\0';
+ module = pos2+1;
+
+ if(!fnmatch(pattern, argv[2], 0))
+ printf("%s\n", module);
+ }
+ }
+ return 0;
+}