Fossil SCM
Move the file-specific definitions of the isatty() and fileno() macros into util.c's fossil_isatty() and fossil_fileno() in prep for an upcoming change which needs isatty().
Commit
898a70ce82a524ca054ed77dfab897b9383337d0c645a039e2ff78e49b60c3ce
Parent
e17b8da85584d60…
6 files changed
+1
-1
+1
-7
+1
-2
+1
-1
+4
-9
+23
+1
-1
| --- src/cgi.c | ||
| +++ src/cgi.c | ||
| @@ -2122,11 +2122,11 @@ | ||
| 2122 | 2122 | for(i=0; zToken[i] && zToken[i]!='?'; i++){} |
| 2123 | 2123 | if( zToken[i] ) zToken[i++] = 0; |
| 2124 | 2124 | cgi_setenv("PATH_INFO", zToken); |
| 2125 | 2125 | cgi_setenv("QUERY_STRING", &zToken[i]); |
| 2126 | 2126 | if( zIpAddr==0 ){ |
| 2127 | - zIpAddr = cgi_remote_ip(fileno(g.httpIn)); | |
| 2127 | + zIpAddr = cgi_remote_ip(fossil_fileno(g.httpIn)); | |
| 2128 | 2128 | } |
| 2129 | 2129 | if( zIpAddr ){ |
| 2130 | 2130 | cgi_setenv("REMOTE_ADDR", zIpAddr); |
| 2131 | 2131 | g.zIpAddr = fossil_strdup(zIpAddr); |
| 2132 | 2132 | } |
| 2133 | 2133 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -2122,11 +2122,11 @@ | |
| 2122 | for(i=0; zToken[i] && zToken[i]!='?'; i++){} |
| 2123 | if( zToken[i] ) zToken[i++] = 0; |
| 2124 | cgi_setenv("PATH_INFO", zToken); |
| 2125 | cgi_setenv("QUERY_STRING", &zToken[i]); |
| 2126 | if( zIpAddr==0 ){ |
| 2127 | zIpAddr = cgi_remote_ip(fileno(g.httpIn)); |
| 2128 | } |
| 2129 | if( zIpAddr ){ |
| 2130 | cgi_setenv("REMOTE_ADDR", zIpAddr); |
| 2131 | g.zIpAddr = fossil_strdup(zIpAddr); |
| 2132 | } |
| 2133 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -2122,11 +2122,11 @@ | |
| 2122 | for(i=0; zToken[i] && zToken[i]!='?'; i++){} |
| 2123 | if( zToken[i] ) zToken[i++] = 0; |
| 2124 | cgi_setenv("PATH_INFO", zToken); |
| 2125 | cgi_setenv("QUERY_STRING", &zToken[i]); |
| 2126 | if( zIpAddr==0 ){ |
| 2127 | zIpAddr = cgi_remote_ip(fossil_fileno(g.httpIn)); |
| 2128 | } |
| 2129 | if( zIpAddr ){ |
| 2130 | cgi_setenv("REMOTE_ADDR", zIpAddr); |
| 2131 | g.zIpAddr = fossil_strdup(zIpAddr); |
| 2132 | } |
| 2133 |
+1
-7
| --- src/http.c | ||
| +++ src/http.c | ||
| @@ -21,16 +21,10 @@ | ||
| 21 | 21 | #include "http.h" |
| 22 | 22 | #include <assert.h> |
| 23 | 23 | |
| 24 | 24 | #ifdef _WIN32 |
| 25 | 25 | #include <io.h> |
| 26 | -#ifndef isatty | |
| 27 | -#define isatty(d) _isatty(d) | |
| 28 | -#endif | |
| 29 | -#ifndef fileno | |
| 30 | -#define fileno(s) _fileno(s) | |
| 31 | -#endif | |
| 32 | 26 | #endif |
| 33 | 27 | |
| 34 | 28 | |
| 35 | 29 | #if INTERFACE |
| 36 | 30 | /* |
| @@ -206,11 +200,11 @@ | ||
| 206 | 200 | Blob x; |
| 207 | 201 | char *zUser; |
| 208 | 202 | char *zPw; |
| 209 | 203 | char *zPrompt; |
| 210 | 204 | char *zHttpAuth = 0; |
| 211 | - if( !isatty(fileno(stdin)) ) return 0; | |
| 205 | + if( !fossil_isatty(fossil_fileno(stdin)) ) return 0; | |
| 212 | 206 | zPrompt = mprintf("\n%s authorization required by\n%s\n", |
| 213 | 207 | g.url.isHttps==1 ? "Encrypted HTTPS" : "Unencrypted HTTP", g.url.canonical); |
| 214 | 208 | fossil_print("%s", zPrompt); |
| 215 | 209 | free(zPrompt); |
| 216 | 210 | if ( g.url.user && g.url.passwd && use_fossil_creds_for_httpauth_prompt() ){ |
| 217 | 211 |
| --- src/http.c | |
| +++ src/http.c | |
| @@ -21,16 +21,10 @@ | |
| 21 | #include "http.h" |
| 22 | #include <assert.h> |
| 23 | |
| 24 | #ifdef _WIN32 |
| 25 | #include <io.h> |
| 26 | #ifndef isatty |
| 27 | #define isatty(d) _isatty(d) |
| 28 | #endif |
| 29 | #ifndef fileno |
| 30 | #define fileno(s) _fileno(s) |
| 31 | #endif |
| 32 | #endif |
| 33 | |
| 34 | |
| 35 | #if INTERFACE |
| 36 | /* |
| @@ -206,11 +200,11 @@ | |
| 206 | Blob x; |
| 207 | char *zUser; |
| 208 | char *zPw; |
| 209 | char *zPrompt; |
| 210 | char *zHttpAuth = 0; |
| 211 | if( !isatty(fileno(stdin)) ) return 0; |
| 212 | zPrompt = mprintf("\n%s authorization required by\n%s\n", |
| 213 | g.url.isHttps==1 ? "Encrypted HTTPS" : "Unencrypted HTTP", g.url.canonical); |
| 214 | fossil_print("%s", zPrompt); |
| 215 | free(zPrompt); |
| 216 | if ( g.url.user && g.url.passwd && use_fossil_creds_for_httpauth_prompt() ){ |
| 217 |
| --- src/http.c | |
| +++ src/http.c | |
| @@ -21,16 +21,10 @@ | |
| 21 | #include "http.h" |
| 22 | #include <assert.h> |
| 23 | |
| 24 | #ifdef _WIN32 |
| 25 | #include <io.h> |
| 26 | #endif |
| 27 | |
| 28 | |
| 29 | #if INTERFACE |
| 30 | /* |
| @@ -206,11 +200,11 @@ | |
| 200 | Blob x; |
| 201 | char *zUser; |
| 202 | char *zPw; |
| 203 | char *zPrompt; |
| 204 | char *zHttpAuth = 0; |
| 205 | if( !fossil_isatty(fossil_fileno(stdin)) ) return 0; |
| 206 | zPrompt = mprintf("\n%s authorization required by\n%s\n", |
| 207 | g.url.isHttps==1 ? "Encrypted HTTPS" : "Unencrypted HTTP", g.url.canonical); |
| 208 | fossil_print("%s", zPrompt); |
| 209 | free(zPrompt); |
| 210 | if ( g.url.user && g.url.passwd && use_fossil_creds_for_httpauth_prompt() ){ |
| 211 |
+1
-2
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -21,11 +21,10 @@ | ||
| 21 | 21 | #include "VERSION.h" |
| 22 | 22 | #include "config.h" |
| 23 | 23 | #if defined(_WIN32) |
| 24 | 24 | # include <windows.h> |
| 25 | 25 | # include <io.h> |
| 26 | -# define isatty(h) _isatty(h) | |
| 27 | 26 | # define GETPID (int)GetCurrentProcessId |
| 28 | 27 | #endif |
| 29 | 28 | |
| 30 | 29 | /* BUGBUG: This (PID_T) does not work inside of INTERFACE block. */ |
| 31 | 30 | #if USE_SEE |
| @@ -705,11 +704,11 @@ | ||
| 705 | 704 | int rc; |
| 706 | 705 | |
| 707 | 706 | g.zPhase = "init"; |
| 708 | 707 | #if !defined(_WIN32_WCE) |
| 709 | 708 | if( fossil_getenv("FOSSIL_BREAK") ){ |
| 710 | - if( isatty(0) && isatty(2) ){ | |
| 709 | + if( fossil_isatty(0) && fossil_isatty(2) ){ | |
| 711 | 710 | fprintf(stderr, |
| 712 | 711 | "attach debugger to process %d and press any key to continue.\n", |
| 713 | 712 | GETPID()); |
| 714 | 713 | fgetc(stdin); |
| 715 | 714 | }else{ |
| 716 | 715 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -21,11 +21,10 @@ | |
| 21 | #include "VERSION.h" |
| 22 | #include "config.h" |
| 23 | #if defined(_WIN32) |
| 24 | # include <windows.h> |
| 25 | # include <io.h> |
| 26 | # define isatty(h) _isatty(h) |
| 27 | # define GETPID (int)GetCurrentProcessId |
| 28 | #endif |
| 29 | |
| 30 | /* BUGBUG: This (PID_T) does not work inside of INTERFACE block. */ |
| 31 | #if USE_SEE |
| @@ -705,11 +704,11 @@ | |
| 705 | int rc; |
| 706 | |
| 707 | g.zPhase = "init"; |
| 708 | #if !defined(_WIN32_WCE) |
| 709 | if( fossil_getenv("FOSSIL_BREAK") ){ |
| 710 | if( isatty(0) && isatty(2) ){ |
| 711 | fprintf(stderr, |
| 712 | "attach debugger to process %d and press any key to continue.\n", |
| 713 | GETPID()); |
| 714 | fgetc(stdin); |
| 715 | }else{ |
| 716 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -21,11 +21,10 @@ | |
| 21 | #include "VERSION.h" |
| 22 | #include "config.h" |
| 23 | #if defined(_WIN32) |
| 24 | # include <windows.h> |
| 25 | # include <io.h> |
| 26 | # define GETPID (int)GetCurrentProcessId |
| 27 | #endif |
| 28 | |
| 29 | /* BUGBUG: This (PID_T) does not work inside of INTERFACE block. */ |
| 30 | #if USE_SEE |
| @@ -705,11 +704,11 @@ | |
| 704 | int rc; |
| 705 | |
| 706 | g.zPhase = "init"; |
| 707 | #if !defined(_WIN32_WCE) |
| 708 | if( fossil_getenv("FOSSIL_BREAK") ){ |
| 709 | if( fossil_isatty(0) && fossil_isatty(2) ){ |
| 710 | fprintf(stderr, |
| 711 | "attach debugger to process %d and press any key to continue.\n", |
| 712 | GETPID()); |
| 713 | fgetc(stdin); |
| 714 | }else{ |
| 715 |
+1
-1
| --- src/printf.c | ||
| +++ src/printf.c | ||
| @@ -1269,8 +1269,8 @@ | ||
| 1269 | 1269 | void fossil_binary_mode(FILE *p){ |
| 1270 | 1270 | #if defined(_WIN32) |
| 1271 | 1271 | _setmode(_fileno(p), _O_BINARY); |
| 1272 | 1272 | #endif |
| 1273 | 1273 | #ifdef __EMX__ /* OS/2 */ |
| 1274 | - setmode(fileno(p), O_BINARY); | |
| 1274 | + fossil_setmode(fossil_fileno(p), O_BINARY); | |
| 1275 | 1275 | #endif |
| 1276 | 1276 | } |
| 1277 | 1277 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -1269,8 +1269,8 @@ | |
| 1269 | void fossil_binary_mode(FILE *p){ |
| 1270 | #if defined(_WIN32) |
| 1271 | _setmode(_fileno(p), _O_BINARY); |
| 1272 | #endif |
| 1273 | #ifdef __EMX__ /* OS/2 */ |
| 1274 | setmode(fileno(p), O_BINARY); |
| 1275 | #endif |
| 1276 | } |
| 1277 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -1269,8 +1269,8 @@ | |
| 1269 | void fossil_binary_mode(FILE *p){ |
| 1270 | #if defined(_WIN32) |
| 1271 | _setmode(_fileno(p), _O_BINARY); |
| 1272 | #endif |
| 1273 | #ifdef __EMX__ /* OS/2 */ |
| 1274 | fossil_setmode(fossil_fileno(p), O_BINARY); |
| 1275 | #endif |
| 1276 | } |
| 1277 |
+4
-9
| --- src/url.c | ||
| +++ src/url.c | ||
| @@ -21,16 +21,10 @@ | ||
| 21 | 21 | #include "url.h" |
| 22 | 22 | #include <stdio.h> |
| 23 | 23 | |
| 24 | 24 | #ifdef _WIN32 |
| 25 | 25 | #include <io.h> |
| 26 | -#ifndef isatty | |
| 27 | -#define isatty(d) _isatty(d) | |
| 28 | -#endif | |
| 29 | -#ifndef fileno | |
| 30 | -#define fileno(s) _fileno(s) | |
| 31 | -#endif | |
| 32 | 26 | #endif |
| 33 | 27 | |
| 34 | 28 | #if INTERFACE |
| 35 | 29 | /* |
| 36 | 30 | ** Flags for url_parse() |
| @@ -324,11 +318,12 @@ | ||
| 324 | 318 | blob_reset(&cfile); |
| 325 | 319 | }else if( pUrlData->user!=0 && pUrlData->passwd==0 |
| 326 | 320 | && (urlFlags & URL_PROMPT_PW)!=0 ){ |
| 327 | 321 | url_prompt_for_password_local(pUrlData); |
| 328 | 322 | }else if( pUrlData->user!=0 && ( urlFlags & URL_ASK_REMEMBER_PW ) ){ |
| 329 | - if( isatty(fileno(stdin)) && ( urlFlags & URL_REMEMBER_PW )==0 ){ | |
| 323 | + if( fossil_isatty(fossil_fileno(stdin)) | |
| 324 | + && ( urlFlags & URL_REMEMBER_PW )==0 ){ | |
| 330 | 325 | if( save_password_prompt(pUrlData->passwd) ){ |
| 331 | 326 | pUrlData->flags = urlFlags |= URL_REMEMBER_PW; |
| 332 | 327 | }else{ |
| 333 | 328 | pUrlData->flags = urlFlags &= ~URL_REMEMBER_PW; |
| 334 | 329 | } |
| @@ -735,11 +730,11 @@ | ||
| 735 | 730 | ** the provided UrlData structure. Store the result into the "passwd" member |
| 736 | 731 | ** of the provided UrlData structure. |
| 737 | 732 | */ |
| 738 | 733 | void url_prompt_for_password_local(UrlData *pUrlData){ |
| 739 | 734 | if( pUrlData->isSsh || pUrlData->isFile ) return; |
| 740 | - if( isatty(fileno(stdin)) | |
| 735 | + if( fossil_isatty(fossil_fileno(stdin)) | |
| 741 | 736 | && (pUrlData->flags & URL_PROMPT_PW)!=0 |
| 742 | 737 | && (pUrlData->flags & URL_PROMPTED)==0 |
| 743 | 738 | ){ |
| 744 | 739 | pUrlData->flags |= URL_PROMPTED; |
| 745 | 740 | pUrlData->passwd = prompt_for_user_password(pUrlData->canonical); |
| @@ -796,11 +791,11 @@ | ||
| 796 | 791 | ** URL but no password. |
| 797 | 792 | */ |
| 798 | 793 | void url_get_password_if_needed(void){ |
| 799 | 794 | if( (g.url.user && g.url.user[0]) |
| 800 | 795 | && (g.url.passwd==0 || g.url.passwd[0]==0) |
| 801 | - && isatty(fileno(stdin)) | |
| 796 | + && fossil_isatty(fossil_fileno(stdin)) | |
| 802 | 797 | ){ |
| 803 | 798 | url_prompt_for_password(); |
| 804 | 799 | } |
| 805 | 800 | } |
| 806 | 801 | |
| 807 | 802 |
| --- src/url.c | |
| +++ src/url.c | |
| @@ -21,16 +21,10 @@ | |
| 21 | #include "url.h" |
| 22 | #include <stdio.h> |
| 23 | |
| 24 | #ifdef _WIN32 |
| 25 | #include <io.h> |
| 26 | #ifndef isatty |
| 27 | #define isatty(d) _isatty(d) |
| 28 | #endif |
| 29 | #ifndef fileno |
| 30 | #define fileno(s) _fileno(s) |
| 31 | #endif |
| 32 | #endif |
| 33 | |
| 34 | #if INTERFACE |
| 35 | /* |
| 36 | ** Flags for url_parse() |
| @@ -324,11 +318,12 @@ | |
| 324 | blob_reset(&cfile); |
| 325 | }else if( pUrlData->user!=0 && pUrlData->passwd==0 |
| 326 | && (urlFlags & URL_PROMPT_PW)!=0 ){ |
| 327 | url_prompt_for_password_local(pUrlData); |
| 328 | }else if( pUrlData->user!=0 && ( urlFlags & URL_ASK_REMEMBER_PW ) ){ |
| 329 | if( isatty(fileno(stdin)) && ( urlFlags & URL_REMEMBER_PW )==0 ){ |
| 330 | if( save_password_prompt(pUrlData->passwd) ){ |
| 331 | pUrlData->flags = urlFlags |= URL_REMEMBER_PW; |
| 332 | }else{ |
| 333 | pUrlData->flags = urlFlags &= ~URL_REMEMBER_PW; |
| 334 | } |
| @@ -735,11 +730,11 @@ | |
| 735 | ** the provided UrlData structure. Store the result into the "passwd" member |
| 736 | ** of the provided UrlData structure. |
| 737 | */ |
| 738 | void url_prompt_for_password_local(UrlData *pUrlData){ |
| 739 | if( pUrlData->isSsh || pUrlData->isFile ) return; |
| 740 | if( isatty(fileno(stdin)) |
| 741 | && (pUrlData->flags & URL_PROMPT_PW)!=0 |
| 742 | && (pUrlData->flags & URL_PROMPTED)==0 |
| 743 | ){ |
| 744 | pUrlData->flags |= URL_PROMPTED; |
| 745 | pUrlData->passwd = prompt_for_user_password(pUrlData->canonical); |
| @@ -796,11 +791,11 @@ | |
| 796 | ** URL but no password. |
| 797 | */ |
| 798 | void url_get_password_if_needed(void){ |
| 799 | if( (g.url.user && g.url.user[0]) |
| 800 | && (g.url.passwd==0 || g.url.passwd[0]==0) |
| 801 | && isatty(fileno(stdin)) |
| 802 | ){ |
| 803 | url_prompt_for_password(); |
| 804 | } |
| 805 | } |
| 806 | |
| 807 |
| --- src/url.c | |
| +++ src/url.c | |
| @@ -21,16 +21,10 @@ | |
| 21 | #include "url.h" |
| 22 | #include <stdio.h> |
| 23 | |
| 24 | #ifdef _WIN32 |
| 25 | #include <io.h> |
| 26 | #endif |
| 27 | |
| 28 | #if INTERFACE |
| 29 | /* |
| 30 | ** Flags for url_parse() |
| @@ -324,11 +318,12 @@ | |
| 318 | blob_reset(&cfile); |
| 319 | }else if( pUrlData->user!=0 && pUrlData->passwd==0 |
| 320 | && (urlFlags & URL_PROMPT_PW)!=0 ){ |
| 321 | url_prompt_for_password_local(pUrlData); |
| 322 | }else if( pUrlData->user!=0 && ( urlFlags & URL_ASK_REMEMBER_PW ) ){ |
| 323 | if( fossil_isatty(fossil_fileno(stdin)) |
| 324 | && ( urlFlags & URL_REMEMBER_PW )==0 ){ |
| 325 | if( save_password_prompt(pUrlData->passwd) ){ |
| 326 | pUrlData->flags = urlFlags |= URL_REMEMBER_PW; |
| 327 | }else{ |
| 328 | pUrlData->flags = urlFlags &= ~URL_REMEMBER_PW; |
| 329 | } |
| @@ -735,11 +730,11 @@ | |
| 730 | ** the provided UrlData structure. Store the result into the "passwd" member |
| 731 | ** of the provided UrlData structure. |
| 732 | */ |
| 733 | void url_prompt_for_password_local(UrlData *pUrlData){ |
| 734 | if( pUrlData->isSsh || pUrlData->isFile ) return; |
| 735 | if( fossil_isatty(fossil_fileno(stdin)) |
| 736 | && (pUrlData->flags & URL_PROMPT_PW)!=0 |
| 737 | && (pUrlData->flags & URL_PROMPTED)==0 |
| 738 | ){ |
| 739 | pUrlData->flags |= URL_PROMPTED; |
| 740 | pUrlData->passwd = prompt_for_user_password(pUrlData->canonical); |
| @@ -796,11 +791,11 @@ | |
| 791 | ** URL but no password. |
| 792 | */ |
| 793 | void url_get_password_if_needed(void){ |
| 794 | if( (g.url.user && g.url.user[0]) |
| 795 | && (g.url.passwd==0 || g.url.passwd[0]==0) |
| 796 | && fossil_isatty(fossil_fileno(stdin)) |
| 797 | ){ |
| 798 | url_prompt_for_password(); |
| 799 | } |
| 800 | } |
| 801 | |
| 802 |
+23
| --- src/util.c | ||
| +++ src/util.c | ||
| @@ -28,19 +28,42 @@ | ||
| 28 | 28 | /* |
| 29 | 29 | ** For the fossil_timer_xxx() family of functions... |
| 30 | 30 | */ |
| 31 | 31 | #ifdef _WIN32 |
| 32 | 32 | # include <windows.h> |
| 33 | +# include <io.h> | |
| 33 | 34 | #else |
| 34 | 35 | # include <sys/time.h> |
| 35 | 36 | # include <sys/resource.h> |
| 36 | 37 | # include <sys/types.h> |
| 37 | 38 | # include <sys/stat.h> |
| 38 | 39 | # include <unistd.h> |
| 39 | 40 | # include <fcntl.h> |
| 40 | 41 | # include <errno.h> |
| 41 | 42 | #endif |
| 43 | + | |
| 44 | +/* | |
| 45 | +** Returns the same as the platform's isatty() or _isatty() function. | |
| 46 | +*/ | |
| 47 | +int fossil_isatty(int fd){ | |
| 48 | +#ifdef _WIN32 | |
| 49 | + return _isatty(fd); | |
| 50 | +#else | |
| 51 | + return isatty(fd); | |
| 52 | +#endif | |
| 53 | +} | |
| 54 | + | |
| 55 | +/* | |
| 56 | +** Returns the same as the platform's fileno() or _fileno() function. | |
| 57 | +*/ | |
| 58 | +int fossil_fileno(FILE *p){ | |
| 59 | +#ifdef _WIN32 | |
| 60 | + return _fileno(p); | |
| 61 | +#else | |
| 62 | + return fileno(p); | |
| 63 | +#endif | |
| 64 | +} | |
| 42 | 65 | |
| 43 | 66 | /* |
| 44 | 67 | ** Exit. Take care to close the database first. |
| 45 | 68 | */ |
| 46 | 69 | NORETURN void fossil_exit(int rc){ |
| 47 | 70 |
| --- src/util.c | |
| +++ src/util.c | |
| @@ -28,19 +28,42 @@ | |
| 28 | /* |
| 29 | ** For the fossil_timer_xxx() family of functions... |
| 30 | */ |
| 31 | #ifdef _WIN32 |
| 32 | # include <windows.h> |
| 33 | #else |
| 34 | # include <sys/time.h> |
| 35 | # include <sys/resource.h> |
| 36 | # include <sys/types.h> |
| 37 | # include <sys/stat.h> |
| 38 | # include <unistd.h> |
| 39 | # include <fcntl.h> |
| 40 | # include <errno.h> |
| 41 | #endif |
| 42 | |
| 43 | /* |
| 44 | ** Exit. Take care to close the database first. |
| 45 | */ |
| 46 | NORETURN void fossil_exit(int rc){ |
| 47 |
| --- src/util.c | |
| +++ src/util.c | |
| @@ -28,19 +28,42 @@ | |
| 28 | /* |
| 29 | ** For the fossil_timer_xxx() family of functions... |
| 30 | */ |
| 31 | #ifdef _WIN32 |
| 32 | # include <windows.h> |
| 33 | # include <io.h> |
| 34 | #else |
| 35 | # include <sys/time.h> |
| 36 | # include <sys/resource.h> |
| 37 | # include <sys/types.h> |
| 38 | # include <sys/stat.h> |
| 39 | # include <unistd.h> |
| 40 | # include <fcntl.h> |
| 41 | # include <errno.h> |
| 42 | #endif |
| 43 | |
| 44 | /* |
| 45 | ** Returns the same as the platform's isatty() or _isatty() function. |
| 46 | */ |
| 47 | int fossil_isatty(int fd){ |
| 48 | #ifdef _WIN32 |
| 49 | return _isatty(fd); |
| 50 | #else |
| 51 | return isatty(fd); |
| 52 | #endif |
| 53 | } |
| 54 | |
| 55 | /* |
| 56 | ** Returns the same as the platform's fileno() or _fileno() function. |
| 57 | */ |
| 58 | int fossil_fileno(FILE *p){ |
| 59 | #ifdef _WIN32 |
| 60 | return _fileno(p); |
| 61 | #else |
| 62 | return fileno(p); |
| 63 | #endif |
| 64 | } |
| 65 | |
| 66 | /* |
| 67 | ** Exit. Take care to close the database first. |
| 68 | */ |
| 69 | NORETURN void fossil_exit(int rc){ |
| 70 |