summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2006-02-16 21:05:49 +0000
committerAurelien Foret <aurelien@archlinux.org>2006-02-16 21:05:49 +0000
commit181efcdeaaa5b7e65d8baeaee02451103a1c1224 (patch)
tree5665bbec75923fd0f4be2bfc47dfe82684e3d66a
parent58a7e85534f260a49a324dd5b3f408ce1e21cd18 (diff)
downloadpacman-181efcdeaaa5b7e65d8baeaee02451103a1c1224.tar.xz
- grep is now a static function
- code cleanup
-rw-r--r--lib/libalpm/util.c54
-rw-r--r--lib/libalpm/util.h1
2 files changed, 26 insertions, 29 deletions
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index ea189c09..6a256096 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -58,7 +58,6 @@ long _alpm_gzopen_frontend(char *pathname, int oflags, int mode)
break;
case O_RDWR:
default:
- errno = EINVAL;
return -1;
}
@@ -71,7 +70,6 @@ long _alpm_gzopen_frontend(char *pathname, int oflags, int mode)
}
if(!(gzf = gzdopen(fd, gzoflags))) {
close(fd);
- errno = ENOMEM;
return -1;
}
@@ -179,31 +177,6 @@ char *_alpm_strtrim(char *str)
return(str);
}
-/* A cheap grep for text files, returns 1 if a substring
- * was found in the text file fn, 0 if it wasn't
- */
-int _alpm_grep(const char *fn, const char *needle)
-{
- FILE *fp;
-
- if((fp = fopen(fn, "r")) == NULL) {
- return(0);
- }
- while(!feof(fp)) {
- char line[1024];
- fgets(line, 1024, fp);
- if(feof(fp)) {
- continue;
- }
- if(strstr(line, needle)) {
- fclose(fp);
- return(1);
- }
- }
- fclose(fp);
- return(0);
-}
-
/* Create a lock file
*/
int _alpm_lckmk(char *file)
@@ -358,6 +331,31 @@ int _alpm_ldconfig(char *root)
return(0);
}
+/* A cheap grep for text files, returns 1 if a substring
+ * was found in the text file fn, 0 if it wasn't
+ */
+static int grep(const char *fn, const char *needle)
+{
+ FILE *fp;
+
+ if((fp = fopen(fn, "r")) == NULL) {
+ return(0);
+ }
+ while(!feof(fp)) {
+ char line[1024];
+ fgets(line, 1024, fp);
+ if(feof(fp)) {
+ continue;
+ }
+ if(strstr(line, needle)) {
+ fclose(fp);
+ return(1);
+ }
+ }
+ fclose(fp);
+ return(0);
+}
+
int _alpm_runscriptlet(char *root, char *installfn, char *script, char *ver, char *oldver)
{
char scriptfn[PATH_MAX];
@@ -394,7 +392,7 @@ int _alpm_runscriptlet(char *root, char *installfn, char *script, char *ver, cha
scriptpath = scriptfn + strlen(root) - 1;
}
- if(!_alpm_grep(scriptfn, script)) {
+ if(!grep(scriptfn, script)) {
/* script not found in scriptlet file */
goto cleanup;
}
diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h
index 50c70145..225820e1 100644
--- a/lib/libalpm/util.h
+++ b/lib/libalpm/util.h
@@ -48,7 +48,6 @@ int _alpm_makepath(char *path);
int _alpm_copyfile(char *src, char *dest);
char *_alpm_strtoupper(char *str);
char *_alpm_strtrim(char *str);
-int _alpm_grep(const char *fn, const char *needle);
int _alpm_lckmk(char *file);
int _alpm_lckrm(char *file);
int _alpm_unpack(char *archive, const char *prefix, const char *fn);