Merge branch '2845_cleanup'

* 2845_cleanup:
  Clarify cvs dependency.
  (mcview_moveto_eol): comparison of unsigned expression < 0 fixup.
  Makefile.ams cleanup.
  Code indentation.
  Try fix of compile warnings about assigned but unused variables
  Code cleanup: removed unused variables amd removed unnedeed code.
  (exec_extension): ret rid of double filename conversion.
  Ticket #2839: Fix keybindings for Quit command of mcedit.
  Tweak of select codepage code in case of --disable-charset
  Fix of 'External panelize' dialog: update of 'Command' field content after mouse click.
  Fix of f13 key handling.
  Fix typos.
  Ticket #2538: mcviewer: unused result of str_term_width1().
  src/filemanager/mountlist.c: apply mc code indentation policy.
  Ticket #2845: code cleanup before 4.8.4 release.
This commit is contained in:
Andrew Borodin 2012-07-17 17:04:42 +04:00
commit 03916ee15b
141 changed files with 13335 additions and 12078 deletions

View File

@ -19,7 +19,7 @@ Build requirements for GNU Midnight Commander
- pcre (if glib < 2.14)
- slang or ncurses
- gettext
- cvs
- cvs (for gettext < 0.18 or if gettext >= 0.18 is built with --with-cvs)
- libssh2 >= 1.2.5 is required only for sftp vfs (1.2.7 if you need ssh-agent support)
- libaspell to support spell checking in the internal editor

View File

