allowfunc fopen
allowfunc gmtime
allowfunc localtime
+allowfunc open
allowfunc socket
return 2;
#ifdef UNDER_CE
+ /* !checksrc! disable BANNEDFUNC 1 */
stat(file, &file_info);
#else
fstat(fileno(fp), &file_info);
/* to get the file size */
#ifdef UNDER_CE
+ /* !checksrc! disable BANNEDFUNC 1 */
if(stat("debugit", &file_info) != 0) {
#else
if(fstat(fileno(fd), &file_info) != 0) {
/* to get the file size */
#ifdef UNDER_CE
+ /* !checksrc! disable BANNEDFUNC 1 */
if(stat(LOCAL_FILE, &file_info) != 0) {
#else
if(fstat(fileno(hd_src), &file_info) != 0) {
}
#ifdef UNDER_CE
+ /* !checksrc! disable BANNEDFUNC 1 */
if(stat(upload, &file_info) != 0) {
#else
if(fstat(fileno(i->in), &file_info) != 0) {
/* get the file size of the local file */
#ifdef UNDER_CE
+ /* !checksrc! disable BANNEDFUNC 1 */
if(stat(file, &file_info) != 0) {
#else
if(fstat(fileno(hd_src), &file_info) != 0) {
#define CURL_DISABLE_LDAP 1
#ifndef _MSC_VER
+/* !checksrc! disable BANNEDFUNC 1 */
extern int stat(const char *path, struct stat *buffer);
#endif
#if !defined(CURL_DISABLE_COOKIES) || !defined(CURL_DISABLE_ALTSVC) || \
!defined(CURL_DISABLE_HSTS)
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
#include "urldata.h"
#include "rand.h"
#include "curl_fopen.h"
goto fail;
if(
#ifdef UNDER_CE
+ /* !checksrc! disable BANNEDFUNC 1 */
stat(filename, &sb) == -1
#else
fstat(fileno(*fh), &sb) == -1
result = CURLE_WRITE_ERROR;
#if (defined(ANDROID) || defined(__ANDROID__)) && \
(defined(__i386__) || defined(__arm__))
- fd = open(tempstore, O_WRONLY | O_CREAT | O_EXCL, (mode_t)(0600|sb.st_mode));
+ fd = curlx_open(tempstore, O_WRONLY | O_CREAT | O_EXCL,
+ (mode_t)(0600 | sb.st_mode));
#else
- fd = open(tempstore, O_WRONLY | O_CREAT | O_EXCL, 0600|sb.st_mode);
+ fd = curlx_open(tempstore, O_WRONLY | O_CREAT | O_EXCL,
+ 0600 | sb.st_mode);
#endif
if(fd == -1)
goto fail;
# endif
# define LSEEK_ERROR (long)-1
# endif
-# ifndef UNDER_CE
- int curlx_win32_stat(const char *path, struct_stat *buffer);
- int curlx_win32_open(const char *filename, int oflag, ...);
-# define stat(fname, stp) curlx_win32_stat(fname, stp)
-# define open curlx_win32_open
-# endif
#elif defined(__DJGPP__)
/* Requires DJGPP 2.04 */
# include <unistd.h>
#if defined(_WIN32) && !defined(UNDER_CE)
FILE *curlx_win32_fopen(const char *filename, const char *mode);
+int curlx_win32_stat(const char *path, struct_stat *buffer);
+int curlx_win32_open(const char *filename, int oflag, ...);
#define CURLX_FOPEN_LOW(fname, mode) curlx_win32_fopen(fname, mode)
+#define curlx_stat(fname, stp) curlx_win32_stat(fname, stp)
+#define curlx_open curlx_win32_open
#else
-#define CURLX_FOPEN_LOW fopen
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h> /* for open() */
+#endif
+#define CURLX_FOPEN_LOW fopen
+#define curlx_stat(fname, stp) stat(fname, stp)
+#define curlx_open open
#endif
#ifdef CURLDEBUG
-#define curlx_fopen(file,mode) curl_dbg_fopen(file,mode,__LINE__,__FILE__)
+#define curlx_fopen(file,mode) curl_dbg_fopen(file,mode,__LINE__,__FILE__)
#define curlx_fdopen(file,mode) curl_dbg_fdopen(file,mode,__LINE__,__FILE__)
-#define curlx_fclose(file) curl_dbg_fclose(file,__LINE__,__FILE__)
+#define curlx_fclose(file) curl_dbg_fclose(file,__LINE__,__FILE__)
#else
-#define curlx_fopen CURLX_FOPEN_LOW
-#define curlx_fdopen fdopen
-#define curlx_fclose fclose
+#define curlx_fopen CURLX_FOPEN_LOW
+#define curlx_fdopen fdopen
+#define curlx_fclose fclose
#endif
#endif /* HEADER_CURLX_FOPEN_H */
#include <sys/param.h>
#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include "transfer.h"
#include "url.h"
#include "parsedate.h" /* for the week day and month names */
+#include "curlx/fopen.h"
#include "curlx/warnless.h"
#include "curl_range.h"
/* The last 3 #include files should be in this order */
return CURLE_URL_MALFORMAT;
}
- fd = open(actual_path, O_RDONLY|CURL_O_BINARY);
+ fd = curlx_open(actual_path, O_RDONLY | CURL_O_BINARY);
file->path = actual_path;
#else
if(memchr(real_path, 0, real_path_len)) {
extern int __unix_path_semantics;
if(strchr(real_path + 1, ':')) {
/* Amiga absolute path */
- fd = open(real_path + 1, O_RDONLY);
+ fd = curlx_open(real_path + 1, O_RDONLY);
file->path++;
}
else if(__unix_path_semantics) {
/* -lunix fallback */
- fd = open(real_path, O_RDONLY);
+ fd = curlx_open(real_path, O_RDONLY);
}
}
#else
- fd = open(real_path, O_RDONLY);
+ fd = curlx_open(real_path, O_RDONLY);
file->path = real_path;
#endif
#endif
#if (defined(ANDROID) || defined(__ANDROID__)) && \
(defined(__i386__) || defined(__arm__))
- fd = open(file->path, mode, (mode_t)data->set.new_file_perms);
+ fd = curlx_open(file->path, mode, (mode_t)data->set.new_file_perms);
#else
- fd = open(file->path, mode, data->set.new_file_perms);
+ fd = curlx_open(file->path, mode, data->set.new_file_perms);
#endif
if(fd < 0) {
failf(data, "cannot open %s for writing", file->path);
struct_stat statbuf;
int result;
- result = stat(file, &statbuf);
+ result = curlx_stat(file, &statbuf);
switch(statbuf.st_fab_rfm) {
case FAB$C_VAR:
char *base;
struct_stat sbuf;
- if(stat(filename, &sbuf))
+ if(curlx_stat(filename, &sbuf))
result = CURLE_READ_ERROR;
else {
part->data = strdup(filename);
#ifdef HAVE_NETINET_UDP_H
#include <netinet/udp.h>
#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
#ifdef USE_NGHTTP3
#include <nghttp3/nghttp3.h>
#endif
#include "../urldata.h"
#include "../bufq.h"
#include "../curlx/dynbuf.h"
+#include "../curlx/fopen.h"
#include "../cfilters.h"
#include "../curl_trc.h"
#include "curl_ngtcp2.h"
result = curlx_dyn_add(&fname, ".sqlog");
if(!result) {
- int qlogfd = open(curlx_dyn_ptr(&fname), O_WRONLY|O_CREAT|CURL_O_BINARY,
- data->set.new_file_perms);
+ int qlogfd = curlx_open(curlx_dyn_ptr(&fname),
+ O_WRONLY | O_CREAT | CURL_O_BINARY,
+ data->set.new_file_perms);
if(qlogfd != -1)
*qlogfdp = qlogfd;
}
#include <limits.h>
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#include "../sockaddr.h" /* required for Curl_sockaddr_storage */
#include "../multiif.h"
#include "../select.h"
+#include "../curlx/fopen.h"
#include "../curlx/warnless.h"
#include "curl_path.h"
#include "../curlx/strparse.h"
sshc->rsa = aprintf("%s/.ssh/id_rsa", home);
if(!sshc->rsa)
out_of_memory = TRUE;
- else if(stat(sshc->rsa, &sbuf)) {
+ else if(curlx_stat(sshc->rsa, &sbuf)) {
free(sshc->rsa);
sshc->rsa = aprintf("%s/.ssh/id_dsa", home);
if(!sshc->rsa)
out_of_memory = TRUE;
- else if(stat(sshc->rsa, &sbuf)) {
+ else if(curlx_stat(sshc->rsa, &sbuf)) {
Curl_safefree(sshc->rsa);
}
}
if(!out_of_memory && !sshc->rsa) {
/* Nothing found; try the current dir. */
sshc->rsa = strdup("id_rsa");
- if(sshc->rsa && stat(sshc->rsa, &sbuf)) {
+ if(sshc->rsa && curlx_stat(sshc->rsa, &sbuf)) {
free(sshc->rsa);
sshc->rsa = strdup("id_dsa");
- if(sshc->rsa && stat(sshc->rsa, &sbuf)) {
+ if(sshc->rsa && curlx_stat(sshc->rsa, &sbuf)) {
free(sshc->rsa);
/* Out of guesses. Set to the empty string to avoid
* surprising info messages. */
"fclose" => 1,
"fdopen" => 1,
"fopen" => 1,
+ "open" => 1,
+ "stat" => 1,
);
my %warnings_extended = (
***************************************************************************/
#include "tool_setup.h"
-#ifdef HAVE_FCNTL_H
-/* for open() */
-#include <fcntl.h>
-#endif
-
#include "tool_cfgable.h"
#include "tool_msgs.h"
#include "tool_cb_wrt.h"
else {
int fd;
do {
- fd = open(fname, O_CREAT | O_WRONLY | O_EXCL | CURL_O_BINARY, OPENMODE);
+ fd = curlx_open(fname, O_CREAT | O_WRONLY | O_EXCL | CURL_O_BINARY,
+ OPENMODE);
/* Keep retrying in the hope that it is not interrupted sometime */
/* !checksrc! disable ERRNOVAR 1 */
} while(fd == -1 && errno == EINTR);
return FALSE;
next_num++;
do {
- fd = open(curlx_dyn_ptr(&fbuffer),
- O_CREAT | O_WRONLY | O_EXCL | CURL_O_BINARY, OPENMODE);
+ fd = curlx_open(curlx_dyn_ptr(&fbuffer),
+ O_CREAT | O_WRONLY | O_EXCL | CURL_O_BINARY,
+ OPENMODE);
/* Keep retrying in the hope that it is not interrupted sometime */
} while(fd == -1 && errno == EINTR);
}
identify whether it is a reserved device name and not a regular
filename. */
#ifdef MSDOS
- if(base && ((stat(base, &st_buf)) == 0) && (S_ISCHR(st_buf.st_mode))) {
+ if(base && (curlx_stat(base, &st_buf) == 0) && S_ISCHR(st_buf.st_mode)) {
/* Prepend a '_' */
size_t blen = strlen(base);
if(blen) {
}
#else
struct_stat statbuf;
- if(stat(filename, &statbuf) != -1) {
+ if(curlx_stat(filename, &statbuf) != -1) {
*stamp = (curl_off_t)statbuf.st_mtime;
rc = 0;
}
#endif
#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
#include "tool_findfile.h"
#include "tool_cfgable.h"
else
c = aprintf("%s" DIR_CHAR "%s", home, fname);
if(c) {
- int fd = open(c, O_RDONLY);
+ int fd = curlx_open(c, O_RDONLY);
if(fd >= 0) {
char *path = strdup(c);
close(fd);
#ifndef HAVE_GETPASS_R
/* this file is only for systems without getpass_r() */
-#ifdef HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
#ifdef HAVE_TERMIOS_H
# include <termios.h>
#elif defined(HAVE_TERMIO_H)
{
ssize_t nread;
bool disabled;
- int fd = open("/dev/tty", O_RDONLY);
+ int fd = curlx_open("/dev/tty", O_RDONLY);
if(fd == -1)
fd = STDIN_FILENO; /* use stdin if the tty could not be used */
***************************************************************************/
#include "tool_setup.h"
-#ifdef HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-
#ifdef HAVE_LOCALE_H
# include <locale.h>
#endif
#ifdef __VMS
/* Calculate the real upload size for VMS */
per->infd = -1;
- if(stat(per->uploadfile, &fileinfo) == 0) {
+ if(curlx_stat(per->uploadfile, &fileinfo) == 0) {
fileinfo.st_size = VmsSpecialSize(uploadfile, &fileinfo);
switch(fileinfo.st_fab_rfm) {
case FAB$C_VAR:
case FAB$C_VFC:
case FAB$C_STMCR:
- per->infd = open(per->uploadfile, O_RDONLY | CURL_O_BINARY);
+ per->infd = curlx_open(per->uploadfile, O_RDONLY | CURL_O_BINARY);
break;
default:
- per->infd = open(per->uploadfile, O_RDONLY | CURL_O_BINARY,
- "rfm=stmlf", "ctx=stm");
+ per->infd = curlx_open(per->uploadfile, O_RDONLY | CURL_O_BINARY,
+ "rfm=stmlf", "ctx=stm");
}
}
if(per->infd == -1)
#else
- per->infd = open(per->uploadfile, O_RDONLY | CURL_O_BINARY);
+ per->infd = curlx_open(per->uploadfile, O_RDONLY | CURL_O_BINARY);
if((per->infd == -1) || fstat(per->infd, &fileinfo))
#endif
{
}
if(result && config->rm_partial) {
struct_stat st;
- if(!stat(outs->filename, &st) &&
- S_ISREG(st.st_mode)) {
+ if(!curlx_stat(outs->filename, &st) && S_ISREG(st.st_mode)) {
if(!unlink(outs->filename))
notef("Removed output file: %s", outs->filename);
else
if(config->skip_existing) {
struct_stat fileinfo;
- if(!stat(per->outfile, &fileinfo)) {
+ if(!curlx_stat(per->outfile, &fileinfo)) {
/* file is present */
notef("skips transfer, \"%s\" exists locally", per->outfile);
per->skip = TRUE;
of the file as it is now and open it for append instead */
struct_stat fileinfo;
/* VMS -- Danger, the filesize is only valid for stream files */
- if(stat(per->outfile, &fileinfo) == 0)
+ if(curlx_stat(per->outfile, &fileinfo) == 0)
/* set offset to current file size: */
config->resume_from = fileinfo.st_size;
else
/* get the file size of the local file */
#ifdef UNDER_CE
+ /* !checksrc! disable BANNEDFUNC 1 */
hd = stat(libtest_arg2, &file_info);
#else
hd = fstat(fileno(hd_src), &file_info);
/* open a dummy descriptor */
- t518_testfd[0] = open(DEV_NULL, O_RDONLY);
+ t518_testfd[0] = curlx_open(DEV_NULL, O_RDONLY);
if(t518_testfd[0] < 0) {
curl_msnprintf(strbuff, sizeof(strbuff), "opening of %s failed", DEV_NULL);
t518_store_errmsg(strbuff, errno);
/* get the file size of the local file */
#ifdef UNDER_CE
+ /* !checksrc! disable BANNEDFUNC 1 */
hd = stat(libtest_arg2, &file_info);
#else
hd = fstat(fileno(hd_src), &file_info);
/* open a dummy descriptor */
- t537_testfd[0] = open(DEV_NULL, O_RDONLY);
+ t537_testfd[0] = curlx_open(DEV_NULL, O_RDONLY);
if(t537_testfd[0] < 0) {
curl_msnprintf(strbuff, sizeof(strbuff), "opening of %s failed", DEV_NULL);
t537_store_errmsg(strbuff, errno);
/* get the file size of the local file */
#ifdef UNDER_CE
+ /* !checksrc! disable BANNEDFUNC 1 */
hd = stat(libtest_arg2, &file_info);
#else
hd = fstat(fileno(hd_src), &file_info);
curl_free(stream_uri);
stream_uri = NULL;
- sdp = open(libtest_arg2, O_RDONLY);
+ sdp = curlx_open(libtest_arg2, O_RDONLY);
if(sdp == -1) {
curl_mfprintf(stderr, "can't open %s\n", libtest_arg2);
res = TEST_ERR_MAJOR_BAD;
stream_uri = NULL;
/* PUT style GET_PARAMETERS */
- params = open(libtest_arg2, O_RDONLY);
+ params = curlx_open(libtest_arg2, O_RDONLY);
if(params == -1) {
curl_mfprintf(stderr, "can't open %s\n", libtest_arg2);
res = TEST_ERR_MAJOR_BAD;
/* get the file size of the local file */
#ifdef UNDER_CE
+ /* !checksrc! disable BANNEDFUNC 1 */
hd = stat(libtest_arg2, &file_info);
#else
hd = fstat(fileno(hd_src), &file_info);
allowfunc fopen
allowfunc freeaddrinfo
allowfunc getaddrinfo
+allowfunc open
allowfunc recv
allowfunc send
allowfunc socket
(void)!write(STDERR_FILENO, msg, sizeof(msg) - 1);
}
else {
- int fd;
#ifdef _WIN32
- fd = _open(serverlogfile, O_WRONLY|O_CREAT|O_APPEND, S_IREAD | S_IWRITE);
+#define OPENMODE S_IREAD | S_IWRITE
#else
- fd = open(serverlogfile, O_WRONLY|O_CREAT|O_APPEND, S_IRUSR | S_IWUSR);
+#define OPENMODE S_IRUSR | S_IWUSR
#endif
+ int fd = open(serverlogfile, O_WRONLY | O_CREAT | O_APPEND, OPENMODE);
if(fd != -1) {
static const char msg[] = "exit_signal_handler: called\n";
(void)!write(fd, msg, sizeof(msg) - 1);