+* Fri Jul 24 2009 Andrew McNab <Andrew.McNab@cern.ch>
+- Back port fixes from 1.7.x, including:
+- Remove 2 argument open(...O_CREAT...) instance in
+ grst_admin_file.c
+- Change (GRSTerrorLogFunc) to return int, to allow
+ if-less C macro using && instead.
* Fri Jul 3 2009 Andrew McNab <Andrew.McNab@cern.ch>
- ==== GridSite version 1.5.12 ====
* Fri Jul 3 2009 Andrew McNab <Andrew.McNab@cern.ch>
// No such file or directory
#define GRST_RET_NO_SUCH_FILE 1003
+/* We use && now rather than if so this macro can be used inside if...else
+ but that means the function must return an int rather than be void */
+#define GRSTerrorLog(GRSTerrorLevel, ...) ((GRSTerrorLogFunc != NULL) && ((GRSTerrorLogFunc)(__FILE__, __LINE__, GRSTerrorLevel, __VA_ARGS__)))
-// #define GRSTerrorLog(GRSTerrorLevel, GRSTerrorFmt, ...) if (GRSTerrorLogFunc != NULL) (GRSTerrorLogFunc)(__FILE__, __LINE__, GRSTerrorLevel, GRSTerrorFmt, __VA_ARGS__)
-
-#define GRSTerrorLog(GRSTerrorLevel, ...) if (GRSTerrorLogFunc != NULL) (GRSTerrorLogFunc)(__FILE__, __LINE__, GRSTerrorLevel, __VA_ARGS__)
-
-extern void (*GRSTerrorLogFunc)(char *, int, int, char *, ...);
+extern int (*GRSTerrorLogFunc)(char *, int, int, char *, ...);
/* these levels are the same as Unix syslog() and Apache ap_log_error() */
char *dir_path, char *file, char *dir_uri,
char *admin_file)
{
- int fd, numfiles;
+ int numfiles;
char *dir_path_file, *dir_path_vfile, *p, *vfile, *dnlistsuri,
*fulluri, *server_name, *realfile;
struct stat statbuf;
GRSThttpBody bp;
struct dirent *subdirfile_ent;
DIR *subDIR;
+ FILE *fp;
if ((file[0] == '\0') ||
((strcmp(file, GRST_ACL_FILE) != 0) && !GRSTgaclPermHasWrite(perm)) ||
strcat(dir_path_file, "/");
strcat(dir_path_file, vfile);
- fd = open(dir_path_file, O_WRONLY | O_CREAT);
- if (fd != -1) close(fd);
+ fp = fopen(dir_path_file, "w");
+ if (fp != NULL) fclose(fp);
}
printf("Status: 302 Moved Temporarily\nContent-Length: 0\n"
#include "gridsite.h"
-void (*GRSTerrorLogFunc)(char *, int, int, char *, ...) = NULL;
+int (*GRSTerrorLogFunc)(char *, int, int, char *, ...) = NULL;
"(Version: %s)\n", p, VERSION);
}
-void htproxy_logfunc(char *file, int line, int level, char *fmt, ...)
+int htproxy_logfunc(char *file, int line, int level, char *fmt, ...)
{
char *mesg;
va_list ap;
fprintf(stderr, "%s(%d) %s\n", file, line, mesg);
free(mesg);
+ return 0;
}
int main(int argc, char *argv[])
}
static server_rec *mod_gridsite_log_func_server;
-static void mod_gridsite_log_func(char *file, int line, int level,
+static int mod_gridsite_log_func(char *file, int line, int level,
char *fmt, ...)
{
char *mesg;
0, mod_gridsite_log_func_server, "%s", mesg);
free(mesg);
+ return 0;
}
static void mod_gridsite_child_init(apr_pool_t *pPool, server_rec *pServer)
.destroy = slashgrid_destroy
};
-void slashgrid_logfunc(char *file, int line, int level, char *fmt, ...)
+int slashgrid_logfunc(char *file, int line, int level, char *fmt, ...)
{
char *mesg;
va_list ap;
syslog(level, "%s(%d) %s", file, line, mesg);
free(mesg);
+ return 0;
}
int main(int argc, char *argv[])