@ -5,7 +5,7 @@ if ENABLE_MCLIB
tr '.' ' '| \
while read v1 v2 v3; do echo $$v2':'$$v3':'$$v1; done`
libmc_la_LDFLAGS=-no-undefined -version-info $(LIB_VERSION) -release $(LIBMC_RELEASE)
AM_LDFLAGS=-no-undefined -version-info $(LIB_VERSION) -release $(LIBMC_RELEASE)
lib_LTLIBRARIES = libmc.la
else
@ -50,7 +50,7 @@ if CHARSET
libmc_la_SOURCES += charsets.c charsets.h
endif
libmc_la_CFLAGS= $(GLIB_CFLAGS) -I$(top_srcdir) $(PCRE_CFLAGS)
AM_CFLAGS= $(GLIB_CFLAGS) -I$(top_srcdir) $(PCRE_CFLAGS)
libmc_la_LIBADD = \
event/libmcevent.la \
@ -72,4 +72,3 @@ else
endif
libmc_la_LIBADD += $(PCRE_LIBS) $(LIBICONV) $(INTLLIBS)

View File

@ -99,7 +99,6 @@ static void
load_codepages_list_from_file (GPtrArray ** list, const char *fname)
{
FILE *f;
guint i;
char buf[BUF_MEDIUM];
char *default_codepage = NULL;
@ -107,7 +106,7 @@ load_codepages_list_from_file (GPtrArray ** list, const char *fname)
if (f == NULL)
return;
for (i = 0; fgets (buf, sizeof buf, f) != NULL;)
while (fgets (buf, sizeof buf, f) != NULL)
{
/* split string into id and cpname */
char *p = buf;
@ -141,6 +140,8 @@ load_codepages_list_from_file (GPtrArray ** list, const char *fname)
}
else
{
unsigned int i;
/* whether id is already present in list */
/* if yes, overwrite description */
for (i = 0; i < (*list)->len; i++)

View File

@ -7,6 +7,8 @@ libmcevent_la_SOURCES = \
manage.c \
raise.c
libmcevent_la_CFLAGS=-I$(top_srcdir) \
$(GLIB_CFLAGS) $(PCRE_CFLAGS) \
-DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\"
AM_CPPFLAGS = \
-DDATADIR=\""$(pkgdatadir)/"\" \
-DLOCALEDIR=\""$(localedir)"\"
AM_CFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS) $(PCRE_CFLAGS)

View File

@ -25,7 +25,8 @@ GTree *mc_event_get_event_group_by_name (const gchar * event_group_name, gboolea
GPtrArray *mc_event_get_event_by_name (GTree * event_group, const gchar * event_name,
gboolean create_new, GError ** mcerror);
mc_event_callback_t *mc_event_is_callback_in_array (GPtrArray * callbacks,
mc_event_callback_func_t event_callback, gpointer event_init_data);
mc_event_callback_func_t event_callback,
gpointer event_init_data);
/*** inline functions ****************************************************************************/
#endif /* MC_EVENT_INTERNAL_H */

View File

@ -6,6 +6,8 @@ libmcfilehighlight_la_SOURCES = \
ini-file-read.c \
internal.h
libmcfilehighlight_la_CFLAGS = -I$(top_srcdir) \
$(GLIB_CFLAGS) $(PCRE_CFLAGS) \
-DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\"
AM_CPPFLAGS = \
-DDATADIR=\""$(pkgdatadir)/"\" \
-DLOCALEDIR=\""$(localedir)"\"
AM_CFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS) $(PCRE_CFLAGS)

View File

@ -7,6 +7,7 @@ libmcconfig_la_SOURCES = \
set.c \
paths.c
libmcconfig_la_CFLAGS = -I$(top_srcdir) \
$(GLIB_CFLAGS) \
AM_CPPFLAGS = \
-DLOCALEDIR=\""$(localedir)"\"
AM_CFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS)

View File

@ -9,6 +9,8 @@ libsearch_la_SOURCES = \
glob.c \
hex.c
libsearch_la_CFLAGS = -I$(top_srcdir) \
$(GLIB_CFLAGS) \
-DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" $(PCRE_CFLAGS)
AM_CPPFLAGS = \
-DDATADIR=\""$(pkgdatadir)/"\" \
-DLOCALEDIR=\""$(localedir)"\"
AM_CFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS) $(PCRE_CFLAGS)

View File

@ -9,6 +9,8 @@ libmcskin_la_SOURCES = \
lines.c \
internal.h
libmcskin_la_CFLAGS = -I$(top_srcdir) \
$(GLIB_CFLAGS) $(PCRE_CFLAGS) \
-DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\"
AM_CPPFLAGS = \
-DDATADIR=\""$(pkgdatadir)/"\" \
-DLOCALEDIR=\""$(localedir)"\"
AM_CFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS) $(PCRE_CFLAGS)

View File

@ -8,6 +8,4 @@ libmcstrutil_la_SOURCES = \
strutilutf8.c \
strverscmp.c
libmcstrutil_la_CFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS)
AM_CFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS)

View File

@ -319,7 +319,6 @@ str_8bit_fit_to_term (const char *text, int width, align_crt_t just_mode)
goto finally;
memset (actual, ' ', width - length - ident);
actual += width - length - ident;
remain -= width - length - ident;
}
}
else
@ -393,7 +392,6 @@ str_8bit_term_trim (const char *text, int width)
{
memset (actual, '.', width);
actual += width;
remain -= width;
}
else
{

View File

@ -260,7 +260,6 @@ str_ascii_fit_to_term (const char *text, int width, align_crt_t just_mode)
goto finally;
memset (actual, ' ', width - length - ident);
actual += width - length - ident;
remain -= width - length - ident;
}
}
else
@ -340,7 +339,6 @@ str_ascii_term_trim (const char *text, int width)
{
memset (actual, '.', width);
actual += width;
remain -= width;
}
else
{

View File

@ -675,7 +675,7 @@ str_utf8_term_trim (const char *text, int width)
if (width < 1)
{
result [0] = '\0';
result[0] = '\0';
return result;
}

View File

@ -22,13 +22,15 @@ TTY_SRC = \
libmctty_la_SOURCES = $(TTY_SRC) $(TTY_SCREEN_SRC)
libmctty_la_CFLAGS = -I$(top_srcdir)
AM_CPPFLAGS = \
-DDATADIR=\""$(pkgdatadir)/"\" \
-DLOCALEDIR=\""$(localedir)"\"
AM_CFLAGS = -I$(top_srcdir)
if HAVE_GMODULE
libmctty_la_CFLAGS += $(GMODULE_CFLAGS)
AM_CFLAGS += $(GMODULE_CFLAGS)
else
libmctty_la_CFLAGS += $(GLIB_CFLAGS)
AM_CFLAGS += $(GLIB_CFLAGS)
endif
libmctty_la_CFLAGS += -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\"

View File

@ -47,7 +47,7 @@ void tty_set_normal_attrs (void);
void tty_color_set_defaults (const char *, const char *, const char *);
extern gboolean tty_use_256colors(void);
extern gboolean tty_use_256colors (void);
/*** inline functions ****************************************************************************/
#endif /* MC_COLOR_H */

View File

@ -110,7 +110,7 @@ is_8bit_printable (unsigned char c)
/* --------------------------------------------------------------------------------------------- */
static char *
resolve_symlinks (const vfs_path_t *vpath)
resolve_symlinks (const vfs_path_t * vpath)
{
char *p, *p2;
char *buf, *buf2, *q, *r, c;
@ -208,9 +208,8 @@ mc_util_write_backup_content (const char *from_file_name, const char *to_file_na
if (fwrite ((const void *) contents, 1, length, backup_fd) != length)
ret1 = FALSE;
{
int ret2;
ret2 = fflush (backup_fd);
ret2 = fclose (backup_fd);
(void) fflush (backup_fd);
(void) fclose (backup_fd);
}
g_free (contents);
return ret1;

View File

@ -1523,10 +1523,8 @@ vfs_s_get_line (struct vfs_class *me, int sock, char *buf, int buf_len, char ter
{
if (logfile)
{
size_t ret1;
int ret2;
ret1 = fwrite (&c, 1, 1, logfile);
ret2 = fflush (logfile);
(void) fwrite (&c, 1, 1, logfile);
(void) fflush (logfile);
}
if (c == '\n')
return 1;

View File

@ -104,13 +104,11 @@ mc_def_getlocalcopy (const vfs_path_t * filename_vpath)
fdin = -1;
if (i == -1)
goto fail;
i = close (fdout);
fdout = -1;
if (i == -1)
{
fdout = -1;
goto fail;
}
if (mc_stat (filename_vpath, &mystat) != -1)
mc_chmod (tmp_vpath, mystat.st_mode);

View File

@ -176,7 +176,7 @@ struct vfs_s_inode *vfs_s_find_root (struct vfs_class *me, struct vfs_s_entry *e
/* outside interface */
void vfs_s_init_class (struct vfs_class *vclass, struct vfs_s_subclass *sub);
const char *vfs_s_get_path (const vfs_path_t * vpath, struct vfs_s_super **archive, int flags);
struct vfs_s_super *vfs_get_super_by_vpath(const vfs_path_t * vpath);
struct vfs_s_super *vfs_get_super_by_vpath (const vfs_path_t * vpath);
void vfs_s_invalidate (struct vfs_class *me, struct vfs_s_super *super);
char *vfs_s_fullpath (struct vfs_class *me, struct vfs_s_inode *ino);

View File

@ -22,6 +22,8 @@ libmcwidget_la_SOURCES = \
widget-common.c widget-common.h \
wtools.c wtools.h
libmcwidget_la_CFLAGS = -I$(top_srcdir) \
$(GLIB_CFLAGS) $(PCRE_CFLAGS) \
-DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\"
AM_CPPFLAGS = \
-DDATADIR=\""$(pkgdatadir)/"\" \
-DLOCALEDIR=\""$(localedir)"\"
AM_CFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS) $(PCRE_CFLAGS)

View File

@ -365,8 +365,7 @@ dlg_mouse_event (Dlg_head * h, Gpm_Event * event)
int y = event->y;
/* close the dialog by mouse click out of dialog area */
if (mouse_close_dialog && !h->fullscreen && ((event->buttons & GPM_B_LEFT) != 0)
&& ((event->type & GPM_DOWN) != 0) /* left click */
if (mouse_close_dialog && !h->fullscreen && ((event->buttons & GPM_B_LEFT) != 0) && ((event->type & GPM_DOWN) != 0) /* left click */
&& !((x > h->x) && (x <= h->x + h->cols) && (y > h->y) && (y <= h->y + h->lines)))
{
h->ret_value = B_CANCEL;

View File

@ -63,7 +63,7 @@ typedef enum
/* Dialog state */
typedef enum
{
DLG_CONSTRUCT = 0, /* DIalog has been constructed but bot run yet */
DLG_CONSTRUCT = 0, /* Dialog has been constructed but not run yet */
DLG_ACTIVE = 1, /* Dialog is visible and active */
DLG_SUSPENDED = 2, /* Dialog is suspended */
DLG_CLOSED = 3 /* Dialog is closed */

View File

@ -24,9 +24,9 @@ extern int num_history_items_recorded;
/* read history to the mc_config, but don't save config to file */
GList *history_get (const char *input_name);
/* load history form the mc_config */
GList *history_load (struct mc_config_t * cfg, const char *name);
GList *history_load (struct mc_config_t *cfg, const char *name);
/* save history to the mc_config, but don't save config to file */
void history_save (struct mc_config_t * cfg, const char *name, GList * h);
void history_save (struct mc_config_t *cfg, const char *name, GList * h);
/* for repositioning of history dialog we should pass widget to this
* function, as position of history dialog depends on widget's position */
char *history_show (GList ** history, Widget * widget, int current);

View File

@ -114,14 +114,12 @@ draw_history_button (WInput * in)
widget_move (&in->widget, 0, in->field_width - HISTORY_BUTTON_WIDTH);
tty_setcolor (disabled ? DISABLED_COLOR : in->color[WINPUTC_HISTORY]);
#ifdef LARGE_HISTORY_BUTTON
{
Dlg_head *h;
h = in->widget.owner;
tty_print_string ("[ ]");
widget_move (&in->widget, 0, in->field_width - HISTORY_BUTTON_WIDTH + 1);
}
#endif
tty_print_char (c);
}
@ -197,7 +195,8 @@ do_show_hist (WInput * in)
len = get_history_length (in->history);
r = history_show (&in->history, &in->widget, g_list_position (in->history_current, in->history));
r = history_show (&in->history, &in->widget,
g_list_position (in->history_current, in->history));
if (r != NULL)
{
input_assign_text (in, r);
@ -1137,8 +1136,6 @@ input_handle_char (WInput * in, int key)
cb_ret_t v;
unsigned long command;
v = MSG_NOT_HANDLED;
if (quote != 0)
{
input_free_completions (in);

View File

@ -123,9 +123,13 @@ listbox_draw (WListbox * l, gboolean focused)
const Dlg_head *h = l->widget.owner;
const gboolean disabled = (((Widget *) l)->options & W_DISABLED) != 0;
const int normalc = disabled ? DISABLED_COLOR : h->color[DLG_COLOR_NORMAL];
int selc =
disabled ? DISABLED_COLOR : focused ? h->
color[DLG_COLOR_HOT_FOCUS] : h->color[DLG_COLOR_FOCUS];
/* *INDENT-OFF* */
int selc = disabled
? DISABLED_COLOR
: focused
? h->color[DLG_COLOR_HOT_FOCUS]
: h->color[DLG_COLOR_FOCUS];
/* *INDENT-ON* */
GList *le;
int pos;

View File

@ -77,8 +77,7 @@ quick_dialog_skip (QuickDialog * qd, int nskip)
DLG_CENTER | DLG_TRYUP | DLG_REVERSE);
else
dd = create_dlg (TRUE, qd->ypos, qd->xpos, qd->ylen, qd->xlen,
dialog_colors, qd->callback, qd->mouse, qd->help, qd->title,
DLG_REVERSE);
dialog_colors, qd->callback, qd->mouse, qd->help, qd->title, DLG_REVERSE);
for (qw = qd->widgets; qw->widget_type != quick_end; qw++)
{

View File

@ -33,7 +33,7 @@ dnl Enable large-file support. This has the effect of changing the size
dnl of field f_blocks in 'struct statvfs' from 32 bit to 64 bit on
dnl glibc/Hurd, HP-UX 11, Solaris (32-bit mode). It also changes the size
dnl of field f_blocks in 'struct statfs' from 32 bit to 64 bit on
dnl MacOS X >= 10.5 (32-bit mode).
dnl Mac OS X >= 10.5 (32-bit mode).
AC_REQUIRE([AC_SYS_LARGEFILE])
AC_MSG_NOTICE([checking how to get file system space usage])
@ -68,7 +68,7 @@ struct statvfs fsd;
#if defined __APPLE__ && defined __MACH__
#include <limits.h>
/* On MacOS X >= 10.5, f_blocks in 'struct statvfs' is a 32-bit quantity;
/* On Mac OS X >= 10.5, f_blocks in 'struct statvfs' is a 32-bit quantity;
that commonly limits file systems to 4 TiB. Whereas f_blocks in
'struct statfs' is a 64-bit type, thanks to the large-file support
that was enabled above. In this case, don't use statvfs(); use statfs()
@ -137,7 +137,7 @@ if test $ac_fsusage_space = no; then
fi
if test $ac_fsusage_space = no; then
# glibc/Linux, MacOS X, FreeBSD < 5.0, NetBSD < 3.0, OpenBSD < 4.4.
# glibc/Linux, Mac OS X, FreeBSD < 5.0, NetBSD < 3.0, OpenBSD < 4.4.
# (glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0,
# OpenBSD >= 4.4, AIX, HP-UX, OSF/1, Cygwin already handled above.)
# (On IRIX you need to include <sys/statfs.h>, not only <sys/mount.h> and

View File

@ -301,7 +301,7 @@ Replace = f4
ReplaceContinue = f14
Complete = alt-tab
InsertFile = f15
Quit = f10, esc
Quit = f10; esc
InsertOverwrite = insert
Help = f1
Date =

View File

@ -301,7 +301,7 @@ Replace = f4
ReplaceContinue = f14
Complete = alt-tab
InsertFile = f15
Quit = f10, esc
Quit = f10; esc
InsertOverwrite = insert
Help = f1
Date =

View File

@ -19,7 +19,7 @@ SUBDIRS += consaver
AM_CPPFLAGS += -DSAVERDIR=\""$(pkglibexecdir)"\"
endif
AM_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir) $(PCRE_CFLAGS)
AM_CFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS) $(PCRE_CFLAGS)
localedir = $(datadir)/locale
pkglibexecdir = $(libexecdir)/@PACKAGE@

View File

@ -86,7 +86,9 @@ static gboolean parse_mc_v_argument (const gchar * option_name, const gchar * va
static GOptionContext *context;
#ifdef HAVE_SUBSHELL_SUPPORT
static gboolean mc_args__nouse_subshell = FALSE;
#endif /* HAVE_SUBSHELL_SUPPORT */
static gboolean mc_args__show_datadirs = FALSE;
static gboolean mc_args__show_datadirs_extended = FALSE;
static gboolean mc_args__show_configure_opts = FALSE;

View File

@ -200,7 +200,7 @@ background_attention (int fd, void *closure)
/* void *routine; */
int argc, i, result, status;
char *data[MAXCALLARGS];
ssize_t bytes, ret;
ssize_t bytes;
struct TaskList *p;
int to_child_fd = -1;
enum ReturnType type;
@ -330,9 +330,9 @@ background_attention (int fd, void *closure)
}
/* Send the result code and the value for shared variables */
ret = write (to_child_fd, &result, sizeof (int));
(void) write (to_child_fd, &result, sizeof (int));
if (have_ctx && to_child_fd != -1)
ret = write (to_child_fd, ctx, sizeof (FileOpContext));
(void) write (to_child_fd, ctx, sizeof (FileOpContext));
}
else if (type == Return_String)
{
@ -365,15 +365,15 @@ background_attention (int fd, void *closure)
if (resstr)
{
len = strlen (resstr);
ret = write (to_child_fd, &len, sizeof (len));
(void) write (to_child_fd, &len, sizeof (len));
if (len != 0)
ret = write (to_child_fd, resstr, len);
(void) write (to_child_fd, resstr, len);
g_free (resstr);
}
else
{
len = 0;
ret = write (to_child_fd, &len, sizeof (len));
(void) write (to_child_fd, &len, sizeof (len));
}
}
for (i = 0; i < argc; i++)
@ -398,17 +398,16 @@ static void
parent_call_header (void *routine, int argc, enum ReturnType type, FileOpContext * ctx)
{
int have_ctx;
ssize_t ret;
have_ctx = (ctx != NULL);
ret = write (parent_fd, &routine, sizeof (routine));
ret = write (parent_fd, &argc, sizeof (int));
ret = write (parent_fd, &type, sizeof (type));
ret = write (parent_fd, &have_ctx, sizeof (have_ctx));
(void) write (parent_fd, &routine, sizeof (routine));
(void) write (parent_fd, &argc, sizeof (int));
(void) write (parent_fd, &type, sizeof (type));
(void) write (parent_fd, &have_ctx, sizeof (have_ctx));
if (have_ctx)
ret = write (parent_fd, ctx, sizeof (FileOpContext));
(void) write (parent_fd, ctx, sizeof (FileOpContext));
}
/* --------------------------------------------------------------------------------------------- */
@ -417,7 +416,6 @@ static int
parent_va_call (void *routine, gpointer data, int argc, va_list ap)
{
int i;
ssize_t ret;
struct FileOpContext *ctx = (struct FileOpContext *) data;
parent_call_header (routine, argc, Return_Integer, ctx);
@ -428,13 +426,13 @@ parent_va_call (void *routine, gpointer data, int argc, va_list ap)
len = va_arg (ap, int);
value = va_arg (ap, void *);
ret = write (parent_fd, &len, sizeof (int));
ret = write (parent_fd, value, len);
(void) write (parent_fd, &len, sizeof (int));
(void) write (parent_fd, value, len);
}
ret = read (from_parent_fd, &i, sizeof (int));
(void) read (from_parent_fd, &i, sizeof (int));
if (ctx)
ret = read (from_parent_fd, ctx, sizeof (FileOpContext));
(void) read (from_parent_fd, ctx, sizeof (FileOpContext));
return i;
}

View File

@ -66,7 +66,6 @@ clipboard_file_to_ext_clip (const gchar * event_group_name, const gchar * event_
gpointer init_data, gpointer data)
{
char *tmp, *cmd;
int res = 0;
const char *d = getenv ("DISPLAY");
(void) event_group_name;
@ -81,7 +80,7 @@ clipboard_file_to_ext_clip (const gchar * event_group_name, const gchar * event_
cmd = g_strconcat (clipboard_store_path, " ", tmp, " 2>/dev/null", (char *) NULL);
if (cmd != NULL)
res = my_system (EXECUTE_AS_SHELL, shell, cmd);
(void) my_system (EXECUTE_AS_SHELL, shell, cmd);
g_free (cmd);
g_free (tmp);
@ -127,7 +126,6 @@ clipboard_text_to_file (const gchar * event_group_name, const gchar * event_name
{
int file;
vfs_path_t *fname_vpath = NULL;
ssize_t ret;
size_t str_len;
const char *text = (const char *) data;
@ -147,7 +145,7 @@ clipboard_text_to_file (const gchar * event_group_name, const gchar * event_name
return TRUE;
str_len = strlen (text);
ret = mc_write (file, (char *) text, str_len);
(void) mc_write (file, (char *) text, str_len);
mc_close (file);
return TRUE;
}

View File

@ -90,7 +90,6 @@ show_console_contents_linux (int starty, unsigned char begin_line, unsigned char
unsigned char message = 0;
unsigned short bytes = 0;
int i;
ssize_t ret;
/* Is tty console? */
if (mc_global.tty.console_flag == '\0')
@ -105,29 +104,29 @@ show_console_contents_linux (int starty, unsigned char begin_line, unsigned char
/* Send command to the console handler */
message = CONSOLE_CONTENTS;
ret = write (pipefd1[1], &message, 1);
(void) write (pipefd1[1], &message, 1);
/* Check for outdated cons.saver */
ret = read (pipefd2[0], &message, 1);
(void) read (pipefd2[0], &message, 1);
if (message != CONSOLE_CONTENTS)
return;
/* Send the range of lines that we want */
ret = write (pipefd1[1], &begin_line, 1);
ret = write (pipefd1[1], &end_line, 1);
(void) write (pipefd1[1], &begin_line, 1);
(void) write (pipefd1[1], &end_line, 1);
/* Read the corresponding number of bytes */
ret = read (pipefd2[0], &bytes, 2);
(void) read (pipefd2[0], &bytes, 2);
/* Read the bytes and output them */
for (i = 0; i < bytes; i++)
{
if ((i % COLS) == 0)
tty_gotoyx (starty + (i / COLS), 0);
ret = read (pipefd2[0], &message, 1);
(void) read (pipefd2[0], &message, 1);
tty_print_char (message);
}
/* Read the value of the mc_global.tty.console_flag */
ret = read (pipefd2[0], &message, 1);
(void) read (pipefd2[0], &message, 1);
}
/* --------------------------------------------------------------------------------------------- */
@ -240,10 +239,9 @@ handle_console_linux (console_action_t action)
if (action == CONSOLE_DONE || mc_global.tty.console_flag == '\0')
{
/* We are done -> Let's clean up */
pid_t ret;
close (pipefd1[1]);
close (pipefd2[0]);
ret = waitpid (cons_saver_pid, &status, 0);
(void) waitpid (cons_saver_pid, &status, 0);
mc_global.tty.console_flag = '\0';
}
break;
@ -382,9 +380,10 @@ console_save (void)
for (i = 0; i < screen_shot.xsize * screen_shot.ysize; i++)
{
screen_shot.buf[i] =
(screen_shot.buf[i] & 0xff00) | (unsigned char) revmap.
scrmap[screen_shot.buf[i] & 0xff];
/* *INDENT-OFF* */
screen_shot.buf[i] = (screen_shot.buf[i] & 0xff00)
| (unsigned char) revmap.scrmap[screen_shot.buf[i] & 0xff];
/* *INDENT-ON* */
}
}

View File

@ -4,4 +4,4 @@ pkglibexec_PROGRAMS = cons.saver
cons_saver_SOURCES = cons.saver.c
cons_saver_CFLAGS= -I$(top_srcdir)
AM_CFLAGS= -I$(top_srcdir)

View File

@ -143,8 +143,7 @@ send_contents (char *buffer, unsigned int columns, unsigned int rows)
static void __attribute__ ((noreturn)) die (void)
{
unsigned char zero = 0;
ssize_t ret;
ret = write (1, &zero, 1);
(void) write (1, &zero, 1);
exit (3);
}

View File

@ -5,9 +5,10 @@ libdiffviewer_la_SOURCES = \
search.c \
ydiff.c ydiff.h
AM_CPPFLAGS = \
-DDATADIR=\""$(pkgdatadir)/"\" \
-DLOCALEDIR=\""$(localedir)"\"
libdiffviewer_la_CFLAGS = -I$(top_srcdir) \
$(GLIB_CFLAGS) $(PCRE_CFLAGS) \
-DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\"
AM_CFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS) $(PCRE_CFLAGS)
libdiffviewer_la_LIBADD = ../../lib/libmc.la

View File

@ -117,46 +117,6 @@ TAB_SKIP (int ts, int pos)
/* --------------------------------------------------------------------------------------------- */
static void
dview_set_codeset (WDiff * dview)
{
#ifdef HAVE_CHARSET
const char *encoding_id = NULL;
dview->utf8 = TRUE;
encoding_id =
get_codepage_id (mc_global.source_codepage >=
0 ? mc_global.source_codepage : mc_global.display_codepage);
if (encoding_id != NULL)
{
GIConv conv;
conv = str_crt_conv_from (encoding_id);
if (conv != INVALID_CONV)
{
if (dview->converter != str_cnv_from_term)
str_close_conv (dview->converter);
dview->converter = conv;
}
dview->utf8 = (gboolean) str_isutf8 (encoding_id);
}
#else
(void) dview;
#endif
}
/* --------------------------------------------------------------------------------------------- */
#ifdef HAVE_CHARSET
static void
dview_select_encoding (WDiff * dview)
{
if (do_select_codepage ())
dview_set_codeset (dview);
}
#endif /* HAVE_CHARSET */
/* --------------------------------------------------------------------------------------------- */
static gboolean
rewrite_backup_content (const vfs_path_t * from_file_name_vpath, const char *to_file_name)
{
@ -632,31 +592,22 @@ dview_get_utf (char *str, int *char_width, gboolean * result)
if (str == NULL)
{
*result = FALSE;
width = 0;
return 0;
}
res = g_utf8_get_char_validated (str, -1);
if (res < 0)
{
ch = *str;
width = 0;
}
else
{
ch = res;
/* Calculate UTF-8 char width */
next_ch = g_utf8_next_char (str);
if (next_ch)
{
if (next_ch != NULL)
width = next_ch - str;
}
else
{
ch = 0;
width = 0;
}
}
*char_width = width;
return ch;
@ -2197,7 +2148,6 @@ static void
do_merge_hunk (WDiff * dview)
{
int from1, to1, from2, to2;
int res;
int hunk;
hunk = get_current_hunk (dview, &from1, &to1, &from2, &to2);
@ -2244,7 +2194,7 @@ do_merge_hunk (WDiff * dview)
}
fflush (merge_file);
fclose (merge_file);
res = rewrite_backup_content (merge_file_name_vpath, dview->file[0]);
rewrite_backup_content (merge_file_name_vpath, dview->file[0]);
mc_unlink (merge_file_name_vpath);
vfs_path_free (merge_file_name_vpath);
}
@ -2281,6 +2231,118 @@ dview_compute_areas (WDiff * dview)
/* --------------------------------------------------------------------------------------------- */
static void
dview_reread (WDiff * dview)
{
int ndiff;
destroy_hdiff (dview);
if (dview->a[0] != NULL)
{
g_array_foreach (dview->a[0], DIFFLN, cc_free_elt);
g_array_free (dview->a[0], TRUE);
}
if (dview->a[1] != NULL)
{
g_array_foreach (dview->a[1], DIFFLN, cc_free_elt);
g_array_free (dview->a[1], TRUE);
}
dview->a[0] = g_array_new (FALSE, FALSE, sizeof (DIFFLN));
dview->a[1] = g_array_new (FALSE, FALSE, sizeof (DIFFLN));
ndiff = redo_diff (dview);
if (ndiff >= 0)
dview->ndiff = ndiff;
}
/* --------------------------------------------------------------------------------------------- */
#ifdef HAVE_CHARSET
static void
dview_set_codeset (WDiff * dview)
{
const char *encoding_id = NULL;
dview->utf8 = TRUE;
encoding_id =
get_codepage_id (mc_global.source_codepage >=
0 ? mc_global.source_codepage : mc_global.display_codepage);
if (encoding_id != NULL)
{
GIConv conv;
conv = str_crt_conv_from (encoding_id);
if (conv != INVALID_CONV)
{
if (dview->converter != str_cnv_from_term)
str_close_conv (dview->converter);
dview->converter = conv;
}
dview->utf8 = (gboolean) str_isutf8 (encoding_id);
}
}
/* --------------------------------------------------------------------------------------------- */
static void
dview_select_encoding (WDiff * dview)
{
if (do_select_codepage ())
dview_set_codeset (dview);
dview_reread (dview);
tty_touch_screen ();
repaint_screen ();
}
#endif /* HAVE_CHARSET */
/* --------------------------------------------------------------------------------------------- */
static void
dview_diff_options (WDiff * dview)
{
const char *quality_str[] = {
N_("No&rmal"),
N_("&Fastest (Assume large files)"),
N_("&Minimal (Find a smaller set of change)")
};
QuickWidget diffopt_widgets[] = {
QUICK_BUTTON (6, 10, 14, OPTY, N_("&Cancel"), B_CANCEL, NULL),
QUICK_BUTTON (2, 10, 14, OPTY, N_("&OK"), B_ENTER, NULL),
QUICK_CHECKBOX (3, OPTX, 12, OPTY,
N_("Strip &trailing carriage return"), &dview->opt.strip_trailing_cr),
QUICK_CHECKBOX (3, OPTX, 11, OPTY,
N_("Ignore all &whitespace"), &dview->opt.ignore_all_space),
QUICK_CHECKBOX (3, OPTX, 10, OPTY,
N_("Ignore &space change"), &dview->opt.ignore_space_change),
QUICK_CHECKBOX (3, OPTX, 9, OPTY,
N_("Ignore tab &expansion"), &dview->opt.ignore_tab_expansion),
QUICK_CHECKBOX (3, OPTX, 8, OPTY,
N_("&Ignore case"), &dview->opt.ignore_case),
QUICK_LABEL (3, OPTX, 7, OPTY, N_("Diff extra options")),
QUICK_RADIO (3, OPTX, 3, OPTY,
3, (const char **) quality_str, (int *) &dview->opt.quality),
QUICK_LABEL (3, OPTX, 2, OPTY, N_("Diff algorithm")),
QUICK_END
};
QuickDialog diffopt = {
OPTX, OPTY, -1, -1,
N_("Diff Options"), "[Diff Options]",
diffopt_widgets, NULL, NULL, FALSE
};
if (quick_dialog (&diffopt) != B_CANCEL)
{
dview_reread (dview);
}
}
/* --------------------------------------------------------------------------------------------- */
static int
dview_init (WDiff * dview, const char *args, const char *file1, const char *file2,
const char *label1, const char *label2, DSRC dsrc)
@ -2328,8 +2390,9 @@ dview_init (WDiff * dview, const char *args, const char *file1, const char *file
dview->hdiff = NULL;
dview->dsrc = dsrc;
dview->converter = str_cnv_from_term;
#ifdef HAVE_CHARSET
dview_set_codeset (dview);
#endif
dview->a[0] = g_array_new (FALSE, FALSE, sizeof (DIFFLN));
dview->a[1] = g_array_new (FALSE, FALSE, sizeof (DIFFLN));
@ -2374,77 +2437,6 @@ dview_init (WDiff * dview, const char *args, const char *file1, const char *file
/* --------------------------------------------------------------------------------------------- */
static void
dview_reread (WDiff * dview)
{
int ndiff = dview->ndiff;
destroy_hdiff (dview);
if (dview->a[0] != NULL)
{
g_array_foreach (dview->a[0], DIFFLN, cc_free_elt);
g_array_free (dview->a[0], TRUE);
}
if (dview->a[1] != NULL)
{
g_array_foreach (dview->a[1], DIFFLN, cc_free_elt);
g_array_free (dview->a[1], TRUE);
}
dview->a[0] = g_array_new (FALSE, FALSE, sizeof (DIFFLN));
dview->a[1] = g_array_new (FALSE, FALSE, sizeof (DIFFLN));
ndiff = redo_diff (dview);
if (ndiff >= 0)
dview->ndiff = ndiff;
}
/* --------------------------------------------------------------------------------------------- */
static void
dview_diff_options (WDiff * dview)
{
const char *quality_str[] = {
N_("No&rmal"),
N_("&Fastest (Assume large files)"),
N_("&Minimal (Find a smaller set of change)")
};
QuickWidget diffopt_widgets[] = {
QUICK_BUTTON (6, 10, 14, OPTY, N_("&Cancel"), B_CANCEL, NULL),
QUICK_BUTTON (2, 10, 14, OPTY, N_("&OK"), B_ENTER, NULL),
QUICK_CHECKBOX (3, OPTX, 12, OPTY,
N_("Strip &trailing carriage return"), &dview->opt.strip_trailing_cr),
QUICK_CHECKBOX (3, OPTX, 11, OPTY,
N_("Ignore all &whitespace"), &dview->opt.ignore_all_space),
QUICK_CHECKBOX (3, OPTX, 10, OPTY,
N_("Ignore &space change"), &dview->opt.ignore_space_change),
QUICK_CHECKBOX (3, OPTX, 9, OPTY,
N_("Ignore tab &expansion"), &dview->opt.ignore_tab_expansion),
QUICK_CHECKBOX (3, OPTX, 8, OPTY,
N_("&Ignore case"), &dview->opt.ignore_case),
QUICK_LABEL (3, OPTX, 7, OPTY, N_("Diff extra options")),
QUICK_RADIO (3, OPTX, 3, OPTY,
3, (const char **) quality_str, (int *) &dview->opt.quality),
QUICK_LABEL (3, OPTX, 2, OPTY, N_("Diff algorithm")),
QUICK_END
};
QuickDialog diffopt = {
OPTX, OPTY, -1, -1,
N_("Diff Options"), "[Diff Options]",
diffopt_widgets, NULL, NULL, FALSE
};
if (quick_dialog (&diffopt) != B_CANCEL)
{
dview_reread (dview);
}
}
/* --------------------------------------------------------------------------------------------- */
static void
dview_fini (WDiff * dview)
{
@ -2984,7 +2976,7 @@ dview_ok_to_exit (WDiff * dview)
break;
case 1: /* No */
if (mc_util_restore_from_backup_if_possible (dview->file[0], "~~~"))
res = mc_util_unlink_backup_if_possible (dview->file[0], "~~~");
mc_util_unlink_backup_if_possible (dview->file[0], "~~~");
/* fall through */
default:
res = TRUE;
@ -3141,9 +3133,6 @@ dview_execute_cmd (WDiff * dview, unsigned long command)
#ifdef HAVE_CHARSET
case CK_SelectCodepage:
dview_select_encoding (dview);
dview_reread (dview);
tty_touch_screen ();
repaint_screen ();
break;
#endif
case CK_Cancel:

View File

@ -21,4 +21,4 @@ libedit_la_SOURCES += \
endif
endif
libedit_la_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir) $(PCRE_CFLAGS)
AM_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir) $(PCRE_CFLAGS)

View File

@ -257,7 +257,7 @@ void edit_insert_over (WEdit * edit);
int edit_insert_column_of_text_from_file (WEdit * edit, int file,
long *start_pos, long *end_pos, int *col1, int *col2);
char *edit_get_word_from_pos (WEdit * edit, long start_pos, long *start, gsize *len, gsize *cut);
char *edit_get_word_from_pos (WEdit * edit, long start_pos, long *start, gsize * len, gsize * cut);
long edit_insert_file (WEdit * edit, const vfs_path_t * filename_vpath);
gboolean edit_load_back_cmd (WEdit * edit);
gboolean edit_load_forward_cmd (WEdit * edit);

View File

@ -2001,7 +2001,7 @@ is_break_char (char c)
/* --------------------------------------------------------------------------------------------- */
char *
edit_get_word_from_pos (WEdit *edit, long start_pos, long *start, gsize *len, gsize *cut)
edit_get_word_from_pos (WEdit * edit, long start_pos, long *start, gsize * len, gsize * cut)
{
long word_start;
long cut_len = 0;

View File

@ -504,7 +504,7 @@ edit_save_cmd (WEdit * edit)
*/
static inline gboolean
edit_load_file_from_filename (Dlg_head *h, const vfs_path_t *vpath)
edit_load_file_from_filename (Dlg_head * h, const vfs_path_t * vpath)
{
return edit_add_window (h, h->y + 1, h->x, h->lines - 2, h->cols, vpath, 0);
}
@ -555,7 +555,7 @@ edit_block_delete (WEdit * edit)
{
long count;
long start_mark, end_mark;
int curs_pos, line_width;
int curs_pos;
long curs_line, c1, c2;
if (eval_marks (edit, &start_mark, &end_mark))
@ -583,9 +583,6 @@ edit_block_delete (WEdit * edit)
curs_line = edit->curs_line;
/* calculate line width and cursor position before cut */
line_width = edit_move_forward3 (edit, edit_bol (edit, edit->curs1), 0,
edit_eol (edit, edit->curs1));
curs_pos = edit->curs_col + edit->over_col;
/* move cursor to start of selection */
@ -596,12 +593,14 @@ edit_block_delete (WEdit * edit)
{
if (edit->column_highlight)
{
int line_width;
if (edit->mark2 < 0)
edit_mark_cmd (edit, 0);
edit_delete_column_of_text (edit);
/* move cursor to the saved position */
edit_move_to_line (edit, curs_line);
/* calculate line width after cut */
/* calculate line width and cursor position before cut */
line_width = edit_move_forward3 (edit, edit_bol (edit, edit->curs1), 0,
edit_eol (edit, edit->curs1));
if (option_cursor_beyond_eol && curs_pos > line_width)
@ -3401,19 +3400,17 @@ edit_complete_word_cmd (WEdit * edit)
/* --------------------------------------------------------------------------------------------- */
#ifdef HAVE_CHARSET
void
edit_select_codepage_cmd (WEdit * edit)
{
#ifdef HAVE_CHARSET
if (do_select_codepage ())
edit_set_codeset (edit);
edit->force = REDRAW_PAGE;
send_message ((Widget *) edit, WIDGET_DRAW, 0);
#else
(void) edit;
#endif
}
#endif
/* --------------------------------------------------------------------------------------------- */

View File

@ -27,7 +27,7 @@ struct selection
void editcmd_dialog_replace_show (WEdit *, const char *, const char *, char **, char **);
gboolean editcmd_dialog_search_show (WEdit *edit);
gboolean editcmd_dialog_search_show (WEdit * edit);
int editcmd_dialog_raw_key_query (const char *, const char *, int);

View File

@ -176,12 +176,13 @@ create_command_menu (void)
menu_entry_create (_("Record/Repeat &actions"), CK_RepeatStartStopRecord));
entries = g_list_prepend (entries, menu_separator_create ());
#ifdef HAVE_ASPELL
entries =
g_list_prepend (entries, menu_entry_create (_("S&pell check"), CK_SpellCheck));
entries = g_list_prepend (entries, menu_entry_create (_("S&pell check"), CK_SpellCheck));
entries =
g_list_prepend (entries, menu_entry_create (_("C&heck word"), CK_SpellCheckCurrentWord));
entries =
g_list_prepend (entries, menu_entry_create (_("Change spelling &language"), CK_SpellCheckSelectLang));
g_list_prepend (entries,
menu_entry_create (_("Change spelling &language"),
CK_SpellCheckSelectLang));
entries = g_list_prepend (entries, menu_separator_create ());
#endif /* HAVE_ASPELL */
entries = g_list_prepend (entries, menu_entry_create (_("&Mail..."), CK_Mail));

View File

@ -672,7 +672,7 @@ edit_event (Gpm_Event * event, void *data)
*/
static int
edit_dialog_event (Gpm_Event *event, void *data)
edit_dialog_event (Gpm_Event * event, void *data)
{
Dlg_head *h = (Dlg_head *) data;
Widget *w;
@ -1081,10 +1081,11 @@ edit_file (const vfs_path_t * file_vpath, int line)
return ok;
}
/* --------------------------------------------------------------------------------------------- */
gboolean
edit_files (const GList *files)
edit_files (const GList * files)
{
static gboolean made_directory = FALSE;
Dlg_head *edit_dlg;
@ -1129,8 +1130,7 @@ edit_files (const GList *files)
gboolean f_ok;
f_ok = edit_add_window (edit_dlg, edit_dlg->y + 1, edit_dlg->x,
edit_dlg->lines - 2, edit_dlg->cols,
f->file_vpath, f->line_number);
edit_dlg->lines - 2, edit_dlg->cols, f->file_vpath, f->line_number);
/* at least one file has been opened succefully */
ok = ok || f_ok;
}
@ -1232,7 +1232,7 @@ edit_save_size (WEdit * edit)
*/
gboolean
edit_add_window (Dlg_head * h, int y, int x, int lines, int cols, const vfs_path_t *f, int fline)
edit_add_window (Dlg_head * h, int y, int x, int lines, int cols, const vfs_path_t * f, int fline)
{
WEdit *edit;
Widget *w;

View File

@ -72,8 +72,8 @@ static struct AspellStringEnumeration *(*mc_aspell_word_list_elements) (const st
static const char *(*mc_aspell_config_retrieve) (struct AspellConfig * ths, const char *key);
static void (*mc_delete_aspell_speller) (struct AspellSpeller * ths);
/*
static void (*mc_delete_aspell_config) (struct AspellConfig * ths);
*/
static void (*mc_delete_aspell_config) (struct AspellConfig * ths);
*/
static void (*mc_delete_aspell_can_have_error) (struct AspellCanHaveError * ths);
static const char *(*mc_aspell_error_message) (const struct AspellCanHaveError * ths);
static void (*mc_delete_aspell_string_enumeration) (struct AspellStringEnumeration * ths);
@ -86,7 +86,7 @@ static const char *(*mc_aspell_string_enumeration_next) (struct AspellStringEnum
static void (*mc_delete_aspell_dict_info_enumeration) (struct AspellDictInfoEnumeration * ths);
static unsigned int (*mc_aspell_word_list_size) (const struct AspellWordList * ths);
static const struct AspellError *(*mc_aspell_error) (const struct AspellCanHaveError * ths);
static int (*mc_aspell_speller_add_to_personal) (struct AspellSpeller * ths, const char * word,
static int (*mc_aspell_speller_add_to_personal) (struct AspellSpeller * ths, const char *word,
int word_size);
static int (*mc_aspell_speller_save_all_word_lists) (struct AspellSpeller * ths);
@ -193,8 +193,7 @@ spell_available (void)
(void *) &mc_aspell_speller_error_message))
goto error_ret;
if (!g_module_symbol (spell_module, "aspell_speller_error",
(void *) &mc_aspell_speller_error))
if (!g_module_symbol (spell_module, "aspell_speller_error", (void *) &mc_aspell_speller_error))
goto error_ret;
if (!g_module_symbol (spell_module, "aspell_error", (void *) &mc_aspell_error))

View File

@ -16,9 +16,9 @@
void aspell_init (void);
void aspell_clean (void);
gboolean aspell_check (const char *word, const int word_size);
unsigned int aspell_suggest (GArray *suggest, const char *word, const int word_size);
void aspell_array_clean (GArray *array);
unsigned int aspell_get_lang_list (GArray *lang_list);
unsigned int aspell_suggest (GArray * suggest, const char *word, const int word_size);
void aspell_array_clean (GArray * array);
unsigned int aspell_get_lang_list (GArray * lang_list);
const char *aspell_get_lang (void);
gboolean aspell_set_lang (const char *lang);
gboolean aspell_add_to_dict (const char *word, const int word_size);

View File

@ -59,7 +59,7 @@
*/
int
spell_dialog_spell_suggest_show (WEdit * edit, const char *word, char **new_word, GArray *suggest)
spell_dialog_spell_suggest_show (WEdit * edit, const char *word, char **new_word, GArray * suggest)
{
int sug_dlg_h = 14; /* dialog height */
@ -154,7 +154,7 @@ spell_dialog_spell_suggest_show (WEdit * edit, const char *word, char **new_word
*/
char *
spell_dialog_lang_list_show (GArray *languages)
spell_dialog_lang_list_show (GArray * languages)
{
int lang_dlg_h = 12; /* dialog height */

View File

@ -17,8 +17,8 @@
/*** declarations of public functions ************************************************************/
int spell_dialog_spell_suggest_show (WEdit * edit, const char *word, char **new_word,
GArray *suggest);
char *spell_dialog_lang_list_show (GArray *languages);
GArray * suggest);
char *spell_dialog_lang_list_show (GArray * languages);
/*** inline functions ****************************************************************************/

View File

@ -340,7 +340,7 @@ toggle_panels (void)
#ifdef HAVE_SUBSHELL_SUPPORT
if (mc_global.tty.use_subshell)
{
new_dir_p = vfs_current_is_local () ? &new_dir_vpath : NULL;
new_dir_p = vfs_current_is_local ()? &new_dir_vpath : NULL;
invoke_subshell (NULL, VISIBLY, new_dir_p);
}
else

View File

@ -31,8 +31,10 @@ libmcfilemanager_la_SOURCES = \
libmcfilemanager_la_SOURCES += mountlist.c mountlist.h
#endif
libmcfilemanager_la_CFLAGS = -I$(top_srcdir) \
$(GLIB_CFLAGS) $(PCRE_CFLAGS) \
-DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\"
AM_CPPFLAGS = \
-DDATADIR=\""$(pkgdatadir)/"\" \
-DLOCALEDIR=\""$(localedir)"\"
AM_CFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS) $(PCRE_CFLAGS)
libmcfilemanager_la_LIBADD = ../../lib/libmc.la

View File

@ -258,15 +258,13 @@ do_chown (uid_t u, gid_t g)
static void
apply_chowns (uid_t u, gid_t g)
{
char *fname;
need_update = end_chown = 1;
do_chown (u, g);
do
{
fname = next_file ();
next_file ();
do_chown (u, g);
}
while (current_panel->marked);

View File

@ -236,7 +236,7 @@ select_unselect_cmd (const char *title, const char *history_name, gboolean do_se
if (quick_dialog (&quick_dlg) == B_CANCEL)
return;
if (!reg_exp)
if (reg_exp == NULL)
return;
if (!*reg_exp)
{

View File

@ -83,7 +83,8 @@ WInput *cmdline;
static char *
examine_cd (const char *_path)
{
typedef enum { copy_sym, subst_var } state_t;
typedef enum
{ copy_sym, subst_var } state_t;
state_t state = copy_sym;
char *q;
@ -424,7 +425,7 @@ do_cd_command (char *orig_cmd)
path = examine_cd (&cmd[operand_pos]);
if (*path == '\0')
q_vpath = vfs_path_from_str (mc_config_get_home_dir());
q_vpath = vfs_path_from_str (mc_config_get_home_dir ());
else
q_vpath = vfs_path_from_str_flags (path, VPF_NO_CANON);

View File

@ -102,7 +102,7 @@ static gboolean do_local_copy = FALSE;
/* --------------------------------------------------------------------------------------------- */
static void
exec_cleanup_file_name (vfs_path_t * filename_vpath, gboolean has_changed)
exec_cleanup_file_name (const vfs_path_t * filename_vpath, gboolean has_changed)
{
if (localfilecopy_vpath == NULL)
return;
@ -122,7 +122,7 @@ exec_cleanup_file_name (vfs_path_t * filename_vpath, gboolean has_changed)
/* --------------------------------------------------------------------------------------------- */
static char *
exec_get_file_name (vfs_path_t * filename_vpath)
exec_get_file_name (const vfs_path_t * filename_vpath)
{
if (!do_local_copy)
return quote_func (vfs_path_get_last_path_str (filename_vpath), 0);
@ -144,7 +144,7 @@ exec_get_file_name (vfs_path_t * filename_vpath)
/* --------------------------------------------------------------------------------------------- */
static char *
exec_get_export_variables (vfs_path_t * filename_vpath)
exec_get_export_variables (const vfs_path_t * filename_vpath)
{
char *text;
GString *export_vars_string;
@ -189,7 +189,7 @@ exec_get_export_variables (vfs_path_t * filename_vpath)
/* --------------------------------------------------------------------------------------------- */
static char *
exec_make_shell_string (const char *lc_data, vfs_path_t * filename_vpath)
exec_make_shell_string (const char *lc_data, const vfs_path_t * filename_vpath)
{
GString *shell_string;
char lc_prompt[80] = "\0";
@ -315,7 +315,7 @@ exec_make_shell_string (const char *lc_data, vfs_path_t * filename_vpath)
/* --------------------------------------------------------------------------------------------- */
static void
exec_extension_view (char *cmd, vfs_path_t * filename_vpath, int start_line,
exec_extension_view (char *cmd, const vfs_path_t * filename_vpath, int start_line,
vfs_path_t * temp_file_name_vpath)
{
int def_hex_mode = mcview_default_hex_mode, changed_hex_mode = 0;
@ -376,16 +376,14 @@ exec_extension_cd (void)
/* --------------------------------------------------------------------------------------------- */
static void
exec_extension (const char *filename, const char *lc_data, int start_line)
exec_extension (const vfs_path_t * filename_vpath, const char *lc_data, int start_line)
{
char *shell_string, *export_variables;
vfs_path_t *temp_file_name_vpath = NULL;
int cmd_file_fd;
FILE *cmd_file;
char *cmd = NULL;
vfs_path_t *filename_vpath;
g_return_if_fail (filename != NULL);
g_return_if_fail (lc_data != NULL);
pbuffer = NULL;
@ -395,8 +393,6 @@ exec_extension (const char *filename, const char *lc_data, int start_line)
is_cd = FALSE;
written_nonspace = FALSE;
filename_vpath = vfs_path_from_str (filename);
/* Avoid making a local copy if we are doing a cd */
do_local_copy = !vfs_file_is_local (filename_vpath);
@ -494,7 +490,6 @@ exec_extension (const char *filename, const char *lc_data, int start_line)
exec_cleanup_file_name (filename_vpath, TRUE);
ret:
vfs_path_free (temp_file_name_vpath);
vfs_path_free (filename_vpath);
}
/* --------------------------------------------------------------------------------------------- */
@ -947,7 +942,7 @@ regex_command (const vfs_path_t * filename_vpath, const char *action)
*/
if (p < q)
{
exec_extension (filename, r + 1, view_at_line_number);
exec_extension (filename_vpath, r + 1, view_at_line_number);
ret = 1;
}
break;

View File

@ -238,7 +238,7 @@ free_link (void *data)
/* --------------------------------------------------------------------------------------------- */
static void *
free_linklist (GSList *lp)
free_linklist (GSList * lp)
{
g_slist_foreach (lp, (GFunc) free_link, NULL);
g_slist_free (lp);
@ -249,7 +249,7 @@ free_linklist (GSList *lp)
/* --------------------------------------------------------------------------------------------- */
static gboolean
is_in_linklist (const GSList *lp, const vfs_path_t * vpath, const struct stat *sb)
is_in_linklist (const GSList * lp, const vfs_path_t * vpath, const struct stat *sb)
{
const struct vfs_class *class;
ino_t ino = sb->st_ino;

View File

@ -57,9 +57,9 @@
#if ((STAT_STATVFS || STAT_STATVFS64) \
&& (HAVE_STRUCT_STATVFS_F_BASETYPE || HAVE_STRUCT_STATVFS_F_FSTYPENAME \
|| (! HAVE_STRUCT_STATFS_F_FSTYPENAME)))
# define USE_STATVFS 1
#define USE_STATVFS 1
#else
# define USE_STATVFS 0
#define USE_STATVFS 0
#endif
#include <errno.h>
@ -70,36 +70,36 @@
#include <sys/stat.h>
#if USE_STATVFS
# include <sys/statvfs.h>
#include <sys/statvfs.h>
#elif HAVE_SYS_VFS_H
# include <sys/vfs.h>
#include <sys/vfs.h>
#elif HAVE_SYS_MOUNT_H && HAVE_SYS_PARAM_H
/* NOTE: freebsd5.0 needs sys/param.h and sys/mount.h for statfs.
It does have statvfs.h, but shouldn't use it, since it doesn't
HAVE_STRUCT_STATVFS_F_BASETYPE. So find a clean way to fix it. */
/* NetBSD 1.5.2 needs these, for the declaration of struct statfs. */
# include <sys/param.h>
# include <sys/mount.h>
# if HAVE_NFS_NFS_CLNT_H && HAVE_NFS_VFS_H
#include <sys/param.h>
#include <sys/mount.h>
#if HAVE_NFS_NFS_CLNT_H && HAVE_NFS_VFS_H
/* Ultrix 4.4 needs these for the declaration of struct statfs. */
# include <netinet/in.h>
# include <nfs/nfs_clnt.h>
# include <nfs/vfs.h>
# endif
#include <netinet/in.h>
#include <nfs/nfs_clnt.h>
#include <nfs/vfs.h>
#endif
#elif HAVE_OS_H /* BeOS */
# include <fs_info.h>
#include <fs_info.h>
#endif
#if USE_STATVFS
# define STRUCT_STATVFS struct statvfs
# if ! STAT_STATVFS && STAT_STATVFS64
# define STATFS statvfs64
# else
# define STATFS statvfs
# endif
#define STRUCT_STATVFS struct statvfs
#if ! STAT_STATVFS && STAT_STATVFS64
#define STATFS statvfs64
#else
# define STATFS statfs
# if HAVE_OS_H /* BeOS */
#define STATFS statvfs
#endif
#else
#define STATFS statfs
#if HAVE_OS_H /* BeOS */
/* BeOS has a statvfs function, but it does not return sensible values
for f_files, f_ffree and f_favail, and lacks f_type, f_basetype and
f_fstypename. Use 'struct fs_info' instead. */
@ -113,29 +113,27 @@ statfs (char const *filename, struct fs_info *buf)
errno = (device == B_ENTRY_NOT_FOUND ? ENOENT
: device == B_BAD_VALUE ? EINVAL
: device == B_NAME_TOO_LONG ? ENAMETOOLONG
: device == B_NO_MEMORY ? ENOMEM
: device == B_FILE_ERROR ? EIO
: 0);
: device == B_NO_MEMORY ? ENOMEM : device == B_FILE_ERROR ? EIO : 0);
return -1;
}
/* If successful, buf->dev will be == device. */
return fs_stat_dev (device, buf);
}
# define STRUCT_STATVFS struct fs_info
# else
# define STRUCT_STATVFS struct statfs
# endif
#define STRUCT_STATVFS struct fs_info
#else
#define STRUCT_STATVFS struct statfs
#endif
#endif
#if HAVE_STRUCT_STATVFS_F_BASETYPE
# define STATXFS_FILE_SYSTEM_TYPE_MEMBER_NAME f_basetype
#define STATXFS_FILE_SYSTEM_TYPE_MEMBER_NAME f_basetype
#else
# if HAVE_STRUCT_STATVFS_F_FSTYPENAME || HAVE_STRUCT_STATFS_F_FSTYPENAME
# define STATXFS_FILE_SYSTEM_TYPE_MEMBER_NAME f_fstypename
# elif HAVE_OS_H /* BeOS */
# define STATXFS_FILE_SYSTEM_TYPE_MEMBER_NAME fsh_name
# endif
#if HAVE_STRUCT_STATVFS_F_FSTYPENAME || HAVE_STRUCT_STATFS_F_FSTYPENAME
#define STATXFS_FILE_SYSTEM_TYPE_MEMBER_NAME f_fstypename
#elif HAVE_OS_H /* BeOS */
#define STATXFS_FILE_SYSTEM_TYPE_MEMBER_NAME fsh_name
#endif
#endif
#include <unistd.h>

View File

@ -1694,10 +1694,9 @@ do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs,
/* absolute path */
if (start_dir_len < 0)
{
int ret;
vfs_path_free (current_panel->cwd_vpath);
current_panel->cwd_vpath = vfs_path_from_str (PATH_SEP_STR);
ret = chdir (PATH_SEP_STR);
chdir (PATH_SEP_STR);
}
panelize_save_panel (current_panel);
}

View File

@ -73,7 +73,7 @@ struct Widget *get_panel_widget (int idx);
struct WPanel *get_other_panel (void);
void save_panel_dir (int idx);
char *get_panel_dir_for (const struct WPanel * widget);
char *get_panel_dir_for (const struct WPanel *widget);
void set_hintbar (const char *str);

View File

@ -631,10 +631,7 @@ create_panels (void)
/* 3. Create active panel */
if (current_dir == NULL)
{
current_dir = vfs_path_to_str (original_dir);
mc_chdir (original_dir);
}
else
{
vfs_path_t *vpath;
@ -1603,7 +1600,7 @@ midnight_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void
/* --------------------------------------------------------------------------------------------- */
static int
midnight_event (Gpm_Event *event, void *data)
midnight_event (Gpm_Event * event, void *data)
{
Dlg_head *h = (Dlg_head *) data;
int ret = MOU_UNHANDLED;

View File

@ -202,7 +202,7 @@
#undef closedir
#ifndef ME_DUMMY
# define ME_DUMMY(Fs_name, Fs_type) \
#define ME_DUMMY(Fs_name, Fs_type) \
(strcmp (Fs_type, "autofs") == 0 \
|| strcmp (Fs_type, "none") == 0 \
|| strcmp (Fs_type, "proc") == 0 \
@ -240,7 +240,7 @@ me_remote (char const *fs_name, char const *fs_type _GL_UNUSED)
#ifndef ME_REMOTE
/* A file system is `remote' if its Fs_name contains a `:'
or if (it is of type (smbfs or cifs) and its Fs_name starts with `//'). */
# define ME_REMOTE(Fs_name, Fs_type) \
#define ME_REMOTE(Fs_name, Fs_type) \
(strchr (Fs_name, ':') != NULL \
|| ((Fs_name)[0] == '/' \
&& (Fs_name)[1] == '/' \
@ -290,9 +290,9 @@ struct mount_entry
char *me_mountdir; /* Mount point directory name. */
char *me_type; /* "nfs", "4.2", etc. */
dev_t me_dev; /* Device number of me_mountdir. */
unsigned int me_dummy : 1; /* Nonzero for dummy file systems. */
unsigned int me_remote : 1; /* Nonzero for remote fileystems. */
unsigned int me_type_malloced : 1; /* Nonzero if me_type was malloced. */
unsigned int me_dummy:1; /* Nonzero for dummy file systems. */
unsigned int me_remote:1; /* Nonzero for remote fileystems. */
unsigned int me_type_malloced:1; /* Nonzero if me_type was malloced. */
struct mount_entry *me_next;
};
@ -1044,7 +1044,7 @@ read_file_system_list (int need_fs_type)
&& (ignore == options || ignore[-1] == ',')
&& (ignore[sizeof ("ignore") - 1] == ','
|| ignore[sizeof ("ignore") - 1] == '\0'));
me->me_dev = (dev_t)(-1); /* vmt_fsid might be the info we want. */
me->me_dev = (dev_t) (-1); /* vmt_fsid might be the info we want. */
/* Add to the linked list. */
*mtail = me;
@ -1233,7 +1233,9 @@ safe_read (int fd, void *buf, size_t count)
INT_MAX bytes fails with errno == EINVAL. See
<http://lists.gnu.org/archive/html/bug-gnu-utils/2002-04/msg00010.html>.
When decreasing COUNT, keep it block-aligned. */
/* *INDENT-OFF* */
enum { BUGGY_READ_MAXIMUM = INT_MAX & ~8191 };
/* *INDENT-ON* */
for (;;)
{
@ -1306,8 +1308,11 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
return -1;
/* f_frsize isn't guaranteed to be supported. */
fsp->fsu_blocksize = (fsd.f_frsize
? PROPAGATE_ALL_ONES (fsd.f_frsize) : PROPAGATE_ALL_ONES (fsd.f_bsize));
/* *INDENT-OFF* */
fsp->fsu_blocksize = fsd.f_frsize
? PROPAGATE_ALL_ONES (fsd.f_frsize)
: PROPAGATE_ALL_ONES (fsd.f_bsize);
/* *INDENT-ON* */
#elif defined STAT_STATVFS64 /* AIX */
@ -1317,8 +1322,11 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
return -1;
/* f_frsize isn't guaranteed to be supported. */
fsp->fsu_blocksize = (fsd.f_frsize
? PROPAGATE_ALL_ONES (fsd.f_frsize) : PROPAGATE_ALL_ONES (fsd.f_bsize));
/* *INDENT-OFF* */
fsp->fsu_blocksize = fsd.f_frsize
? PROPAGATE_ALL_ONES (fsd.f_frsize)
: PROPAGATE_ALL_ONES (fsd.f_bsize);
/* *INDENT-ON* */
#elif defined STAT_STATFS2_FS_DATA /* Ultrix */
@ -1379,7 +1387,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize);
#elif defined STAT_STATFS2_BSIZE /* glibc/Linux, 4.3BSD, SunOS 4, \
MacOS X < 10.4, FreeBSD < 5.0, \
Mac OS X < 10.4, FreeBSD < 5.0, \
NetBSD < 3.0, OpenBSD < 4.4 */
struct statfs fsd;
@ -1447,7 +1455,6 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.f_ffree);
#endif
(void) disk; /* avoid argument-unused warning */
return 0;
}
@ -1517,7 +1524,9 @@ my_statfs (struct my_statfs *myfs_stats, const char *path)
myfs_stats->typename = entry->me_type;
myfs_stats->mpoint = entry->me_mountdir;
myfs_stats->device = entry->me_devname;
myfs_stats->avail = ((uintmax_t) (getuid () ? fs_use.fsu_bavail : fs_use.fsu_bfree) * fs_use.fsu_blocksize) >> 10;
myfs_stats->avail =
((uintmax_t) (getuid ()? fs_use.fsu_bavail : fs_use.fsu_bfree) *
fs_use.fsu_blocksize) >> 10;
myfs_stats->total = ((uintmax_t) fs_use.fsu_blocks * fs_use.fsu_blocksize) >> 10;
myfs_stats->nfree = (uintmax_t) fs_use.fsu_ffree;
myfs_stats->nodes = (uintmax_t) fs_use.fsu_files;

View File

@ -1,6 +1,6 @@
/*
Declarations for list of mounted filesystems
*/
*/
/** \file mountlist.h
* \brief Header: list of mounted filesystems

View File

@ -3015,6 +3015,8 @@ subshell_chdir (const vfs_path_t * vpath)
#ifdef HAVE_SUBSHELL_SUPPORT
if (mc_global.tty.use_subshell && vfs_current_is_local ())
do_subshell_chdir (vpath, FALSE, TRUE);
#else /* HAVE_SUBSHELL_SUPPORT */
(void) vpath;
#endif /* HAVE_SUBSHELL_SUPPORT */
}
@ -4121,7 +4123,7 @@ panel_new_with_dir (const char *panel_name, const char *wpath)
vfs_path_t *vpath;
vpath = vfs_path_from_str (curdir);
err = mc_chdir (vpath);
mc_chdir (vpath);
vfs_path_free (vpath);
}
g_free (curdir);

View File

@ -138,6 +138,7 @@ panelize_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void
{
case DLG_INIT:
case DLG_POST_KEY:
case DLG_FOCUS:
tty_setcolor (MENU_ENTRY_COLOR);
update_command ();
return MSG_HANDLED;
@ -387,9 +388,8 @@ do_external_panelize (char *command)
current_panel->count = next_free;
if (list->list[0].fname[0] == PATH_SEP)
{
int ret;
panel_set_cwd (current_panel, PATH_SEP_STR);
ret = chdir (PATH_SEP_STR);
chdir (PATH_SEP_STR);
}
}
else
@ -599,8 +599,7 @@ load_panelize (void)
if (!profile_keys || *profile_keys == NULL)
{
add2panelize (g_strdup (_("Modified git files")),
g_strdup ("git ls-files --modified"));
add2panelize (g_strdup (_("Modified git files")), g_strdup ("git ls-files --modified"));
add2panelize (g_strdup (_("Find rejects after patching")),
g_strdup ("find . -name \\*.rej -print"));
add2panelize (g_strdup (_("Find *.orig after patching")),

View File

@ -739,7 +739,6 @@ static void
tree_rescan (void *data)
{
WTree *tree = data;
int ret;
vfs_path_t *old_vpath;
old_vpath = vfs_path_clone (vfs_get_raw_current_dir ());
@ -749,7 +748,7 @@ tree_rescan (void *data)
if (tree->selected_ptr != NULL && mc_chdir (tree->selected_ptr->name) == 0)
{
tree_store_rescan (tree->selected_ptr->name);
ret = mc_chdir (old_vpath);
mc_chdir (old_vpath);
}
vfs_path_free (old_vpath);
}

View File

@ -408,7 +408,7 @@ tree_store_add_entry (const vfs_path_t * name)
abort ();
/* Search for the correct place */
while (current && (flag = pathcmp (current->name, name)) < 0)
while (current != NULL && (flag = pathcmp (current->name, name)) < 0)
{
old = current;
current = current->next;
@ -430,6 +430,7 @@ tree_store_add_entry (const vfs_path_t * name)
}
else
{
if (old != NULL)
old->next = new;
new->prev = old;
}
@ -440,7 +441,7 @@ tree_store_add_entry (const vfs_path_t * name)
{
/* Insert in to the middle of the list */
new->prev = old;
if (old)
if (old != NULL)
{
/* Yes, in the middle */
new->next = old->next;

View File

@ -19,7 +19,7 @@ struct WEdit;
/*** declarations of public functions ************************************************************/
gboolean user_menu_cmd (struct WEdit *edit_widget, const char * menu_file, int selected_entry);
gboolean user_menu_cmd (struct WEdit *edit_widget, const char *menu_file, int selected_entry);
char *expand_format (struct WEdit *edit_widget, char c, gboolean do_quote);
int check_format_view (const char *);
int check_format_var (const char *, char **);

View File

@ -93,7 +93,6 @@ static const global_keymap_ini_t default_main_keymap[] = {
{"Delete", "f8"},
{"Menu", "f9"},
{"Quit", "f10"},
{"ViewFile", "f13"},
{"MenuLastSelected", "f19"},
{"QuitQuiet", "f20"},
{"History", "alt-h"},

View File

@ -373,7 +373,8 @@ learn_save (void)
esc_str = strutils_escape (learnkeys[i].sequence, -1, ";\\", TRUE);
mc_config_set_string_raw_value (mc_main_config, section, key_name_conv_tab[i].name, esc_str);
mc_config_set_string_raw_value (mc_main_config, section, key_name_conv_tab[i].name,
esc_str);
g_free (esc_str);
}

View File

@ -603,10 +603,8 @@ main (int argc, char *argv[])
S_IRUSR | S_IWUSR);
if (last_wd_fd != -1)
{
ssize_t ret1;
int ret2;
ret1 = write (last_wd_fd, last_wd_string, strlen (last_wd_string));
ret2 = close (last_wd_fd);
(void) write (last_wd_fd, last_wd_string, strlen (last_wd_string));
(void) close (last_wd_fd);
}
}
g_free (last_wd_string);

View File

@ -108,8 +108,8 @@ char *load_anon_passwd (void);
void load_keymap_defs (gboolean load_from_file);
void free_keymap_defs (void);
void panel_load_setup (struct WPanel * panel, const char *section);
void panel_save_setup (struct WPanel * panel, const char *section);
void panel_load_setup (struct WPanel *panel, const char *section);
void panel_save_setup (struct WPanel *panel, const char *section);
void panels_load_options (void);
void panels_save_options (void);

View File

@ -252,10 +252,7 @@ init_subshell_child (const char *pty_name)
/* It simplifies things to change to our home directory here, */
/* and the user's startup file may do a `cd' command anyway */
{
int ret;
ret = chdir (mc_config_get_home_dir ()); /* FIXME? What about when we re-run the subshell? */
}
chdir (mc_config_get_home_dir ()); /* FIXME? What about when we re-run the subshell? */
/* Set MC_SID to prevent running one mc from another */
mc_sid = getsid (0);

View File

@ -1,5 +1,4 @@
AM_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)
AM_CPPFLAGS =
noinst_LTLIBRARIES = libvfs-cpio.la

