summaryrefslogtreecommitdiff
path: root/spectro/conv.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2017-12-03 20:38:41 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2017-12-03 20:38:41 +0100
commitba627dd9ecb578e9852c7b9cce67ec63199d1acf (patch)
tree27c4258311ca8c8ed7ff67a8a0bc7280e8fcae79 /spectro/conv.c
parent69aec3b712232e93600ecd741269fed1f90b412a (diff)
parent3abb40d43649adb3807180692d8579c405524675 (diff)
Merge branch 'release/2.0.0+repack-1'2.0.0+repack-1
Diffstat (limited to 'spectro/conv.c')
-rwxr-xr-x[-rw-r--r--]spectro/conv.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/spectro/conv.c b/spectro/conv.c
index 284a30c..a728566 100644..100755
--- a/spectro/conv.c
+++ b/spectro/conv.c
@@ -41,6 +41,9 @@
#include <stdarg.h>
#include <errno.h>
#include <string.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <pwd.h>
/* select() defined, but not poll(), so emulate poll() */
#if defined(FD_CLR) && !defined(POLLIN)
@@ -59,6 +62,7 @@
#include "sa_config.h"
#endif
#include "numsup.h"
+#include "cgats.h"
#include "xspect.h"
#include "insttypes.h"
#include "conv.h"
@@ -241,6 +245,12 @@ void empty_con_chars(void) {
if ((stdinh = GetStdHandle(STD_INPUT_HANDLE)) == INVALID_HANDLE_VALUE)
return;
for (;;) {
+ /* Wait for 1msec */
+
+ /* Do dummy read, as stdin seems to be signalled on startup */
+ if (WaitForSingleObject(stdinh, 1) == WAIT_OBJECT_0)
+ ReadFile(stdinh, buf, 0, &bread, NULL);
+
if (WaitForSingleObject(stdinh, 1) == WAIT_OBJECT_0) {
ReadFile(stdinh, buf, 100, &bread, NULL);
} else {
@@ -423,6 +433,13 @@ athread *new_athread(
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+/* Return the login $HOME directory. */
+/* (Useful if we might be running sudo) */
+/* No NT equivalent ?? */
+char *login_HOME() {
+ return getenv("HOME");
+}
+
/* Delete a file */
void delete_file(char *fname) {
_unlink(fname);
@@ -789,6 +806,7 @@ static void *threadproc(
athread *p = (athread *)param;
/* Register this thread with the Objective-C garbage collector */
+ /* (Hmm. Done by default in latter versions though, hence deprecated in them ?) */
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
objc_registerThreadWithCollector();
#endif
@@ -833,6 +851,29 @@ athread *new_athread(
/* - - - - - - - - - - - - - - - - - - - - - - - - */
+/* Return the login $HOME directory. */
+/* (Useful if we might be running sudo) */
+char *login_HOME() {
+
+ if (getuid() == 0) { /* If we are running as root */
+ char *uids;
+
+ if ((uids = getenv("SUDO_UID")) != NULL) { /* And we sudo's to get it */
+ int uid;
+ struct passwd *pwd;
+
+ uid = atoi(uids);
+
+ if ((pwd = getpwuid(uid)) != NULL) {
+ return pwd->pw_dir;
+ }
+ }
+ }
+
+ return getenv("HOME");
+}
+
+
/* Delete a file */
void delete_file(char *fname) {
unlink(fname);