Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=fwlive.git;a=commitdiff;h=553660449a6394ba1ef99f827512bd08a82d37fb
commit 553660449a6394ba1ef99f827512bd08a82d37fb Author: James Buren <[email protected]> Date: Mon Mar 4 02:57:45 2013 -0600 add function for detecting if we running on the linux virtual console diff --git a/new/fwsetup/local.h b/new/fwsetup/local.h index 9d09490..83219fc 100644 --- a/new/fwsetup/local.h +++ b/new/fwsetup/local.h @@ -105,6 +105,7 @@ struct module const char *name; }; +extern bool areweinvc(void); extern void file2str(const char *path,char *s,size_t n); extern void strfcpy(char *s,size_t n,const char *fmt,...) __attribute__((format(printf,3,4))); extern void strfcat(char *s,size_t n,const char *fmt,...) __attribute__((format(printf,3,4))); @@ -151,7 +152,7 @@ static inline bool areweinfwlive(void) return (env != 0 && strcmp(env,"fwlive") == 0); } -static inline bool areweingui(void) +static inline bool areweinx11(void) { const char *env = getenv("DISPLAY"); diff --git a/new/fwsetup/utility.c b/new/fwsetup/utility.c index 7681a41..2b4831a 100644 --- a/new/fwsetup/utility.c +++ b/new/fwsetup/utility.c @@ -30,6 +30,24 @@ static inline bool umount_retry(const char *path) return false; } +extern bool areweinvc(void) +{ + char tty[TEXT_MAX] = {0}; + regex_t re = {0}; + bool result = true; + + if( + ttyname_r(STDIN_FILENO,tty,sizeof(tty)) != 0 || + regcomp(&re,"^/dev/tty[0-9]+$",REG_EXTENDED|REG_NOSUB) != 0 || + regexec(&re,tty,0,0,0) != 0 + ) + result = false; + + regfree(&re); + + return result; +} + extern void file2str(const char *path,char *s,size_t n) { FILE *file = 0; _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