View File

@ -11,7 +11,7 @@
/*** declarations of public functions ************************************************************/
void init_cpiofs(void);
void init_cpiofs (void);
/*** inline functions ****************************************************************************/

View File

@ -1,8 +1,8 @@
SUBDIRS = helpers
DIST_SUBDIRS = helpers
AM_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)
AM_CPPFLAGS = -DLIBEXECDIR=\""$(libexecdir)/@PACKAGE@/"\"
AM_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)
noinst_LTLIBRARIES = libvfs-extfs.la

View File

@ -422,7 +422,7 @@ extfs_open_archive (int fstype, const char *name, struct archive **pparc)
goto ret;
}
tmp = name_quote ( vfs_path_get_last_path_str (name_vpath), 0);
tmp = name_quote (vfs_path_get_last_path_str (name_vpath), 0);
}
cmd = g_strconcat (info->path, info->prefix, " list ",

View File

@ -1,8 +1,8 @@
SUBDIRS = helpers
DIST_SUBDIRS = helpers
AM_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)
AM_CPPFLAGS = -DLIBEXECDIR=\""$(libexecdir)/@PACKAGE@/"\"
AM_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)
noinst_LTLIBRARIES = libvfs-fish.la

View File

@ -251,9 +251,8 @@ fish_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, c
if (logfile)
{
size_t ret;
ret = fwrite (str, strlen (str), 1, logfile);
ret = fflush (logfile);
(void) fwrite (str, strlen (str), 1, logfile);
(void) fflush (logfile);
}
tty_enable_interrupt_key ();
@ -330,13 +329,13 @@ fish_pipeopen (struct vfs_s_super *super, const char *path, const char *argv[])
}
else
{
res = dup2 (fileset1[0], 0);
(void) dup2 (fileset1[0], 0);
close (fileset1[0]);
close (fileset1[1]);
res = dup2 (fileset2[1], 1);
(void) dup2 (fileset2[1], 1);
close (2);
/* stderr to /dev/null */
res = open ("/dev/null", O_WRONLY);
(void) open ("/dev/null", O_WRONLY);
close (fileset2[0]);
close (fileset2[1]);
execvp (path, const_cast (char **, argv));
@ -710,18 +709,24 @@ fish_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
char *temp;
char *data_start = buffer + 1;
char *filename = data_start;
char *linkname = data_start;
char *filename_bound = filename + strlen (filename);
char *linkname_bound = filename_bound;
char *filename_bound;
filename_bound = filename + strlen (filename);
if (!strcmp (data_start, "\".\"") || !strcmp (data_start, "\"..\""))
break; /* We'll do "." and ".." ourselves */
if (S_ISLNK (ST.st_mode))
{
char *linkname;
char *linkname_bound;
/* we expect: "escaped-name" -> "escaped-name"
// -> cannot occur in filenames,
// because it will be escaped to -\> */
linkname_bound = filename_bound;
if (*filename == '"')
++filename;

View File

@ -21,7 +21,7 @@ extern int fish_directory_timeout;
/*** declarations of public functions ************************************************************/
void init_fish(void);
void init_fish (void);
/*** inline functions ****************************************************************************/

View File

@ -1,5 +1,4 @@
AM_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)
AM_CPPFLAGS =
noinst_LTLIBRARIES = libvfs-ftpfs.la

View File

@ -477,8 +477,7 @@ ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply,
}
else
{
size_t ret;
ret = fwrite (cmdstr, cmdlen, 1, MEDATA->logfile);
(void) fwrite (cmdstr, cmdlen, 1, MEDATA->logfile);
}
fflush (MEDATA->logfile);
@ -2488,7 +2487,8 @@ ftpfs_netrc_lookup (const char *host, char **login, char **pass)
}
/* Ignore unsafe passwords */
if (strcmp (*login, "anonymous") && strcmp (*login, "ftp")
if (*login != NULL &&
strcmp (*login, "anonymous") != 0 && strcmp (*login, "ftp") != 0
&& ftpfs_netrc_bad_mode (netrcname))
{
need_break = 1;

View File

@ -1,5 +1,4 @@
AM_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)
AM_CPPFLAGS =
noinst_LTLIBRARIES = libvfs-local.la

View File

@ -11,7 +11,7 @@
/*** declarations of public functions ************************************************************/
void vfs_plugins_init(void);
void vfs_plugins_init (void);
/*** inline functions ****************************************************************************/

View File

@ -1,5 +1,4 @@
AM_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)
AM_CPPFLAGS =
noinst_LTLIBRARIES = libvfs-sfs.la

