Removed further compiler warnings

This commit is contained in:
Stefan Ritt 2019-05-22 09:30:20 +02:00
parent e950e2cac3
commit 465d738c96

View File

@ -1,339 +1,342 @@
/******************************************************************** /********************************************************************
Name: elogd.h Name: elogd.h
Created by: Stefan Ritt Created by: Stefan Ritt
Copyright 2000 + Stefan Ritt Copyright 2000 + Stefan Ritt
ELOG is free software: you can redistribute it and/or modify ELOG is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
ELOG is distributed in the hope that it will be useful, ELOG is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
In addition, as a special exception, the copyright holders give In addition, as a special exception, the copyright holders give
permission to link the code of portions of this program with the permission to link the code of portions of this program with the
OpenSSL library under certain conditions as described in each OpenSSL library under certain conditions as described in each
individual source file, and distribute linked combinations individual source file, and distribute linked combinations
including the two. including the two.
You must obey the GNU General Public License in all respects You must obey the GNU General Public License in all respects
for all of the code used other than OpenSSL. If you modify for all of the code used other than OpenSSL. If you modify
file(s) with this exception, you may extend this exception to your file(s) with this exception, you may extend this exception to your
version of the file(s), but you are not obligated to do so. If you version of the file(s), but you are not obligated to do so. If you
do not wish to do so, delete this exception statement from your do not wish to do so, delete this exception statement from your
version. If you delete this exception statement from all source version. If you delete this exception statement from all source
files in the program, then also delete it here. files in the program, then also delete it here.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with ELOG. If not, see <http://www.gnu.org/licenses/>. along with ELOG. If not, see <http://www.gnu.org/licenses/>.
Contents: Header file for ELOG program Contents: Header file for ELOG program
\********************************************************************/ \********************************************************************/
/* Include version from central version file */ /* Include version from central version file */
#include "elog-version.h" #include "elog-version.h"
#define _GNU_SOURCE #define _GNU_SOURCE
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <locale.h> #include <locale.h>
/* Default name of the configuration file. */ /* Default name of the configuration file. */
#ifndef CFGFILE #ifndef CFGFILE
#define CFGFILE "elogd.cfg" #define CFGFILE "elogd.cfg"
#endif #endif
/* Default TCP port for server. */ /* Default TCP port for server. */
#ifndef DEFAULT_PORT #ifndef DEFAULT_PORT
#define DEFAULT_PORT 80 #define DEFAULT_PORT 80
#endif #endif
#ifdef _MSC_VER /* unused function parameters */
#define UNUSED(x) __attribute__((unused)) x
#define OS_WINNT
#ifdef _MSC_VER
#define DIR_SEPARATOR '\\'
#define DIR_SEPARATOR_STR "\\" #define OS_WINNT
#define snprintf _snprintf #define DIR_SEPARATOR '\\'
#define strcasestr StrStrIA #define DIR_SEPARATOR_STR "\\"
#include <windows.h> #define snprintf _snprintf
#include <io.h> #define strcasestr StrStrIA
#include <conio.h>
#include <time.h> #include <windows.h>
#include <direct.h> #include <io.h>
#include <sys/stat.h> #include <conio.h>
#include <errno.h> #include <time.h>
#include <direct.h>
#include <Shlwapi.h> #include <sys/stat.h>
#include <errno.h>
#else
#include <Shlwapi.h>
#define OS_UNIX
#else
#ifdef __APPLE__
#define OS_MACOSX #define OS_UNIX
#endif
#ifdef __APPLE__
#define TRUE 1 #define OS_MACOSX
#define FALSE 0 #endif
#ifndef O_TEXT #define TRUE 1
#define O_TEXT 0 #define FALSE 0
#define O_BINARY 0
#endif #ifndef O_TEXT
#define O_TEXT 0
#define DIR_SEPARATOR '/' #define O_BINARY 0
#define DIR_SEPARATOR_STR "/" #endif
#ifndef DEFAULT_USER #define DIR_SEPARATOR '/'
#define DEFAULT_USER "nobody" #define DIR_SEPARATOR_STR "/"
#endif
#ifndef DEFAULT_USER
#ifndef DEFAULT_GROUP #define DEFAULT_USER "nobody"
#define DEFAULT_GROUP "nogroup" #endif
#endif
#ifndef DEFAULT_GROUP
#ifndef PIDFILE #define DEFAULT_GROUP "nogroup"
#define PIDFILE "/var/run/elogd.pid" #endif
#endif
#ifndef PIDFILE
typedef int BOOL; #define PIDFILE "/var/run/elogd.pid"
#endif
#include <netdb.h>
#include <netinet/in.h> typedef int BOOL;
#include <arpa/inet.h>
#include <sys/socket.h> #include <netdb.h>
#include <sys/time.h> #include <netinet/in.h>
#include <sys/types.h> #include <arpa/inet.h>
#include <sys/stat.h> #include <sys/socket.h>
#include <sys/wait.h> #include <sys/time.h>
#include <unistd.h> #include <sys/types.h>
#include <signal.h> #include <sys/stat.h>
#include <time.h> #include <sys/wait.h>
#include <dirent.h> #include <unistd.h>
#include <errno.h> #include <signal.h>
#include <ctype.h> #include <time.h>
#include <pwd.h> #include <dirent.h>
#include <grp.h> #include <errno.h>
#include <syslog.h> #include <ctype.h>
#include <termios.h> #include <pwd.h>
#include <grp.h>
#define closesocket(s) close(s) #include <syslog.h>
#include <termios.h>
#ifndef stricmp
#define stricmp(s1, s2) strcasecmp(s1, s2) #define closesocket(s) close(s)
#endif
#ifndef stricmp
#endif /* OS_UNIX */ #define stricmp(s1, s2) strcasecmp(s1, s2)
#endif
/* SSL includes */
#ifdef HAVE_SSL #endif /* OS_UNIX */
#include <openssl/ssl.h>
#endif /* SSL includes */
#ifdef HAVE_SSL
/* local includes */ #include <openssl/ssl.h>
#include "regex.h" #endif
#include "mxml.h"
#include "strlcpy.h" /* local includes */
#include "regex.h"
#define SYSLOG_PRIORITY LOG_NOTICE /* Default priority for syslog facility */ #include "mxml.h"
#include "strlcpy.h"
#define TELL(fh) lseek(fh, 0, SEEK_CUR)
#define SYSLOG_PRIORITY LOG_NOTICE /* Default priority for syslog facility */
#ifdef OS_WINNT
#define TRUNCATE(fh) chsize(fh, TELL(fh)) #define TELL(fh) lseek(fh, 0, SEEK_CUR)
#else
#define TRUNCATE(fh) ftruncate(fh, TELL(fh)) #ifdef OS_WINNT
#endif #define TRUNCATE(fh) chsize(fh, TELL(fh))
#else
#define NAME_LENGTH 1500 #define TRUNCATE(fh) ftruncate(fh, TELL(fh))
#endif
#define DEFAULT_TIME_FORMAT "%c"
#define DEFAULT_DATE_FORMAT "%x" #define NAME_LENGTH 1500
#define DEFAULT_HTTP_CHARSET "ISO-8859-1" #define DEFAULT_TIME_FORMAT "%c"
#define DEFAULT_DATE_FORMAT "%x"
#define SUCCESS 1
#define FAILURE 0 #define DEFAULT_HTTP_CHARSET "ISO-8859-1"
#define EL_SUCCESS 1 #define SUCCESS 1
#define EL_FIRST_MSG 2 #define FAILURE 0
#define EL_LAST_MSG 3
#define EL_NO_MSG 4 #define EL_SUCCESS 1
#define EL_FILE_ERROR 5 #define EL_FIRST_MSG 2
#define EL_UPGRADE 6 #define EL_LAST_MSG 3
#define EL_EMPTY 7 #define EL_NO_MSG 4
#define EL_MEM_ERROR 8 #define EL_FILE_ERROR 5
#define EL_DUPLICATE 9 #define EL_UPGRADE 6
#define EL_INVAL_FILE 10 #define EL_EMPTY 7
#define EL_MEM_ERROR 8
#define EL_FIRST 1 #define EL_DUPLICATE 9
#define EL_LAST 2 #define EL_INVAL_FILE 10
#define EL_NEXT 3
#define EL_PREV 4 #define EL_FIRST 1
#define EL_LAST 2
#define MAX_GROUPS 32 #define EL_NEXT 3
#define MAX_PARAM 200 #define EL_PREV 4
#define MAX_ATTACHMENTS 50
#define MAX_N_LIST 100 #define MAX_GROUPS 32
#define MAX_N_ATTR 100 #define MAX_PARAM 200
#define MAX_N_EMAIL 500 #define MAX_ATTACHMENTS 50
#define MAX_REPLY_TO 100 #define MAX_N_LIST 100
#define CMD_SIZE 10000 #define MAX_N_ATTR 100
#define TEXT_SIZE 250000 #define MAX_N_EMAIL 500
#define MAX_PATH_LENGTH 256 #define MAX_REPLY_TO 100
#define CMD_SIZE 10000
#define MAX_CONTENT_LENGTH 10*1024*1024 #define TEXT_SIZE 250000
#define MAX_PATH_LENGTH 256
/* attribute flags */
#define AF_REQUIRED (1<<0) #define MAX_CONTENT_LENGTH 10*1024*1024
#define AF_LOCKED (1<<1)
#define AF_MULTI (1<<2) /* attribute flags */
#define AF_FIXED_EDIT (1<<3) #define AF_REQUIRED (1<<0)
#define AF_FIXED_REPLY (1<<4) #define AF_LOCKED (1<<1)
#define AF_ICON (1<<5) #define AF_MULTI (1<<2)
#define AF_RADIO (1<<6) #define AF_FIXED_EDIT (1<<3)
#define AF_EXTENDABLE (1<<7) #define AF_FIXED_REPLY (1<<4)
#define AF_DATE (1<<8) #define AF_ICON (1<<5)
#define AF_DATETIME (1<<9) #define AF_RADIO (1<<6)
#define AF_TIME (1<<10) #define AF_EXTENDABLE (1<<7)
#define AF_NUMERIC (1<<11) #define AF_DATE (1<<8)
#define AF_USERLIST (1<<12) #define AF_DATETIME (1<<9)
#define AF_MUSERLIST (1<<13) #define AF_TIME (1<<10)
#define AF_USEREMAIL (1<<14) #define AF_NUMERIC (1<<11)
#define AF_MUSEREMAIL (1<<15) #define AF_USERLIST (1<<12)
#define AF_MUSERLIST (1<<13)
/* attribute format flags */ #define AF_USEREMAIL (1<<14)
#define AFF_SAME_LINE 1 #define AF_MUSEREMAIL (1<<15)
#define AFF_MULTI_LINE 2
#define AFF_DATE 4 /* attribute format flags */
#define AFF_EXTENDABLE 8 #define AFF_SAME_LINE 1
#define AFF_MULTI_LINE 2
typedef struct { #define AFF_DATE 4
int message_id; #define AFF_EXTENDABLE 8
char subdir[256];
char file_name[32]; typedef struct {
time_t file_time; int message_id;
int offset; char subdir[256];
int in_reply_to; char file_name[32];
unsigned char md5_digest[16]; time_t file_time;
} EL_INDEX; int offset;
int in_reply_to;
typedef struct { unsigned char md5_digest[16];
char name[256]; } EL_INDEX;
char name_enc[256];
char data_dir[256]; typedef struct {
char top_group[256]; char name[256];
EL_INDEX *el_index; char name_enc[256];
int *n_el_index; char data_dir[256];
int n_attr; char top_group[256];
PMXML_NODE pwd_xml_tree; EL_INDEX *el_index;
} LOGBOOK; int *n_el_index;
int n_attr;
typedef struct { PMXML_NODE pwd_xml_tree;
int message_id; } LOGBOOK;
unsigned char md5_digest[16];
} MD5_INDEX; typedef struct {
int message_id;
typedef struct LBNODE *LBLIST; unsigned char md5_digest[16];
} MD5_INDEX;
typedef struct LBNODE {
char name[256]; typedef struct LBNODE *LBLIST;
LBLIST *member;
int n_members; typedef struct LBNODE {
int is_top; char name[256];
} LBNODE; LBLIST *member;
int n_members;
typedef struct { int is_top;
LOGBOOK *lbs; } LBNODE;
int index;
char string[256]; typedef struct {
int number; LOGBOOK *lbs;
int in_reply_to; int index;
} MSG_LIST; char string[256];
int number;
typedef struct { int in_reply_to;
char user_name[256]; } MSG_LIST;
char session_id[32];
char host_ip[32]; typedef struct {
time_t time; char user_name[256];
} SESSION_ID; char session_id[32];
char host_ip[32];
void show_error(char *error); time_t time;
int is_verbose(void); } SESSION_ID;
extern void eprintf(const char *, ...);
BOOL enum_user_line(LOGBOOK * lbs, int n, char *user, int size); void show_error(char *error);
int get_user_line(LOGBOOK * lbs, char *user, char *password, char *full_name, char *email, int is_verbose(void);
BOOL email_notify[1000], time_t * last_access, int *inactive); extern void eprintf(const char *, ...);
int get_full_name(LOGBOOK *lbs, char *uname, char *full_name); BOOL enum_user_line(LOGBOOK * lbs, int n, char *user, int size);
int set_user_inactive(LOGBOOK * lbs, char *user, int inactive); int get_user_line(LOGBOOK * lbs, char *user, char *password, char *full_name, char *email,
int strbreak(char *str, char list[][NAME_LENGTH], int size, char *brk, BOOL ignore_quotes); BOOL email_notify[1000], time_t * last_access, int *inactive);
int execute_shell(LOGBOOK * lbs, int message_id, char attrib[MAX_N_ATTR][NAME_LENGTH], int get_full_name(LOGBOOK *lbs, char *uname, char *full_name);
char att_file[MAX_ATTACHMENTS][256], char *sh_cmd); int set_user_inactive(LOGBOOK * lbs, char *user, int inactive);
BOOL isparam(char *param); int strbreak(char *str, char list[][NAME_LENGTH], int size, char *brk, BOOL ignore_quotes);
char *getparam(char *param); int execute_shell(LOGBOOK * lbs, int message_id, char attrib[MAX_N_ATTR][NAME_LENGTH],
void write_logfile(LOGBOOK * lbs, const char *str); char att_file[MAX_ATTACHMENTS][256], char *sh_cmd);
BOOL check_login_user(LOGBOOK * lbs, char *user); BOOL isparam(char *param);
LBLIST get_logbook_hierarchy(void); char *getparam(char *param);
BOOL is_logbook_in_group(LBLIST pgrp, char *logbook); void write_logfile(LOGBOOK * lbs, const char *str);
BOOL is_admin_user(LOGBOOK * lbs, char *user); BOOL check_login_user(LOGBOOK * lbs, char *user);
BOOL is_admin_user_global(char *user); LBLIST get_logbook_hierarchy(void);
void free_logbook_hierarchy(LBLIST root); BOOL is_logbook_in_group(LBLIST pgrp, char *logbook);
void show_top_text(LOGBOOK * lbs); BOOL is_admin_user(LOGBOOK * lbs, char *user);
void show_bottom_text(LOGBOOK * lbs); BOOL is_admin_user_global(char *user);
int set_attributes(LOGBOOK * lbs, char attributes[][NAME_LENGTH], int n); void free_logbook_hierarchy(LBLIST root);
void show_elog_list(LOGBOOK * lbs, int past_n, int last_n, int page_n, BOOL default_page, char *info); void show_top_text(LOGBOOK * lbs);
int change_config_line(LOGBOOK * lbs, char *option, char *old_value, char *new_value); void show_bottom_text(LOGBOOK * lbs);
int read_password(char *pwd, int size); int set_attributes(LOGBOOK * lbs, char attributes[][NAME_LENGTH], int n);
int getcfg(char *group, char *param, char *value, int vsize); void show_elog_list(LOGBOOK * lbs, int past_n, int last_n, int page_n, BOOL default_page, char *info);
int build_subst_list(LOGBOOK * lbs, char list[][NAME_LENGTH], char value[][NAME_LENGTH], int change_config_line(LOGBOOK * lbs, char *option, char *old_value, char *new_value);
char attrib[][NAME_LENGTH], BOOL format_date); int read_password(char *pwd, int size);
void highlight_searchtext(regex_t * re_buf, char *src, char *dst, BOOL hidden); int getcfg(char *group, char *param, char *value, int vsize);
int parse_config_file(char *config_file); int build_subst_list(LOGBOOK * lbs, char list[][NAME_LENGTH], char value[][NAME_LENGTH],
PMXML_NODE load_password_file(LOGBOOK * lbs, char *error, int error_size); char attrib[][NAME_LENGTH], BOOL format_date);
int load_password_files(void); void highlight_searchtext(regex_t * re_buf, char *src, char *dst, BOOL hidden);
BOOL check_login(LOGBOOK * lbs, char *sid); int parse_config_file(char *config_file);
void compose_base_url(LOGBOOK * lbs, char *base_url, int size, BOOL email_notify); PMXML_NODE load_password_file(LOGBOOK * lbs, char *error, int error_size);
void show_elog_entry(LOGBOOK * lbs, char *dec_path, char *command); int load_password_files(void);
char *loc(char *orig); BOOL check_login(LOGBOOK * lbs, char *sid);
void strencode(char *text); void compose_base_url(LOGBOOK * lbs, char *base_url, int size, BOOL email_notify);
void strencode_nouml(char *text); void show_elog_entry(LOGBOOK * lbs, char *dec_path, char *command);
char *stristr(const char *str, const char *pattern); char *loc(char *orig);
int scan_attributes(char *logbook); void strencode(char *text);
int is_inline_attachment(char *encoding, int message_id, char *text, int i, char *att); void strencode_nouml(char *text);
int setgroup(char *str); char *stristr(const char *str, const char *pattern);
int setuser(char *str); int scan_attributes(char *logbook);
int setegroup(char *str); int is_inline_attachment(char *encoding, int message_id, char *text, int i, char *att);
int seteuser(char *str); int setgroup(char *str);
void strencode2(char *b, const char *text, int size); int setuser(char *str);
void load_config_section(char *section, char **buffer, char *error); int setegroup(char *str);
void remove_crlf(char *buffer); int seteuser(char *str);
time_t convert_date(char *date_string); void strencode2(char *b, const char *text, int size);
time_t convert_datetime(char *date_string); void load_config_section(char *section, char **buffer, char *error);
int get_thumb_name(const char *file_name, char *thumb_name, int size, int index); void remove_crlf(char *buffer);
int create_thumbnail(LOGBOOK * lbs, char *file_name); time_t convert_date(char *date_string);
int ascii_compare(const void *s1, const void *s2); time_t convert_datetime(char *date_string);
int ascii_compare2(const void *s1, const void *s2); int get_thumb_name(const char *file_name, char *thumb_name, int size, int index);
void do_crypt(const char *s, char *d, int size); int create_thumbnail(LOGBOOK * lbs, char *file_name);
BOOL get_password_file(LOGBOOK * lbs, char *file_name, int size); int ascii_compare(const void *s1, const void *s2);
LOGBOOK *get_first_lbs_with_global_passwd(void); int ascii_compare2(const void *s1, const void *s2);
void do_crypt(const char *s, char *d, int size);
/* functions from auth.c */ BOOL get_password_file(LOGBOOK * lbs, char *file_name, int size);
int auth_verify_password(LOGBOOK *lbs, const char *user, const char *password, char *error_str, int error_size); LOGBOOK *get_first_lbs_with_global_passwd(void);
int auth_change_password(LOGBOOK *lbs, const char *user, const char *old_pwd, const char *new_pwd, char *error_str, int error_size);
int auth_verify_password_krb5(LOGBOOK *lbs, const char *user, const char *password, char *error_str, int error_size); /* functions from auth.c */
int auth_change_password_krb5(LOGBOOK *lbs, const char *user, const char *old_pwd, const char *new_pwd, char *error, int error_size); int auth_verify_password(LOGBOOK *lbs, const char *user, const char *password, char *error_str, int error_size);
int auth_change_password(LOGBOOK *lbs, const char *user, const char *old_pwd, const char *new_pwd, char *error_str, int error_size);
int auth_verify_password_krb5(LOGBOOK *lbs, const char *user, const char *password, char *error_str, int error_size);
int auth_change_password_krb5(LOGBOOK *lbs, const char *user, const char *old_pwd, const char *new_pwd, char *error, int error_size);