fixed a build issue for missing lchown against old macosx sdks
added Awk::writeConsoleBytes(), Awk::writePipeBytes(), Awk::writeFileBytes()
This commit is contained in:
parent
50eec135d8
commit
03301b79bf
@ -337,7 +337,7 @@ QSE_EXPORT void* qse_fs_getxtn (
|
||||
#if defined(QSE_HAVE_INLINE)
|
||||
static QSE_INLINE qse_fs_errnum_t qse_fs_geterrnum (qse_fs_t* fs) { return fs->errnum; }
|
||||
#else
|
||||
# define qse_fs_geterrnum(fs) ((fs)->errnum)
|
||||
# define qse_fs_geterrnum(fs) (((qse_fs_t*)(fs))->errnum)
|
||||
#endif
|
||||
|
||||
QSE_EXPORT int qse_fs_getopt (
|
||||
@ -418,10 +418,10 @@ QSE_EXPORT int qse_fs_setattrwcs (
|
||||
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
# define qse_fs_getattr(fs,path,attr,flags) qse_fs_getattrmbs(fs,path,attr,flags)
|
||||
# define qse_fs_setattr(fs,path,attr,flags) qse_fssetattrmbs(fs,path,attr,flags)
|
||||
# define qse_fs_setattr(fs,path,attr,flags) qse_fs_setattrmbs(fs,path,attr,flags)
|
||||
#else
|
||||
# define qse_fs_getattr(fs,path,attr,flags) qse_fs_getattrwcs(fs,path,attr,flags)
|
||||
# define qse_fs_setattr(fs,path,attr,flags) qse_fssetattrwcs(fs,path,attr,flags)
|
||||
# define qse_fs_setattr(fs,path,attr,flags) qse_fs_setattrwcs(fs,path,attr,flags)
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -2020,6 +2020,12 @@ Awk::ssize_t Awk::writePipe (Pipe& io, const char_t* buf, size_t len)
|
||||
return -1;
|
||||
}
|
||||
|
||||
Awk::ssize_t Awk::writePipeBytes (Pipe& io, const qse_mchar_t* buf, size_t len)
|
||||
{
|
||||
((Run*)io)->setError (QSE_AWK_ENOIMPL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int Awk::flushPipe (Pipe& io)
|
||||
{
|
||||
((Run*)io)->setError (QSE_AWK_ENOIMPL);
|
||||
@ -2050,6 +2056,12 @@ Awk::ssize_t Awk::writeFile (File& io, const char_t* buf, size_t len)
|
||||
return -1;
|
||||
}
|
||||
|
||||
Awk::ssize_t Awk::writeFileBytes (File& io, const qse_mchar_t* buf, size_t len)
|
||||
{
|
||||
((Run*)io)->setError (QSE_AWK_ENOIMPL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int Awk::flushFile (File& io)
|
||||
{
|
||||
((Run*)io)->setError (QSE_AWK_ENOIMPL);
|
||||
@ -2080,6 +2092,12 @@ Awk::ssize_t Awk::writeConsole (Console& io, const char_t* buf, size_t len)
|
||||
return -1;
|
||||
}
|
||||
|
||||
Awk::ssize_t Awk::writeConsoleBytes (Console& io, const qse_mchar_t* buf, size_t len)
|
||||
{
|
||||
((Run*)io)->setError (QSE_AWK_ENOIMPL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int Awk::flushConsole (Console& io)
|
||||
{
|
||||
((Run*)io)->setError (QSE_AWK_ENOIMPL);
|
||||
|
@ -338,7 +338,10 @@
|
||||
# define QSE_CHROOT(path) QSE_LIBCALL1(chroot,path)
|
||||
#endif
|
||||
|
||||
#if defined(SYS_lchown) && defined(QSE_USE_SYSCALL)
|
||||
#if !defined(SYS_lchown) && !defined(HAVE_LCHOWN) && defined(__APPLE__) && defined(__MACH__) && defined(__POWERPC__)
|
||||
/* special handling for old darwin/macosx sdks */
|
||||
# define QSE_LCHOWN(path,owner,group) syscall(364,path,owner,group)
|
||||
#elif defined(SYS_lchown) && defined(QSE_USE_SYSCALL)
|
||||
# define QSE_LCHOWN(path,owner,group) syscall(SYS_lchown,path,owner,group)
|
||||
#else
|
||||
# define QSE_LCHOWN(path,owner,group) QSE_LIBCALL3(lchown,path,owner,group)
|
||||
|
@ -346,9 +346,9 @@ int qse_fs_setattrsys (qse_fs_t* fs, qse_fs_char_t* path, const qse_fattr_t* att
|
||||
int x;
|
||||
|
||||
if (flags & QSE_FILE_ATTR_SYMLINK)
|
||||
x = QSE_LCHOWN (path, attr->uid, attr->gid);
|
||||
x = QSE_LCHOWN(path, attr->uid, attr->gid);
|
||||
else
|
||||
x = QSE_CHOWN (path, attr->uid, attr->gid);
|
||||
x = QSE_CHOWN(path, attr->uid, attr->gid);
|
||||
|
||||
if (x <= -1)
|
||||
{
|
||||
|
@ -34,6 +34,7 @@
|
||||
/* TODO: windows event log */
|
||||
#else
|
||||
#include <syslog.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/un.h>
|
||||
|
@ -35,6 +35,7 @@
|
||||
#else
|
||||
# include <setjmp.h>
|
||||
# if defined(HAVE_UCONTEXT_H)
|
||||
# include <signal.h> /* for old DARWIN/MACOSX */
|
||||
# include <ucontext.h>
|
||||
# endif
|
||||
# if defined(HAVE_MAKECONTEXT) && defined(HAVE_SWAPCONTEXT) && \
|
||||
|
@ -23,6 +23,7 @@ static void print_usage (const qse_char_t* argv0)
|
||||
qse_fprintf (QSE_STDERR, QSE_T(" -r recursive\n"));
|
||||
qse_fprintf (QSE_STDERR, QSE_T(" -s symlink\n"));
|
||||
qse_fprintf (QSE_STDERR, QSE_T(" -g glob\n"));
|
||||
qse_fprintf (QSE_STDERR, QSE_T(" -w chown instead. wins over other options. honors -s\n"));
|
||||
}
|
||||
|
||||
static int fs_actcb (qse_fs_t* fs, qse_fs_action_t act, const qse_char_t* srcpath, const qse_char_t* dstpath, qse_uintmax_t total, qse_uintmax_t done)
|
||||
@ -66,10 +67,11 @@ static int fs_main (int argc, qse_char_t* argv[])
|
||||
int ret = 0;
|
||||
qse_cint_t c;
|
||||
int cpfile_flags = 0;
|
||||
int act_chown = 0;
|
||||
|
||||
static qse_opt_t opt =
|
||||
{
|
||||
QSE_T("foprsg"),
|
||||
QSE_T("foprsgw"),
|
||||
QSE_NULL
|
||||
};
|
||||
|
||||
@ -101,6 +103,10 @@ static int fs_main (int argc, qse_char_t* argv[])
|
||||
cpfile_flags |= QSE_FS_CPFILE_GLOB;
|
||||
break;
|
||||
|
||||
case QSE_T('w'):
|
||||
act_chown = 1;
|
||||
break;
|
||||
|
||||
case QSE_T('?'):
|
||||
qse_fprintf (QSE_STDERR, QSE_T("illegal option - '%c'\n"), opt.opt);
|
||||
goto wrong_usage;
|
||||
@ -118,15 +124,31 @@ static int fs_main (int argc, qse_char_t* argv[])
|
||||
|
||||
fs = qse_fs_open (QSE_MMGR_GETDFL(), 0);
|
||||
|
||||
if (act_chown)
|
||||
{
|
||||
qse_fattr_t attr;
|
||||
int attr_flags = QSE_FILE_ATTR_OWNER;
|
||||
if (cpfile_flags & QSE_FS_CPFILE_SYMLINK) attr_flags |= QSE_FILE_ATTR_SYMLINK;
|
||||
attr.uid = qse_strtoulong(argv[opt.ind], 10, QSE_NULL);
|
||||
attr.gid = -1;
|
||||
if (qse_fs_setattr(fs, argv[opt.ind + 1], &attr, attr_flags) <= -1)
|
||||
{
|
||||
qse_fprintf (QSE_STDERR, QSE_T("cannot change file uid - %d\n"), qse_fs_geterrnum(fs));
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qse_memset (&cbs, 0, QSE_SIZEOF(cbs));
|
||||
cbs.actcb = fs_actcb;
|
||||
qse_fs_setopt (fs, QSE_FS_CBS, &cbs);
|
||||
|
||||
if (qse_fs_cpfile (fs, argv[opt.ind], argv[opt.ind + 1], cpfile_flags) <= -1)
|
||||
if (qse_fs_cpfile(fs, argv[opt.ind], argv[opt.ind + 1], cpfile_flags) <= -1)
|
||||
{
|
||||
qse_fprintf (QSE_STDERR, QSE_T("cannot copy file - %d\n"), qse_fs_geterrnum(fs));
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
|
||||
qse_fs_close (fs);
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user