View File

@ -190,8 +190,11 @@ sfs_vfmake (const vfs_path_t * vpath, vfs_path_t * cache_vpath)
COPY_CHAR;
continue;
}
if (ptr != NULL)
{
COPY_STRING (ptr);
}
}
else
{
if (*s_iter == '%')

View File

@ -1,5 +1,4 @@
AM_CFLAGS = $(GLIB_CFLAGS) $(LIBSSH_CFLAGS) -I$(top_srcdir)
AM_CPPFLAGS =
noinst_LTLIBRARIES = libvfs-sftpfs.la

View File

@ -380,13 +380,13 @@ void
sftpfs_init_config_variables_patterns (void)
{
size_t structure_offsets[] = {
offsetof(sftpfs_ssh_config_entity_t, user),
offsetof(sftpfs_ssh_config_entity_t, real_host),
offsetof(sftpfs_ssh_config_entity_t, identities_only),
offsetof(sftpfs_ssh_config_entity_t, identity_file),
offsetof(sftpfs_ssh_config_entity_t, port),
offsetof(sftpfs_ssh_config_entity_t, password_auth),
offsetof(sftpfs_ssh_config_entity_t, pubkey_auth)
offsetof (sftpfs_ssh_config_entity_t, user),
offsetof (sftpfs_ssh_config_entity_t, real_host),
offsetof (sftpfs_ssh_config_entity_t, identities_only),
offsetof (sftpfs_ssh_config_entity_t, identity_file),
offsetof (sftpfs_ssh_config_entity_t, port),
offsetof (sftpfs_ssh_config_entity_t, password_auth),
offsetof (sftpfs_ssh_config_entity_t, pubkey_auth)
};
int i;

View File

@ -2,8 +2,8 @@ DIST_SUBDIRS =
SUBDIRS = helpers
AM_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir) -DCONFIGDIR=\""@smbconfigdir@"\"
AM_CPPFLAGS =
AM_CPPFLAGS = -DCONFIGDIR=\""@smbconfigdir@"\"
AM_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)
noinst_LTLIBRARIES = libvfs-smbfs.la

