mirror of
https://github.com/troglobit/libite.git
synced 2026-10-18 10:49:38 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e48c9c5589 | ||
|
|
2c875afe06 | ||
|
|
10e4a1d057 | ||
|
|
3dde2922c3 | ||
|
|
4dd9459f65 |
No files matched your search
+10
-1
@@ -4,6 +4,14 @@ Change Log
|
|||||||
All notable changes to the project are documented in this file.
|
All notable changes to the project are documented in this file.
|
||||||
|
|
||||||
|
|
||||||
|
[v1.9.1][] - 2017-07-03
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
### Changes
|
||||||
|
- Add missing `whichp()` predicate function to accompany `which()`
|
||||||
|
- Allow `which("ps aux")`, which skips any arguments to command
|
||||||
|
|
||||||
|
|
||||||
[v1.9.0][] - 2017-07-02
|
[v1.9.0][] - 2017-07-02
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
@@ -244,7 +252,8 @@ problems this may cause!
|
|||||||
Initial extraction of frog DNA from [Finit][]. See [README][] for API details.
|
Initial extraction of frog DNA from [Finit][]. See [README][] for API details.
|
||||||
|
|
||||||
|
|
||||||
[UNRELEASED]: https://github.com/troglobit/libite/compare/v1.9.0...HEAD
|
[UNRELEASED]: https://github.com/troglobit/libite/compare/v1.9.1...HEAD
|
||||||
|
[v1.9.1]: https://github.com/troglobit/libite/compare/v1.9.0...v1.9.1
|
||||||
[v1.9.0]: https://github.com/troglobit/libite/compare/v1.8.3...v1.9.0
|
[v1.9.0]: https://github.com/troglobit/libite/compare/v1.8.3...v1.9.0
|
||||||
[v1.8.3]: https://github.com/troglobit/libite/compare/v1.8.2...v1.8.3
|
[v1.8.3]: https://github.com/troglobit/libite/compare/v1.8.2...v1.8.3
|
||||||
[v1.8.2]: https://github.com/troglobit/libite/compare/v1.8.1...v1.8.2
|
[v1.8.2]: https://github.com/troglobit/libite/compare/v1.8.1...v1.8.2
|
||||||
|
|||||||
@@ -288,11 +288,16 @@ Generic Functions
|
|||||||
optional listing of file and directory permissions if `show_perms` is
|
optional listing of file and directory permissions if `show_perms` is
|
||||||
set. The `path` argument should be a directory.
|
set. The `path` argument should be a directory.
|
||||||
|
|
||||||
- `which(cmd)`
|
- `which(cmd)`, `whichp(cmd)`
|
||||||
|
|
||||||
C implementation of UNIX which(1). Returns a malloc'ed string with the
|
C implementation of UNIX which(1). Returns a malloc'ed string with the
|
||||||
full path to `cmd` on success, otherwise `NULL`.
|
full path to `cmd` on success, otherwise `NULL`.
|
||||||
|
|
||||||
|
`whichp()` is a predicate function, returns `TRUE` or `FALSE`.
|
||||||
|
|
||||||
|
**Note:** `which("/bin/ps aux")` will return `/bin/ps`, or `TRUE`,
|
||||||
|
provided of course `/bin/ps` exists.
|
||||||
|
|
||||||
|
|
||||||
GNU Functions
|
GNU Functions
|
||||||
-------------
|
-------------
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
AC_INIT(libite, 1.9.0, https://github.com/troglobit/libite/issues)
|
AC_INIT(libite, 1.9.1, https://github.com/troglobit/libite/issues)
|
||||||
AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz])
|
AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz])
|
||||||
AM_SILENT_RULES([yes])
|
AM_SILENT_RULES([yes])
|
||||||
|
|
||||||
|
|||||||
Vendored
+12
@@ -1,3 +1,15 @@
|
|||||||
|
libite (1.9.1-1) unstable; urgency=low
|
||||||
|
|
||||||
|
* New upstream reelase, v1.9.1.
|
||||||
|
|
||||||
|
-- Joachim Nilsson <troglobit@gmail.com> Sun, 02 Jul 2017 19:23:00 +0100
|
||||||
|
|
||||||
|
libite (1.9.0-1) unstable; urgency=low
|
||||||
|
|
||||||
|
* New upstream reelase.
|
||||||
|
|
||||||
|
-- Joachim Nilsson <troglobit@gmail.com> Sun, 02 Jul 2017 19:23:00 +0100
|
||||||
|
|
||||||
libite (1.8.3-1) unstable; urgency=low
|
libite (1.8.3-1) unstable; urgency=low
|
||||||
|
|
||||||
* New upstream reelase.
|
* New upstream reelase.
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ void progress (int percent, int max_width);
|
|||||||
void progress_simple(int percent);
|
void progress_simple(int percent);
|
||||||
|
|
||||||
char *which (const char *cmd);
|
char *which (const char *cmd);
|
||||||
|
int whichp (const char *cmd);
|
||||||
|
|
||||||
#ifndef touch
|
#ifndef touch
|
||||||
#include <sys/stat.h> /* utimensat() */
|
#include <sys/stat.h> /* utimensat() */
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ int main(void)
|
|||||||
{ "free", 1 },
|
{ "free", 1 },
|
||||||
{ "modinfo", 1 },
|
{ "modinfo", 1 },
|
||||||
{ "useradd", 1 },
|
{ "useradd", 1 },
|
||||||
|
{ "/bin/which", 1 },
|
||||||
|
{ "/bin/ps aux", 1 },
|
||||||
{ "/etc/passwd", 0 },
|
{ "/etc/passwd", 0 },
|
||||||
{ NULL, 0 }
|
{ NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,12 +14,30 @@
|
|||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h> /* snprintf() */
|
#include <stdio.h> /* snprintf() */
|
||||||
#include <stdlib.h> /* realloc(), free() */
|
#include <stdlib.h> /* realloc(), free() */
|
||||||
#include <string.h> /* strtok_r() */
|
#include <string.h> /* strtok_r() */
|
||||||
#include <unistd.h> /* access() */
|
#include <unistd.h> /* access() */
|
||||||
|
|
||||||
|
/* Strip any arguments in "/path/to/bin --some args", modifies input string */
|
||||||
|
static char *strip_args(char *path)
|
||||||
|
{
|
||||||
|
size_t i = 0;
|
||||||
|
|
||||||
|
if (!path)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* Find first whitespace (space/tab/etc.) */
|
||||||
|
while (path[i] && !isspace(path[i]))
|
||||||
|
i++;
|
||||||
|
path[i] = 0;
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Like which(1), returns a malloc'ed path to cmd on success, or NULL
|
* Like which(1), returns a malloc'ed path to cmd on success, or NULL
|
||||||
*/
|
*/
|
||||||
@@ -34,7 +52,10 @@ char *which(const char *cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cmd[0] == '/') {
|
if (cmd[0] == '/') {
|
||||||
path = strdup(cmd);
|
path = strip_args(strdup(cmd));
|
||||||
|
if (!path)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if (!access(path, X_OK))
|
if (!access(path, X_OK))
|
||||||
return path;
|
return path;
|
||||||
|
|
||||||
@@ -66,7 +87,8 @@ char *which(const char *cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
snprintf(path, pathlen, "%s/%s", tok, cmd);
|
snprintf(path, pathlen, "%s/%s", tok, cmd);
|
||||||
if (!access(path, X_OK)) {
|
path = strip_args(path);
|
||||||
|
if (!path || !access(path, X_OK)) {
|
||||||
free(env);
|
free(env);
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
@@ -81,6 +103,22 @@ char *which(const char *cmd)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Like which(), above, but only answers TRUE(1)/FALSE(0)
|
||||||
|
*/
|
||||||
|
int whichp(const char *cmd)
|
||||||
|
{
|
||||||
|
char *path;
|
||||||
|
|
||||||
|
path = which(cmd);
|
||||||
|
if (path) {
|
||||||
|
free(path);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Local Variables:
|
* Local Variables:
|
||||||
* indent-tabs-mode: t
|
* indent-tabs-mode: t
|
||||||
|
|||||||
Reference in new issue
Block a user