summaryrefslogtreecommitdiff
path: root/spectro/conv.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2017-11-25 10:16:00 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2017-11-25 10:16:00 +0100
commitf6b8e0eae4374f339487a33e3e4fe5462d5816e1 (patch)
tree5f5f764fd6cda404b2ad6e85762c03fce3a335db /spectro/conv.c
parent615ab5513e79c4abc5bbe5c993587785b6a1738b (diff)
New upstream version 2.0.0upstream/2.0.0
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);