View File

@ -2,7 +2,7 @@
Unix SMB/Netbios implementation.
Version 1.9.
SMB Byte handling
*/
*/
#ifndef _BYTEORDER_H
#define _BYTEORDER_H
@ -11,73 +11,73 @@
This file implements macros for machine independent short and
int manipulation
Here is a description of this file that I emailed to the samba list once:
Here is a description of this file that I emailed to the samba list once:
> I am confused about the way that byteorder.h works in Samba. I have
> looked at it, and I would have thought that you might make a distinction
> between LE and BE machines, but you only seem to distinguish between 386
> and all other architectures.
>
> Can you give me a clue?
> I am confused about the way that byteorder.h works in Samba. I have
> looked at it, and I would have thought that you might make a distinction
> between LE and BE machines, but you only seem to distinguish between 386
> and all other architectures.
>
> Can you give me a clue?
sure.
sure.
The distinction between 386 and other architectures is only there as
an optimisation. You can take it out completely and it will make no
difference. The routines (macros) in byteorder.h are totally byteorder
independent. The 386 optimsation just takes advantage of the fact that
the x86 processors don't care about alignment, so we don't have to
align ints on int boundaries etc. If there are other processors out
there that aren't alignment sensitive then you could also define
CAREFUL_ALIGNMENT=0 on those processors as well.
The distinction between 386 and other architectures is only there as
an optimisation. You can take it out completely and it will make no
difference. The routines (macros) in byteorder.h are totally byteorder
independent. The 386 optimsation just takes advantage of the fact that
the x86 processors don't care about alignment, so we don't have to
align ints on int boundaries etc. If there are other processors out
there that aren't alignment sensitive then you could also define
CAREFUL_ALIGNMENT=0 on those processors as well.
Ok, now to the macros themselves. I'll take a simple example, say we
want to extract a 2 byte integer from a SMB packet and put it into a
type called uint16 that is in the local machines byte order, and you
want to do it with only the assumption that uint16 is _at_least_ 16
bits long (this last condition is very important for architectures
that don't have any int types that are 2 bytes long)
Ok, now to the macros themselves. I'll take a simple example, say we
want to extract a 2 byte integer from a SMB packet and put it into a
type called uint16 that is in the local machines byte order, and you
want to do it with only the assumption that uint16 is _at_least_ 16
bits long (this last condition is very important for architectures
that don't have any int types that are 2 bytes long)
You do this:
You do this:
#define CVAL(buf,pos) (((unsigned char *)(buf))[pos])
#define PVAL(buf,pos) ((unsigned)CVAL(buf,pos))
#define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
#define CVAL(buf,pos) (((unsigned char *)(buf))[pos])
#define PVAL(buf,pos) ((unsigned)CVAL(buf,pos))
#define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
then to extract a uint16 value at offset 25 in a buffer you do this:
then to extract a uint16 value at offset 25 in a buffer you do this:
char *buffer = foo_bar();
uint16 xx = SVAL(buffer,25);
char *buffer = foo_bar();
uint16 xx = SVAL(buffer,25);
We are using the byteoder independence of the ANSI C bitshifts to do
the work. A good optimising compiler should turn this into efficient
code, especially if it happens to have the right byteorder :-)
We are using the byteoder independence of the ANSI C bitshifts to do
the work. A good optimising compiler should turn this into efficient
code, especially if it happens to have the right byteorder :-)
I know these macros can be made a bit tidier by removing some of the
casts, but you need to look at byteorder.h as a whole to see the
reasoning behind them. byteorder.h defines the following macros:
I know these macros can be made a bit tidier by removing some of the
casts, but you need to look at byteorder.h as a whole to see the
reasoning behind them. byteorder.h defines the following macros:
SVAL(buf,pos) - extract a 2 byte SMB value
IVAL(buf,pos) - extract a 4 byte SMB value
SVALS(buf,pos) signed version of SVAL()
IVALS(buf,pos) signed version of IVAL()
SVAL(buf,pos) - extract a 2 byte SMB value
IVAL(buf,pos) - extract a 4 byte SMB value
SVALS(buf,pos) signed version of SVAL()
IVALS(buf,pos) signed version of IVAL()
SSVAL(buf,pos,val) - put a 2 byte SMB value into a buffer
SIVAL(buf,pos,val) - put a 4 byte SMB value into a buffer
SSVALS(buf,pos,val) - signed version of SSVAL()
SIVALS(buf,pos,val) - signed version of SIVAL()
SSVAL(buf,pos,val) - put a 2 byte SMB value into a buffer
SIVAL(buf,pos,val) - put a 4 byte SMB value into a buffer
SSVALS(buf,pos,val) - signed version of SSVAL()
SIVALS(buf,pos,val) - signed version of SIVAL()
RSVAL(buf,pos) - like SVAL() but for NMB byte ordering
RSVALS(buf,pos) - like SVALS() but for NMB byte ordering
RIVAL(buf,pos) - like IVAL() but for NMB byte ordering
RIVALS(buf,pos) - like IVALS() but for NMB byte ordering
RSSVAL(buf,pos,val) - like SSVAL() but for NMB ordering
RSIVAL(buf,pos,val) - like SIVAL() but for NMB ordering
RSIVALS(buf,pos,val) - like SIVALS() but for NMB ordering
RSVAL(buf,pos) - like SVAL() but for NMB byte ordering
RSVALS(buf,pos) - like SVALS() but for NMB byte ordering
RIVAL(buf,pos) - like IVAL() but for NMB byte ordering
RIVALS(buf,pos) - like IVALS() but for NMB byte ordering
RSSVAL(buf,pos,val) - like SSVAL() but for NMB ordering
RSIVAL(buf,pos,val) - like SIVAL() but for NMB ordering
RSIVALS(buf,pos,val) - like SIVALS() but for NMB ordering
it also defines lots of intermediate macros, just ignore those :-)
it also defines lots of intermediate macros, just ignore those :-)
*/
*/
/* some switch macros that do both store and read to and from SMB buffers */
@ -142,7 +142,7 @@ it also defines lots of intermediate macros, just ignore those :-)
/*
WARNING: This section is dependent on the length of int16 and int32
being correct
*/
*/
/* get single value from an SMB buffer */
#define SVAL(buf,pos) (*(uint16 *)((char *)(buf) + (pos)))

View File

@ -2,7 +2,7 @@
Unix SMB/Netbios implementation.
Version 1.9.
Character set handling
*/
*/
#ifndef CHARSET_C

View File

