X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=nssm.cpp;h=7c956112065144957696bcc1e0dc6b85a2df413f;hb=7aa403b0a0d8ecf1e59c9d4ab3709181941e2f4c;hp=d543c46de27b96e4bc655a060fd79319a58cb1c3;hpb=7b85809e2f4f36f1cb587e255c72409b06d549a9;p=nssm.git diff --git a/nssm.cpp b/nssm.cpp index d543c46..7c95611 100644 --- a/nssm.cpp +++ b/nssm.cpp @@ -1,63 +1,70 @@ #include "nssm.h" extern unsigned long tls_index; +extern bool is_admin; +extern imports_t imports; -/* String function */ -int str_equiv(const char *a, const char *b) { - int i; - for (i = 0; ; i++) { - if (tolower(b[i]) != tolower(a[i])) return 0; - if (! a[i]) return 1; - } +/* Are two strings case-insensitively equivalent? */ +int str_equiv(const TCHAR *a, const TCHAR *b) { + size_t len = _tcslen(a); + if (_tcslen(b) != len) return 0; + if (_tcsnicmp(a, b, len)) return 0; + return 1; +} + +/* Remove basename of a path. */ +void strip_basename(TCHAR *buffer) { + size_t len = _tcslen(buffer); + size_t i; + for (i = len; i && buffer[i] != _T('\\') && buffer[i] != _T('/'); i--); + /* X:\ is OK. */ + if (i && buffer[i - 1] == _T(':')) i++; + buffer[i] = _T('\0'); } /* How to use me correctly */ int usage(int ret) { - fprintf(stderr, "NSSM: The non-sucking service manager\n"); - fprintf(stderr, "Version %s, %s\n", NSSM_VERSION, NSSM_DATE); - fprintf(stderr, "Usage: nssm