@ -2,7 +2,7 @@
Unix SMB/Netbios implementation.
Version 1.9.
SMB parameters and setup
*/
*/
#ifndef _CLIENT_H
#define _CLIENT_H
@ -54,7 +54,8 @@ struct pwd_info
uchar smb_nt_owf[24];
};
struct cli_state {
struct cli_state
{
int port;
int fd;
uint16 cnum;

View File

@ -4,7 +4,7 @@
Unix SMB/Netbios implementation.
Version 1.9.
Machine customisation and include handling
*/
*/
#ifndef NO_CONFIG_H /* for some tests */
#include "config.h"
@ -156,7 +156,7 @@
/* POSIX terminal handling. */
#include <termios.h>
# include <dirent.h>
#include <dirent.h>
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
@ -194,7 +194,7 @@
#endif
#ifdef HAVE_SYS_STATFS_H
# include <sys/statfs.h>
#include <sys/statfs.h>
#endif
#ifdef HAVE_DUSTAT_H
@ -269,7 +269,7 @@
they actually only need to be at least 16 and 32 bits
respectively. Thus if your word size is 8 bytes just defining them
as signed and unsigned int will work.
*/
*/
#ifndef uint8
#define uint8 unsigned char
@ -334,13 +334,13 @@
*/
#ifndef SMB_INO_T
# define SMB_INO_T ino_t
#define SMB_INO_T ino_t
#endif
#ifndef LARGE_SMB_INO_T
# if defined(SIZEOF_INO_T) && (SIZEOF_INO_T == 8)
# define LARGE_SMB_INO_T 1
# endif
#if defined(SIZEOF_INO_T) && (SIZEOF_INO_T == 8)
#define LARGE_SMB_INO_T 1
#endif
#endif
#ifdef LARGE_SMB_INO_T
@ -350,7 +350,7 @@
#endif
#ifndef SMB_OFF_T
# define SMB_OFF_T off_t
#define SMB_OFF_T off_t
#endif
#define SMB_OFF_T_BITS (sizeof(SMB_OFF_T)*8)
@ -361,9 +361,9 @@
*/
#ifndef LARGE_SMB_OFF_T
# if defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)
# define LARGE_SMB_OFF_T 1
# endif
#if defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)
#define LARGE_SMB_OFF_T 1
#endif
#endif
#ifdef LARGE_SMB_OFF_T
@ -377,7 +377,7 @@
*/
#ifndef SMB_STRUCT_STAT
# define SMB_STRUCT_STAT struct stat
#define SMB_STRUCT_STAT struct stat
#endif
/*
@ -385,7 +385,7 @@
*/
#ifndef SMB_STRUCT_DIRENT
# define SMB_STRUCT_DIRENT struct dirent
#define SMB_STRUCT_DIRENT struct dirent
#endif
/*
@ -393,19 +393,19 @@
*/
#ifndef SMB_STRUCT_FLOCK
# define SMB_STRUCT_FLOCK struct flock
#define SMB_STRUCT_FLOCK struct flock
#endif
#ifndef SMB_F_SETLKW
# define SMB_F_SETLKW F_SETLKW
#define SMB_F_SETLKW F_SETLKW
#endif
#ifndef SMB_F_SETLK
# define SMB_F_SETLK F_SETLK
#define SMB_F_SETLK F_SETLK
#endif
#ifndef SMB_F_GETLK
# define SMB_F_GETLK F_GETLK
#define SMB_F_GETLK F_GETLK
#endif
#if defined(HAVE_LONGLONG)
@ -549,19 +549,19 @@
#endif
#ifndef HAVE_INITGROUPS
int initgroups(char *name,gid_t id);
int initgroups (char *name, gid_t id);
#endif
#ifndef HAVE_RENAME
int rename(const char *zfrom, const char *zto);
int rename (const char *zfrom, const char *zto);
#endif
#ifndef HAVE_MKTIME
time_t mktime(struct tm *t);
time_t mktime (struct tm *t);
#endif
#ifndef HAVE_STRTOUL
unsigned long strtoul(const char *nptr, char **endptr, int base);
unsigned long strtoul (const char *nptr, char **endptr, int base);
#endif
#ifdef REPLACE_GETPASS

View File

@ -2,7 +2,7 @@
Unix SMB/Netbios implementation.
Version 1.9.
Kanji Extensions
*/
*/
#ifndef _KANJI_H_
#define _KANJI_H_
@ -118,14 +118,14 @@
/* Ensure we use our definitions in all other files than kanji.c. */
/* Function pointers we will replace. */
extern char *(*multibyte_strchr)(const char *s, int c);
extern char *(*multibyte_strrchr)(const char *s, int c);
extern char *(*multibyte_strstr)(const char *s1, const char *s2);
extern char *(*multibyte_strtok)(char *s1, const char *s2);
extern char *(*_dos_to_unix)(char *str, BOOL overwrite);
extern char *(*_unix_to_dos)(char *str, BOOL overwrite);
extern BOOL (*is_multibyte_char)(char c);
extern int (*_skip_multibyte_char)(char c);
extern char *(*multibyte_strchr) (const char *s, int c);
extern char *(*multibyte_strrchr) (const char *s, int c);
extern char *(*multibyte_strstr) (const char *s1, const char *s2);
extern char *(*multibyte_strtok) (char *s1, const char *s2);
extern char *(*_dos_to_unix) (char *str, BOOL overwrite);
extern char *(*_unix_to_dos) (char *str, BOOL overwrite);
extern BOOL (*is_multibyte_char) (char c);
extern int (*_skip_multibyte_char) (char c);
#define strchr(s1, c) ((*multibyte_strchr)((s1), (c)))
#define strrchr(s1, c) ((*multibyte_strrchr)((s1), (c)))

View File

@ -152,7 +152,7 @@
#define SHORT_CONNECT_TIMEOUT 5000
/* default socket options. Dave Miller thinks we should default to TCP_NODELAY
given the socket IO pattern that Samba uses*/
given the socket IO pattern that Samba uses */
#ifdef TCP_NODELAY
#define DEFAULT_SOCKET_OPTIONS "TCP_NODELAY"
#else

View File

@ -4,7 +4,7 @@
Unix SMB/Netbios implementation.
Version 1.9.
NBT netbios header - version 2
*/
*/
#define PERMANENT_TTL 0
@ -19,9 +19,11 @@
Types of reply packet.
**********************************************************/
enum netbios_reply_type_code { NMB_QUERY, NMB_STATUS, NMB_REG, NMB_REG_REFRESH,
enum netbios_reply_type_code
{ NMB_QUERY, NMB_STATUS, NMB_REG, NMB_REG_REFRESH,
NMB_REL, NMB_WAIT_ACK, NMB_MULTIHOMED_REG,
WINS_REG, WINS_QUERY };
WINS_REG, WINS_QUERY
};
/* From rfc1002, 4.2.1.2 */
/* Question types. */
@ -123,10 +125,14 @@ enum netbios_reply_type_code { NMB_QUERY, NMB_STATUS, NMB_REG, NMB_REG_REFRESH,
*
*/
enum name_source {LMHOSTS_NAME, REGISTER_NAME, SELF_NAME, DNS_NAME,
DNSFAIL_NAME, PERMANENT_NAME, WINS_PROXY_NAME};
enum node_type {B_NODE=0, P_NODE=1, M_NODE=2, NBDD_NODE=3};
enum packet_type {NMB_PACKET, DGRAM_PACKET};
enum name_source
{ LMHOSTS_NAME, REGISTER_NAME, SELF_NAME, DNS_NAME,
DNSFAIL_NAME, PERMANENT_NAME, WINS_PROXY_NAME
};
enum node_type
{ B_NODE = 0, P_NODE = 1, M_NODE = 2, NBDD_NODE = 3 };
enum packet_type
{ NMB_PACKET, DGRAM_PACKET };
enum master_state
{
@ -226,12 +232,13 @@ struct work_record
/* typedefs needed to define copy & free functions for userdata. */
struct userdata_struct;
typedef struct userdata_struct * (*userdata_copy_fn)(struct userdata_struct *);
typedef void (*userdata_free_fn)(struct userdata_struct *);
typedef struct userdata_struct *(*userdata_copy_fn) (struct userdata_struct *);
typedef void (*userdata_free_fn) (struct userdata_struct *);
/* Structure to define any userdata passed around. */
struct userdata_struct {
struct userdata_struct
{
userdata_copy_fn copy_fn;
userdata_free_fn free_fn;
unsigned int userdata_len;
@ -243,69 +250,53 @@ struct packet_struct;
struct res_rec;
/* typedef to define the function called when this response packet comes in. */
typedef void (*response_function)(struct subnet_record *, struct response_record *,
typedef void (*response_function) (struct subnet_record *, struct response_record *,
struct packet_struct *);
/* typedef to define the function called when this response record times out. */
typedef void (*timeout_response_function)(struct subnet_record *,
struct response_record *);
typedef void (*timeout_response_function) (struct subnet_record *, struct response_record *);
/* typedef to define the function called when the request that caused this
response record to be created is successful. */
typedef void (*success_function)(struct subnet_record *, struct userdata_struct *, ...);
typedef void (*success_function) (struct subnet_record *, struct userdata_struct *, ...);
/* typedef to define the function called when the request that caused this
response record to be created is unsuccessful. */
typedef void (*fail_function)(struct subnet_record *, struct response_record *, ...);
typedef void (*fail_function) (struct subnet_record *, struct response_record *, ...);
/* List of typedefs for success and fail functions of the different query
types. Used to catch any compile time prototype errors. */
typedef void (*register_name_success_function)( struct subnet_record *,
typedef void (*register_name_success_function) (struct subnet_record *,
struct userdata_struct *,
struct nmb_name *, uint16, int, struct in_addr);
typedef void (*register_name_fail_function) (struct subnet_record *,
struct response_record *, struct nmb_name *);
typedef void (*release_name_success_function) (struct subnet_record *,
struct userdata_struct *,
struct nmb_name *, struct in_addr);
typedef void (*release_name_fail_function) (struct subnet_record *,
struct response_record *, struct nmb_name *);
typedef void (*refresh_name_success_function) (struct subnet_record *,
struct userdata_struct *,
struct nmb_name *, uint16, int, struct in_addr);
typedef void (*refresh_name_fail_function) (struct subnet_record *,
struct response_record *, struct nmb_name *);
typedef void (*query_name_success_function) (struct subnet_record *,
struct userdata_struct *,
struct nmb_name *,
uint16,
int,
struct in_addr);
typedef void (*register_name_fail_function)( struct subnet_record *,
struct response_record *,
struct nmb_name *);
struct in_addr, struct res_rec * answers);
typedef void (*release_name_success_function)( struct subnet_record *,
typedef void (*query_name_fail_function) (struct subnet_record *,
struct response_record *, struct nmb_name *, int);
typedef void (*node_status_success_function) (struct subnet_record *,
struct userdata_struct *,
struct nmb_name *,
struct in_addr);
typedef void (*release_name_fail_function)( struct subnet_record *,
struct response_record *,
struct nmb_name *);
typedef void (*refresh_name_success_function)( struct subnet_record *,
struct userdata_struct *,
struct nmb_name *,
uint16,
int,
struct in_addr);
typedef void (*refresh_name_fail_function)( struct subnet_record *,
struct response_record *,
struct nmb_name *);
typedef void (*query_name_success_function)( struct subnet_record *,
struct userdata_struct *,
struct nmb_name *,
struct in_addr,
struct res_rec *answers);
typedef void (*query_name_fail_function)( struct subnet_record *,
struct response_record *,
struct nmb_name *,
int);
typedef void (*node_status_success_function)( struct subnet_record *,
struct userdata_struct *,
struct res_rec *,
struct in_addr);
typedef void (*node_status_fail_function)( struct subnet_record *,
struct response_record *);
struct res_rec *, struct in_addr);
typedef void (*node_status_fail_function) (struct subnet_record *, struct response_record *);
/* Initiated name queries are recorded in this list to track any responses. */
@ -344,9 +335,10 @@ struct response_record
B nodes will have their own, totally separate subnet record, with their
own netbios name set. These do NOT interact with other subnet records'
netbios names.
*/
*/
enum subnet_type {
enum subnet_type
{
NORMAL_SUBNET = 0, /* Subnet listed in interfaces list. */
UNICAST_SUBNET = 1, /* Subnet for unicast packets. */
REMOTE_BROADCAST_SUBNET = 2, /* Subnet for remote broadcasts. */
@ -354,7 +346,8 @@ enum subnet_type {
};
/* A resource record. */
struct res_rec {
struct res_rec
{
struct nmb_name rr_name;
int rr_type;
int rr_class;
@ -366,11 +359,13 @@ struct res_rec {
/* An nmb packet. */
struct nmb_packet
{
struct {
struct
{
int name_trn_id;
int opcode;
BOOL response;
struct {
struct
{
BOOL bcast;
BOOL recursion_available;
BOOL recursion_desired;
@ -384,7 +379,8 @@ struct nmb_packet
int arcount;
} header;
struct {
struct
{
struct nmb_name question_name;
int question_type;
int question_class;
@ -398,10 +394,13 @@ struct nmb_packet
/* A datagram - this normally contains SMB data in the data[] array. */
struct dgram_packet {
struct {
struct dgram_packet
{
struct
{
int msg_type;
struct {
struct
{
enum node_type node_type;
BOOL first;
BOOL more;
@ -431,7 +430,8 @@ struct packet_struct
int fd;
time_t timestamp;
enum packet_type packet_type;
union {
union
{
struct nmb_packet nmb;
struct dgram_packet dgram;
} packet;
@ -501,5 +501,6 @@ extern struct subnet_record *remote_broadcast_subnet;
#define NEXT_SUBNET_INCLUDING_UNICAST(x) (get_next_subnet_maybe_unicast((x)))
/* To be removed. */
enum state_type { TEST };
enum state_type
{ TEST };
#endif /* _NAMESERV_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
Unix SMB/Netbios implementation.
Version 1.9.
SMB parameters and setup
*/
*/
#ifndef _SMB_H
#define _SMB_H
@ -51,19 +51,20 @@ typedef int BOOL;
arguemnts to DEBUG() right. We have got them wrong too often in the
past */
#ifdef HAVE_STDARG_H
int Debug1( const char *, ... )
int
Debug1 (const char *, ...)
#ifdef __GNUC__
__attribute__ ((format (printf, 1, 2)))
#endif
;
BOOL dbgtext( const char *, ... )
;
BOOL dbgtext (const char *, ...)
#ifdef __GNUC__
__attribute__ ((format (printf, 1, 2)))
#endif
;
;
#else
int Debug1();
BOOL dbgtext();
int Debug1 ();
BOOL dbgtext ();
#endif
/* If we have these macros, we can add additional info to the header. */
@ -136,8 +137,8 @@ BOOL dbgtext();
#define DIR_STRUCT_SIZE 43
/* these define all the command types recognised by the server - there
are lots of gaps so probably there are some rare commands that are not
implemented */
are lots of gaps so probably there are some rare commands that are not
implemented */
#define pSETDIR '\377'
@ -366,10 +367,10 @@ struct sam_passwd
char *dir_drive; /* home directory drive string */
char *logon_script; /* logon script string */
char *profile_path; /* profile path string */
char *acct_desc ; /* user description string */
char *acct_desc; /* user description string */
char *workstations; /* login from workstations string */
char *unknown_str ; /* don't know what this is, yet. */
char *munged_dial ; /* munged path name and dial-back tel number */
char *unknown_str; /* don't know what this is, yet. */
char *munged_dial; /* munged path name and dial-back tel number */
uid_t smb_userid; /* this is actually the unix uid_t */
gid_t smb_grpid; /* this is actually the unix gid_t */
@ -432,9 +433,9 @@ typedef struct sid_info
/* local group member info */
typedef struct local_grp_member_info
{
DOM_SID sid ; /* matches with name */
DOM_SID sid; /* matches with name */
uint8 sid_use; /* usr=1 grp=2 dom=3 alias=4 wkng=5 del=6 inv=7 unk=8 */
fstring name ; /* matches with sid: must be of the form "DOMAIN\account" */
fstring name; /* matches with sid: must be of the form "DOMAIN\account" */
} LOCAL_GRP_MEMBER;
@ -532,7 +533,8 @@ typedef struct
time_t status_time;
} dir_status_struct;
struct uid_cache {
struct uid_cache
{
int entries;
uid_t list[UID_CACHE_SIZE];
};
@ -655,7 +657,8 @@ typedef struct
} user_struct;
enum {LPQ_QUEUED,LPQ_PAUSED,LPQ_SPOOLING,LPQ_PRINTING};
enum
{ LPQ_QUEUED, LPQ_PAUSED, LPQ_SPOOLING, LPQ_PRINTING };
typedef struct
{
@ -668,7 +671,8 @@ typedef struct
char file[100];
} print_queue_struct;
enum {LPSTAT_OK, LPSTAT_STOPPED, LPSTAT_ERROR};
enum
{ LPSTAT_OK, LPSTAT_STOPPED, LPSTAT_ERROR };
typedef struct
{
@ -709,31 +713,34 @@ typedef struct
/* each implementation of the share mode code needs
to support the following operations */
struct share_ops {
BOOL (*stop_mgmt)(void);
BOOL (*lock_entry)(connection_struct *, SMB_DEV_T , SMB_INO_T , int *);
BOOL (*unlock_entry)(connection_struct *, SMB_DEV_T , SMB_INO_T , int );
int (*get_entries)(connection_struct *, int , SMB_DEV_T , SMB_INO_T , share_mode_entry **);
void (*del_entry)(int , files_struct *);
BOOL (*set_entry)(int, files_struct *, uint16 , uint16 );
BOOL (*mod_entry)(int, files_struct *, void (*)(share_mode_entry *, SMB_DEV_T, SMB_INO_T, void *), void *);
int (*forall)(void (*)(share_mode_entry *, char *));
void (*status)(FILE *);
struct share_ops
{
BOOL (*stop_mgmt) (void);
BOOL (*lock_entry) (connection_struct *, SMB_DEV_T, SMB_INO_T, int *);
BOOL (*unlock_entry) (connection_struct *, SMB_DEV_T, SMB_INO_T, int);
int (*get_entries) (connection_struct *, int, SMB_DEV_T, SMB_INO_T, share_mode_entry **);
void (*del_entry) (int, files_struct *);
BOOL (*set_entry) (int, files_struct *, uint16, uint16);
BOOL (*mod_entry) (int, files_struct *,
void (*)(share_mode_entry *, SMB_DEV_T, SMB_INO_T, void *), void *);
int (*forall) (void (*)(share_mode_entry *, char *));
void (*status) (FILE *);
};
/* each implementation of the shared memory code needs
to support the following operations */
struct shmem_ops {
BOOL (*shm_close)( void );
int (*shm_alloc)(int );
BOOL (*shm_free)(int );
int (*get_userdef_off)(void);
void *(*offset2addr)(int );
int (*addr2offset)(void *addr);
BOOL (*lock_hash_entry)(unsigned int);
BOOL (*unlock_hash_entry)( unsigned int );
BOOL (*get_usage)(int *,int *,int *);
unsigned (*hash_size)(void);
struct shmem_ops
{
BOOL (*shm_close) (void);
int (*shm_alloc) (int);
BOOL (*shm_free) (int);
int (*get_userdef_off) (void);
void *(*offset2addr) (int);
int (*addr2offset) (void *addr);
BOOL (*lock_hash_entry) (unsigned int);
BOOL (*unlock_hash_entry) (unsigned int);
BOOL (*get_usage) (int *, int *, int *);
unsigned (*hash_size) (void);
};
/*
@ -741,61 +748,63 @@ struct shmem_ops {
* to support the following operations.
*/
struct passdb_ops {
struct passdb_ops
{
/*
* Password database ops.
*/
void *(*startsmbpwent)(BOOL);
void (*endsmbpwent)(void *);
SMB_BIG_UINT (*getsmbpwpos)(void *);
BOOL (*setsmbpwpos)(void *, SMB_BIG_UINT);
void *(*startsmbpwent) (BOOL);
void (*endsmbpwent) (void *);
SMB_BIG_UINT (*getsmbpwpos) (void *);
BOOL (*setsmbpwpos) (void *, SMB_BIG_UINT);
/*
* smb password database query functions.
*/
struct smb_passwd *(*getsmbpwnam)(char *);
struct smb_passwd *(*getsmbpwuid)(uid_t);
struct smb_passwd *(*getsmbpwrid)(uint32);
struct smb_passwd *(*getsmbpwent)(void *);
struct smb_passwd *(*getsmbpwnam) (char *);
struct smb_passwd *(*getsmbpwuid) (uid_t);
struct smb_passwd *(*getsmbpwrid) (uint32);
struct smb_passwd *(*getsmbpwent) (void *);
/*
* smb password database modification functions.
*/
BOOL (*add_smbpwd_entry)(struct smb_passwd *);
BOOL (*mod_smbpwd_entry)(struct smb_passwd *, BOOL);
BOOL (*add_smbpwd_entry) (struct smb_passwd *);
BOOL (*mod_smbpwd_entry) (struct smb_passwd *, BOOL);
/*
* Functions that manipulate a struct sam_passwd.
*/
struct sam_passwd *(*getsam21pwent)(void *);
struct sam_passwd *(*getsam21pwent) (void *);
/*
* sam password database query functions.
*/
struct sam_passwd *(*getsam21pwnam)(char *);
struct sam_passwd *(*getsam21pwuid)(uid_t);
struct sam_passwd *(*getsam21pwrid)(uint32);
struct sam_passwd *(*getsam21pwnam) (char *);
struct sam_passwd *(*getsam21pwuid) (uid_t);
struct sam_passwd *(*getsam21pwrid) (uint32);
/*
* sam password database modification functions.
*/
BOOL (*add_sam21pwd_entry)(struct sam_passwd *);
BOOL (*mod_sam21pwd_entry)(struct sam_passwd *, BOOL);
BOOL (*add_sam21pwd_entry) (struct sam_passwd *);
BOOL (*mod_sam21pwd_entry) (struct sam_passwd *, BOOL);
/*
* sam query display info functions.
*/
struct sam_disp_info *(*getsamdispnam)(char *);
struct sam_disp_info *(*getsamdisprid)(uint32);
struct sam_disp_info *(*getsamdispent)(void *);
struct sam_disp_info *(*getsamdispnam) (char *);
struct sam_disp_info *(*getsamdisprid) (uint32);
struct sam_disp_info *(*getsamdispent) (void *);
#if 0
/*
* password checking functions
*/
struct smb_passwd *(*smb_password_chal )(char *username, char lm_pass[24], char nt_pass[24], char chal[8]);
struct smb_passwd *(*smb_password_check )(char *username, char lm_hash[16], char nt_hash[16]);
struct passwd *(*unix_password_check)(char *username, char *pass, int pass_len);
struct smb_passwd *(*smb_password_chal) (char *username, char lm_pass[24], char nt_pass[24],
char chal[8]);
struct smb_passwd *(*smb_password_check) (char *username, char lm_hash[16], char nt_hash[16]);
struct passwd *(*unix_password_check) (char *username, char *pass, int pass_len);
#endif
};
@ -815,7 +824,8 @@ struct connect_record
};
/* This is used by smbclient to send it to a smbfs mount point */
struct connection_options {
struct connection_options
{
int protocol;
/* Connection-Options */
uint32 max_xmit;
@ -836,16 +846,17 @@ struct connection_options {
/* the following are used by loadparm for option lists */
typedef enum
{
P_BOOL,P_BOOLREV,P_CHAR,P_INTEGER,P_OCTAL,
P_STRING,P_USTRING,P_GSTRING,P_UGSTRING,P_ENUM,P_SEP
P_BOOL, P_BOOLREV, P_CHAR, P_INTEGER, P_OCTAL,
P_STRING, P_USTRING, P_GSTRING, P_UGSTRING, P_ENUM, P_SEP
} parm_type;
typedef enum
{
P_LOCAL,P_GLOBAL,P_SEPARATOR,P_NONE
P_LOCAL, P_GLOBAL, P_SEPARATOR, P_NONE
} parm_class;
struct enum_list {
struct enum_list
{
int value;
const char *name;
};
@ -856,10 +867,11 @@ struct parm_struct
parm_type type;
parm_class class;
void *ptr;
BOOL (*special)(const char *, char **);
BOOL (*special) (const char *, char **);
const struct enum_list *enum_list;
unsigned flags;
union {
union
{
BOOL bvalue;
int ivalue;
char *svalue;
@ -867,7 +879,8 @@ struct parm_struct
} def;
};
struct bitmap {
struct bitmap
{
uint32 *b;
int n;
};
@ -1000,7 +1013,7 @@ struct bitmap {
#define SMBexit 0x11 /* process exit */
#define SMBlseek 0x12 /* seek */
#define SMBtcon 0x70 /* tree connect */
#define SMBtconX 0x75 /* tree connect and X*/
#define SMBtconX 0x75 /* tree connect and X */
#define SMBtdis 0x71 /* tree disconnect */
#define SMBnegprot 0x72 /* negotiate protocol */
#define SMBdskattr 0x80 /* get disk attributes */
@ -1318,22 +1331,23 @@ struct bitmap {
#define SMB_SUCCESS 0 /* The request was successful. */
#define ERRDOS 0x01 /* Error is from the core DOS operating system set. */
#define ERRSRV 0x02 /* Error is generated by the server network file manager.*/
#define ERRSRV 0x02 /* Error is generated by the server network file manager. */
#define ERRHRD 0x03 /* Error is an hardware error. */
#define ERRCMD 0xFF /* Command was not in the "SMB" format. */
#ifdef HAVE_STDARG_H
int slprintf(char *str, int n, const char *format, ...)
int
slprintf (char *str, int n, const char *format, ...)
#ifdef __GNUC__
__attribute__ ((format (printf, 3, 4)))
#endif
;
;
#else
int slprintf();
int slprintf ();
#endif
#ifdef WITH_DFS
void dfs_unlogin(void);
void dfs_unlogin (void);
extern int dcelogin_atmost_once;
#endif
@ -1474,24 +1488,33 @@ extern int dcelogin_atmost_once;
/* protocol types. It assumes that higher protocols include lower protocols
as subsets */
enum protocol_types {PROTOCOL_NONE,PROTOCOL_CORE,PROTOCOL_COREPLUS,PROTOCOL_LANMAN1,PROTOCOL_LANMAN2,PROTOCOL_NT1};
enum protocol_types
{ PROTOCOL_NONE, PROTOCOL_CORE, PROTOCOL_COREPLUS, PROTOCOL_LANMAN1, PROTOCOL_LANMAN2,
PROTOCOL_NT1
};
/* security levels */
enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER,SEC_DOMAIN};
enum security_types
{ SEC_SHARE, SEC_USER, SEC_SERVER, SEC_DOMAIN };
/* printing types */
enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,
PRINT_QNX,PRINT_PLP,PRINT_LPRNG,PRINT_SOFTQ};
enum printing_types
{ PRINT_BSD, PRINT_SYSV, PRINT_AIX, PRINT_HPUX,
PRINT_QNX, PRINT_PLP, PRINT_LPRNG, PRINT_SOFTQ
};
/* Remote architectures we know about. */
enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT, RA_SAMBA};
enum remote_arch_types
{ RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT, RA_SAMBA };
/* case handling */
enum case_handling {CASE_LOWER,CASE_UPPER};
enum case_handling
{ CASE_LOWER, CASE_UPPER };
#ifdef WITH_SSL
/* SSL version options */
enum ssl_version_enum {SMB_SSL_V2,SMB_SSL_V3,SMB_SSL_V23,SMB_SSL_TLS1};
enum ssl_version_enum
{ SMB_SSL_V2, SMB_SSL_V3, SMB_SSL_V23, SMB_SSL_TLS1 };
#endif /* WITH_SSL */
/* Macros to get at offsets within smb_lkrng and smb_unlkrng
@ -1677,7 +1700,8 @@ extern int unix_ERR_code;
#define SMB_ASSERT_ARRAY(a,n) SMB_ASSERT((sizeof(a)/sizeof((a)[0])) >= (n))
/* A netbios name structure. */
struct nmb_name {
struct nmb_name
{
char name[17];
char scope[64];
unsigned int name_type;
@ -1710,7 +1734,7 @@ struct nmb_name {
Note that map_to_guest only has an effect in user or server
level security.
*/
*/
#define NEVER_MAP_TO_GUEST 0
#define MAP_TO_GUEST_ON_BAD_USER 1

View File

@ -2,7 +2,7 @@
Unix SMB/Netbios implementation.
Version 1.9.
SMB transaction2 handling
*/
*/
#ifndef _TRANS2_H_
#define _TRANS2_H_
@ -243,6 +243,3 @@ Byte offset Type name description
#define TYPE_VIRTUAL 0x40
#endif

View File

@ -22,7 +22,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "includes.h"
#define CTRLZ 26
@ -35,31 +35,42 @@ static BOOL mapsinited = 0;
static char unix2dos[256];
static char dos2unix[256];
static void initmaps(void) {
static void
initmaps (void)
{
int k;
for (k = 0; k < 256; k++) unix2dos[k] = k;
for (k = 0; k < 256; k++) dos2unix[k] = k;
for (k = 0; k < 256; k++)
unix2dos[k] = k;
for (k = 0; k < 256; k++)
dos2unix[k] = k;
mapsinited = True;
}
static void update_map(const char * str) {
static void
update_map (const char *str)
{
const char *p;
for (p = str; *p; p++) {
if (p[1]) {
unix2dos[(unsigned char)*p] = p[1];
dos2unix[(unsigned char)p[1]] = *p;
for (p = str; *p; p++)
{
if (p[1])
{
unix2dos[(unsigned char) *p] = p[1];
dos2unix[(unsigned char) p[1]] = *p;
p++;
}
}
}
static void init_iso8859_1(void) {
static void
init_iso8859_1 (void)
{
int i;
if (!mapsinited) initmaps();
if (!mapsinited)
initmaps ();
/* Do not map undefined characters to some accidental code */
for (i = 128; i < 256; i++)
@ -68,28 +79,31 @@ static void init_iso8859_1(void) {
dos2unix[i] = CTRLZ;
}
/* MSDOS Code Page 850 -> ISO-8859 */
update_map("\240\377\241\255\242\275\243\234\244\317\245\276\246\335\247\365");
update_map("\250\371\251\270\252\246\253\256\254\252\255\360\256\251\257\356");
update_map("\260\370\261\361\262\375\263\374\264\357\265\346\266\364\267\372");
update_map("\270\367\271\373\272\247\273\257\274\254\275\253\276\363\277\250");
update_map("\300\267\301\265\302\266\303\307\304\216\305\217\306\222\307\200");
update_map("\310\324\311\220\312\322\313\323\314\336\315\326\316\327\317\330");
update_map("\320\321\321\245\322\343\323\340\324\342\325\345\326\231\327\236");
update_map("\330\235\331\353\332\351\333\352\334\232\335\355\336\350\337\341");
update_map("\340\205\341\240\342\203\343\306\344\204\345\206\346\221\347\207");
update_map("\350\212\351\202\352\210\353\211\354\215\355\241\356\214\357\213");
update_map("\360\320\361\244\362\225\363\242\364\223\365\344\366\224\367\366");
update_map("\370\233\371\227\372\243\373\226\374\201\375\354\376\347\377\230");
/* MSDOS Code Page 850 -> ISO-8859 */
update_map ("\240\377\241\255\242\275\243\234\244\317\245\276\246\335\247\365");
update_map ("\250\371\251\270\252\246\253\256\254\252\255\360\256\251\257\356");
update_map ("\260\370\261\361\262\375\263\374\264\357\265\346\266\364\267\372");
update_map ("\270\367\271\373\272\247\273\257\274\254\275\253\276\363\277\250");
update_map ("\300\267\301\265\302\266\303\307\304\216\305\217\306\222\307\200");
update_map ("\310\324\311\220\312\322\313\323\314\336\315\326\316\327\317\330");
update_map ("\320\321\321\245\322\343\323\340\324\342\325\345\326\231\327\236");
update_map ("\330\235\331\353\332\351\333\352\334\232\335\355\336\350\337\341");
update_map ("\340\205\341\240\342\203\343\306\344\204\345\206\346\221\347\207");
update_map ("\350\212\351\202\352\210\353\211\354\215\355\241\356\214\357\213");
update_map ("\360\320\361\244\362\225\363\242\364\223\365\344\366\224\367\366");
update_map ("\370\233\371\227\372\243\373\226\374\201\375\354\376\347\377\230");
}
/* Init for eastern european languages. */
static void init_iso8859_2(void) {
static void
init_iso8859_2 (void)
{
int i;
if (!mapsinited) initmaps();
if (!mapsinited)
initmaps ();
/* Do not map undefined characters to some accidental code */
for (i = 128; i < 256; i++)
@ -98,35 +112,37 @@ static void init_iso8859_2(void) {
dos2unix[i] = CTRLZ;
}
/*
/*
* Tranlation table created by Petr Hubeny <psh@capitol.cz>
* Requires client code page = 852
* and character set = ISO8859-2 in smb.conf
*/
/* MSDOS Code Page 852 -> ISO-8859-2 */
update_map("\241\244\242\364\243\235\244\317\245\225\246\227\247\365");
update_map("\250\371\251\346\252\270\253\233\254\215\256\246\257\275");
update_map("\261\245\262\362\263\210\264\357\265\226\266\230\267\363");
update_map("\270\367\271\347\272\255\273\234\274\253\275\361\276\247\277\276");
update_map("\300\350\301\265\302\266\303\306\304\216\305\221\306\217\307\200");
update_map("\310\254\311\220\312\250\313\323\314\267\315\326\316\327\317\322");
update_map("\320\321\321\343\322\325\323\340\324\342\325\212\326\231\327\236");
update_map("\330\374\331\336\332\351\333\353\334\232\335\355\336\335\337\341");
update_map("\340\352\341\240\342\203\343\307\344\204\345\222\346\206\347\207");
update_map("\350\237\351\202\352\251\353\211\354\330\355\241\356\214\357\324");
update_map("\360\320\361\344\362\345\363\242\364\223\365\213\366\224\367\366");
update_map("\370\375\371\205\372\243\373\373\374\201\375\354\376\356\377\372");
/* MSDOS Code Page 852 -> ISO-8859-2 */
update_map ("\241\244\242\364\243\235\244\317\245\225\246\227\247\365");
update_map ("\250\371\251\346\252\270\253\233\254\215\256\246\257\275");
update_map ("\261\245\262\362\263\210\264\357\265\226\266\230\267\363");
update_map ("\270\367\271\347\272\255\273\234\274\253\275\361\276\247\277\276");
update_map ("\300\350\301\265\302\266\303\306\304\216\305\221\306\217\307\200");
update_map ("\310\254\311\220\312\250\313\323\314\267\315\326\316\327\317\322");
update_map ("\320\321\321\343\322\325\323\340\324\342\325\212\326\231\327\236");
update_map ("\330\374\331\336\332\351\333\353\334\232\335\355\336\335\337\341");
update_map ("\340\352\341\240\342\203\343\307\344\204\345\222\346\206\347\207");
update_map ("\350\237\351\202\352\251\353\211\354\330\355\241\356\214\357\324");
update_map ("\360\320\361\344\362\345\363\242\364\223\365\213\366\224\367\366");
update_map ("\370\375\371\205\372\243\373\373\374\201\375\354\376\356\377\372");
}
/* Init for russian language (iso8859-5) */
/* Added by Max Khon <max@iclub.nsu.ru> */
static void init_iso8859_5(void)
static void
init_iso8859_5 (void)
{
int i;
if (!mapsinited) initmaps();
if (!mapsinited)
initmaps ();
/* Do not map undefined characters to some accidental code */
for (i = 128; i < 256; i++)
@ -135,62 +151,70 @@ static void init_iso8859_5(void)
dos2unix[i] = CTRLZ;
}
/* MSDOS Code Page 866 -> ISO8859-5 */
update_map("\260\200\261\201\262\202\263\203\264\204\265\205\266\206\267\207");
update_map("\270\210\271\211\272\212\273\213\274\214\275\215\276\216\277\217");
update_map("\300\220\301\221\302\222\303\223\304\224\305\225\306\226\307\227");
update_map("\310\230\311\231\312\232\313\233\314\234\315\235\316\236\317\237");
update_map("\320\240\321\241\322\242\323\243\324\244\325\245\326\246\327\247");
update_map("\330\250\331\251\332\252\333\253\334\254\335\255\336\256\337\257");
update_map("\340\340\341\341\342\342\343\343\344\344\345\345\346\346\347\347");
update_map("\350\350\351\351\352\352\353\353\354\354\355\355\356\356\357\357");
update_map("\241\360\361\361\244\362\364\363\247\364\367\365\256\366\376\367");
update_map("\360\374\240\377");
/* MSDOS Code Page 866 -> ISO8859-5 */
update_map ("\260\200\261\201\262\202\263\203\264\204\265\205\266\206\267\207");
update_map ("\270\210\271\211\272\212\273\213\274\214\275\215\276\216\277\217");
update_map ("\300\220\301\221\302\222\303\223\304\224\305\225\306\226\307\227");
update_map ("\310\230\311\231\312\232\313\233\314\234\315\235\316\236\317\237");
update_map ("\320\240\321\241\322\242\323\243\324\244\325\245\326\246\327\247");
update_map ("\330\250\331\251\332\252\333\253\334\254\335\255\336\256\337\257");
update_map ("\340\340\341\341\342\342\343\343\344\344\345\345\346\346\347\347");
update_map ("\350\350\351\351\352\352\353\353\354\354\355\355\356\356\357\357");
update_map ("\241\360\361\361\244\362\364\363\247\364\367\365\256\366\376\367");
update_map ("\360\374\240\377");
}
/* Init for russian language (koi8) */
static void init_koi8_r(void)
static void
init_koi8_r (void)
{
if (!mapsinited) initmaps();
if (!mapsinited)
initmaps ();
/* There aren't undefined characters between 128 and 255 */
/* MSDOS Code Page 866 -> KOI8-R */
update_map("\200\304\201\263\202\332\203\277\204\300\205\331\206\303\207\264");
update_map("\210\302\211\301\212\305\213\337\214\334\215\333\216\335\217\336");
update_map("\220\260\221\261\222\262\223\364\224\376\225\371\226\373\227\367");
update_map("\230\363\231\362\232\377\233\365\234\370\235\375\236\372\237\366");
update_map("\240\315\241\272\242\325\243\361\244\326\245\311\246\270\247\267");
update_map("\250\273\251\324\252\323\253\310\254\276\255\275\256\274\257\306");
update_map("\260\307\261\314\262\265\263\360\264\266\265\271\266\321\267\322");
update_map("\270\313\271\317\272\320\273\312\274\330\275\327\276\316\277\374");
update_map("\300\356\301\240\302\241\303\346\304\244\305\245\306\344\307\243");
update_map("\310\345\311\250\312\251\313\252\314\253\315\254\316\255\317\256");
update_map("\320\257\321\357\322\340\323\341\324\342\325\343\326\246\327\242");
update_map("\330\354\331\353\332\247\333\350\334\355\335\351\336\347\337\352");
update_map("\340\236\341\200\342\201\343\226\344\204\345\205\346\224\347\203");
update_map("\350\225\351\210\352\211\353\212\354\213\355\214\356\215\357\216");
update_map("\360\217\361\237\362\220\363\221\364\222\365\223\366\206\367\202");
update_map("\370\234\371\233\372\207\373\230\374\235\375\231\376\227\377\232");
/* MSDOS Code Page 866 -> KOI8-R */
update_map ("\200\304\201\263\202\332\203\277\204\300\205\331\206\303\207\264");
update_map ("\210\302\211\301\212\305\213\337\214\334\215\333\216\335\217\336");
update_map ("\220\260\221\261\222\262\223\364\224\376\225\371\226\373\227\367");
update_map ("\230\363\231\362\232\377\233\365\234\370\235\375\236\372\237\366");
update_map ("\240\315\241\272\242\325\243\361\244\326\245\311\246\270\247\267");
update_map ("\250\273\251\324\252\323\253\310\254\276\255\275\256\274\257\306");
update_map ("\260\307\261\314\262\265\263\360\264\266\265\271\266\321\267\322");
update_map ("\270\313\271\317\272\320\273\312\274\330\275\327\276\316\277\374");
update_map ("\300\356\301\240\302\241\303\346\304\244\305\245\306\344\307\243");
update_map ("\310\345\311\250\312\251\313\252\314\253\315\254\316\255\317\256");
update_map ("\320\257\321\357\322\340\323\341\324\342\325\343\326\246\327\242");
update_map ("\330\354\331\353\332\247\333\350\334\355\335\351\336\347\337\352");
update_map ("\340\236\341\200\342\201\343\226\344\204\345\205\346\224\347\203");
update_map ("\350\225\351\210\352\211\353\212\354\213\355\214\356\215\357\216");
update_map ("\360\217\361\237\362\220\363\221\364\222\365\223\366\206\367\202");
update_map ("\370\234\371\233\372\207\373\230\374\235\375\231\376\227\377\232");
}
/*
* Convert unix to dos
*/
char *unix2dos_format(char *str,BOOL overwrite)
char *
unix2dos_format (char *str, BOOL overwrite)
{
char *p;
char *dp;
if (!mapsinited) initmaps();
if (!mapsinited)
initmaps ();
if (overwrite) {
for (p = str; *p; p++) *p = unix2dos[(unsigned char)*p];
if (overwrite)
{
for (p = str; *p; p++)
*p = unix2dos[(unsigned char) *p];
return str;
} else {
for (p = str, dp = cvtbuf; *p && dp < &(cvtbuf[sizeof(cvtbuf) - 1]); p++,dp++)
*dp = unix2dos[(unsigned char)*p];
}
else
{
for (p = str, dp = cvtbuf; *p && dp < &(cvtbuf[sizeof (cvtbuf) - 1]); p++, dp++)
*dp = unix2dos[(unsigned char) *p];
*dp = 0;
return cvtbuf;
}
@ -199,19 +223,25 @@ char *unix2dos_format(char *str,BOOL overwrite)
/*
* Convert dos to unix
*/
char *dos2unix_format(char *str, BOOL overwrite)
char *
dos2unix_format (char *str, BOOL overwrite)
{
char *p;
char *dp;
if (!mapsinited) initmaps();
if (!mapsinited)
initmaps ();
if (overwrite) {
for (p = str; *p; p++) *p = dos2unix[(unsigned char)*p];
if (overwrite)
{
for (p = str; *p; p++)
*p = dos2unix[(unsigned char) *p];
return str;
} else {
for (p = str, dp = cvtbuf; *p && dp < &(cvtbuf[sizeof(cvtbuf) - 1]); p++,dp++)
*dp = dos2unix[(unsigned char)*p];
}
else
{
for (p = str, dp = cvtbuf; *p && dp < &(cvtbuf[sizeof (cvtbuf) - 1]); p++, dp++)
*dp = dos2unix[(unsigned char) *p];
*dp = 0;
return cvtbuf;
}
@ -221,17 +251,27 @@ char *dos2unix_format(char *str, BOOL overwrite)
/*
* Interpret character set.
*/
void interpret_character_set(const char *str)
void
interpret_character_set (const char *str)
{
if (strequal (str, "iso8859-1")) {
init_iso8859_1();
} else if (strequal (str, "iso8859-2")) {
init_iso8859_2();
} else if (strequal (str, "iso8859-5")) {
init_iso8859_5();
} else if (strequal (str, "koi8-r")) {
init_koi8_r();
} else {
DEBUG(0,("unrecognized character set %s\n", str));
if (strequal (str, "iso8859-1"))
{
init_iso8859_1 ();
}
else if (strequal (str, "iso8859-2"))
{
init_iso8859_2 ();
}
else if (strequal (str, "iso8859-5"))
{
init_iso8859_5 ();
}
else if (strequal (str, "koi8-r"))
{
init_koi8_r ();
}
else
{
DEBUG (0, ("unrecognized character set %s\n", str));
}
}

View File

@ -22,7 +22,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#define CHARSET_C
#include "includes.h"
@ -37,75 +37,75 @@ extern int DEBUGLEVEL;
#if !defined(KANJI)
/* lower->upper mapping for IBM Code Page 850 - MS-DOS Latin 1 */
unsigned char const cp_850[][4] = {
/* dec col/row oct hex description */
/* 133 08/05 205 85 a grave */
/* 183 11/07 267 B7 A grave */ {0x85,0xB7,1,1},
/* 160 10/00 240 A0 a acute */
/* 181 11/05 265 B5 A acute */ {0xA0,0xB5,1,1},
/* 131 08/03 203 83 a circumflex */
/* 182 11/06 266 B6 A circumflex */ {0x83,0xB6,1,1},
/* 198 12/06 306 C6 a tilde */
/* 199 12/07 307 C7 A tilde */ {0xC6,0xC7,1,1},
/* 132 08/04 204 84 a diaeresis */
/* 142 08/14 216 8E A diaeresis */ {0x84,0x8E,1,1},
/* 134 08/06 206 86 a ring */
/* 143 08/15 217 8F A ring */ {0x86,0x8F,1,1},
/* 145 09/01 221 91 ae diphthong */
/* 146 09/02 222 92 AE diphthong */ {0x91,0x92,1,1},
/* 135 08/07 207 87 c cedilla */
/* 128 08/00 200 80 C cedilla */ {0x87,0x80,1,1},
/* 138 08/10 212 8A e grave */
/* 212 13/04 324 D4 E grave */ {0x8A,0xD4,1,1},
/* 130 08/02 202 82 e acute */
/* 144 09/00 220 90 E acute */ {0x82,0x90,1,1},
/* 136 08/08 210 88 e circumflex */
/* 210 13/02 322 D2 E circumflex */ {0x88,0xD2,1,1},
/* 137 08/09 211 89 e diaeresis */
/* 211 13/03 323 D3 E diaeresis */ {0x89,0xD3,1,1},
/* 141 08/13 215 8D i grave */
/* 222 13/14 336 DE I grave */ {0x8D,0xDE,1,1},
/* 161 10/01 241 A1 i acute */
/* 214 13/06 326 D6 I acute */ {0xA1,0xD6,1,1},
/* 140 08/12 214 8C i circumflex */
/* 215 13/07 327 D7 I circumflex */ {0x8C,0xD7,1,1},
/* 139 08/11 213 8B i diaeresis */
/* 216 13/08 330 D8 I diaeresis */ {0x8B,0xD8,1,1},
/* 208 13/00 320 D0 Icelandic eth */
/* 209 13/01 321 D1 Icelandic Eth */ {0xD0,0xD1,1,1},
/* 164 10/04 244 A4 n tilde */
/* 165 10/05 245 A5 N tilde */ {0xA4,0xA5,1,1},
/* 149 09/05 225 95 o grave */
/* 227 14/03 343 E3 O grave */ {0x95,0xE3,1,1},
/* 162 10/02 242 A2 o acute */
/* 224 14/00 340 E0 O acute */ {0xA2,0xE0,1,1},
/* 147 09/03 223 93 o circumflex */
/* 226 14/02 342 E2 O circumflex */ {0x93,0xE2,1,1},
/* 228 14/04 344 E4 o tilde */
/* 229 14/05 345 E5 O tilde */ {0xE4,0xE5,1,1},
/* 148 09/04 224 94 o diaeresis */
/* 153 09/09 231 99 O diaeresis */ {0x94,0x99,1,1},
/* 155 09/11 233 9B o slash */
/* 157 09/13 235 9D O slash */ {0x9B,0x9D,1,1},
/* 151 09/07 227 97 u grave */
/* 235 14/11 353 EB U grave */ {0x97,0xEB,1,1},
/* 163 10/03 243 A3 u acute */
/* 233 14/09 351 E9 U acute */ {0xA3,0xE9,1,1},
/* 150 09/06 226 96 u circumflex */
/* 234 14/10 352 EA U circumflex */ {0x96,0xEA,1,1},
/* 129 08/01 201 81 u diaeresis */
/* 154 09/10 232 9A U diaeresis */ {0x81,0x9A,1,1},
/* 236 14/12 354 EC y acute */
/* 237 14/13 355 ED Y acute */ {0xEC,0xED,1,1},
/* 231 14/07 347 E7 Icelandic thorn */
/* 232 14/08 350 E8 Icelandic Thorn */ {0xE7,0xE8,1,1},
/* dec col/row oct hex description */
/* 133 08/05 205 85 a grave */
/* 183 11/07 267 B7 A grave */ {0x85, 0xB7, 1, 1},
/* 160 10/00 240 A0 a acute */
/* 181 11/05 265 B5 A acute */ {0xA0, 0xB5, 1, 1},
/* 131 08/03 203 83 a circumflex */
/* 182 11/06 266 B6 A circumflex */ {0x83, 0xB6, 1, 1},
/* 198 12/06 306 C6 a tilde */
/* 199 12/07 307 C7 A tilde */ {0xC6, 0xC7, 1, 1},
/* 132 08/04 204 84 a diaeresis */
/* 142 08/14 216 8E A diaeresis */ {0x84, 0x8E, 1, 1},
/* 134 08/06 206 86 a ring */
/* 143 08/15 217 8F A ring */ {0x86, 0x8F, 1, 1},
/* 145 09/01 221 91 ae diphthong */
/* 146 09/02 222 92 AE diphthong */ {0x91, 0x92, 1, 1},
/* 135 08/07 207 87 c cedilla */
/* 128 08/00 200 80 C cedilla */ {0x87, 0x80, 1, 1},
/* 138 08/10 212 8A e grave */
/* 212 13/04 324 D4 E grave */ {0x8A, 0xD4, 1, 1},
/* 130 08/02 202 82 e acute */
/* 144 09/00 220 90 E acute */ {0x82, 0x90, 1, 1},
/* 136 08/08 210 88 e circumflex */
/* 210 13/02 322 D2 E circumflex */ {0x88, 0xD2, 1, 1},
/* 137 08/09 211 89 e diaeresis */
/* 211 13/03 323 D3 E diaeresis */ {0x89, 0xD3, 1, 1},
/* 141 08/13 215 8D i grave */
/* 222 13/14 336 DE I grave */ {0x8D, 0xDE, 1, 1},
/* 161 10/01 241 A1 i acute */
/* 214 13/06 326 D6 I acute */ {0xA1, 0xD6, 1, 1},
/* 140 08/12 214 8C i circumflex */
/* 215 13/07 327 D7 I circumflex */ {0x8C, 0xD7, 1, 1},
/* 139 08/11 213 8B i diaeresis */
/* 216 13/08 330 D8 I diaeresis */ {0x8B, 0xD8, 1, 1},
/* 208 13/00 320 D0 Icelandic eth */
/* 209 13/01 321 D1 Icelandic Eth */ {0xD0, 0xD1, 1, 1},
/* 164 10/04 244 A4 n tilde */
/* 165 10/05 245 A5 N tilde */ {0xA4, 0xA5, 1, 1},
/* 149 09/05 225 95 o grave */
/* 227 14/03 343 E3 O grave */ {0x95, 0xE3, 1, 1},
/* 162 10/02 242 A2 o acute */
/* 224 14/00 340 E0 O acute */ {0xA2, 0xE0, 1, 1},
/* 147 09/03 223 93 o circumflex */
/* 226 14/02 342 E2 O circumflex */ {0x93, 0xE2, 1, 1},
/* 228 14/04 344 E4 o tilde */
/* 229 14/05 345 E5 O tilde */ {0xE4, 0xE5, 1, 1},
/* 148 09/04 224 94 o diaeresis */
/* 153 09/09 231 99 O diaeresis */ {0x94, 0x99, 1, 1},
/* 155 09/11 233 9B o slash */
/* 157 09/13 235 9D O slash */ {0x9B, 0x9D, 1, 1},
/* 151 09/07 227 97 u grave */
/* 235 14/11 353 EB U grave */ {0x97, 0xEB, 1, 1},
/* 163 10/03 243 A3 u acute */
/* 233 14/09 351 E9 U acute */ {0xA3, 0xE9, 1, 1},
/* 150 09/06 226 96 u circumflex */
/* 234 14/10 352 EA U circumflex */ {0x96, 0xEA, 1, 1},
/* 129 08/01 201 81 u diaeresis */
/* 154 09/10 232 9A U diaeresis */ {0x81, 0x9A, 1, 1},
/* 236 14/12 354 EC y acute */
/* 237 14/13 355 ED Y acute */ {0xEC, 0xED, 1, 1},
/* 231 14/07 347 E7 Icelandic thorn */
/* 232 14/08 350 E8 Icelandic Thorn */ {0xE7, 0xE8, 1, 1},
{0x9C,0,0,0}, /* Pound */
{0,0,0,0}
{0x9C, 0, 0, 0}, /* Pound */
{0, 0, 0, 0}
};
#else /* KANJI */
/* lower->upper mapping for IBM Code Page 932 - MS-DOS Japanese SJIS */
unsigned char const cp_932[][4] = {
{0,0,0,0}
{0, 0, 0, 0}
};
#endif /* KANJI */
@ -128,58 +128,67 @@ char *lower_char_map = xx_lower_char_map;
* mapping from lower to upper, but not upper to lower.
*/
static void add_dos_char(int lower, BOOL map_lower_to_upper,
int upper, BOOL map_upper_to_lower)
static void
add_dos_char (int lower, BOOL map_lower_to_upper, int upper, BOOL map_upper_to_lower)
{
lower &= 0xff;
upper &= 0xff;
DEBUGADD( 6, ( "Adding chars 0x%x 0x%x (l->u = %s) (u->l = %s)\n",
DEBUGADD (6, ("Adding chars 0x%x 0x%x (l->u = %s) (u->l = %s)\n",
lower, upper,
map_lower_to_upper ? "True" : "False",
map_upper_to_lower ? "True" : "False" ) );
if (lower) dos_char_map[lower] = 1;
if (upper) dos_char_map[upper] = 1;
lower_char_map[lower] = (char)lower; /* Define tolower(lower) */
upper_char_map[upper] = (char)upper; /* Define toupper(upper) */
if (lower && upper) {
if(map_upper_to_lower)
lower_char_map[upper] = (char)lower;
if(map_lower_to_upper)
upper_char_map[lower] = (char)upper;
map_lower_to_upper ? "True" : "False", map_upper_to_lower ? "True" : "False"));
if (lower)
dos_char_map[lower] = 1;
if (upper)
dos_char_map[upper] = 1;
lower_char_map[lower] = (char) lower; /* Define tolower(lower) */
upper_char_map[upper] = (char) upper; /* Define toupper(upper) */
if (lower && upper)
{
if (map_upper_to_lower)
lower_char_map[upper] = (char) lower;
if (map_lower_to_upper)
upper_char_map[lower] = (char) upper;
}
}
/****************************************************************************
initialise the charset arrays
****************************************************************************/
void charset_initialise(void)
void
charset_initialise (void)
{
int i;
#ifdef LC_ALL
/* include <locale.h> in includes.h if available for OS */
/* we take only standard 7-bit ASCII definitions from ctype */
setlocale(LC_ALL,"C");
setlocale (LC_ALL, "C");
#endif
for (i= 0;i<=255;i++) {
for (i = 0; i <= 255; i++)
{
dos_char_map[i] = 0;
}
for (i=0;i<=127;i++) {
if (isalnum(i) || strchr("._^$~!#%&-{}()@'`",(char)i))
add_dos_char(i,False,0,False);
for (i = 0; i <= 127; i++)
{
if (isalnum (i) || strchr ("._^$~!#%&-{}()@'`", (char) i))
add_dos_char (i, False, 0, False);
}
for (i=0; i<=255; i++) {
char c = (char)i;
for (i = 0; i <= 255; i++)
{
char c = (char) i;
upper_char_map[i] = lower_char_map[i] = c;
/* Some systems have buggy isupper/islower for characters
above 127. Best not to rely on them. */
if(i < 128) {
if (isupper((int)c)) lower_char_map[i] = tolower(c);
if (islower((int)c)) upper_char_map[i] = toupper(c);
if (i < 128)
{
if (isupper ((int) c))
lower_char_map[i] = tolower (c);
if (islower ((int) c))
upper_char_map[i] = toupper (c);
}
}
}
@ -190,7 +199,8 @@ load the client codepage.
typedef const unsigned char (*codepage_p)[4];
static codepage_p load_client_codepage( int client_codepage )
static codepage_p
load_client_codepage (int client_codepage)
{
pstring codepage_file_name;
unsigned char buf[8];
@ -199,26 +209,23 @@ static codepage_p load_client_codepage( int client_codepage )
codepage_p cp_p = NULL;
SMB_STRUCT_STAT st;
DEBUG(5, ("load_client_codepage: loading codepage %d.\n", client_codepage));
DEBUG (5, ("load_client_codepage: loading codepage %d.\n", client_codepage));
if(strlen(CODEPAGEDIR) + 14 > sizeof(codepage_file_name))
if (strlen (CODEPAGEDIR) + 14 > sizeof (codepage_file_name))
{
DEBUG(0,("load_client_codepage: filename too long to load\n"));
DEBUG (0, ("load_client_codepage: filename too long to load\n"));
return NULL;
}
pstrcpy(codepage_file_name, CODEPAGEDIR);
pstrcat(codepage_file_name, "/");
pstrcat(codepage_file_name, "codepage.");
slprintf(&codepage_file_name[strlen(codepage_file_name)],
sizeof(pstring)-(strlen(codepage_file_name)+1),
"%03d",
client_codepage);
pstrcpy (codepage_file_name, CODEPAGEDIR);
pstrcat (codepage_file_name, "/");
pstrcat (codepage_file_name, "codepage.");
slprintf (&codepage_file_name[strlen (codepage_file_name)],
sizeof (pstring) - (strlen (codepage_file_name) + 1), "%03d", client_codepage);
if(sys_stat(codepage_file_name,&st)!=0)
if (sys_stat (codepage_file_name, &st) != 0)
{
DEBUG(0,("load_client_codepage: filename %s does not exist.\n",
codepage_file_name));
DEBUG (0, ("load_client_codepage: filename %s does not exist.\n", codepage_file_name));
return NULL;
}
@ -229,10 +236,10 @@ static codepage_p load_client_codepage( int client_codepage )
*/
size = st.st_size;
if( size < CODEPAGE_HEADER_SIZE || size > (CODEPAGE_HEADER_SIZE + 4 * MAXCODEPAGELINES))
if (size < CODEPAGE_HEADER_SIZE || size > (CODEPAGE_HEADER_SIZE + 4 * MAXCODEPAGELINES))
{
DEBUG(0,("load_client_codepage: file %s is an incorrect size for a \
code page file (size=%d).\n", codepage_file_name, (int)size));
DEBUG (0, ("load_client_codepage: file %s is an incorrect size for a \
code page file (size=%d).\n", codepage_file_name, (int) size));
return NULL;
}
@ -241,125 +248,119 @@ code page file (size=%d).\n", codepage_file_name, (int)size));
is held in little endian format.
*/
if((fp = sys_fopen( codepage_file_name, "r")) == NULL)
if ((fp = sys_fopen (codepage_file_name, "r")) == NULL)
{
DEBUG(0,("load_client_codepage: cannot open file %s. Error was %s\n",
DEBUG (0, ("load_client_codepage: cannot open file %s. Error was %s\n",
codepage_file_name, unix_error_string (errno)));
return NULL;
}
if(fread( buf, 1, CODEPAGE_HEADER_SIZE, fp)!=CODEPAGE_HEADER_SIZE)
if (fread (buf, 1, CODEPAGE_HEADER_SIZE, fp) != CODEPAGE_HEADER_SIZE)
{
DEBUG(0,("load_client_codepage: cannot read header from file %s. Error was %s\n",
DEBUG (0, ("load_client_codepage: cannot read header from file %s. Error was %s\n",
codepage_file_name, unix_error_string (errno)));
goto clean_and_exit;
}
/* Check the version value */
if(SVAL(buf,CODEPAGE_VERSION_OFFSET) != CODEPAGE_FILE_VERSION_ID)
if (SVAL (buf, CODEPAGE_VERSION_OFFSET) != CODEPAGE_FILE_VERSION_ID)
{
DEBUG(0,("load_client_codepage: filename %s has incorrect version id. \
Needed %hu, got %hu.\n",
codepage_file_name, (uint16)CODEPAGE_FILE_VERSION_ID,
SVAL(buf,CODEPAGE_VERSION_OFFSET)));
DEBUG (0, ("load_client_codepage: filename %s has incorrect version id. \
Needed %hu, got %hu.\n", codepage_file_name, (uint16) CODEPAGE_FILE_VERSION_ID, SVAL (buf, CODEPAGE_VERSION_OFFSET)));
goto clean_and_exit;
}
/* Check the codepage matches */
if(SVAL(buf,CODEPAGE_CLIENT_CODEPAGE_OFFSET) != (uint16)client_codepage)
if (SVAL (buf, CODEPAGE_CLIENT_CODEPAGE_OFFSET) != (uint16) client_codepage)
{
DEBUG(0,("load_client_codepage: filename %s has incorrect codepage. \
Needed %hu, got %hu.\n",
codepage_file_name, (uint16)client_codepage,
SVAL(buf,CODEPAGE_CLIENT_CODEPAGE_OFFSET)));
DEBUG (0, ("load_client_codepage: filename %s has incorrect codepage. \
Needed %hu, got %hu.\n", codepage_file_name, (uint16) client_codepage, SVAL (buf, CODEPAGE_CLIENT_CODEPAGE_OFFSET)));
goto clean_and_exit;
}
/* Check the length is correct. */
if(IVAL(buf,CODEPAGE_LENGTH_OFFSET) != (size - CODEPAGE_HEADER_SIZE))
if (IVAL (buf, CODEPAGE_LENGTH_OFFSET) != (size - CODEPAGE_HEADER_SIZE))
{
DEBUG(0,("load_client_codepage: filename %s has incorrect size headers. \
Needed %u, got %u.\n", codepage_file_name, (uint32)(size - CODEPAGE_HEADER_SIZE),
IVAL(buf,CODEPAGE_LENGTH_OFFSET)));
DEBUG (0, ("load_client_codepage: filename %s has incorrect size headers. \
Needed %u, got %u.\n", codepage_file_name, (uint32) (size - CODEPAGE_HEADER_SIZE), IVAL (buf, CODEPAGE_LENGTH_OFFSET)));
goto clean_and_exit;
}
size -= CODEPAGE_HEADER_SIZE; /* Remove header */
/* Make sure the size is a multiple of 4. */
if((size % 4 ) != 0)
if ((size % 4) != 0)
{
DEBUG(0,("load_client_codepage: filename %s has a codepage size not a \
DEBUG (0, ("load_client_codepage: filename %s has a codepage size not a \
multiple of 4.\n", codepage_file_name));
goto clean_and_exit;
}
/* Allocate space for the code page file and read it all in. */
if((cp_p = (codepage_p)malloc( size + 4 )) == NULL)
if ((cp_p = (codepage_p) malloc (size + 4)) == NULL)
{
DEBUG(0,("load_client_codepage: malloc fail.\n"));
DEBUG (0, ("load_client_codepage: malloc fail.\n"));
goto clean_and_exit;
}
if(fread( (char *)cp_p, 1, size, fp)!=size)
if (fread ((char *) cp_p, 1, size, fp) != size)
{
DEBUG(0,("load_client_codepage: read fail on file %s. Error was %s.\n",
DEBUG (0, ("load_client_codepage: read fail on file %s. Error was %s.\n",
codepage_file_name, unix_error_string (errno)));
goto clean_and_exit;
}
/* Ensure array is correctly terminated. */
memset(((char *)cp_p) + size, '\0', 4);
memset (((char *) cp_p) + size, '\0', 4);
fclose(fp);
fclose (fp);
return cp_p;
clean_and_exit:
clean_and_exit:
/* pseudo destructor :-) */
if(fp != NULL)
fclose(fp);
if(cp_p)
free((char *)cp_p);
if (fp != NULL)
fclose (fp);
if (cp_p)
free ((char *) cp_p);
return NULL;
}
/****************************************************************************
initialise the client codepage.
****************************************************************************/
void codepage_initialise(int client_codepage)
void
codepage_initialise (int client_codepage)
{
int i;
static codepage_p cp = NULL;
if(cp != NULL)
if (cp != NULL)
{
DEBUG(6,
DEBUG (6,
("codepage_initialise: called twice - ignoring second client code page = %d\n",
client_codepage));
return;
}
DEBUG(6,("codepage_initialise: client code page = %d\n", client_codepage));
DEBUG (6, ("codepage_initialise: client code page = %d\n", client_codepage));
/*
* Known client codepages - these can be added to.
*/
cp = load_client_codepage( client_codepage );
cp = load_client_codepage (client_codepage);
if(cp == NULL)
if (cp == NULL)
{
#ifdef KANJI
DEBUG(6,("codepage_initialise: loading dynamic codepage file %s/codepage.%d \
for code page %d failed. Using default client codepage 932\n",
CODEPAGEDIR, client_codepage, client_codepage));
DEBUG (6, ("codepage_initialise: loading dynamic codepage file %s/codepage.%d \
for code page %d failed. Using default client codepage 932\n", CODEPAGEDIR, client_codepage, client_codepage));
cp = cp_932;
client_codepage = KANJI_CODEPAGE;
#else /* KANJI */
DEBUG(6,("codepage_initialise: loading dynamic codepage file %s/codepage.%d \
for code page %d failed. Using default client codepage 850\n",
CODEPAGEDIR, client_codepage, client_codepage));
DEBUG (6, ("codepage_initialise: loading dynamic codepage file %s/codepage.%d \
for code page %d failed. Using default client codepage 850\n", CODEPAGEDIR, client_codepage, client_codepage));
cp = cp_850;
client_codepage = MSDOS_LATIN_1_CODEPAGE;
#endif /* KANJI */
@ -368,35 +369,41 @@ for code page %d failed. Using default client codepage 850\n",
/*
* Setup the function pointers for the loaded codepage.
*/
initialize_multibyte_vectors( client_codepage );
initialize_multibyte_vectors (client_codepage);
if(cp)
if (cp)
{
for(i = 0; !((cp[i][0] == '\0') && (cp[i][1] == '\0')); i++)
add_dos_char(cp[i][0], (BOOL)cp[i][2], cp[i][1], (BOOL)cp[i][3]);
for (i = 0; !((cp[i][0] == '\0') && (cp[i][1] == '\0')); i++)
add_dos_char (cp[i][0], (BOOL) cp[i][2], cp[i][1], (BOOL) cp[i][3]);
}
}
/*******************************************************************
add characters depending on a string passed by the user
********************************************************************/
void add_char_string(const char *s)
void
add_char_string (const char *s)
{
char *extra_chars = (char *)strdup(s);
char *extra_chars = (char *) strdup (s);
char *t;
if (!extra_chars) return;
if (!extra_chars)
return;
for (t=strtok(extra_chars," \t\r\n"); t; t=strtok(NULL," \t\r\n")) {
char c1=0,c2=0;
int i1=0,i2=0;
if (isdigit((unsigned char)*t) || (*t)=='-') {
sscanf(t,"%i:%i",&i1,&i2);
add_dos_char(i1,True,i2,True);
} else {
sscanf(t,"%c:%c",&c1,&c2);
add_dos_char((unsigned char)c1,True,(unsigned char)c2, True);
for (t = strtok (extra_chars, " \t\r\n"); t; t = strtok (NULL, " \t\r\n"))
{
char c1 = 0, c2 = 0;
int i1 = 0, i2 = 0;
if (isdigit ((unsigned char) *t) || (*t) == '-')
{
sscanf (t, "%i:%i", &i1, &i2);
add_dos_char (i1, True, i2, True);
}
else
{
sscanf (t, "%c:%c", &c1, &c2);
add_dos_char ((unsigned char) c1, True, (unsigned char) c2, True);
}
}
free(extra_chars);
free (extra_chars);
}

Some files were not shown because too many files have changed in this diff Show More