mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 21:06:52 +03:00
Merge branch '2846_cleanup' into 4.8.1-stable
* 2846_cleanup: Clarify cvs dependency. Indent files. (mcview_moveto_eol): comparison of unsigned expression < 0 fixup. Try fix of compile warnings about assigned but unused variables Code cleanup: removed unused variables amd removed unnedeed code. Fix of f13 key handling. Ticket #2538: mcviewer: unused result of str_term_width1(). src/filemanager/mountlist.c: apply mc code indentation policy. Sync with gnulib 06b335ade65c8fe60fee8b9e18b670bb54ed924a: Minor optimization and type accuracy of some editor functions. Fix of mult-byte characters and tabulation printing. Menubar: ignore GPM_UP event. Accuracy use of arguments of dlg_move and widget_move macros. Ticket #2846: code cleanup before 4.8.1.4 release.
This commit is contained in:
commit
232f8c458a
@ -19,7 +19,7 @@ Build requirements for GNU Midnight Commander
|
|||||||
- pcre (if glib < 2.14)
|
- pcre (if glib < 2.14)
|
||||||
- slang or ncurses
|
- slang or ncurses
|
||||||
- gettext
|
- gettext
|
||||||
- cvs
|
- cvs (for gettext < 0.18 or if gettext >= 0.18 is built with --with-cvs)
|
||||||
|
|
||||||
|
|
||||||
Installation instructions for GNU Midnight Commander
|
Installation instructions for GNU Midnight Commander
|
||||||
|
@ -99,7 +99,6 @@ static void
|
|||||||
load_codepages_list_from_file (GPtrArray ** list, const char *fname)
|
load_codepages_list_from_file (GPtrArray ** list, const char *fname)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
guint i;
|
|
||||||
char buf[BUF_MEDIUM];
|
char buf[BUF_MEDIUM];
|
||||||
char *default_codepage = NULL;
|
char *default_codepage = NULL;
|
||||||
|
|
||||||
@ -107,7 +106,7 @@ load_codepages_list_from_file (GPtrArray ** list, const char *fname)
|
|||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; fgets (buf, sizeof buf, f) != NULL;)
|
while (fgets (buf, sizeof buf, f) != NULL)
|
||||||
{
|
{
|
||||||
/* split string into id and cpname */
|
/* split string into id and cpname */
|
||||||
char *p = buf;
|
char *p = buf;
|
||||||
@ -141,6 +140,8 @@ load_codepages_list_from_file (GPtrArray ** list, const char *fname)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
/* whether id is already present in list */
|
/* whether id is already present in list */
|
||||||
/* if yes, overwrite description */
|
/* if yes, overwrite description */
|
||||||
for (i = 0; i < (*list)->len; i++)
|
for (i = 0; i < (*list)->len; i++)
|
||||||
|
@ -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,
|
GPtrArray *mc_event_get_event_by_name (GTree * event_group, const gchar * event_name,
|
||||||
gboolean create_new, GError ** mcerror);
|
gboolean create_new, GError ** mcerror);
|
||||||
mc_event_callback_t *mc_event_is_callback_in_array (GPtrArray * callbacks,
|
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 ****************************************************************************/
|
/*** inline functions ****************************************************************************/
|
||||||
#endif /* MC_EVENT_INTERNAL_H */
|
#endif /* MC_EVENT_INTERNAL_H */
|
||||||
|
@ -208,7 +208,7 @@ typedef struct
|
|||||||
|
|
||||||
/* Ugly hack in order to distinguish between left and right panel in menubar */
|
/* Ugly hack in order to distinguish between left and right panel in menubar */
|
||||||
/* Set if the command is being run from the "Right" menu */
|
/* Set if the command is being run from the "Right" menu */
|
||||||
gboolean is_right; /* If the selected menu was the right */
|
gboolean is_right; /* If the selected menu was the right */
|
||||||
} widget;
|
} widget;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
Hooks.
|
Hooks.
|
||||||
|
|
||||||
Slavaz: Warning! this file is deprecated and should be replaced
|
Slavaz: Warning! this file is deprecated and should be replaced
|
||||||
by mcevents functional.
|
by mcevents functional.
|
||||||
|
|
||||||
Copyright (C) 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003,
|
Copyright (C) 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003,
|
||||||
2004, 2005, 2007, 2009, 2010, 2011
|
2004, 2005, 2007, 2009, 2010, 2011
|
||||||
|
@ -540,7 +540,7 @@ mc_config_get_full_vpath (const char *config_name)
|
|||||||
|
|
||||||
str_path = mc_config_get_full_path (config_name);
|
str_path = mc_config_get_full_path (config_name);
|
||||||
|
|
||||||
ret_vpath = vfs_path_from_str(str_path);
|
ret_vpath = vfs_path_from_str (str_path);
|
||||||
g_free (str_path);
|
g_free (str_path);
|
||||||
return ret_vpath;
|
return ret_vpath;
|
||||||
}
|
}
|
||||||
|
@ -319,7 +319,6 @@ str_8bit_fit_to_term (const char *text, int width, align_crt_t just_mode)
|
|||||||
goto finally;
|
goto finally;
|
||||||
memset (actual, ' ', width - length - ident);
|
memset (actual, ' ', width - length - ident);
|
||||||
actual += width - length - ident;
|
actual += width - length - ident;
|
||||||
remain -= width - length - ident;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -393,7 +392,6 @@ str_8bit_term_trim (const char *text, int width)
|
|||||||
{
|
{
|
||||||
memset (actual, '.', width);
|
memset (actual, '.', width);
|
||||||
actual += width;
|
actual += width;
|
||||||
remain -= width;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -260,7 +260,6 @@ str_ascii_fit_to_term (const char *text, int width, align_crt_t just_mode)
|
|||||||
goto finally;
|
goto finally;
|
||||||
memset (actual, ' ', width - length - ident);
|
memset (actual, ' ', width - length - ident);
|
||||||
actual += width - length - ident;
|
actual += width - length - ident;
|
||||||
remain -= width - length - ident;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -340,7 +339,6 @@ str_ascii_term_trim (const char *text, int width)
|
|||||||
{
|
{
|
||||||
memset (actual, '.', width);
|
memset (actual, '.', width);
|
||||||
actual += width;
|
actual += width;
|
||||||
remain -= width;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -675,7 +675,7 @@ str_utf8_term_trim (const char *text, int width)
|
|||||||
|
|
||||||
if (width < 1)
|
if (width < 1)
|
||||||
{
|
{
|
||||||
result [0] = '\0';
|
result[0] = '\0';
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ void tty_set_normal_attrs (void);
|
|||||||
|
|
||||||
void tty_color_set_defaults (const char *, const char *, const char *);
|
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 ****************************************************************************/
|
/*** inline functions ****************************************************************************/
|
||||||
#endif /* MC_COLOR_H */
|
#endif /* MC_COLOR_H */
|
||||||
|
@ -110,7 +110,7 @@ is_8bit_printable (unsigned char c)
|
|||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
resolve_symlinks (const vfs_path_t *vpath)
|
resolve_symlinks (const vfs_path_t * vpath)
|
||||||
{
|
{
|
||||||
char *p, *p2;
|
char *p, *p2;
|
||||||
char *buf, *buf2, *q, *r, c;
|
char *buf, *buf2, *q, *r, c;
|
||||||
@ -164,7 +164,7 @@ resolve_symlinks (const vfs_path_t *vpath)
|
|||||||
canonicalize_pathname (buf);
|
canonicalize_pathname (buf);
|
||||||
r = strchr (buf, 0);
|
r = strchr (buf, 0);
|
||||||
if (!*r || *(r - 1) != PATH_SEP)
|
if (!*r || *(r - 1) != PATH_SEP)
|
||||||
/* FIXME: this condition is always true because r points to the EOL */
|
/* FIXME: this condition is always true because r points to the EOL */
|
||||||
{
|
{
|
||||||
*r++ = PATH_SEP;
|
*r++ = PATH_SEP;
|
||||||
*r = 0;
|
*r = 0;
|
||||||
@ -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)
|
if (fwrite ((const void *) contents, 1, length, backup_fd) != length)
|
||||||
ret1 = FALSE;
|
ret1 = FALSE;
|
||||||
{
|
{
|
||||||
int ret2;
|
(void) fflush (backup_fd);
|
||||||
ret2 = fflush (backup_fd);
|
(void) fclose (backup_fd);
|
||||||
ret2 = fclose (backup_fd);
|
|
||||||
}
|
}
|
||||||
g_free (contents);
|
g_free (contents);
|
||||||
return ret1;
|
return ret1;
|
||||||
|
@ -1523,10 +1523,8 @@ vfs_s_get_line (struct vfs_class *me, int sock, char *buf, int buf_len, char ter
|
|||||||
{
|
{
|
||||||
if (logfile)
|
if (logfile)
|
||||||
{
|
{
|
||||||
size_t ret1;
|
(void) fwrite (&c, 1, 1, logfile);
|
||||||
int ret2;
|
(void) fflush (logfile);
|
||||||
ret1 = fwrite (&c, 1, 1, logfile);
|
|
||||||
ret2 = fflush (logfile);
|
|
||||||
}
|
}
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -104,13 +104,11 @@ mc_def_getlocalcopy (const vfs_path_t * filename_vpath)
|
|||||||
fdin = -1;
|
fdin = -1;
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
i = close (fdout);
|
i = close (fdout);
|
||||||
fdout = -1;
|
fdout = -1;
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
{
|
|
||||||
fdout = -1;
|
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
|
||||||
|
|
||||||
if (mc_stat (filename_vpath, &mystat) != -1)
|
if (mc_stat (filename_vpath, &mystat) != -1)
|
||||||
mc_chmod (tmp_vpath, mystat.st_mode);
|
mc_chmod (tmp_vpath, mystat.st_mode);
|
||||||
|
@ -174,7 +174,7 @@ _vfs_translate_path (const char *path, int size, GIConv defcnv, GString * buffer
|
|||||||
(void) defcnv;
|
(void) defcnv;
|
||||||
|
|
||||||
g_string_assign (buffer, path);
|
g_string_assign (buffer, path);
|
||||||
#endif /* HAVE_CHARSET */
|
#endif /* HAVE_CHARSET */
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
@ -614,7 +614,7 @@ vfs_change_encoding (vfs_path_t * vpath, const char *encoding)
|
|||||||
|
|
||||||
return vpath;
|
return vpath;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_CHARSET */
|
#endif /* HAVE_CHARSET */
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ struct vfs_s_inode *vfs_s_find_root (struct vfs_class *me, struct vfs_s_entry *e
|
|||||||
/* outside interface */
|
/* outside interface */
|
||||||
void vfs_s_init_class (struct vfs_class *vclass, struct vfs_s_subclass *sub);
|
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);
|
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);
|
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);
|
char *vfs_s_fullpath (struct vfs_class *me, struct vfs_s_inode *ino);
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#define B_HELP 3
|
#define B_HELP 3
|
||||||
#define B_USER 100
|
#define B_USER 100
|
||||||
|
|
||||||
#define dlg_move(h, _y, _x) tty_gotoyx (((Dlg_head *)(h))->y + _y, ((Dlg_head *)(h))->x + _x)
|
#define dlg_move(h, _y, _x) tty_gotoyx (((Dlg_head *)(h))->y + (_y), ((Dlg_head *)(h))->x + (_x))
|
||||||
|
|
||||||
/*** enums ***************************************************************************************/
|
/*** enums ***************************************************************************************/
|
||||||
|
|
||||||
|
@ -24,9 +24,9 @@ extern int num_history_items_recorded;
|
|||||||
/* read history to the mc_config, but don't save config to file */
|
/* read history to the mc_config, but don't save config to file */
|
||||||
GList *history_get (const char *input_name);
|
GList *history_get (const char *input_name);
|
||||||
/* load history form the mc_config */
|
/* 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 */
|
/* 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
|
/* for repositioning of history dialog we should pass widget to this
|
||||||
* function, as position of history dialog depends on widget's position */
|
* function, as position of history dialog depends on widget's position */
|
||||||
char *history_show (GList ** history, Widget * widget);
|
char *history_show (GList ** history, Widget * widget);
|
||||||
|
@ -108,14 +108,12 @@ draw_history_button (WInput * in)
|
|||||||
c = in->history->next ? (in->history->prev ? '|' : 'v') : '^';
|
c = in->history->next ? (in->history->prev ? '|' : 'v') : '^';
|
||||||
widget_move (&in->widget, 0, in->field_width - HISTORY_BUTTON_WIDTH);
|
widget_move (&in->widget, 0, in->field_width - HISTORY_BUTTON_WIDTH);
|
||||||
tty_setcolor (disabled ? DISABLED_COLOR : in->color[WINPUTC_HISTORY]);
|
tty_setcolor (disabled ? DISABLED_COLOR : in->color[WINPUTC_HISTORY]);
|
||||||
|
|
||||||
#ifdef LARGE_HISTORY_BUTTON
|
#ifdef LARGE_HISTORY_BUTTON
|
||||||
{
|
tty_print_string ("[ ]");
|
||||||
Dlg_head *h;
|
widget_move (&in->widget, 0, in->field_width - HISTORY_BUTTON_WIDTH + 1);
|
||||||
h = in->widget.owner;
|
|
||||||
tty_print_string ("[ ]");
|
|
||||||
widget_move (&in->widget, 0, in->field_width - HISTORY_BUTTON_WIDTH + 1);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tty_print_char (c);
|
tty_print_char (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1115,8 +1113,6 @@ input_handle_char (WInput * in, int key)
|
|||||||
cb_ret_t v;
|
cb_ret_t v;
|
||||||
unsigned long command;
|
unsigned long command;
|
||||||
|
|
||||||
v = MSG_NOT_HANDLED;
|
|
||||||
|
|
||||||
if (quote != 0)
|
if (quote != 0)
|
||||||
{
|
{
|
||||||
input_free_completions (in);
|
input_free_completions (in);
|
||||||
|
@ -123,9 +123,13 @@ listbox_draw (WListbox * l, gboolean focused)
|
|||||||
const Dlg_head *h = l->widget.owner;
|
const Dlg_head *h = l->widget.owner;
|
||||||
const gboolean disabled = (((Widget *) l)->options & W_DISABLED) != 0;
|
const gboolean disabled = (((Widget *) l)->options & W_DISABLED) != 0;
|
||||||
const int normalc = disabled ? DISABLED_COLOR : h->color[DLG_COLOR_NORMAL];
|
const int normalc = disabled ? DISABLED_COLOR : h->color[DLG_COLOR_NORMAL];
|
||||||
int selc =
|
/* *INDENT-OFF* */
|
||||||
disabled ? DISABLED_COLOR : focused ? h->
|
int selc = disabled
|
||||||
color[DLG_COLOR_HOT_FOCUS] : h->color[DLG_COLOR_FOCUS];
|
? DISABLED_COLOR
|
||||||
|
: focused
|
||||||
|
? h->color[DLG_COLOR_HOT_FOCUS]
|
||||||
|
: h->color[DLG_COLOR_FOCUS];
|
||||||
|
/* *INDENT-ON* */
|
||||||
|
|
||||||
GList *le;
|
GList *le;
|
||||||
int pos;
|
int pos;
|
||||||
|
@ -2,9 +2,12 @@
|
|||||||
Pulldown menu code
|
Pulldown menu code
|
||||||
|
|
||||||
Copyright (C) 1994, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
Copyright (C) 1994, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
||||||
2007, 2009, 2011
|
2007, 2009, 2011, 2012
|
||||||
The Free Software Foundation, Inc.
|
The Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Written by:
|
||||||
|
Andrew Borodin <aborodin@vmail.ru>, 2012
|
||||||
|
|
||||||
This file is part of the Midnight Commander.
|
This file is part of the Midnight Commander.
|
||||||
|
|
||||||
The Midnight Commander is free software: you can redistribute it
|
The Midnight Commander is free software: you can redistribute it
|
||||||
@ -602,6 +605,9 @@ menubar_event (Gpm_Event * event, void *data)
|
|||||||
if (!menubar->is_active && ((event->buttons & (GPM_B_MIDDLE | GPM_B_UP | GPM_B_DOWN)) != 0))
|
if (!menubar->is_active && ((event->buttons & (GPM_B_MIDDLE | GPM_B_UP | GPM_B_DOWN)) != 0))
|
||||||
return MOU_NORMAL;
|
return MOU_NORMAL;
|
||||||
|
|
||||||
|
if (event->y == 1 && (event->type & GPM_UP) != 0)
|
||||||
|
return MOU_NORMAL;
|
||||||
|
|
||||||
if (!menubar->is_dropped)
|
if (!menubar->is_dropped)
|
||||||
{
|
{
|
||||||
menubar->previous_widget = dlg_get_current_widget_id (menubar->widget.owner);
|
menubar->previous_widget = dlg_get_current_widget_id (menubar->widget.owner);
|
||||||
@ -613,9 +619,6 @@ menubar_event (Gpm_Event * event, void *data)
|
|||||||
/* Mouse operations on the menubar */
|
/* Mouse operations on the menubar */
|
||||||
if (event->y == 1 || !was_active)
|
if (event->y == 1 || !was_active)
|
||||||
{
|
{
|
||||||
if ((event->type & GPM_UP) != 0)
|
|
||||||
return MOU_NORMAL;
|
|
||||||
|
|
||||||
/* wheel events on menubar */
|
/* wheel events on menubar */
|
||||||
if (event->buttons & GPM_B_UP)
|
if (event->buttons & GPM_B_UP)
|
||||||
menubar_left (menubar);
|
menubar_left (menubar);
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
/*** typedefs(not structures) and defined constants **********************************************/
|
/*** typedefs(not structures) and defined constants **********************************************/
|
||||||
|
|
||||||
#define widget_move(w, _y, _x) tty_gotoyx (((Widget *)(w))->y + _y, ((Widget *)(w))->x + _x)
|
#define widget_move(w, _y, _x) tty_gotoyx (((Widget *)(w))->y + (_y), ((Widget *)(w))->x + (_x))
|
||||||
/* Sets/clear the specified flag in the options field */
|
/* Sets/clear the specified flag in the options field */
|
||||||
#define widget_option(w,f,i) \
|
#define widget_option(w,f,i) \
|
||||||
w.options = ((i) ? ((w).options | (f)) : ((w).options & (~(f))))
|
w.options = ((i) ? ((w).options | (f)) : ((w).options & (~(f))))
|
||||||
|
@ -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 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 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 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_REQUIRE([AC_SYS_LARGEFILE])
|
||||||
|
|
||||||
AC_MSG_NOTICE([checking how to get file system space usage])
|
AC_MSG_NOTICE([checking how to get file system space usage])
|
||||||
@ -68,7 +68,7 @@ struct statvfs fsd;
|
|||||||
|
|
||||||
#if defined __APPLE__ && defined __MACH__
|
#if defined __APPLE__ && defined __MACH__
|
||||||
#include <limits.h>
|
#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
|
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
|
'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()
|
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
|
fi
|
||||||
|
|
||||||
if test $ac_fsusage_space = no; then
|
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,
|
# (glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0,
|
||||||
# OpenBSD >= 4.4, AIX, HP-UX, OSF/1, Cygwin already handled above.)
|
# 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
|
# (On IRIX you need to include <sys/statfs.h>, not only <sys/mount.h> and
|
||||||
|
@ -88,7 +88,9 @@ static gboolean parse_mc_v_argument (const gchar * option_name, const gchar * va
|
|||||||
|
|
||||||
static GOptionContext *context;
|
static GOptionContext *context;
|
||||||
|
|
||||||
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||||
static gboolean mc_args__nouse_subshell = FALSE;
|
static gboolean mc_args__nouse_subshell = FALSE;
|
||||||
|
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||||
static gboolean mc_args__show_datadirs = FALSE;
|
static gboolean mc_args__show_datadirs = FALSE;
|
||||||
static gboolean mc_args__show_datadirs_extended = FALSE;
|
static gboolean mc_args__show_datadirs_extended = FALSE;
|
||||||
static gboolean mc_args__show_configure_opts = FALSE;
|
static gboolean mc_args__show_configure_opts = FALSE;
|
||||||
@ -609,9 +611,11 @@ mc_setup_by_args (int argc, char **argv, GError ** error)
|
|||||||
smbfs_set_debug (mc_args__debug_level);
|
smbfs_set_debug (mc_args__debug_level);
|
||||||
#endif /* ENABLE_VFS_SMB */
|
#endif /* ENABLE_VFS_SMB */
|
||||||
|
|
||||||
|
#if defined ENABLE_VFS_FTP || defined ENABLE_VFS_FTP
|
||||||
if (mc_args__netfs_logfile != NULL)
|
if (mc_args__netfs_logfile != NULL)
|
||||||
{
|
{
|
||||||
vfs_path_t *vpath;
|
vfs_path_t *vpath;
|
||||||
|
|
||||||
#ifdef ENABLE_VFS_FTP
|
#ifdef ENABLE_VFS_FTP
|
||||||
vpath = vfs_path_from_str ("ftp://");
|
vpath = vfs_path_from_str ("ftp://");
|
||||||
mc_setctl (vpath, VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile);
|
mc_setctl (vpath, VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile);
|
||||||
@ -623,6 +627,7 @@ mc_setup_by_args (int argc, char **argv, GError ** error)
|
|||||||
vfs_path_free (vpath);
|
vfs_path_free (vpath);
|
||||||
#endif /* ENABLE_VFS_SMB */
|
#endif /* ENABLE_VFS_SMB */
|
||||||
}
|
}
|
||||||
|
#endif /* ENABLE_VFS_FTP || ENABLE_VFS_SMB */
|
||||||
|
|
||||||
base = x_basename (argv[0]);
|
base = x_basename (argv[0]);
|
||||||
tmp = (argc > 0) ? argv[1] : NULL;
|
tmp = (argc > 0) ? argv[1] : NULL;
|
||||||
|
@ -200,7 +200,7 @@ background_attention (int fd, void *closure)
|
|||||||
/* void *routine; */
|
/* void *routine; */
|
||||||
int argc, i, result, status;
|
int argc, i, result, status;
|
||||||
char *data[MAXCALLARGS];
|
char *data[MAXCALLARGS];
|
||||||
ssize_t bytes, ret;
|
ssize_t bytes;
|
||||||
struct TaskList *p;
|
struct TaskList *p;
|
||||||
int to_child_fd = -1;
|
int to_child_fd = -1;
|
||||||
enum ReturnType type;
|
enum ReturnType type;
|
||||||
@ -330,9 +330,9 @@ background_attention (int fd, void *closure)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send the result code and the value for shared variables */
|
/* 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)
|
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)
|
else if (type == Return_String)
|
||||||
{
|
{
|
||||||
@ -365,15 +365,15 @@ background_attention (int fd, void *closure)
|
|||||||
if (resstr)
|
if (resstr)
|
||||||
{
|
{
|
||||||
len = strlen (resstr);
|
len = strlen (resstr);
|
||||||
ret = write (to_child_fd, &len, sizeof (len));
|
(void) write (to_child_fd, &len, sizeof (len));
|
||||||
if (len != 0)
|
if (len != 0)
|
||||||
ret = write (to_child_fd, resstr, len);
|
(void) write (to_child_fd, resstr, len);
|
||||||
g_free (resstr);
|
g_free (resstr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
len = 0;
|
len = 0;
|
||||||
ret = write (to_child_fd, &len, sizeof (len));
|
(void) write (to_child_fd, &len, sizeof (len));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; i < argc; i++)
|
for (i = 0; i < argc; i++)
|
||||||
@ -398,17 +398,16 @@ static void
|
|||||||
parent_call_header (void *routine, int argc, enum ReturnType type, FileOpContext * ctx)
|
parent_call_header (void *routine, int argc, enum ReturnType type, FileOpContext * ctx)
|
||||||
{
|
{
|
||||||
int have_ctx;
|
int have_ctx;
|
||||||
ssize_t ret;
|
|
||||||
|
|
||||||
have_ctx = (ctx != NULL);
|
have_ctx = (ctx != NULL);
|
||||||
|
|
||||||
ret = write (parent_fd, &routine, sizeof (routine));
|
(void) write (parent_fd, &routine, sizeof (routine));
|
||||||
ret = write (parent_fd, &argc, sizeof (int));
|
(void) write (parent_fd, &argc, sizeof (int));
|
||||||
ret = write (parent_fd, &type, sizeof (type));
|
(void) write (parent_fd, &type, sizeof (type));
|
||||||
ret = write (parent_fd, &have_ctx, sizeof (have_ctx));
|
(void) write (parent_fd, &have_ctx, sizeof (have_ctx));
|
||||||
|
|
||||||
if (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)
|
parent_va_call (void *routine, gpointer data, int argc, va_list ap)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
ssize_t ret;
|
|
||||||
struct FileOpContext *ctx = (struct FileOpContext *) data;
|
struct FileOpContext *ctx = (struct FileOpContext *) data;
|
||||||
|
|
||||||
parent_call_header (routine, argc, Return_Integer, ctx);
|
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);
|
len = va_arg (ap, int);
|
||||||
value = va_arg (ap, void *);
|
value = va_arg (ap, void *);
|
||||||
ret = write (parent_fd, &len, sizeof (int));
|
(void) write (parent_fd, &len, sizeof (int));
|
||||||
ret = write (parent_fd, value, len);
|
(void) write (parent_fd, value, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = read (from_parent_fd, &i, sizeof (int));
|
(void) read (from_parent_fd, &i, sizeof (int));
|
||||||
if (ctx)
|
if (ctx)
|
||||||
ret = read (from_parent_fd, ctx, sizeof (FileOpContext));
|
(void) read (from_parent_fd, ctx, sizeof (FileOpContext));
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,6 @@ clipboard_file_to_ext_clip (const gchar * event_group_name, const gchar * event_
|
|||||||
gpointer init_data, gpointer data)
|
gpointer init_data, gpointer data)
|
||||||
{
|
{
|
||||||
char *tmp, *cmd;
|
char *tmp, *cmd;
|
||||||
int res = 0;
|
|
||||||
const char *d = getenv ("DISPLAY");
|
const char *d = getenv ("DISPLAY");
|
||||||
|
|
||||||
(void) event_group_name;
|
(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);
|
cmd = g_strconcat (clipboard_store_path, " ", tmp, " 2>/dev/null", (char *) NULL);
|
||||||
|
|
||||||
if (cmd != 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 (cmd);
|
||||||
g_free (tmp);
|
g_free (tmp);
|
||||||
@ -127,7 +126,6 @@ clipboard_text_to_file (const gchar * event_group_name, const gchar * event_name
|
|||||||
{
|
{
|
||||||
int file;
|
int file;
|
||||||
vfs_path_t *fname_vpath = NULL;
|
vfs_path_t *fname_vpath = NULL;
|
||||||
ssize_t ret;
|
|
||||||
size_t str_len;
|
size_t str_len;
|
||||||
const char *text = (const char *) data;
|
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;
|
return TRUE;
|
||||||
|
|
||||||
str_len = strlen (text);
|
str_len = strlen (text);
|
||||||
ret = mc_write (file, (char *) text, str_len);
|
(void) mc_write (file, (char *) text, str_len);
|
||||||
mc_close (file);
|
mc_close (file);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,6 @@ show_console_contents_linux (int starty, unsigned char begin_line, unsigned char
|
|||||||
unsigned char message = 0;
|
unsigned char message = 0;
|
||||||
unsigned short bytes = 0;
|
unsigned short bytes = 0;
|
||||||
int i;
|
int i;
|
||||||
ssize_t ret;
|
|
||||||
|
|
||||||
/* Is tty console? */
|
/* Is tty console? */
|
||||||
if (mc_global.tty.console_flag == '\0')
|
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 */
|
/* Send command to the console handler */
|
||||||
message = CONSOLE_CONTENTS;
|
message = CONSOLE_CONTENTS;
|
||||||
ret = write (pipefd1[1], &message, 1);
|
(void) write (pipefd1[1], &message, 1);
|
||||||
/* Check for outdated cons.saver */
|
/* Check for outdated cons.saver */
|
||||||
ret = read (pipefd2[0], &message, 1);
|
(void) read (pipefd2[0], &message, 1);
|
||||||
if (message != CONSOLE_CONTENTS)
|
if (message != CONSOLE_CONTENTS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Send the range of lines that we want */
|
/* Send the range of lines that we want */
|
||||||
ret = write (pipefd1[1], &begin_line, 1);
|
(void) write (pipefd1[1], &begin_line, 1);
|
||||||
ret = write (pipefd1[1], &end_line, 1);
|
(void) write (pipefd1[1], &end_line, 1);
|
||||||
/* Read the corresponding number of bytes */
|
/* Read the corresponding number of bytes */
|
||||||
ret = read (pipefd2[0], &bytes, 2);
|
(void) read (pipefd2[0], &bytes, 2);
|
||||||
|
|
||||||
/* Read the bytes and output them */
|
/* Read the bytes and output them */
|
||||||
for (i = 0; i < bytes; i++)
|
for (i = 0; i < bytes; i++)
|
||||||
{
|
{
|
||||||
if ((i % COLS) == 0)
|
if ((i % COLS) == 0)
|
||||||
tty_gotoyx (starty + (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);
|
tty_print_char (message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the value of the mc_global.tty.console_flag */
|
/* 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')
|
if (action == CONSOLE_DONE || mc_global.tty.console_flag == '\0')
|
||||||
{
|
{
|
||||||
/* We are done -> Let's clean up */
|
/* We are done -> Let's clean up */
|
||||||
pid_t ret;
|
|
||||||
close (pipefd1[1]);
|
close (pipefd1[1]);
|
||||||
close (pipefd2[0]);
|
close (pipefd2[0]);
|
||||||
ret = waitpid (cons_saver_pid, &status, 0);
|
(void) waitpid (cons_saver_pid, &status, 0);
|
||||||
mc_global.tty.console_flag = '\0';
|
mc_global.tty.console_flag = '\0';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -382,9 +380,10 @@ console_save (void)
|
|||||||
|
|
||||||
for (i = 0; i < screen_shot.xsize * screen_shot.ysize; i++)
|
for (i = 0; i < screen_shot.xsize * screen_shot.ysize; i++)
|
||||||
{
|
{
|
||||||
screen_shot.buf[i] =
|
/* *INDENT-OFF* */
|
||||||
(screen_shot.buf[i] & 0xff00) | (unsigned char) revmap.
|
screen_shot.buf[i] = (screen_shot.buf[i] & 0xff00)
|
||||||
scrmap[screen_shot.buf[i] & 0xff];
|
| (unsigned char) revmap.scrmap[screen_shot.buf[i] & 0xff];
|
||||||
|
/* *INDENT-ON* */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,8 +143,7 @@ send_contents (char *buffer, unsigned int columns, unsigned int rows)
|
|||||||
static void __attribute__ ((noreturn)) die (void)
|
static void __attribute__ ((noreturn)) die (void)
|
||||||
{
|
{
|
||||||
unsigned char zero = 0;
|
unsigned char zero = 0;
|
||||||
ssize_t ret;
|
(void) write (1, &zero, 1);
|
||||||
ret = write (1, &zero, 1);
|
|
||||||
exit (3);
|
exit (3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -632,31 +632,22 @@ dview_get_utf (char *str, int *char_width, gboolean * result)
|
|||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
{
|
{
|
||||||
*result = FALSE;
|
*result = FALSE;
|
||||||
width = 0;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = g_utf8_get_char_validated (str, -1);
|
res = g_utf8_get_char_validated (str, -1);
|
||||||
|
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
{
|
|
||||||
ch = *str;
|
ch = *str;
|
||||||
width = 0;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ch = res;
|
ch = res;
|
||||||
/* Calculate UTF-8 char width */
|
/* Calculate UTF-8 char width */
|
||||||
next_ch = g_utf8_next_char (str);
|
next_ch = g_utf8_next_char (str);
|
||||||
if (next_ch)
|
if (next_ch != NULL)
|
||||||
{
|
|
||||||
width = next_ch - str;
|
width = next_ch - str;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
ch = 0;
|
ch = 0;
|
||||||
width = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
*char_width = width;
|
*char_width = width;
|
||||||
return ch;
|
return ch;
|
||||||
@ -2197,7 +2188,6 @@ static void
|
|||||||
do_merge_hunk (WDiff * dview)
|
do_merge_hunk (WDiff * dview)
|
||||||
{
|
{
|
||||||
int from1, to1, from2, to2;
|
int from1, to1, from2, to2;
|
||||||
int res;
|
|
||||||
int hunk;
|
int hunk;
|
||||||
|
|
||||||
hunk = get_current_hunk (dview, &from1, &to1, &from2, &to2);
|
hunk = get_current_hunk (dview, &from1, &to1, &from2, &to2);
|
||||||
@ -2244,7 +2234,7 @@ do_merge_hunk (WDiff * dview)
|
|||||||
}
|
}
|
||||||
fflush (merge_file);
|
fflush (merge_file);
|
||||||
fclose (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);
|
mc_unlink (merge_file_name_vpath);
|
||||||
vfs_path_free (merge_file_name_vpath);
|
vfs_path_free (merge_file_name_vpath);
|
||||||
}
|
}
|
||||||
@ -2377,7 +2367,7 @@ dview_init (WDiff * dview, const char *args, const char *file1, const char *file
|
|||||||
static void
|
static void
|
||||||
dview_reread (WDiff * dview)
|
dview_reread (WDiff * dview)
|
||||||
{
|
{
|
||||||
int ndiff = dview->ndiff;
|
int ndiff;
|
||||||
|
|
||||||
destroy_hdiff (dview);
|
destroy_hdiff (dview);
|
||||||
if (dview->a[0] != NULL)
|
if (dview->a[0] != NULL)
|
||||||
@ -2984,7 +2974,7 @@ dview_ok_to_exit (WDiff * dview)
|
|||||||
break;
|
break;
|
||||||
case 1: /* No */
|
case 1: /* No */
|
||||||
if (mc_util_restore_from_backup_if_possible (dview->file[0], "~~~"))
|
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 */
|
/* fall through */
|
||||||
default:
|
default:
|
||||||
res = TRUE;
|
res = TRUE;
|
||||||
|
@ -7,8 +7,9 @@ noinst_LTLIBRARIES =
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
libedit_la_SOURCES = \
|
libedit_la_SOURCES = \
|
||||||
bookmark.c edit.c editcmd.c editwidget.c editdraw.c editkeys.c \
|
bookmark.c edit.c editcmd.c editwidget.c editwidget.h \
|
||||||
editmenu.c editoptions.c edit-impl.h edit.h edit-widget.h \
|
editdraw.c editkeys.c \
|
||||||
|
editmenu.c editoptions.c edit-impl.h edit.h \
|
||||||
syntax.c wordproc.c \
|
syntax.c wordproc.c \
|
||||||
choosesyntax.c etags.c etags.h editcmd_dialogs.c editcmd_dialogs.h
|
choosesyntax.c etags.c etags.h editcmd_dialogs.c editcmd_dialogs.h
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
#include "lib/global.h"
|
#include "lib/global.h"
|
||||||
#include "lib/util.h" /* MAX_SAVED_BOOKMARKS */
|
#include "lib/util.h" /* MAX_SAVED_BOOKMARKS */
|
||||||
|
|
||||||
#include "edit-widget.h"
|
#include "editwidget.h"
|
||||||
|
|
||||||
/*** global variables ****************************************************************************/
|
/*** global variables ****************************************************************************/
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
#include "lib/widget.h" /* Listbox */
|
#include "lib/widget.h" /* Listbox */
|
||||||
|
|
||||||
#include "edit-impl.h"
|
#include "edit-impl.h"
|
||||||
#include "edit-widget.h"
|
#include "editwidget.h"
|
||||||
|
|
||||||
/*** global variables ****************************************************************************/
|
/*** global variables ****************************************************************************/
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ long edit_eol (WEdit * edit, long current);
|
|||||||
void edit_update_curs_row (WEdit * edit);
|
void edit_update_curs_row (WEdit * edit);
|
||||||
void edit_update_curs_col (WEdit * edit);
|
void edit_update_curs_col (WEdit * edit);
|
||||||
void edit_find_bracket (WEdit * edit);
|
void edit_find_bracket (WEdit * edit);
|
||||||
int edit_reload_line (WEdit * edit, const vfs_path_t * filename_vpath, long line);
|
gboolean edit_reload_line (WEdit * edit, const vfs_path_t * filename_vpath, long line);
|
||||||
void edit_set_codeset (WEdit * edit);
|
void edit_set_codeset (WEdit * edit);
|
||||||
|
|
||||||
void edit_block_copy_cmd (WEdit * edit);
|
void edit_block_copy_cmd (WEdit * edit);
|
||||||
@ -226,12 +226,11 @@ int edit_save_confirm_cmd (WEdit * edit);
|
|||||||
int edit_save_as_cmd (WEdit * edit);
|
int edit_save_as_cmd (WEdit * edit);
|
||||||
WEdit *edit_init (WEdit * edit, int y, int x, int lines, int cols,
|
WEdit *edit_init (WEdit * edit, int y, int x, int lines, int cols,
|
||||||
const vfs_path_t * filename_vpath, long line);
|
const vfs_path_t * filename_vpath, long line);
|
||||||
int edit_clean (WEdit * edit);
|
gboolean edit_clean (WEdit * edit);
|
||||||
gboolean edit_ok_to_exit (WEdit * edit);
|
gboolean edit_ok_to_exit (WEdit * edit);
|
||||||
int edit_renew (WEdit * edit);
|
gboolean edit_renew (WEdit * edit);
|
||||||
int edit_new_cmd (WEdit * edit);
|
gboolean edit_new_cmd (WEdit * edit);
|
||||||
int edit_reload (WEdit * edit, const vfs_path_t * filename_vpath);
|
gboolean edit_load_cmd (WEdit * edit, edit_current_file_t what);
|
||||||
int edit_load_cmd (WEdit * edit, edit_current_file_t what);
|
|
||||||
void edit_mark_cmd (WEdit * edit, int unmark);
|
void edit_mark_cmd (WEdit * edit, int unmark);
|
||||||
void edit_mark_current_word_cmd (WEdit * edit);
|
void edit_mark_current_word_cmd (WEdit * edit);
|
||||||
void edit_mark_current_line_cmd (WEdit * edit);
|
void edit_mark_current_line_cmd (WEdit * edit);
|
||||||
@ -250,8 +249,8 @@ void edit_insert_over (WEdit * edit);
|
|||||||
int edit_insert_column_of_text_from_file (WEdit * edit, int file,
|
int edit_insert_column_of_text_from_file (WEdit * edit, int file,
|
||||||
long *start_pos, long *end_pos, int *col1, int *col2);
|
long *start_pos, long *end_pos, int *col1, int *col2);
|
||||||
long edit_insert_file (WEdit * edit, const vfs_path_t * filename_vpath);
|
long edit_insert_file (WEdit * edit, const vfs_path_t * filename_vpath);
|
||||||
int edit_load_back_cmd (WEdit * edit);
|
gboolean edit_load_back_cmd (WEdit * edit);
|
||||||
int edit_load_forward_cmd (WEdit * edit);
|
gboolean edit_load_forward_cmd (WEdit * edit);
|
||||||
void edit_block_process_cmd (WEdit * edit, int macro_number);
|
void edit_block_process_cmd (WEdit * edit, int macro_number);
|
||||||
void edit_refresh_cmd (WEdit * edit);
|
void edit_refresh_cmd (WEdit * edit);
|
||||||
void edit_date_cmd (WEdit * edit);
|
void edit_date_cmd (WEdit * edit);
|
||||||
@ -314,4 +313,17 @@ void edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_inserti
|
|||||||
|
|
||||||
/*** inline functions ****************************************************************************/
|
/*** inline functions ****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load a new file into the editor. If it fails, preserve the old file.
|
||||||
|
* To do it, allocate a new widget, initialize it and, if the new file
|
||||||
|
* was loaded, copy the data to the old widget.
|
||||||
|
*
|
||||||
|
* @returns TRUE on success, FALSE on failure.
|
||||||
|
*/
|
||||||
|
static inline gboolean
|
||||||
|
edit_reload (WEdit * edit, const vfs_path_t * filename_vpath)
|
||||||
|
{
|
||||||
|
return edit_reload_line (edit, filename_vpath, 0);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* MC__EDIT_IMPL_H */
|
#endif /* MC__EDIT_IMPL_H */
|
||||||
|
@ -2,12 +2,13 @@
|
|||||||
Editor low level data handling and cursor fundamentals.
|
Editor low level data handling and cursor fundamentals.
|
||||||
|
|
||||||
Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2004, 2005, 2006,
|
Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2004, 2005, 2006,
|
||||||
2007, 2008, 2009, 2010, 2011
|
2007, 2008, 2009, 2010, 2011, 2012
|
||||||
The Free Software Foundation, Inc.
|
The Free Software Foundation, Inc.
|
||||||
|
|
||||||
Written by:
|
Written by:
|
||||||
Paul Sheer 1996, 1997
|
Paul Sheer 1996, 1997
|
||||||
Ilia Maslakov <il.smind@gmail.com> 2009, 2010, 2011
|
Ilia Maslakov <il.smind@gmail.com> 2009, 2010, 2011
|
||||||
|
Andrew Borodin <aborodin@vmail.ru> 2012.
|
||||||
|
|
||||||
This file is part of the Midnight Commander.
|
This file is part of the Midnight Commander.
|
||||||
|
|
||||||
@ -69,7 +70,7 @@
|
|||||||
#include "src/keybind-defaults.h"
|
#include "src/keybind-defaults.h"
|
||||||
|
|
||||||
#include "edit-impl.h"
|
#include "edit-impl.h"
|
||||||
#include "edit-widget.h"
|
#include "editwidget.h"
|
||||||
|
|
||||||
/*** global variables ****************************************************************************/
|
/*** global variables ****************************************************************************/
|
||||||
|
|
||||||
@ -242,17 +243,19 @@ edit_init_buffers (WEdit * edit)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load file OR text into buffers. Set cursor to the beginning of file.
|
* Load file OR text into buffers. Set cursor to the beginning of file.
|
||||||
* @returns 1 on error.
|
*
|
||||||
|
* @returns FALSE on error.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static gboolean
|
||||||
edit_load_file_fast (WEdit * edit, const vfs_path_t * filename_vpath)
|
edit_load_file_fast (WEdit * edit, const vfs_path_t * filename_vpath)
|
||||||
{
|
{
|
||||||
long buf, buf2;
|
long buf, buf2;
|
||||||
int file = -1;
|
int file = -1;
|
||||||
int ret = 1;
|
gboolean ret = FALSE;
|
||||||
|
|
||||||
edit->curs2 = edit->last_byte;
|
edit->curs2 = edit->last_byte;
|
||||||
buf2 = edit->curs2 >> S_EDIT_BUF_SIZE;
|
buf2 = edit->curs2 >> S_EDIT_BUF_SIZE;
|
||||||
@ -267,7 +270,7 @@ edit_load_file_fast (WEdit * edit, const vfs_path_t * filename_vpath)
|
|||||||
g_free (filename);
|
g_free (filename);
|
||||||
edit_error_dialog (_("Error"), errmsg);
|
edit_error_dialog (_("Error"), errmsg);
|
||||||
g_free (errmsg);
|
g_free (errmsg);
|
||||||
return 1;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!edit->buffers2[buf2])
|
if (!edit->buffers2[buf2])
|
||||||
@ -288,11 +291,11 @@ edit_load_file_fast (WEdit * edit, const vfs_path_t * filename_vpath)
|
|||||||
if (mc_read (file, (char *) edit->buffers2[buf], EDIT_BUF_SIZE) < 0)
|
if (mc_read (file, (char *) edit->buffers2[buf], EDIT_BUF_SIZE) < 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ret = 0;
|
ret = TRUE;
|
||||||
}
|
}
|
||||||
while (0);
|
while (FALSE);
|
||||||
|
|
||||||
if (ret != 0)
|
if (!ret)
|
||||||
{
|
{
|
||||||
gchar *errmsg, *filename;
|
gchar *errmsg, *filename;
|
||||||
|
|
||||||
@ -370,9 +373,16 @@ edit_insert_stream (WEdit * edit, FILE * f)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
/** Open file and create it if necessary. Return 0 for success, 1 for error. */
|
/**
|
||||||
|
* Open file and create it if necessary.
|
||||||
|
*
|
||||||
|
* @param edit editor object
|
||||||
|
* @param filename_vpath file name
|
||||||
|
* @param st buffer for store stat info
|
||||||
|
* @returns TRUE for success, FALSE for error.
|
||||||
|
*/
|
||||||
|
|
||||||
static int
|
static gboolean
|
||||||
check_file_access (WEdit * edit, const vfs_path_t * filename_vpath, struct stat *st)
|
check_file_access (WEdit * edit, const vfs_path_t * filename_vpath, struct stat *st)
|
||||||
{
|
{
|
||||||
int file;
|
int file;
|
||||||
@ -396,11 +406,9 @@ check_file_access (WEdit * edit, const vfs_path_t * filename_vpath, struct stat
|
|||||||
g_free (filename);
|
g_free (filename);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
/* New file, delete it if it's not modified or saved */
|
||||||
/* New file, delete it if it's not modified or saved */
|
edit->delete_file = 1;
|
||||||
edit->delete_file = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check what we have opened */
|
/* Check what we have opened */
|
||||||
@ -448,55 +456,55 @@ check_file_access (WEdit * edit, const vfs_path_t * filename_vpath, struct stat
|
|||||||
{
|
{
|
||||||
edit_error_dialog (_("Error"), errmsg);
|
edit_error_dialog (_("Error"), errmsg);
|
||||||
g_free (errmsg);
|
g_free (errmsg);
|
||||||
return 1;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return 0;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open the file and load it into the buffers, either directly or using
|
* Open the file and load it into the buffers, either directly or using
|
||||||
* a filter. Return 0 on success, 1 on error.
|
* a filter. Return TRUE on success, FALSE on error.
|
||||||
*
|
*
|
||||||
* Fast loading (edit_load_file_fast) is used when the file size is
|
* Fast loading (edit_load_file_fast) is used when the file size is
|
||||||
* known. In this case the data is read into the buffers by blocks.
|
* known. In this case the data is read into the buffers by blocks.
|
||||||
* If the file size is not known, the data is loaded byte by byte in
|
* If the file size is not known, the data is loaded byte by byte in
|
||||||
* edit_insert_file.
|
* edit_insert_file.
|
||||||
|
*
|
||||||
|
* @param edit editor object
|
||||||
|
* @return TRUE if file was successfully opened and loaded to buffers, FALSE otherwise
|
||||||
*/
|
*/
|
||||||
|
static gboolean
|
||||||
static int
|
|
||||||
edit_load_file (WEdit * edit)
|
edit_load_file (WEdit * edit)
|
||||||
{
|
{
|
||||||
int fast_load = 1;
|
gboolean fast_load = TRUE;
|
||||||
|
|
||||||
/* Cannot do fast load if a filter is used */
|
/* Cannot do fast load if a filter is used */
|
||||||
if (edit_find_filter (edit->filename_vpath) >= 0)
|
if (edit_find_filter (edit->filename_vpath) >= 0)
|
||||||
fast_load = 0;
|
fast_load = FALSE;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FIXME: line end translation should disable fast loading as well
|
* FIXME: line end translation should disable fast loading as well
|
||||||
* Consider doing fseek() to the end and ftell() for the real size.
|
* Consider doing fseek() to the end and ftell() for the real size.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (edit->filename_vpath != NULL)
|
if (edit->filename_vpath != NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* VFS may report file size incorrectly, and slow load is not a big
|
* VFS may report file size incorrectly, and slow load is not a big
|
||||||
* deal considering overhead in VFS.
|
* deal considering overhead in VFS.
|
||||||
*/
|
*/
|
||||||
if (!vfs_file_is_local (edit->filename_vpath))
|
if (!vfs_file_is_local (edit->filename_vpath))
|
||||||
fast_load = 0;
|
fast_load = FALSE;
|
||||||
|
|
||||||
/* If we are dealing with a real file, check that it exists */
|
/* If we are dealing with a real file, check that it exists */
|
||||||
if (check_file_access (edit, edit->filename_vpath, &edit->stat1))
|
if (!check_file_access (edit, edit->filename_vpath, &edit->stat1))
|
||||||
return 1;
|
return FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* nothing to load */
|
/* nothing to load */
|
||||||
fast_load = 0;
|
fast_load = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
edit_init_buffers (edit);
|
edit_init_buffers (edit);
|
||||||
@ -518,13 +526,13 @@ edit_load_file (WEdit * edit)
|
|||||||
if (edit_insert_file (edit, edit->filename_vpath) < 0)
|
if (edit_insert_file (edit, edit->filename_vpath) < 0)
|
||||||
{
|
{
|
||||||
edit_clean (edit);
|
edit_clean (edit);
|
||||||
return 1;
|
return FALSE;
|
||||||
}
|
}
|
||||||
edit->undo_stack_disable = 0;
|
edit->undo_stack_disable = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
edit->lb = LB_ASIS;
|
edit->lb = LB_ASIS;
|
||||||
return 0;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
@ -2283,7 +2291,7 @@ edit_init (WEdit * edit, int y, int x, int lines, int cols, const vfs_path_t * f
|
|||||||
edit->converter = str_cnv_from_term;
|
edit->converter = str_cnv_from_term;
|
||||||
edit_set_codeset (edit);
|
edit_set_codeset (edit);
|
||||||
|
|
||||||
if (edit_load_file (edit))
|
if (!edit_load_file (edit))
|
||||||
{
|
{
|
||||||
/* edit_load_file already gives an error message */
|
/* edit_load_file already gives an error message */
|
||||||
if (to_free)
|
if (to_free)
|
||||||
@ -2316,15 +2324,15 @@ edit_init (WEdit * edit, int y, int x, int lines, int cols, const vfs_path_t * f
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
/** Clear the edit struct, freeing everything in it. Return 1 on success */
|
|
||||||
|
|
||||||
int
|
/** Clear the edit struct, freeing everything in it. Return TRUE on success */
|
||||||
|
gboolean
|
||||||
edit_clean (WEdit * edit)
|
edit_clean (WEdit * edit)
|
||||||
{
|
{
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
||||||
if (!edit)
|
if (edit == NULL)
|
||||||
return 0;
|
return FALSE;
|
||||||
|
|
||||||
/* a stale lock, remove it */
|
/* a stale lock, remove it */
|
||||||
if (edit->locked)
|
if (edit->locked)
|
||||||
@ -2360,13 +2368,13 @@ edit_clean (WEdit * edit)
|
|||||||
|
|
||||||
edit_purge_widget (edit);
|
edit_purge_widget (edit);
|
||||||
|
|
||||||
return 1;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
/** returns 1 on success */
|
|
||||||
|
|
||||||
int
|
/** returns TRUE on success */
|
||||||
|
gboolean
|
||||||
edit_renew (WEdit * edit)
|
edit_renew (WEdit * edit)
|
||||||
{
|
{
|
||||||
int y = edit->widget.y;
|
int y = edit->widget.y;
|
||||||
@ -2379,44 +2387,15 @@ edit_renew (WEdit * edit)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
/**
|
|
||||||
* Load a new file into the editor. If it fails, preserve the old file.
|
|
||||||
* To do it, allocate a new widget, initialize it and, if the new file
|
|
||||||
* was loaded, copy the data to the old widget.
|
|
||||||
* Return 1 on success, 0 on failure.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int
|
|
||||||
edit_reload (WEdit * edit, const vfs_path_t * filename_vpath)
|
|
||||||
{
|
|
||||||
WEdit *e;
|
|
||||||
int y = edit->widget.y;
|
|
||||||
int x = edit->widget.x;
|
|
||||||
int lines = edit->widget.lines;
|
|
||||||
int columns = edit->widget.cols;
|
|
||||||
|
|
||||||
e = g_malloc0 (sizeof (WEdit));
|
|
||||||
e->widget = edit->widget;
|
|
||||||
if (edit_init (e, y, x, lines, columns, filename_vpath, 0) == NULL)
|
|
||||||
{
|
|
||||||
g_free (e);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
edit_clean (edit);
|
|
||||||
memcpy (edit, e, sizeof (WEdit));
|
|
||||||
g_free (e);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
|
||||||
/**
|
/**
|
||||||
* Load a new file into the editor and set line. If it fails, preserve the old file.
|
* Load a new file into the editor and set line. If it fails, preserve the old file.
|
||||||
* To do it, allocate a new widget, initialize it and, if the new file
|
* To do it, allocate a new widget, initialize it and, if the new file
|
||||||
* was loaded, copy the data to the old widget.
|
* was loaded, copy the data to the old widget.
|
||||||
* Return 1 on success, 0 on failure.
|
*
|
||||||
|
* @returns TRUE on success, FALSE on failure.
|
||||||
*/
|
*/
|
||||||
|
gboolean
|
||||||
int
|
|
||||||
edit_reload_line (WEdit * edit, const vfs_path_t * filename_vpath, long line)
|
edit_reload_line (WEdit * edit, const vfs_path_t * filename_vpath, long line)
|
||||||
{
|
{
|
||||||
WEdit *e;
|
WEdit *e;
|
||||||
@ -2427,15 +2406,18 @@ edit_reload_line (WEdit * edit, const vfs_path_t * filename_vpath, long line)
|
|||||||
|
|
||||||
e = g_malloc0 (sizeof (WEdit));
|
e = g_malloc0 (sizeof (WEdit));
|
||||||
e->widget = edit->widget;
|
e->widget = edit->widget;
|
||||||
|
|
||||||
if (edit_init (e, y, x, lines, columns, filename_vpath, line) == NULL)
|
if (edit_init (e, y, x, lines, columns, filename_vpath, line) == NULL)
|
||||||
{
|
{
|
||||||
g_free (e);
|
g_free (e);
|
||||||
return 0;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
edit_clean (edit);
|
edit_clean (edit);
|
||||||
memcpy (edit, e, sizeof (WEdit));
|
memcpy (edit, e, sizeof (WEdit));
|
||||||
g_free (e);
|
g_free (e);
|
||||||
return 1;
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
@ -61,7 +61,7 @@ extern int show_right_margin;
|
|||||||
void edit_stack_init (void);
|
void edit_stack_init (void);
|
||||||
void edit_stack_free (void);
|
void edit_stack_free (void);
|
||||||
|
|
||||||
int edit_file (const vfs_path_t * _file_vpath, int line);
|
gboolean edit_file (const vfs_path_t * _file_vpath, int line);
|
||||||
|
|
||||||
char *edit_get_file_name (const WEdit * edit);
|
char *edit_get_file_name (const WEdit * edit);
|
||||||
int edit_get_curs_col (const WEdit * edit);
|
int edit_get_curs_col (const WEdit * edit);
|
||||||
|
@ -2,11 +2,12 @@
|
|||||||
Editor high level editing commands
|
Editor high level editing commands
|
||||||
|
|
||||||
Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2004, 2005, 2006,
|
Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2004, 2005, 2006,
|
||||||
2007, 2011
|
2007, 2011, 2012
|
||||||
The Free Software Foundation, Inc.
|
The Free Software Foundation, Inc.
|
||||||
|
|
||||||
Written by:
|
Written by:
|
||||||
Paul Sheer, 1996, 1997
|
Paul Sheer, 1996, 1997
|
||||||
|
Andrew Borodin <aborodin@vmail.ru> 2012
|
||||||
|
|
||||||
This file is part of the Midnight Commander.
|
This file is part of the Midnight Commander.
|
||||||
|
|
||||||
@ -75,7 +76,7 @@
|
|||||||
#include "src/filemanager/layout.h" /* mc_refresh() */
|
#include "src/filemanager/layout.h" /* mc_refresh() */
|
||||||
|
|
||||||
#include "edit-impl.h"
|
#include "edit-impl.h"
|
||||||
#include "edit-widget.h"
|
#include "editwidget.h"
|
||||||
#include "editcmd_dialogs.h"
|
#include "editcmd_dialogs.h"
|
||||||
#include "etags.h"
|
#include "etags.h"
|
||||||
|
|
||||||
@ -489,18 +490,24 @@ edit_save_cmd (WEdit * edit)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
/** returns 1 on error */
|
/**
|
||||||
|
* Load file content
|
||||||
|
*
|
||||||
|
* @param edit widget object
|
||||||
|
* @param exp_vpath vfs file path
|
||||||
|
* @return TRUE if file content was successfully loaded, FALSE otherwise
|
||||||
|
*/
|
||||||
|
|
||||||
static int
|
static gboolean
|
||||||
edit_load_file_from_filename (WEdit * edit, const vfs_path_t * exp_vpath)
|
edit_load_file_from_filename (WEdit * edit, const vfs_path_t * exp_vpath)
|
||||||
{
|
{
|
||||||
int prev_locked = edit->locked;
|
int prev_locked = edit->locked;
|
||||||
vfs_path_t *prev_filename;
|
vfs_path_t *prev_filename;
|
||||||
int ret = 0;
|
gboolean ret = TRUE;
|
||||||
|
|
||||||
prev_filename = vfs_path_clone (edit->filename_vpath);
|
prev_filename = vfs_path_clone (edit->filename_vpath);
|
||||||
if (!edit_reload (edit, exp_vpath))
|
if (!edit_reload (edit, exp_vpath))
|
||||||
ret = 1;
|
ret = FALSE;
|
||||||
else if (prev_locked)
|
else if (prev_locked)
|
||||||
unlock_file (prev_filename);
|
unlock_file (prev_filename);
|
||||||
|
|
||||||
@ -648,7 +655,7 @@ edit_block_delete (WEdit * edit)
|
|||||||
{
|
{
|
||||||
long count;
|
long count;
|
||||||
long start_mark, end_mark;
|
long start_mark, end_mark;
|
||||||
int curs_pos, line_width;
|
int curs_pos;
|
||||||
long curs_line, c1, c2;
|
long curs_line, c1, c2;
|
||||||
|
|
||||||
if (eval_marks (edit, &start_mark, &end_mark))
|
if (eval_marks (edit, &start_mark, &end_mark))
|
||||||
@ -676,9 +683,6 @@ edit_block_delete (WEdit * edit)
|
|||||||
|
|
||||||
curs_line = edit->curs_line;
|
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;
|
curs_pos = edit->curs_col + edit->over_col;
|
||||||
|
|
||||||
/* move cursor to start of selection */
|
/* move cursor to start of selection */
|
||||||
@ -689,12 +693,14 @@ edit_block_delete (WEdit * edit)
|
|||||||
{
|
{
|
||||||
if (edit->column_highlight)
|
if (edit->column_highlight)
|
||||||
{
|
{
|
||||||
|
int line_width;
|
||||||
|
|
||||||
if (edit->mark2 < 0)
|
if (edit->mark2 < 0)
|
||||||
edit_mark_cmd (edit, 0);
|
edit_mark_cmd (edit, 0);
|
||||||
edit_delete_column_of_text (edit);
|
edit_delete_column_of_text (edit);
|
||||||
/* move cursor to the saved position */
|
/* move cursor to the saved position */
|
||||||
edit_move_to_line (edit, curs_line);
|
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,
|
line_width = edit_move_forward3 (edit, edit_bol (edit, edit->curs1), 0,
|
||||||
edit_eol (edit, edit->curs1));
|
edit_eol (edit, edit->curs1));
|
||||||
if (option_cursor_beyond_eol && curs_pos > line_width)
|
if (option_cursor_beyond_eol && curs_pos > line_width)
|
||||||
@ -2069,23 +2075,21 @@ edit_save_confirm_cmd (WEdit * edit)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
/** returns 1 on success */
|
|
||||||
|
|
||||||
int
|
/* returns TRUE on success */
|
||||||
|
gboolean
|
||||||
edit_new_cmd (WEdit * edit)
|
edit_new_cmd (WEdit * edit)
|
||||||
{
|
{
|
||||||
if (edit->modified)
|
if (edit->modified
|
||||||
|
&& edit_query_dialog2 (_("Warning"),
|
||||||
|
_("Current text was modified without a file save.\n"
|
||||||
|
"Continue discards these changes"),
|
||||||
|
_("C&ontinue"), _("&Cancel")) == 1)
|
||||||
{
|
{
|
||||||
if (edit_query_dialog2
|
edit->force |= REDRAW_COMPLETELY;
|
||||||
(_("Warning"),
|
return TRUE;
|
||||||
_
|
|
||||||
("Current text was modified without a file save.\nContinue discards these changes"),
|
|
||||||
_("C&ontinue"), _("&Cancel")))
|
|
||||||
{
|
|
||||||
edit->force |= REDRAW_COMPLETELY;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
edit->force |= REDRAW_COMPLETELY;
|
edit->force |= REDRAW_COMPLETELY;
|
||||||
|
|
||||||
return edit_renew (edit); /* if this gives an error, something has really screwed up */
|
return edit_renew (edit); /* if this gives an error, something has really screwed up */
|
||||||
@ -2093,17 +2097,19 @@ edit_new_cmd (WEdit * edit)
|
|||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
gboolean
|
||||||
edit_load_cmd (WEdit * edit, edit_current_file_t what)
|
edit_load_cmd (WEdit * edit, edit_current_file_t what)
|
||||||
{
|
{
|
||||||
|
gboolean ret = TRUE;
|
||||||
|
|
||||||
if (edit->modified
|
if (edit->modified
|
||||||
&& (edit_query_dialog2
|
&& edit_query_dialog2 (_("Warning"),
|
||||||
(_("Warning"),
|
_("Current text was modified without a file save.\n"
|
||||||
_("Current text was modified without a file save.\n"
|
"Continue discards these changes"), _("C&ontinue"),
|
||||||
"Continue discards these changes"), _("C&ontinue"), _("&Cancel")) == 1))
|
_("&Cancel")) == 1)
|
||||||
{
|
{
|
||||||
edit->force |= REDRAW_COMPLETELY;
|
edit->force |= REDRAW_COMPLETELY;
|
||||||
return 0;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (what)
|
switch (what)
|
||||||
@ -2117,18 +2123,16 @@ edit_load_cmd (WEdit * edit, edit_current_file_t what)
|
|||||||
MC_HISTORY_EDIT_LOAD, filename);
|
MC_HISTORY_EDIT_LOAD, filename);
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
|
|
||||||
if (exp != NULL)
|
if (exp != NULL && *exp != '\0')
|
||||||
{
|
{
|
||||||
if (*exp != '\0')
|
vfs_path_t *exp_vpath;
|
||||||
{
|
|
||||||
vfs_path_t *exp_vpath;
|
|
||||||
|
|
||||||
exp_vpath = vfs_path_from_str (exp);
|
exp_vpath = vfs_path_from_str (exp);
|
||||||
edit_load_file_from_filename (edit, exp_vpath);
|
ret = edit_load_file_from_filename (edit, exp_vpath);
|
||||||
vfs_path_free (exp_vpath);
|
vfs_path_free (exp_vpath);
|
||||||
}
|
|
||||||
g_free (exp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free (exp);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -2145,7 +2149,7 @@ edit_load_cmd (WEdit * edit, edit_current_file_t what)
|
|||||||
}
|
}
|
||||||
|
|
||||||
edit->force |= REDRAW_COMPLETELY;
|
edit->force |= REDRAW_COMPLETELY;
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
@ -3021,8 +3025,8 @@ edit_save_block_cmd (WEdit * edit)
|
|||||||
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
/** returns TRUE on success */
|
|
||||||
|
|
||||||
|
/** returns TRUE on success */
|
||||||
gboolean
|
gboolean
|
||||||
edit_insert_file_cmd (WEdit * edit)
|
edit_insert_file_cmd (WEdit * edit)
|
||||||
{
|
{
|
||||||
@ -3358,78 +3362,57 @@ edit_begin_end_repeat_cmd (WEdit * edit)
|
|||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
gboolean
|
||||||
edit_load_forward_cmd (WEdit * edit)
|
edit_load_forward_cmd (WEdit * edit)
|
||||||
{
|
{
|
||||||
if (edit->modified)
|
if (edit->modified
|
||||||
|
&& edit_query_dialog2 (_("Warning"),
|
||||||
|
_("Current text was modified without a file save.\n"
|
||||||
|
"Continue discards these changes"), _("C&ontinue"),
|
||||||
|
_("&Cancel")) == 1)
|
||||||
{
|
{
|
||||||
if (edit_query_dialog2
|
edit->force |= REDRAW_COMPLETELY;
|
||||||
(_("Warning"),
|
return TRUE;
|
||||||
_("Current text was modified without a file save\n"
|
|
||||||
"Continue discards these changes"), _("C&ontinue"), _("&Cancel")))
|
|
||||||
{
|
|
||||||
edit->force |= REDRAW_COMPLETELY;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (edit_stack_iterator + 1 < MAX_HISTORY_MOVETO)
|
|
||||||
{
|
|
||||||
if (edit_history_moveto[edit_stack_iterator + 1].line < 1)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
edit_stack_iterator++;
|
|
||||||
if (edit_history_moveto[edit_stack_iterator].filename_vpath)
|
|
||||||
{
|
|
||||||
edit_reload_line (edit, edit_history_moveto[edit_stack_iterator].filename_vpath,
|
|
||||||
edit_history_moveto[edit_stack_iterator].line);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (edit_stack_iterator + 1 >= MAX_HISTORY_MOVETO)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (edit_history_moveto[edit_stack_iterator + 1].line < 1)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
edit_stack_iterator++;
|
||||||
|
if (edit_history_moveto[edit_stack_iterator].filename_vpath != NULL)
|
||||||
|
return edit_reload_line (edit, edit_history_moveto[edit_stack_iterator].filename_vpath,
|
||||||
|
edit_history_moveto[edit_stack_iterator].line);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
gboolean
|
||||||
edit_load_back_cmd (WEdit * edit)
|
edit_load_back_cmd (WEdit * edit)
|
||||||
{
|
{
|
||||||
if (edit->modified)
|
if (edit->modified
|
||||||
|
&& edit_query_dialog2 (_("Warning"),
|
||||||
|
_("Current text was modified without a file save.\n"
|
||||||
|
"Continue discards these changes"), _("C&ontinue"),
|
||||||
|
_("&Cancel")) == 1)
|
||||||
{
|
{
|
||||||
if (edit_query_dialog2
|
edit->force |= REDRAW_COMPLETELY;
|
||||||
(_("Warning"),
|
return TRUE;
|
||||||
_("Current text was modified without a file save\n"
|
|
||||||
"Continue discards these changes"), _("C&ontinue"), _("&Cancel")))
|
|
||||||
{
|
|
||||||
edit->force |= REDRAW_COMPLETELY;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (edit_stack_iterator > 0)
|
|
||||||
{
|
|
||||||
edit_stack_iterator--;
|
|
||||||
if (edit_history_moveto[edit_stack_iterator].filename_vpath)
|
|
||||||
{
|
|
||||||
edit_reload_line (edit, edit_history_moveto[edit_stack_iterator].filename_vpath,
|
|
||||||
edit_history_moveto[edit_stack_iterator].line);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (edit_stack_iterator < 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
edit_stack_iterator--;
|
||||||
|
if (edit_history_moveto[edit_stack_iterator].filename_vpath != NULL)
|
||||||
|
return edit_reload_line (edit, edit_history_moveto[edit_stack_iterator].filename_vpath,
|
||||||
|
edit_history_moveto[edit_stack_iterator].line);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
#include "src/main.h"
|
#include "src/main.h"
|
||||||
#include "src/history.h"
|
#include "src/history.h"
|
||||||
|
|
||||||
#include "src/editor/edit-widget.h"
|
#include "src/editor/editwidget.h"
|
||||||
#include "src/editor/etags.h"
|
#include "src/editor/etags.h"
|
||||||
#include "src/editor/editcmd_dialogs.h"
|
#include "src/editor/editcmd_dialogs.h"
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ struct selection
|
|||||||
|
|
||||||
void editcmd_dialog_replace_show (WEdit *, const char *, const char *, char **, char **);
|
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);
|
int editcmd_dialog_raw_key_query (const char *, const char *, int);
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
#include "src/main.h" /* macro_index */
|
#include "src/main.h" /* macro_index */
|
||||||
|
|
||||||
#include "edit-impl.h"
|
#include "edit-impl.h"
|
||||||
#include "edit-widget.h"
|
#include "editwidget.h"
|
||||||
|
|
||||||
/*** global variables ****************************************************************************/
|
/*** global variables ****************************************************************************/
|
||||||
|
|
||||||
@ -246,17 +246,15 @@ print_to_widget (WEdit * edit, long row, int start_col, int start_col_real,
|
|||||||
}
|
}
|
||||||
|
|
||||||
edit_move (x1, y);
|
edit_move (x1, y);
|
||||||
p = line;
|
|
||||||
i = 1;
|
i = 1;
|
||||||
while (p->ch)
|
for (p = line; p->ch != 0; p++)
|
||||||
{
|
{
|
||||||
int style;
|
int style;
|
||||||
unsigned int textchar;
|
unsigned int textchar;
|
||||||
int color;
|
int color;
|
||||||
|
|
||||||
if (cols_to_skip)
|
if (cols_to_skip != 0)
|
||||||
{
|
{
|
||||||
p++;
|
|
||||||
cols_to_skip--;
|
cols_to_skip--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -279,41 +277,23 @@ print_to_widget (WEdit * edit, long row, int start_col, int start_col_real,
|
|||||||
tty_setcolor (EDITOR_MARKED_COLOR);
|
tty_setcolor (EDITOR_MARKED_COLOR);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
tty_setcolor (EDITOR_WHITESPACE_COLOR);
|
||||||
#if 0
|
|
||||||
if (color != EDITOR_NORMAL_COLOR)
|
|
||||||
{
|
|
||||||
textchar = ' ';
|
|
||||||
tty_lowlevel_setcolor (color);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
tty_setcolor (EDITOR_WHITESPACE_COLOR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if (style & MOD_BOLD)
|
||||||
|
tty_setcolor (EDITOR_BOLD_COLOR);
|
||||||
|
else if (style & MOD_MARKED)
|
||||||
|
tty_setcolor (EDITOR_MARKED_COLOR);
|
||||||
else
|
else
|
||||||
{
|
tty_lowlevel_setcolor (color);
|
||||||
if (style & MOD_BOLD)
|
|
||||||
{
|
|
||||||
tty_setcolor (EDITOR_BOLD_COLOR);
|
|
||||||
}
|
|
||||||
else if (style & MOD_MARKED)
|
|
||||||
{
|
|
||||||
tty_setcolor (EDITOR_MARKED_COLOR);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tty_lowlevel_setcolor (color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (show_right_margin)
|
if (show_right_margin)
|
||||||
{
|
{
|
||||||
if (i > option_word_wrap_line_length + edit->start_col)
|
if (i > option_word_wrap_line_length + edit->start_col)
|
||||||
tty_setcolor (EDITOR_RIGHT_MARGIN_COLOR);
|
tty_setcolor (EDITOR_RIGHT_MARGIN_COLOR);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
tty_print_anychar (textchar);
|
tty_print_anychar (textchar);
|
||||||
p++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,6 +335,7 @@ edit_draw_this_line (WEdit * edit, long b, long row, long start_col, long end_co
|
|||||||
edit_get_syntax_color (edit, b - 1, &color);
|
edit_get_syntax_color (edit, b - 1, &color);
|
||||||
q = edit_move_forward3 (edit, b, start_col - edit->start_col, 0);
|
q = edit_move_forward3 (edit, b, start_col - edit->start_col, 0);
|
||||||
start_col_real = (col = (int) edit_move_forward3 (edit, b, 0, q)) + edit->start_col;
|
start_col_real = (col = (int) edit_move_forward3 (edit, b, 0, q)) + edit->start_col;
|
||||||
|
|
||||||
if (option_line_state)
|
if (option_line_state)
|
||||||
{
|
{
|
||||||
cur_line = edit->start_line + row;
|
cur_line = edit->start_line + row;
|
||||||
@ -390,6 +371,9 @@ edit_draw_this_line (WEdit * edit, long b, long row, long start_col, long end_co
|
|||||||
while (col <= end_col - edit->start_col)
|
while (col <= end_col - edit->start_col)
|
||||||
{
|
{
|
||||||
int cw = 1;
|
int cw = 1;
|
||||||
|
int tab_over = 0;
|
||||||
|
gboolean wide_width_char = FALSE;
|
||||||
|
gboolean control_char = FALSE;
|
||||||
|
|
||||||
p->ch = 0;
|
p->ch = 0;
|
||||||
p->style = 0;
|
p->style = 0;
|
||||||
@ -439,6 +423,9 @@ edit_draw_this_line (WEdit * edit, long b, long row, long start_col, long end_co
|
|||||||
break;
|
break;
|
||||||
case '\t':
|
case '\t':
|
||||||
i = TAB_SIZE - ((int) col % TAB_SIZE);
|
i = TAB_SIZE - ((int) col % TAB_SIZE);
|
||||||
|
tab_over = (end_col - edit->start_col) - (col + i - 1);
|
||||||
|
if (tab_over < 0)
|
||||||
|
i += tab_over;
|
||||||
col += i;
|
col += i;
|
||||||
if (tty_use_colors () &&
|
if (tty_use_colors () &&
|
||||||
((visible_tabs || (visible_tws && q >= tws)) && enable_show_tabs_tws))
|
((visible_tabs || (visible_tws && q >= tws)) && enable_show_tabs_tws))
|
||||||
@ -524,6 +511,14 @@ edit_draw_this_line (WEdit * edit, long b, long row, long start_col, long end_co
|
|||||||
{
|
{
|
||||||
c = convert_from_8bit_to_utf_c ((unsigned char) c, edit->converter);
|
c = convert_from_8bit_to_utf_c ((unsigned char) c, edit->converter);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (g_unichar_iswide (c))
|
||||||
|
{
|
||||||
|
wide_width_char = TRUE;
|
||||||
|
col++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (edit->utf8)
|
else if (edit->utf8)
|
||||||
c = convert_from_utf_to_current_c (c, edit->converter);
|
c = convert_from_utf_to_current_c (c, edit->converter);
|
||||||
@ -541,6 +536,7 @@ edit_draw_this_line (WEdit * edit, long b, long row, long start_col, long end_co
|
|||||||
p->style = abn_style;
|
p->style = abn_style;
|
||||||
p++;
|
p++;
|
||||||
col += 2;
|
col += 2;
|
||||||
|
control_char = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (c == 127)
|
if (c == 127)
|
||||||
@ -552,6 +548,7 @@ edit_draw_this_line (WEdit * edit, long b, long row, long start_col, long end_co
|
|||||||
p->style = abn_style;
|
p->style = abn_style;
|
||||||
p++;
|
p++;
|
||||||
col += 2;
|
col += 2;
|
||||||
|
control_char = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!edit->utf8)
|
if (!edit->utf8)
|
||||||
@ -592,6 +589,20 @@ edit_draw_this_line (WEdit * edit, long b, long row, long start_col, long end_co
|
|||||||
{
|
{
|
||||||
q += cw - 1;
|
q += cw - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (col > (end_col - edit->start_col + 1))
|
||||||
|
{
|
||||||
|
if (wide_width_char)
|
||||||
|
{
|
||||||
|
p--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (control_char)
|
||||||
|
{
|
||||||
|
p -= 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -600,7 +611,7 @@ edit_draw_this_line (WEdit * edit, long b, long row, long start_col, long end_co
|
|||||||
start_col_real = start_col = 0;
|
start_col_real = start_col = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
p->ch = '\0';
|
p->ch = 0;
|
||||||
|
|
||||||
print_to_widget (edit, row, start_col, start_col_real, end_col, line, line_stat, book_mark);
|
print_to_widget (edit, row, start_col, start_col_real, end_col, line, line_stat, book_mark);
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "edit-impl.h"
|
#include "edit-impl.h"
|
||||||
#include "edit-widget.h" /* WEdit */
|
#include "editwidget.h" /* WEdit */
|
||||||
#include "editcmd_dialogs.h"
|
#include "editcmd_dialogs.h"
|
||||||
|
|
||||||
#include "src/keybind-defaults.h" /* keybind_lookup_keymap_command() */
|
#include "src/keybind-defaults.h" /* keybind_lookup_keymap_command() */
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
#include "src/keybind-defaults.h"
|
#include "src/keybind-defaults.h"
|
||||||
|
|
||||||
#include "edit-impl.h"
|
#include "edit-impl.h"
|
||||||
#include "edit-widget.h"
|
#include "editwidget.h"
|
||||||
|
|
||||||
/*** global variables ****************************************************************************/
|
/*** global variables ****************************************************************************/
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
#include "lib/global.h"
|
#include "lib/global.h"
|
||||||
#include "lib/widget.h"
|
#include "lib/widget.h"
|
||||||
|
|
||||||
#include "edit-widget.h"
|
#include "editwidget.h"
|
||||||
#include "edit-impl.h"
|
#include "edit-impl.h"
|
||||||
#include "src/setup.h" /* option_tab_spacing */
|
#include "src/setup.h" /* option_tab_spacing */
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
#include "src/main.h" /* home_dir */
|
#include "src/main.h" /* home_dir */
|
||||||
|
|
||||||
#include "edit-impl.h"
|
#include "edit-impl.h"
|
||||||
#include "edit-widget.h"
|
#include "editwidget.h"
|
||||||
|
|
||||||
/*** global variables ****************************************************************************/
|
/*** global variables ****************************************************************************/
|
||||||
|
|
||||||
@ -359,7 +359,7 @@ edit_callback (Widget * w, widget_msg_t msg, int parm)
|
|||||||
/*** public functions ****************************************************************************/
|
/*** public functions ****************************************************************************/
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int
|
gboolean
|
||||||
edit_file (const vfs_path_t * _file_vpath, int line)
|
edit_file (const vfs_path_t * _file_vpath, int line)
|
||||||
{
|
{
|
||||||
static gboolean made_directory = FALSE;
|
static gboolean made_directory = FALSE;
|
||||||
@ -387,7 +387,7 @@ edit_file (const vfs_path_t * _file_vpath, int line)
|
|||||||
wedit = edit_init (NULL, 1, 0, LINES - 2, COLS, _file_vpath, line);
|
wedit = edit_init (NULL, 1, 0, LINES - 2, COLS, _file_vpath, line);
|
||||||
|
|
||||||
if (wedit == NULL)
|
if (wedit == NULL)
|
||||||
return 0;
|
return FALSE;
|
||||||
|
|
||||||
/* Create a new dialog and add it widgets to it */
|
/* Create a new dialog and add it widgets to it */
|
||||||
edit_dlg =
|
edit_dlg =
|
||||||
@ -414,7 +414,7 @@ edit_file (const vfs_path_t * _file_vpath, int line)
|
|||||||
if (edit_dlg->state == DLG_CLOSED)
|
if (edit_dlg->state == DLG_CLOSED)
|
||||||
destroy_dlg (edit_dlg);
|
destroy_dlg (edit_dlg);
|
||||||
|
|
||||||
return 1;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
#include "lib/widget.h" /* message() */
|
#include "lib/widget.h" /* message() */
|
||||||
|
|
||||||
#include "edit-impl.h"
|
#include "edit-impl.h"
|
||||||
#include "edit-widget.h"
|
#include "editwidget.h"
|
||||||
|
|
||||||
/*** global variables ****************************************************************************/
|
/*** global variables ****************************************************************************/
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
#include "src/setup.h" /* option_tab_spacing */
|
#include "src/setup.h" /* option_tab_spacing */
|
||||||
|
|
||||||
#include "edit-impl.h"
|
#include "edit-impl.h"
|
||||||
#include "edit-widget.h"
|
#include "editwidget.h"
|
||||||
|
|
||||||
/*** global variables ****************************************************************************/
|
/*** global variables ****************************************************************************/
|
||||||
|
|
||||||
|
@ -340,7 +340,7 @@ toggle_panels (void)
|
|||||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||||
if (mc_global.tty.use_subshell)
|
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);
|
invoke_subshell (NULL, VISIBLY, new_dir_p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -258,15 +258,13 @@ do_chown (uid_t u, gid_t g)
|
|||||||
static void
|
static void
|
||||||
apply_chowns (uid_t u, gid_t g)
|
apply_chowns (uid_t u, gid_t g)
|
||||||
{
|
{
|
||||||
char *fname;
|
|
||||||
|
|
||||||
need_update = end_chown = 1;
|
need_update = end_chown = 1;
|
||||||
do_chown (u, g);
|
do_chown (u, g);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
fname = next_file ();
|
next_file ();
|
||||||
|
|
||||||
do_chown (u, g);
|
do_chown (u, g);
|
||||||
}
|
}
|
||||||
while (current_panel->marked);
|
while (current_panel->marked);
|
||||||
|
@ -273,7 +273,7 @@ select_unselect_cmd (const char *title, const char *history_name, gboolean do_se
|
|||||||
if (quick_dialog (&quick_dlg) == B_CANCEL)
|
if (quick_dialog (&quick_dlg) == B_CANCEL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!reg_exp)
|
if (reg_exp == NULL)
|
||||||
return;
|
return;
|
||||||
if (!*reg_exp)
|
if (!*reg_exp)
|
||||||
{
|
{
|
||||||
|
@ -83,7 +83,8 @@ WInput *cmdline;
|
|||||||
static char *
|
static char *
|
||||||
examine_cd (const char *_path)
|
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;
|
state_t state = copy_sym;
|
||||||
char *q;
|
char *q;
|
||||||
@ -424,7 +425,7 @@ do_cd_command (char *orig_cmd)
|
|||||||
path = examine_cd (&cmd[operand_pos]);
|
path = examine_cd (&cmd[operand_pos]);
|
||||||
|
|
||||||
if (*path == '\0')
|
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
|
else
|
||||||
q_vpath = vfs_path_from_str_flags (path, VPF_NO_CANON);
|
q_vpath = vfs_path_from_str_flags (path, VPF_NO_CANON);
|
||||||
|
|
||||||
|
@ -516,7 +516,7 @@ regex_check_type (const vfs_path_t * filename_vpath, const char *ptr, int *have_
|
|||||||
if (*have_type == 0)
|
if (*have_type == 0)
|
||||||
{
|
{
|
||||||
vfs_path_t *localfile_vpath;
|
vfs_path_t *localfile_vpath;
|
||||||
const char *realname; /* name used with "file" */
|
const char *realname; /* name used with "file" */
|
||||||
|
|
||||||
#ifdef HAVE_CHARSET
|
#ifdef HAVE_CHARSET
|
||||||
int got_encoding_data;
|
int got_encoding_data;
|
||||||
@ -767,14 +767,14 @@ regex_command (const vfs_path_t * filename_vpath, const char *action, int *move_
|
|||||||
else if (!strncmp (p, "shell/", 6))
|
else if (!strncmp (p, "shell/", 6))
|
||||||
{
|
{
|
||||||
p += 6;
|
p += 6;
|
||||||
if (*p == '.' && file_len >= (size_t)(q - p))
|
if (*p == '.' && file_len >= (size_t) (q - p))
|
||||||
{
|
{
|
||||||
if (!strncmp (p, filename + file_len - (q - p), q - p))
|
if (!strncmp (p, filename + file_len - (q - p), q - p))
|
||||||
found = 1;
|
found = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((size_t)(q - p) == file_len && !strncmp (p, filename, q - p))
|
if ((size_t) (q - p) == file_len && !strncmp (p, filename, q - p))
|
||||||
found = 1;
|
found = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,7 +238,7 @@ free_link (void *data)
|
|||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
free_linklist (GSList *lp)
|
free_linklist (GSList * lp)
|
||||||
{
|
{
|
||||||
g_slist_foreach (lp, (GFunc) free_link, NULL);
|
g_slist_foreach (lp, (GFunc) free_link, NULL);
|
||||||
g_slist_free (lp);
|
g_slist_free (lp);
|
||||||
@ -249,7 +249,7 @@ free_linklist (GSList *lp)
|
|||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static gboolean
|
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;
|
const struct vfs_class *class;
|
||||||
ino_t ino = sb->st_ino;
|
ino_t ino = sb->st_ino;
|
||||||
@ -330,7 +330,7 @@ check_hardlinks (const vfs_path_t * src_vpath, const vfs_path_t * dst_vpath, str
|
|||||||
lnk->dev = dev;
|
lnk->dev = dev;
|
||||||
lnk->src_vpath = vfs_path_clone (src_vpath);
|
lnk->src_vpath = vfs_path_clone (src_vpath);
|
||||||
lnk->dst_vpath = vfs_path_clone (dst_vpath);
|
lnk->dst_vpath = vfs_path_clone (dst_vpath);
|
||||||
linklist = g_slist_prepend (linklist, lnk);
|
linklist = g_slist_prepend (linklist, lnk);
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -57,9 +57,9 @@
|
|||||||
#if ((STAT_STATVFS || STAT_STATVFS64) \
|
#if ((STAT_STATVFS || STAT_STATVFS64) \
|
||||||
&& (HAVE_STRUCT_STATVFS_F_BASETYPE || HAVE_STRUCT_STATVFS_F_FSTYPENAME \
|
&& (HAVE_STRUCT_STATVFS_F_BASETYPE || HAVE_STRUCT_STATVFS_F_FSTYPENAME \
|
||||||
|| (! HAVE_STRUCT_STATFS_F_FSTYPENAME)))
|
|| (! HAVE_STRUCT_STATFS_F_FSTYPENAME)))
|
||||||
# define USE_STATVFS 1
|
#define USE_STATVFS 1
|
||||||
#else
|
#else
|
||||||
# define USE_STATVFS 0
|
#define USE_STATVFS 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -70,36 +70,36 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#if USE_STATVFS
|
#if USE_STATVFS
|
||||||
# include <sys/statvfs.h>
|
#include <sys/statvfs.h>
|
||||||
#elif HAVE_SYS_VFS_H
|
#elif HAVE_SYS_VFS_H
|
||||||
# include <sys/vfs.h>
|
#include <sys/vfs.h>
|
||||||
#elif HAVE_SYS_MOUNT_H && HAVE_SYS_PARAM_H
|
#elif HAVE_SYS_MOUNT_H && HAVE_SYS_PARAM_H
|
||||||
/* NOTE: freebsd5.0 needs sys/param.h and sys/mount.h for statfs.
|
/* 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
|
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. */
|
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. */
|
/* NetBSD 1.5.2 needs these, for the declaration of struct statfs. */
|
||||||
# include <sys/param.h>
|
#include <sys/param.h>
|
||||||
# include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
# if HAVE_NFS_NFS_CLNT_H && HAVE_NFS_VFS_H
|
#if HAVE_NFS_NFS_CLNT_H && HAVE_NFS_VFS_H
|
||||||
/* Ultrix 4.4 needs these for the declaration of struct statfs. */
|
/* Ultrix 4.4 needs these for the declaration of struct statfs. */
|
||||||
# include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
# include <nfs/nfs_clnt.h>
|
#include <nfs/nfs_clnt.h>
|
||||||
# include <nfs/vfs.h>
|
#include <nfs/vfs.h>
|
||||||
# endif
|
#endif
|
||||||
#elif HAVE_OS_H /* BeOS */
|
#elif HAVE_OS_H /* BeOS */
|
||||||
# include <fs_info.h>
|
#include <fs_info.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if USE_STATVFS
|
#if USE_STATVFS
|
||||||
# define STRUCT_STATVFS struct statvfs
|
#define STRUCT_STATVFS struct statvfs
|
||||||
# if ! STAT_STATVFS && STAT_STATVFS64
|
#if ! STAT_STATVFS && STAT_STATVFS64
|
||||||
# define STATFS statvfs64
|
#define STATFS statvfs64
|
||||||
# else
|
|
||||||
# define STATFS statvfs
|
|
||||||
# endif
|
|
||||||
#else
|
#else
|
||||||
# define STATFS statfs
|
#define STATFS statvfs
|
||||||
# if HAVE_OS_H /* BeOS */
|
#endif
|
||||||
|
#else
|
||||||
|
#define STATFS statfs
|
||||||
|
#if HAVE_OS_H /* BeOS */
|
||||||
/* BeOS has a statvfs function, but it does not return sensible values
|
/* 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
|
for f_files, f_ffree and f_favail, and lacks f_type, f_basetype and
|
||||||
f_fstypename. Use 'struct fs_info' instead. */
|
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
|
errno = (device == B_ENTRY_NOT_FOUND ? ENOENT
|
||||||
: device == B_BAD_VALUE ? EINVAL
|
: device == B_BAD_VALUE ? EINVAL
|
||||||
: device == B_NAME_TOO_LONG ? ENAMETOOLONG
|
: device == B_NAME_TOO_LONG ? ENAMETOOLONG
|
||||||
: device == B_NO_MEMORY ? ENOMEM
|
: device == B_NO_MEMORY ? ENOMEM : device == B_FILE_ERROR ? EIO : 0);
|
||||||
: device == B_FILE_ERROR ? EIO
|
|
||||||
: 0);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* If successful, buf->dev will be == device. */
|
/* If successful, buf->dev will be == device. */
|
||||||
return fs_stat_dev (device, buf);
|
return fs_stat_dev (device, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
# define STRUCT_STATVFS struct fs_info
|
#define STRUCT_STATVFS struct fs_info
|
||||||
# else
|
#else
|
||||||
# define STRUCT_STATVFS struct statfs
|
#define STRUCT_STATVFS struct statfs
|
||||||
# endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAVE_STRUCT_STATVFS_F_BASETYPE
|
#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
|
#else
|
||||||
# if HAVE_STRUCT_STATVFS_F_FSTYPENAME || HAVE_STRUCT_STATFS_F_FSTYPENAME
|
#if HAVE_STRUCT_STATVFS_F_FSTYPENAME || HAVE_STRUCT_STATFS_F_FSTYPENAME
|
||||||
# define STATXFS_FILE_SYSTEM_TYPE_MEMBER_NAME f_fstypename
|
#define STATXFS_FILE_SYSTEM_TYPE_MEMBER_NAME f_fstypename
|
||||||
# elif HAVE_OS_H /* BeOS */
|
#elif HAVE_OS_H /* BeOS */
|
||||||
# define STATXFS_FILE_SYSTEM_TYPE_MEMBER_NAME fsh_name
|
#define STATXFS_FILE_SYSTEM_TYPE_MEMBER_NAME fsh_name
|
||||||
# endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -1693,10 +1693,9 @@ do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs,
|
|||||||
/* absolute path */
|
/* absolute path */
|
||||||
if (start_dir_len < 0)
|
if (start_dir_len < 0)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
vfs_path_free (current_panel->cwd_vpath);
|
vfs_path_free (current_panel->cwd_vpath);
|
||||||
current_panel->cwd_vpath = vfs_path_from_str (PATH_SEP_STR);
|
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);
|
panelize_save_panel (current_panel);
|
||||||
}
|
}
|
||||||
|
@ -557,7 +557,7 @@ init_layout (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
equal_split = panels_layout.horizontal_split ?
|
equal_split = panels_layout.horizontal_split ?
|
||||||
panels_layout.horizontal_equal : panels_layout.vertical_equal;
|
panels_layout.horizontal_equal : panels_layout.vertical_equal;
|
||||||
|
|
||||||
/* "Panel split" groupbox */
|
/* "Panel split" groupbox */
|
||||||
bright_widget = button_new (6, 14, B_2RIGHT, NARROW_BUTTON, "&>", b_left_right_cback);
|
bright_widget = button_new (6, 14, B_2RIGHT, NARROW_BUTTON, "&>", b_left_right_cback);
|
||||||
|
@ -71,7 +71,7 @@ struct Widget *get_panel_widget (int idx);
|
|||||||
struct WPanel *get_other_panel (void);
|
struct WPanel *get_other_panel (void);
|
||||||
|
|
||||||
void save_panel_dir (int idx);
|
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);
|
void set_hintbar (const char *str);
|
||||||
|
|
||||||
|
@ -628,10 +628,7 @@ create_panels (void)
|
|||||||
|
|
||||||
/* 3. Create active panel */
|
/* 3. Create active panel */
|
||||||
if (current_dir == NULL)
|
if (current_dir == NULL)
|
||||||
{
|
|
||||||
current_dir = vfs_path_to_str (original_dir);
|
|
||||||
mc_chdir (original_dir);
|
mc_chdir (original_dir);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vfs_path_t *vpath;
|
vfs_path_t *vpath;
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdint.h> /* SIZE_MAX */
|
#include <stdint.h> /* SIZE_MAX */
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -43,7 +43,7 @@
|
|||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined STAT_STATVFS || defined STAT_STATVFS64 /* POSIX 1003.1-2001 (and later) with XSI */
|
#if defined STAT_STATVFS || defined STAT_STATVFS64 /* POSIX 1003.1-2001 (and later) with XSI */
|
||||||
#include <sys/statvfs.h>
|
#include <sys/statvfs.h>
|
||||||
#else
|
#else
|
||||||
/* Don't include backward-compatibility files unless they're needed.
|
/* Don't include backward-compatibility files unless they're needed.
|
||||||
@ -202,7 +202,7 @@
|
|||||||
#undef closedir
|
#undef closedir
|
||||||
|
|
||||||
#ifndef ME_DUMMY
|
#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, "autofs") == 0 \
|
||||||
|| strcmp (Fs_type, "none") == 0 \
|
|| strcmp (Fs_type, "none") == 0 \
|
||||||
|| strcmp (Fs_type, "proc") == 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
|
#ifndef ME_REMOTE
|
||||||
/* A file system is `remote' if its Fs_name contains a `:'
|
/* 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 `//'). */
|
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 \
|
(strchr (Fs_name, ':') != NULL \
|
||||||
|| ((Fs_name)[0] == '/' \
|
|| ((Fs_name)[0] == '/' \
|
||||||
&& (Fs_name)[1] == '/' \
|
&& (Fs_name)[1] == '/' \
|
||||||
@ -270,7 +270,7 @@ me_remote (char const *fs_name, char const *fs_type _GL_UNUSED)
|
|||||||
otherwise, use PROPAGATE_ALL_ONES. */
|
otherwise, use PROPAGATE_ALL_ONES. */
|
||||||
#define PROPAGATE_TOP_BIT(x) ((x) | ~ (EXTRACT_TOP_BIT (x) - 1))
|
#define PROPAGATE_TOP_BIT(x) ((x) | ~ (EXTRACT_TOP_BIT (x) - 1))
|
||||||
|
|
||||||
#ifdef STAT_READ_FILSYS /* SVR2 */
|
#ifdef STAT_READ_FILSYS /* SVR2 */
|
||||||
/* Set errno to zero upon EOF. */
|
/* Set errno to zero upon EOF. */
|
||||||
#define ZERO_BYTE_TRANSFER_ERRNO 0
|
#define ZERO_BYTE_TRANSFER_ERRNO 0
|
||||||
|
|
||||||
@ -279,32 +279,32 @@ me_remote (char const *fs_name, char const *fs_type _GL_UNUSED)
|
|||||||
#else
|
#else
|
||||||
#define IS_EINTR(x) 0
|
#define IS_EINTR(x) 0
|
||||||
#endif
|
#endif
|
||||||
#endif /* STAT_READ_FILSYS */
|
#endif /* STAT_READ_FILSYS */
|
||||||
|
|
||||||
/*** file scope type declarations ****************************************************************/
|
/*** file scope type declarations ****************************************************************/
|
||||||
|
|
||||||
/* A mount table entry. */
|
/* A mount table entry. */
|
||||||
struct mount_entry
|
struct mount_entry
|
||||||
{
|
{
|
||||||
char *me_devname; /* Device node name, including "/dev/". */
|
char *me_devname; /* Device node name, including "/dev/". */
|
||||||
char *me_mountdir; /* Mount point directory name. */
|
char *me_mountdir; /* Mount point directory name. */
|
||||||
char *me_type; /* "nfs", "4.2", etc. */
|
char *me_type; /* "nfs", "4.2", etc. */
|
||||||
dev_t me_dev; /* Device number of me_mountdir. */
|
dev_t me_dev; /* Device number of me_mountdir. */
|
||||||
unsigned int me_dummy : 1; /* Nonzero for dummy file systems. */
|
unsigned int me_dummy:1; /* Nonzero for dummy file systems. */
|
||||||
unsigned int me_remote : 1; /* Nonzero for remote fileystems. */
|
unsigned int me_remote:1; /* Nonzero for remote fileystems. */
|
||||||
unsigned int me_type_malloced : 1; /* Nonzero if me_type was malloced. */
|
unsigned int me_type_malloced:1; /* Nonzero if me_type was malloced. */
|
||||||
struct mount_entry *me_next;
|
struct mount_entry *me_next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct fs_usage
|
struct fs_usage
|
||||||
{
|
{
|
||||||
uintmax_t fsu_blocksize; /* Size of a block. */
|
uintmax_t fsu_blocksize; /* Size of a block. */
|
||||||
uintmax_t fsu_blocks; /* Total blocks. */
|
uintmax_t fsu_blocks; /* Total blocks. */
|
||||||
uintmax_t fsu_bfree; /* Free blocks available to superuser. */
|
uintmax_t fsu_bfree; /* Free blocks available to superuser. */
|
||||||
uintmax_t fsu_bavail; /* Free blocks available to non-superuser. */
|
uintmax_t fsu_bavail; /* Free blocks available to non-superuser. */
|
||||||
int fsu_bavail_top_bit_set; /* 1 if fsu_bavail represents a value < 0. */
|
int fsu_bavail_top_bit_set; /* 1 if fsu_bavail represents a value < 0. */
|
||||||
uintmax_t fsu_files; /* Total file nodes. */
|
uintmax_t fsu_files; /* Total file nodes. */
|
||||||
uintmax_t fsu_ffree; /* Free file nodes. */
|
uintmax_t fsu_ffree; /* Free file nodes. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*** file scope variables ************************************************************************/
|
/*** file scope variables ************************************************************************/
|
||||||
@ -1044,7 +1044,7 @@ read_file_system_list (int need_fs_type)
|
|||||||
&& (ignore == options || ignore[-1] == ',')
|
&& (ignore == options || ignore[-1] == ',')
|
||||||
&& (ignore[sizeof ("ignore") - 1] == ','
|
&& (ignore[sizeof ("ignore") - 1] == ','
|
||||||
|| ignore[sizeof ("ignore") - 1] == '\0'));
|
|| 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. */
|
/* Add to the linked list. */
|
||||||
*mtail = me;
|
*mtail = me;
|
||||||
@ -1221,7 +1221,7 @@ read_file_system_list (int need_fs_type, int all_fs)
|
|||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#ifdef STAT_READ_FILSYS /* SVR2 */
|
#ifdef STAT_READ_FILSYS /* SVR2 */
|
||||||
|
|
||||||
/* Read(write) up to COUNT bytes at BUF from(to) descriptor FD, retrying if
|
/* Read(write) up to COUNT bytes at BUF from(to) descriptor FD, retrying if
|
||||||
interrupted. Return the actual number of bytes read(written), zero for EOF,
|
interrupted. Return the actual number of bytes read(written), zero for EOF,
|
||||||
@ -1229,24 +1229,26 @@ read_file_system_list (int need_fs_type, int all_fs)
|
|||||||
static size_t
|
static size_t
|
||||||
safe_read (int fd, void *buf, size_t count)
|
safe_read (int fd, void *buf, size_t count)
|
||||||
{
|
{
|
||||||
/* Work around a bug in Tru64 5.1. Attempting to read more than
|
/* Work around a bug in Tru64 5.1. Attempting to read more than
|
||||||
INT_MAX bytes fails with errno == EINVAL. See
|
INT_MAX bytes fails with errno == EINVAL. See
|
||||||
<http://lists.gnu.org/archive/html/bug-gnu-utils/2002-04/msg00010.html>.
|
<http://lists.gnu.org/archive/html/bug-gnu-utils/2002-04/msg00010.html>.
|
||||||
When decreasing COUNT, keep it block-aligned. */
|
When decreasing COUNT, keep it block-aligned. */
|
||||||
enum { BUGGY_READ_MAXIMUM = INT_MAX & ~8191 };
|
/* *INDENT-OFF* */
|
||||||
|
enum { BUGGY_READ_MAXIMUM = INT_MAX & ~8191 };
|
||||||
|
/* *INDENT-ON* */
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
ssize_t result = read (fd, buf, count);
|
ssize_t result = read (fd, buf, count);
|
||||||
|
|
||||||
if (0 <= result)
|
if (0 <= result)
|
||||||
return result;
|
return result;
|
||||||
else if (IS_EINTR (errno))
|
else if (IS_EINTR (errno))
|
||||||
continue;
|
continue;
|
||||||
else if (errno == EINVAL && BUGGY_READ_MAXIMUM < count)
|
else if (errno == EINVAL && BUGGY_READ_MAXIMUM < count)
|
||||||
count = BUGGY_READ_MAXIMUM;
|
count = BUGGY_READ_MAXIMUM;
|
||||||
else
|
else
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1262,28 +1264,28 @@ safe_read (int fd, void *buf, size_t count)
|
|||||||
static size_t
|
static size_t
|
||||||
full_read (int fd, void *buf, size_t count)
|
full_read (int fd, void *buf, size_t count)
|
||||||
{
|
{
|
||||||
size_t total = 0;
|
size_t total = 0;
|
||||||
char *ptr = (char *) buf;
|
char *ptr = (char *) buf;
|
||||||
|
|
||||||
while (count > 0)
|
while (count > 0)
|
||||||
{
|
{
|
||||||
size_t n_rw = safe_read (fd, ptr, count);
|
size_t n_rw = safe_read (fd, ptr, count);
|
||||||
if (n_rw == (size_t) (-1))
|
if (n_rw == (size_t) (-1))
|
||||||
break;
|
break;
|
||||||
if (n_rw == 0)
|
if (n_rw == 0)
|
||||||
{
|
{
|
||||||
errno = ZERO_BYTE_TRANSFER_ERRNO;
|
errno = ZERO_BYTE_TRANSFER_ERRNO;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
total += n_rw;
|
total += n_rw;
|
||||||
ptr += n_rw;
|
ptr += n_rw;
|
||||||
count -= n_rw;
|
count -= n_rw;
|
||||||
}
|
}
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* STAT_READ_FILSYS */
|
#endif /* STAT_READ_FILSYS */
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
@ -1298,7 +1300,7 @@ full_read (int fd, void *buf, size_t count)
|
|||||||
static int
|
static int
|
||||||
get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
|
get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
|
||||||
{
|
{
|
||||||
#ifdef STAT_STATVFS /* POSIX, except glibc/Linux */
|
#ifdef STAT_STATVFS /* POSIX, except glibc/Linux */
|
||||||
|
|
||||||
struct statvfs fsd;
|
struct statvfs fsd;
|
||||||
|
|
||||||
@ -1379,7 +1381,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
|
|||||||
fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize);
|
fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize);
|
||||||
|
|
||||||
#elif defined STAT_STATFS2_BSIZE /* glibc/Linux, 4.3BSD, SunOS 4, \
|
#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 */
|
NetBSD < 3.0, OpenBSD < 4.4 */
|
||||||
|
|
||||||
struct statfs fsd;
|
struct statfs fsd;
|
||||||
@ -1517,7 +1519,9 @@ my_statfs (struct my_statfs *myfs_stats, const char *path)
|
|||||||
myfs_stats->typename = entry->me_type;
|
myfs_stats->typename = entry->me_type;
|
||||||
myfs_stats->mpoint = entry->me_mountdir;
|
myfs_stats->mpoint = entry->me_mountdir;
|
||||||
myfs_stats->device = entry->me_devname;
|
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->total = ((uintmax_t) fs_use.fsu_blocks * fs_use.fsu_blocksize) >> 10;
|
||||||
myfs_stats->nfree = (uintmax_t) fs_use.fsu_ffree;
|
myfs_stats->nfree = (uintmax_t) fs_use.fsu_ffree;
|
||||||
myfs_stats->nodes = (uintmax_t) fs_use.fsu_files;
|
myfs_stats->nodes = (uintmax_t) fs_use.fsu_files;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Declarations for list of mounted filesystems
|
Declarations for list of mounted filesystems
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \file mountlist.h
|
/** \file mountlist.h
|
||||||
* \brief Header: list of mounted filesystems
|
* \brief Header: list of mounted filesystems
|
||||||
@ -24,8 +24,8 @@ struct my_statfs
|
|||||||
char *typename;
|
char *typename;
|
||||||
const char *mpoint;
|
const char *mpoint;
|
||||||
const char *device;
|
const char *device;
|
||||||
uintmax_t avail; /* in kB */
|
uintmax_t avail; /* in kB */
|
||||||
uintmax_t total; /* in kB */
|
uintmax_t total; /* in kB */
|
||||||
uintmax_t nfree;
|
uintmax_t nfree;
|
||||||
uintmax_t nodes;
|
uintmax_t nodes;
|
||||||
};
|
};
|
||||||
|
@ -2876,6 +2876,8 @@ subshell_chdir (const vfs_path_t * vpath)
|
|||||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||||
if (mc_global.tty.use_subshell && vfs_current_is_local ())
|
if (mc_global.tty.use_subshell && vfs_current_is_local ())
|
||||||
do_subshell_chdir (vpath, FALSE, TRUE);
|
do_subshell_chdir (vpath, FALSE, TRUE);
|
||||||
|
#else /* HAVE_SUBSHELL_SUPPORT */
|
||||||
|
(void) vpath;
|
||||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3956,7 +3958,7 @@ panel_new_with_dir (const char *panel_name, const char *wpath)
|
|||||||
vfs_path_t *vpath;
|
vfs_path_t *vpath;
|
||||||
|
|
||||||
vpath = vfs_path_from_str (curdir);
|
vpath = vfs_path_from_str (curdir);
|
||||||
err = mc_chdir (vpath);
|
mc_chdir (vpath);
|
||||||
vfs_path_free (vpath);
|
vfs_path_free (vpath);
|
||||||
}
|
}
|
||||||
g_free (curdir);
|
g_free (curdir);
|
||||||
@ -4421,7 +4423,7 @@ remove_encoding_from_path (const vfs_path_t * vpath)
|
|||||||
g_string_free (tmp_conv, TRUE);
|
g_string_free (tmp_conv, TRUE);
|
||||||
return ret_vpath;
|
return ret_vpath;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_CHARSET */
|
#endif /* HAVE_CHARSET */
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
/**
|
/**
|
||||||
|
@ -387,9 +387,8 @@ do_external_panelize (char *command)
|
|||||||
current_panel->count = next_free;
|
current_panel->count = next_free;
|
||||||
if (list->list[0].fname[0] == PATH_SEP)
|
if (list->list[0].fname[0] == PATH_SEP)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
panel_set_cwd (current_panel, PATH_SEP_STR);
|
panel_set_cwd (current_panel, PATH_SEP_STR);
|
||||||
ret = chdir (PATH_SEP_STR);
|
chdir (PATH_SEP_STR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -736,7 +736,6 @@ static void
|
|||||||
tree_rescan (void *data)
|
tree_rescan (void *data)
|
||||||
{
|
{
|
||||||
WTree *tree = data;
|
WTree *tree = data;
|
||||||
int ret;
|
|
||||||
vfs_path_t *old_vpath;
|
vfs_path_t *old_vpath;
|
||||||
|
|
||||||
old_vpath = vfs_path_clone (vfs_get_raw_current_dir ());
|
old_vpath = vfs_path_clone (vfs_get_raw_current_dir ());
|
||||||
@ -746,7 +745,7 @@ tree_rescan (void *data)
|
|||||||
if (tree->selected_ptr != NULL && mc_chdir (tree->selected_ptr->name) == 0)
|
if (tree->selected_ptr != NULL && mc_chdir (tree->selected_ptr->name) == 0)
|
||||||
{
|
{
|
||||||
tree_store_rescan (tree->selected_ptr->name);
|
tree_store_rescan (tree->selected_ptr->name);
|
||||||
ret = mc_chdir (old_vpath);
|
mc_chdir (old_vpath);
|
||||||
}
|
}
|
||||||
vfs_path_free (old_vpath);
|
vfs_path_free (old_vpath);
|
||||||
}
|
}
|
||||||
|
@ -408,7 +408,7 @@ tree_store_add_entry (const vfs_path_t * name)
|
|||||||
abort ();
|
abort ();
|
||||||
|
|
||||||
/* Search for the correct place */
|
/* Search for the correct place */
|
||||||
while (current && (flag = pathcmp (current->name, name)) < 0)
|
while (current != NULL && (flag = pathcmp (current->name, name)) < 0)
|
||||||
{
|
{
|
||||||
old = current;
|
old = current;
|
||||||
current = current->next;
|
current = current->next;
|
||||||
@ -430,7 +430,8 @@ tree_store_add_entry (const vfs_path_t * name)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
old->next = new;
|
if (old != NULL)
|
||||||
|
old->next = new;
|
||||||
new->prev = old;
|
new->prev = old;
|
||||||
}
|
}
|
||||||
new->next = NULL;
|
new->next = NULL;
|
||||||
@ -440,7 +441,7 @@ tree_store_add_entry (const vfs_path_t * name)
|
|||||||
{
|
{
|
||||||
/* Insert in to the middle of the list */
|
/* Insert in to the middle of the list */
|
||||||
new->prev = old;
|
new->prev = old;
|
||||||
if (old)
|
if (old != NULL)
|
||||||
{
|
{
|
||||||
/* Yes, in the middle */
|
/* Yes, in the middle */
|
||||||
new->next = old->next;
|
new->next = old->next;
|
||||||
|
@ -19,7 +19,7 @@ struct WEdit;
|
|||||||
|
|
||||||
/*** declarations of public functions ************************************************************/
|
/*** 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);
|
char *expand_format (struct WEdit *edit_widget, char c, gboolean do_quote);
|
||||||
int check_format_view (const char *);
|
int check_format_view (const char *);
|
||||||
int check_format_var (const char *, char **);
|
int check_format_var (const char *, char **);
|
||||||
|
@ -93,7 +93,6 @@ static const global_keymap_ini_t default_main_keymap[] = {
|
|||||||
{"Delete", "f8"},
|
{"Delete", "f8"},
|
||||||
{"Menu", "f9"},
|
{"Menu", "f9"},
|
||||||
{"Quit", "f10"},
|
{"Quit", "f10"},
|
||||||
{"ViewFile", "f13"},
|
|
||||||
{"MenuLastSelected", "f19"},
|
{"MenuLastSelected", "f19"},
|
||||||
{"QuitQuiet", "f20"},
|
{"QuitQuiet", "f20"},
|
||||||
{"History", "alt-h"},
|
{"History", "alt-h"},
|
||||||
|
@ -373,7 +373,8 @@ learn_save (void)
|
|||||||
|
|
||||||
esc_str = strutils_escape (learnkeys[i].sequence, -1, ";\\", TRUE);
|
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);
|
g_free (esc_str);
|
||||||
}
|
}
|
||||||
|
@ -603,10 +603,8 @@ main (int argc, char *argv[])
|
|||||||
S_IRUSR | S_IWUSR);
|
S_IRUSR | S_IWUSR);
|
||||||
if (last_wd_fd != -1)
|
if (last_wd_fd != -1)
|
||||||
{
|
{
|
||||||
ssize_t ret1;
|
(void) write (last_wd_fd, last_wd_string, strlen (last_wd_string));
|
||||||
int ret2;
|
(void) close (last_wd_fd);
|
||||||
ret1 = write (last_wd_fd, last_wd_string, strlen (last_wd_string));
|
|
||||||
ret2 = close (last_wd_fd);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_free (last_wd_string);
|
g_free (last_wd_string);
|
||||||
|
@ -108,8 +108,8 @@ char *load_anon_passwd (void);
|
|||||||
void load_keymap_defs (gboolean load_from_file);
|
void load_keymap_defs (gboolean load_from_file);
|
||||||
void free_keymap_defs (void);
|
void free_keymap_defs (void);
|
||||||
|
|
||||||
void panel_load_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 panel_save_setup (struct WPanel *panel, const char *section);
|
||||||
|
|
||||||
void panels_load_options (void);
|
void panels_load_options (void);
|
||||||
void panels_save_options (void);
|
void panels_save_options (void);
|
||||||
|
@ -252,10 +252,7 @@ init_subshell_child (const char *pty_name)
|
|||||||
|
|
||||||
/* It simplifies things to change to our home directory here, */
|
/* It simplifies things to change to our home directory here, */
|
||||||
/* and the user's startup file may do a `cd' command anyway */
|
/* and the user's startup file may do a `cd' command anyway */
|
||||||
{
|
chdir (mc_config_get_home_dir ()); /* FIXME? What about when we re-run the subshell? */
|
||||||
int ret;
|
|
||||||
ret = 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 */
|
/* Set MC_SID to prevent running one mc from another */
|
||||||
mc_sid = getsid (0);
|
mc_sid = getsid (0);
|
||||||
|
@ -854,7 +854,7 @@ init_cpiofs (void)
|
|||||||
{
|
{
|
||||||
static struct vfs_s_subclass cpio_subclass;
|
static struct vfs_s_subclass cpio_subclass;
|
||||||
|
|
||||||
cpio_subclass.flags = VFS_S_READONLY; /* FIXME: cpiofs used own temp files */
|
cpio_subclass.flags = VFS_S_READONLY; /* FIXME: cpiofs used own temp files */
|
||||||
cpio_subclass.archive_check = cpio_super_check;
|
cpio_subclass.archive_check = cpio_super_check;
|
||||||
cpio_subclass.archive_same = cpio_super_same;
|
cpio_subclass.archive_same = cpio_super_same;
|
||||||
cpio_subclass.open_archive = cpio_open_archive;
|
cpio_subclass.open_archive = cpio_open_archive;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
/*** declarations of public functions ************************************************************/
|
/*** declarations of public functions ************************************************************/
|
||||||
|
|
||||||
void init_cpiofs(void);
|
void init_cpiofs (void);
|
||||||
|
|
||||||
/*** inline functions ****************************************************************************/
|
/*** inline functions ****************************************************************************/
|
||||||
|
|
||||||
|
@ -422,7 +422,7 @@ extfs_open_archive (int fstype, const char *name, struct archive **pparc)
|
|||||||
goto ret;
|
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 ",
|
cmd = g_strconcat (info->path, info->prefix, " list ",
|
||||||
|
@ -251,9 +251,8 @@ fish_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, c
|
|||||||
|
|
||||||
if (logfile)
|
if (logfile)
|
||||||
{
|
{
|
||||||
size_t ret;
|
(void) fwrite (str, strlen (str), 1, logfile);
|
||||||
ret = fwrite (str, strlen (str), 1, logfile);
|
(void) fflush (logfile);
|
||||||
ret = fflush (logfile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tty_enable_interrupt_key ();
|
tty_enable_interrupt_key ();
|
||||||
@ -330,13 +329,13 @@ fish_pipeopen (struct vfs_s_super *super, const char *path, const char *argv[])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res = dup2 (fileset1[0], 0);
|
(void) dup2 (fileset1[0], 0);
|
||||||
close (fileset1[0]);
|
close (fileset1[0]);
|
||||||
close (fileset1[1]);
|
close (fileset1[1]);
|
||||||
res = dup2 (fileset2[1], 1);
|
(void) dup2 (fileset2[1], 1);
|
||||||
close (2);
|
close (2);
|
||||||
/* stderr to /dev/null */
|
/* stderr to /dev/null */
|
||||||
res = open ("/dev/null", O_WRONLY);
|
(void) open ("/dev/null", O_WRONLY);
|
||||||
close (fileset2[0]);
|
close (fileset2[0]);
|
||||||
close (fileset2[1]);
|
close (fileset2[1]);
|
||||||
execvp (path, const_cast (char **, argv));
|
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 *temp;
|
||||||
char *data_start = buffer + 1;
|
char *data_start = buffer + 1;
|
||||||
char *filename = data_start;
|
char *filename = data_start;
|
||||||
char *linkname = data_start;
|
char *filename_bound;
|
||||||
char *filename_bound = filename + strlen (filename);
|
|
||||||
char *linkname_bound = filename_bound;
|
filename_bound = filename + strlen (filename);
|
||||||
|
|
||||||
if (!strcmp (data_start, "\".\"") || !strcmp (data_start, "\"..\""))
|
if (!strcmp (data_start, "\".\"") || !strcmp (data_start, "\"..\""))
|
||||||
break; /* We'll do "." and ".." ourselves */
|
break; /* We'll do "." and ".." ourselves */
|
||||||
|
|
||||||
if (S_ISLNK (ST.st_mode))
|
if (S_ISLNK (ST.st_mode))
|
||||||
{
|
{
|
||||||
|
char *linkname;
|
||||||
|
char *linkname_bound;
|
||||||
/* we expect: "escaped-name" -> "escaped-name"
|
/* we expect: "escaped-name" -> "escaped-name"
|
||||||
// -> cannot occur in filenames,
|
// -> cannot occur in filenames,
|
||||||
// because it will be escaped to -\> */
|
// because it will be escaped to -\> */
|
||||||
|
|
||||||
|
|
||||||
|
linkname_bound = filename_bound;
|
||||||
|
|
||||||
if (*filename == '"')
|
if (*filename == '"')
|
||||||
++filename;
|
++filename;
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ extern int fish_directory_timeout;
|
|||||||
|
|
||||||
/*** declarations of public functions ************************************************************/
|
/*** declarations of public functions ************************************************************/
|
||||||
|
|
||||||
void init_fish(void);
|
void init_fish (void);
|
||||||
|
|
||||||
/*** inline functions ****************************************************************************/
|
/*** inline functions ****************************************************************************/
|
||||||
|
|
||||||
|
@ -477,8 +477,7 @@ ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
size_t ret;
|
(void) fwrite (cmdstr, cmdlen, 1, MEDATA->logfile);
|
||||||
ret = fwrite (cmdstr, cmdlen, 1, MEDATA->logfile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fflush (MEDATA->logfile);
|
fflush (MEDATA->logfile);
|
||||||
@ -2488,7 +2487,8 @@ ftpfs_netrc_lookup (const char *host, char **login, char **pass)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Ignore unsafe passwords */
|
/* 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))
|
&& ftpfs_netrc_bad_mode (netrcname))
|
||||||
{
|
{
|
||||||
need_break = 1;
|
need_break = 1;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
/*** declarations of public functions ************************************************************/
|
/*** declarations of public functions ************************************************************/
|
||||||
|
|
||||||
void vfs_plugins_init(void);
|
void vfs_plugins_init (void);
|
||||||
|
|
||||||
/*** inline functions ****************************************************************************/
|
/*** inline functions ****************************************************************************/
|
||||||
|
|
||||||
|
@ -190,7 +190,10 @@ sfs_vfmake (const vfs_path_t * vpath, vfs_path_t * cache_vpath)
|
|||||||
COPY_CHAR;
|
COPY_CHAR;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
COPY_STRING (ptr);
|
if (ptr != NULL)
|
||||||
|
{
|
||||||
|
COPY_STRING (ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
Unix SMB/Netbios implementation.
|
Unix SMB/Netbios implementation.
|
||||||
Version 1.9.
|
Version 1.9.
|
||||||
SMB Byte handling
|
SMB Byte handling
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _BYTEORDER_H
|
#ifndef _BYTEORDER_H
|
||||||
#define _BYTEORDER_H
|
#define _BYTEORDER_H
|
||||||
@ -11,73 +11,73 @@
|
|||||||
This file implements macros for machine independent short and
|
This file implements macros for machine independent short and
|
||||||
int manipulation
|
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
|
> 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
|
> 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
|
> between LE and BE machines, but you only seem to distinguish between 386
|
||||||
> and all other architectures.
|
> and all other architectures.
|
||||||
>
|
>
|
||||||
> Can you give me a clue?
|
> Can you give me a clue?
|
||||||
|
|
||||||
sure.
|
sure.
|
||||||
|
|
||||||
The distinction between 386 and other architectures is only there as
|
The distinction between 386 and other architectures is only there as
|
||||||
an optimisation. You can take it out completely and it will make no
|
an optimisation. You can take it out completely and it will make no
|
||||||
difference. The routines (macros) in byteorder.h are totally byteorder
|
difference. The routines (macros) in byteorder.h are totally byteorder
|
||||||
independent. The 386 optimsation just takes advantage of the fact that
|
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
|
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
|
align ints on int boundaries etc. If there are other processors out
|
||||||
there that aren't alignment sensitive then you could also define
|
there that aren't alignment sensitive then you could also define
|
||||||
CAREFUL_ALIGNMENT=0 on those processors as well.
|
CAREFUL_ALIGNMENT=0 on those processors as well.
|
||||||
|
|
||||||
Ok, now to the macros themselves. I'll take a simple example, say we
|
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
|
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
|
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
|
want to do it with only the assumption that uint16 is _at_least_ 16
|
||||||
bits long (this last condition is very important for architectures
|
bits long (this last condition is very important for architectures
|
||||||
that don't have any int types that are 2 bytes long)
|
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 CVAL(buf,pos) (((unsigned char *)(buf))[pos])
|
||||||
#define PVAL(buf,pos) ((unsigned)CVAL(buf,pos))
|
#define PVAL(buf,pos) ((unsigned)CVAL(buf,pos))
|
||||||
#define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
|
#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();
|
char *buffer = foo_bar();
|
||||||
uint16 xx = SVAL(buffer,25);
|
uint16 xx = SVAL(buffer,25);
|
||||||
|
|
||||||
We are using the byteoder independence of the ANSI C bitshifts to do
|
We are using the byteoder independence of the ANSI C bitshifts to do
|
||||||
the work. A good optimising compiler should turn this into efficient
|
the work. A good optimising compiler should turn this into efficient
|
||||||
code, especially if it happens to have the right byteorder :-)
|
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
|
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
|
casts, but you need to look at byteorder.h as a whole to see the
|
||||||
reasoning behind them. byteorder.h defines the following macros:
|
reasoning behind them. byteorder.h defines the following macros:
|
||||||
|
|
||||||
SVAL(buf,pos) - extract a 2 byte SMB value
|
SVAL(buf,pos) - extract a 2 byte SMB value
|
||||||
IVAL(buf,pos) - extract a 4 byte SMB value
|
IVAL(buf,pos) - extract a 4 byte SMB value
|
||||||
SVALS(buf,pos) signed version of SVAL()
|
SVALS(buf,pos) signed version of SVAL()
|
||||||
IVALS(buf,pos) signed version of IVAL()
|
IVALS(buf,pos) signed version of IVAL()
|
||||||
|
|
||||||
SSVAL(buf,pos,val) - put a 2 byte SMB value into a buffer
|
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
|
SIVAL(buf,pos,val) - put a 4 byte SMB value into a buffer
|
||||||
SSVALS(buf,pos,val) - signed version of SSVAL()
|
SSVALS(buf,pos,val) - signed version of SSVAL()
|
||||||
SIVALS(buf,pos,val) - signed version of SIVAL()
|
SIVALS(buf,pos,val) - signed version of SIVAL()
|
||||||
|
|
||||||
RSVAL(buf,pos) - like SVAL() but for NMB byte ordering
|
RSVAL(buf,pos) - like SVAL() but for NMB byte ordering
|
||||||
RSVALS(buf,pos) - like SVALS() 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
|
RIVAL(buf,pos) - like IVAL() but for NMB byte ordering
|
||||||
RIVALS(buf,pos) - like IVALS() 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
|
RSSVAL(buf,pos,val) - like SSVAL() but for NMB ordering
|
||||||
RSIVAL(buf,pos,val) - like SIVAL() but for NMB ordering
|
RSIVAL(buf,pos,val) - like SIVAL() but for NMB ordering
|
||||||
RSIVALS(buf,pos,val) - like SIVALS() 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 */
|
/* 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
|
WARNING: This section is dependent on the length of int16 and int32
|
||||||
being correct
|
being correct
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* get single value from an SMB buffer */
|
/* get single value from an SMB buffer */
|
||||||
#define SVAL(buf,pos) (*(uint16 *)((char *)(buf) + (pos)))
|
#define SVAL(buf,pos) (*(uint16 *)((char *)(buf) + (pos)))
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
Unix SMB/Netbios implementation.
|
Unix SMB/Netbios implementation.
|
||||||
Version 1.9.
|
Version 1.9.
|
||||||
Character set handling
|
Character set handling
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CHARSET_C
|
#ifndef CHARSET_C
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ extern char *lower_char_map;
|
|||||||
/* this is used to determine if a character is safe to use in
|
/* this is used to determine if a character is safe to use in
|
||||||
something that may be put on a command line */
|
something that may be put on a command line */
|
||||||
#define issafe(c) (isalnum((c&0xff)) || strchr("-._",c))
|
#define issafe(c) (isalnum((c&0xff)) || strchr("-._",c))
|
||||||
#endif /* !CHARSET_C */
|
#endif /* !CHARSET_C */
|
||||||
|
|
||||||
/* Dynamic codepage files defines. */
|
/* Dynamic codepage files defines. */
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
Unix SMB/Netbios implementation.
|
Unix SMB/Netbios implementation.
|
||||||
Version 1.9.
|
Version 1.9.
|
||||||
SMB parameters and setup
|
SMB parameters and setup
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _CLIENT_H
|
#ifndef _CLIENT_H
|
||||||
#define _CLIENT_H
|
#define _CLIENT_H
|
||||||
@ -18,25 +18,25 @@
|
|||||||
|
|
||||||
typedef struct file_info
|
typedef struct file_info
|
||||||
{
|
{
|
||||||
SMB_OFF_T size;
|
SMB_OFF_T size;
|
||||||
uint16 mode;
|
uint16 mode;
|
||||||
uid_t uid;
|
uid_t uid;
|
||||||
gid_t gid;
|
gid_t gid;
|
||||||
/* these times are normally kept in GMT */
|
/* these times are normally kept in GMT */
|
||||||
time_t mtime;
|
time_t mtime;
|
||||||
time_t atime;
|
time_t atime;
|
||||||
time_t ctime;
|
time_t ctime;
|
||||||
pstring name;
|
pstring name;
|
||||||
} file_info;
|
} file_info;
|
||||||
|
|
||||||
struct print_job_info
|
struct print_job_info
|
||||||
{
|
{
|
||||||
uint16 id;
|
uint16 id;
|
||||||
uint16 priority;
|
uint16 priority;
|
||||||
size_t size;
|
size_t size;
|
||||||
fstring user;
|
fstring user;
|
||||||
fstring name;
|
fstring name;
|
||||||
time_t t;
|
time_t t;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pwd_info
|
struct pwd_info
|
||||||
@ -54,73 +54,74 @@ struct pwd_info
|
|||||||
uchar smb_nt_owf[24];
|
uchar smb_nt_owf[24];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cli_state {
|
struct cli_state
|
||||||
int port;
|
{
|
||||||
int fd;
|
int port;
|
||||||
uint16 cnum;
|
int fd;
|
||||||
uint16 pid;
|
uint16 cnum;
|
||||||
uint16 mid;
|
uint16 pid;
|
||||||
uint16 vuid;
|
uint16 mid;
|
||||||
int protocol;
|
uint16 vuid;
|
||||||
int sec_mode;
|
int protocol;
|
||||||
int rap_error;
|
int sec_mode;
|
||||||
int privileges;
|
int rap_error;
|
||||||
|
int privileges;
|
||||||
|
|
||||||
fstring eff_name;
|
fstring eff_name;
|
||||||
fstring desthost;
|
fstring desthost;
|
||||||
fstring user_name;
|
fstring user_name;
|
||||||
fstring domain;
|
fstring domain;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The following strings are the
|
* The following strings are the
|
||||||
* ones returned by the server if
|
* ones returned by the server if
|
||||||
* the protocol > NT1.
|
* the protocol > NT1.
|
||||||
*/
|
*/
|
||||||
fstring server_type;
|
fstring server_type;
|
||||||
fstring server_os;
|
fstring server_os;
|
||||||
fstring server_domain;
|
fstring server_domain;
|
||||||
|
|
||||||
fstring share;
|
fstring share;
|
||||||
fstring dev;
|
fstring dev;
|
||||||
struct nmb_name called;
|
struct nmb_name called;
|
||||||
struct nmb_name calling;
|
struct nmb_name calling;
|
||||||
fstring full_dest_host_name;
|
fstring full_dest_host_name;
|
||||||
struct in_addr dest_ip;
|
struct in_addr dest_ip;
|
||||||
|
|
||||||
struct pwd_info pwd;
|
struct pwd_info pwd;
|
||||||
unsigned char cryptkey[8];
|
unsigned char cryptkey[8];
|
||||||
uint32 sesskey;
|
uint32 sesskey;
|
||||||
int serverzone;
|
int serverzone;
|
||||||
uint32 servertime;
|
uint32 servertime;
|
||||||
int readbraw_supported;
|
int readbraw_supported;
|
||||||
int writebraw_supported;
|
int writebraw_supported;
|
||||||
int timeout; /* in milliseconds. */
|
int timeout; /* in milliseconds. */
|
||||||
int max_xmit;
|
int max_xmit;
|
||||||
int max_mux;
|
int max_mux;
|
||||||
char *outbuf;
|
char *outbuf;
|
||||||
char *inbuf;
|
char *inbuf;
|
||||||
int bufsize;
|
int bufsize;
|
||||||
int initialised;
|
int initialised;
|
||||||
int win95;
|
int win95;
|
||||||
uint32 capabilities;
|
uint32 capabilities;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Only used in NT domain calls.
|
* Only used in NT domain calls.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint32 nt_error; /* NT RPC error code. */
|
uint32 nt_error; /* NT RPC error code. */
|
||||||
uint16 nt_pipe_fnum; /* Pipe handle. */
|
uint16 nt_pipe_fnum; /* Pipe handle. */
|
||||||
unsigned char sess_key[16]; /* Current session key. */
|
unsigned char sess_key[16]; /* Current session key. */
|
||||||
unsigned char ntlmssp_hash[258]; /* ntlmssp data. */
|
unsigned char ntlmssp_hash[258]; /* ntlmssp data. */
|
||||||
uint32 ntlmssp_cli_flgs; /* ntlmssp client flags */
|
uint32 ntlmssp_cli_flgs; /* ntlmssp client flags */
|
||||||
uint32 ntlmssp_srv_flgs; /* ntlmssp server flags */
|
uint32 ntlmssp_srv_flgs; /* ntlmssp server flags */
|
||||||
uint32 ntlmssp_seq_num; /* ntlmssp sequence number */
|
uint32 ntlmssp_seq_num; /* ntlmssp sequence number */
|
||||||
DOM_CRED clnt_cred; /* Client credential. */
|
DOM_CRED clnt_cred; /* Client credential. */
|
||||||
fstring mach_acct; /* MYNAME$. */
|
fstring mach_acct; /* MYNAME$. */
|
||||||
fstring srv_name_slash; /* \\remote server. */
|
fstring srv_name_slash; /* \\remote server. */
|
||||||
fstring clnt_name_slash; /* \\local client. */
|
fstring clnt_name_slash; /* \\local client. */
|
||||||
uint16 max_xmit_frag;
|
uint16 max_xmit_frag;
|
||||||
uint16 max_recv_frag;
|
uint16 max_recv_frag;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _CLIENT_H */
|
#endif /* _CLIENT_H */
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
Unix SMB/Netbios implementation.
|
Unix SMB/Netbios implementation.
|
||||||
Version 1.9.
|
Version 1.9.
|
||||||
Machine customisation and include handling
|
Machine customisation and include handling
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NO_CONFIG_H /* for some tests */
|
#ifndef NO_CONFIG_H /* for some tests */
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -156,7 +156,7 @@
|
|||||||
/* POSIX terminal handling. */
|
/* POSIX terminal handling. */
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
|
|
||||||
# include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
#ifdef HAVE_SYS_MMAN_H
|
#ifdef HAVE_SYS_MMAN_H
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
@ -185,23 +185,23 @@
|
|||||||
#include <sys/acl.h>
|
#include <sys/acl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SYS_FS_S5PARAM_H
|
#ifdef HAVE_SYS_FS_S5PARAM_H
|
||||||
#include <sys/fs/s5param.h>
|
#include <sys/fs/s5param.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
|
#if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
|
||||||
#include <sys/filsys.h>
|
#include <sys/filsys.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SYS_STATFS_H
|
#ifdef HAVE_SYS_STATFS_H
|
||||||
# include <sys/statfs.h>
|
#include <sys/statfs.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_DUSTAT_H
|
#ifdef HAVE_DUSTAT_H
|
||||||
#include <sys/dustat.h>
|
#include <sys/dustat.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SYS_STATVFS_H
|
#ifdef HAVE_SYS_STATVFS_H
|
||||||
#include <sys/statvfs.h>
|
#include <sys/statvfs.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -219,7 +219,7 @@
|
|||||||
#include <sys/security.h>
|
#include <sys/security.h>
|
||||||
#include <prot.h>
|
#include <prot.h>
|
||||||
#define PASSWORD_LENGTH 16
|
#define PASSWORD_LENGTH 16
|
||||||
#endif /* HAVE_SYS_SECURITY_H */
|
#endif /* HAVE_SYS_SECURITY_H */
|
||||||
|
|
||||||
#ifdef HAVE_COMPAT_H
|
#ifdef HAVE_COMPAT_H
|
||||||
#include <compat.h>
|
#include <compat.h>
|
||||||
@ -269,7 +269,7 @@
|
|||||||
they actually only need to be at least 16 and 32 bits
|
they actually only need to be at least 16 and 32 bits
|
||||||
respectively. Thus if your word size is 8 bytes just defining them
|
respectively. Thus if your word size is 8 bytes just defining them
|
||||||
as signed and unsigned int will work.
|
as signed and unsigned int will work.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef uint8
|
#ifndef uint8
|
||||||
#define uint8 unsigned char
|
#define uint8 unsigned char
|
||||||
@ -334,23 +334,23 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SMB_INO_T
|
#ifndef SMB_INO_T
|
||||||
# define SMB_INO_T ino_t
|
#define SMB_INO_T ino_t
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef LARGE_SMB_INO_T
|
#ifndef LARGE_SMB_INO_T
|
||||||
# if defined(SIZEOF_INO_T) && (SIZEOF_INO_T == 8)
|
#if defined(SIZEOF_INO_T) && (SIZEOF_INO_T == 8)
|
||||||
# define LARGE_SMB_INO_T 1
|
#define LARGE_SMB_INO_T 1
|
||||||
# endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LARGE_SMB_INO_T
|
#ifdef LARGE_SMB_INO_T
|
||||||
#define SINO_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
|
#define SINO_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
|
||||||
#else
|
#else
|
||||||
#define SINO_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
|
#define SINO_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SMB_OFF_T
|
#ifndef SMB_OFF_T
|
||||||
# define SMB_OFF_T off_t
|
#define SMB_OFF_T off_t
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SMB_OFF_T_BITS (sizeof(SMB_OFF_T)*8)
|
#define SMB_OFF_T_BITS (sizeof(SMB_OFF_T)*8)
|
||||||
@ -361,14 +361,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LARGE_SMB_OFF_T
|
#ifndef LARGE_SMB_OFF_T
|
||||||
# if defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)
|
#if defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)
|
||||||
# define LARGE_SMB_OFF_T 1
|
#define LARGE_SMB_OFF_T 1
|
||||||
# endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LARGE_SMB_OFF_T
|
#ifdef LARGE_SMB_OFF_T
|
||||||
#define SOFF_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
|
#define SOFF_T(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,(v)>>32))
|
||||||
#else
|
#else
|
||||||
#define SOFF_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
|
#define SOFF_T(p, ofs, v) (SIVAL(p,ofs,v),SIVAL(p,(ofs)+4,0))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -377,7 +377,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SMB_STRUCT_STAT
|
#ifndef SMB_STRUCT_STAT
|
||||||
# define SMB_STRUCT_STAT struct stat
|
#define SMB_STRUCT_STAT struct stat
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -385,7 +385,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SMB_STRUCT_DIRENT
|
#ifndef SMB_STRUCT_DIRENT
|
||||||
# define SMB_STRUCT_DIRENT struct dirent
|
#define SMB_STRUCT_DIRENT struct dirent
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -393,19 +393,19 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SMB_STRUCT_FLOCK
|
#ifndef SMB_STRUCT_FLOCK
|
||||||
# define SMB_STRUCT_FLOCK struct flock
|
#define SMB_STRUCT_FLOCK struct flock
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SMB_F_SETLKW
|
#ifndef SMB_F_SETLKW
|
||||||
# define SMB_F_SETLKW F_SETLKW
|
#define SMB_F_SETLKW F_SETLKW
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SMB_F_SETLK
|
#ifndef SMB_F_SETLK
|
||||||
# define SMB_F_SETLK F_SETLK
|
#define SMB_F_SETLK F_SETLK
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SMB_F_GETLK
|
#ifndef SMB_F_GETLK
|
||||||
# define SMB_F_GETLK F_GETLK
|
#define SMB_F_GETLK F_GETLK
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_LONGLONG)
|
#if defined(HAVE_LONGLONG)
|
||||||
@ -515,7 +515,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* what is the longest significant password available on your system?
|
/* what is the longest significant password available on your system?
|
||||||
Knowing this speeds up password searches a lot */
|
Knowing this speeds up password searches a lot */
|
||||||
#ifndef PASSWORD_LENGTH
|
#ifndef PASSWORD_LENGTH
|
||||||
#define PASSWORD_LENGTH 8
|
#define PASSWORD_LENGTH 8
|
||||||
#endif
|
#endif
|
||||||
@ -549,19 +549,19 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_INITGROUPS
|
#ifndef HAVE_INITGROUPS
|
||||||
int initgroups(char *name,gid_t id);
|
int initgroups (char *name, gid_t id);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_RENAME
|
#ifndef HAVE_RENAME
|
||||||
int rename(const char *zfrom, const char *zto);
|
int rename (const char *zfrom, const char *zto);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_MKTIME
|
#ifndef HAVE_MKTIME
|
||||||
time_t mktime(struct tm *t);
|
time_t mktime (struct tm *t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_STRTOUL
|
#ifndef HAVE_STRTOUL
|
||||||
unsigned long strtoul(const char *nptr, char **endptr, int base);
|
unsigned long strtoul (const char *nptr, char **endptr, int base);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef REPLACE_GETPASS
|
#ifdef REPLACE_GETPASS
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
Unix SMB/Netbios implementation.
|
Unix SMB/Netbios implementation.
|
||||||
Version 1.9.
|
Version 1.9.
|
||||||
Kanji Extensions
|
Kanji Extensions
|
||||||
*/
|
*/
|
||||||
#ifndef _KANJI_H_
|
#ifndef _KANJI_H_
|
||||||
#define _KANJI_H_
|
#define _KANJI_H_
|
||||||
|
|
||||||
@ -86,7 +86,7 @@
|
|||||||
#define is_hangul(c) ((0x81 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xfd))
|
#define is_hangul(c) ((0x81 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xfd))
|
||||||
|
|
||||||
/* For traditional Chinese (known as Big5 encoding - code page 950). */
|
/* For traditional Chinese (known as Big5 encoding - code page 950). */
|
||||||
#define is_big5_c1(c) ((0xa1 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xf9))
|
#define is_big5_c1(c) ((0xa1 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xf9))
|
||||||
|
|
||||||
/* For simplified Chinese (code page - 936). */
|
/* For simplified Chinese (code page - 936). */
|
||||||
#define is_simpch_c1(c) ((0xa1 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xf7))
|
#define is_simpch_c1(c) ((0xa1 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0xf7))
|
||||||
@ -118,14 +118,14 @@
|
|||||||
/* Ensure we use our definitions in all other files than kanji.c. */
|
/* Ensure we use our definitions in all other files than kanji.c. */
|
||||||
|
|
||||||
/* Function pointers we will replace. */
|
/* Function pointers we will replace. */
|
||||||
extern char *(*multibyte_strchr)(const char *s, int c);
|
extern char *(*multibyte_strchr) (const char *s, int c);
|
||||||
extern char *(*multibyte_strrchr)(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_strstr) (const char *s1, const char *s2);
|
||||||
extern char *(*multibyte_strtok)(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 *(*_dos_to_unix) (char *str, BOOL overwrite);
|
||||||
extern char *(*_unix_to_dos)(char *str, BOOL overwrite);
|
extern char *(*_unix_to_dos) (char *str, BOOL overwrite);
|
||||||
extern BOOL (*is_multibyte_char)(char c);
|
extern BOOL (*is_multibyte_char) (char c);
|
||||||
extern int (*_skip_multibyte_char)(char c);
|
extern int (*_skip_multibyte_char) (char c);
|
||||||
|
|
||||||
#define strchr(s1, c) ((*multibyte_strchr)((s1), (c)))
|
#define strchr(s1, c) ((*multibyte_strchr)((s1), (c)))
|
||||||
#define strrchr(s1, c) ((*multibyte_strrchr)((s1), (c)))
|
#define strrchr(s1, c) ((*multibyte_strrchr)((s1), (c)))
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
refer to the special "printers" service */
|
refer to the special "printers" service */
|
||||||
#define PRINTERS_NAME "printers"
|
#define PRINTERS_NAME "printers"
|
||||||
|
|
||||||
/* Yves Gaige <yvesg@hptnodur.grenoble.hp.com> requested this set this */
|
/* Yves Gaige <yvesg@hptnodur.grenoble.hp.com> requested this set this */
|
||||||
/* to a maximum of 8 if old smb clients break because of long printer names. */
|
/* to a maximum of 8 if old smb clients break because of long printer names. */
|
||||||
#define MAXPRINTERLEN 15
|
#define MAXPRINTERLEN 15
|
||||||
|
|
||||||
@ -59,7 +59,7 @@
|
|||||||
#ifndef MAX_OPEN_FILES
|
#ifndef MAX_OPEN_FILES
|
||||||
#define MAX_OPEN_FILES 10000
|
#define MAX_OPEN_FILES 10000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* the max number of simultanous connections to the server by all clients */
|
/* the max number of simultanous connections to the server by all clients */
|
||||||
#define MAXSTATUS 100000
|
#define MAXSTATUS 100000
|
||||||
|
|
||||||
@ -80,7 +80,7 @@
|
|||||||
|
|
||||||
/* shall filenames with illegal chars in them get mangled in long
|
/* shall filenames with illegal chars in them get mangled in long
|
||||||
filename listings? */
|
filename listings? */
|
||||||
#define MANGLE_LONG_FILENAMES
|
#define MANGLE_LONG_FILENAMES
|
||||||
|
|
||||||
/* define this if you want to stop spoofing with .. and soft links
|
/* define this if you want to stop spoofing with .. and soft links
|
||||||
NOTE: This also slows down the server considerably */
|
NOTE: This also slows down the server considerably */
|
||||||
@ -152,7 +152,7 @@
|
|||||||
#define SHORT_CONNECT_TIMEOUT 5000
|
#define SHORT_CONNECT_TIMEOUT 5000
|
||||||
|
|
||||||
/* default socket options. Dave Miller thinks we should default to TCP_NODELAY
|
/* 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
|
#ifdef TCP_NODELAY
|
||||||
#define DEFAULT_SOCKET_OPTIONS "TCP_NODELAY"
|
#define DEFAULT_SOCKET_OPTIONS "TCP_NODELAY"
|
||||||
#else
|
#else
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
Unix SMB/Netbios implementation.
|
Unix SMB/Netbios implementation.
|
||||||
Version 1.9.
|
Version 1.9.
|
||||||
NBT netbios header - version 2
|
NBT netbios header - version 2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PERMANENT_TTL 0
|
#define PERMANENT_TTL 0
|
||||||
|
|
||||||
@ -12,16 +12,18 @@
|
|||||||
#define MAINTAIN_LIST 2
|
#define MAINTAIN_LIST 2
|
||||||
#define ELECTION_VERSION 1
|
#define ELECTION_VERSION 1
|
||||||
|
|
||||||
#define MAX_DGRAM_SIZE (576) /* tcp/ip datagram limit is 576 bytes */
|
#define MAX_DGRAM_SIZE (576) /* tcp/ip datagram limit is 576 bytes */
|
||||||
#define MIN_DGRAM_SIZE 12
|
#define MIN_DGRAM_SIZE 12
|
||||||
|
|
||||||
/*********************************************************
|
/*********************************************************
|
||||||
Types of reply packet.
|
Types of reply packet.
|
||||||
**********************************************************/
|
**********************************************************/
|
||||||
|
|
||||||
enum netbios_reply_type_code { NMB_QUERY, NMB_STATUS, NMB_REG, NMB_REG_REFRESH,
|
enum netbios_reply_type_code
|
||||||
NMB_REL, NMB_WAIT_ACK, NMB_MULTIHOMED_REG,
|
{ NMB_QUERY, NMB_STATUS, NMB_REG, NMB_REG_REFRESH,
|
||||||
WINS_REG, WINS_QUERY };
|
NMB_REL, NMB_WAIT_ACK, NMB_MULTIHOMED_REG,
|
||||||
|
WINS_REG, WINS_QUERY
|
||||||
|
};
|
||||||
|
|
||||||
/* From rfc1002, 4.2.1.2 */
|
/* From rfc1002, 4.2.1.2 */
|
||||||
/* Question types. */
|
/* Question types. */
|
||||||
@ -33,14 +35,14 @@ enum netbios_reply_type_code { NMB_QUERY, NMB_STATUS, NMB_REG, NMB_REG_REFRESH,
|
|||||||
|
|
||||||
/* Opcode definitions */
|
/* Opcode definitions */
|
||||||
#define NMB_NAME_QUERY_OPCODE 0x0
|
#define NMB_NAME_QUERY_OPCODE 0x0
|
||||||
#define NMB_NAME_REG_OPCODE 0x05 /* see rfc1002.txt 4.2.2,3,5,6,7,8 */
|
#define NMB_NAME_REG_OPCODE 0x05 /* see rfc1002.txt 4.2.2,3,5,6,7,8 */
|
||||||
#define NMB_NAME_RELEASE_OPCODE 0x06 /* see rfc1002.txt 4.2.9,10,11 */
|
#define NMB_NAME_RELEASE_OPCODE 0x06 /* see rfc1002.txt 4.2.9,10,11 */
|
||||||
#define NMB_WACK_OPCODE 0x07 /* see rfc1002.txt 4.2.16 */
|
#define NMB_WACK_OPCODE 0x07 /* see rfc1002.txt 4.2.16 */
|
||||||
/* Ambiguity in rfc1002 about which of these is correct. */
|
/* Ambiguity in rfc1002 about which of these is correct. */
|
||||||
/* WinNT uses 8 by default but can be made to use 9. */
|
/* WinNT uses 8 by default but can be made to use 9. */
|
||||||
#define NMB_NAME_REFRESH_OPCODE_8 0x08 /* see rfc1002.txt 4.2.4 */
|
#define NMB_NAME_REFRESH_OPCODE_8 0x08 /* see rfc1002.txt 4.2.4 */
|
||||||
#define NMB_NAME_REFRESH_OPCODE_9 0x09 /* see rfc1002.txt 4.2.4 */
|
#define NMB_NAME_REFRESH_OPCODE_9 0x09 /* see rfc1002.txt 4.2.4 */
|
||||||
#define NMB_NAME_MULTIHOMED_REG_OPCODE 0x0F /* Invented by Microsoft. */
|
#define NMB_NAME_MULTIHOMED_REG_OPCODE 0x0F /* Invented by Microsoft. */
|
||||||
|
|
||||||
/* XXXX what about all the other types?? 0x1, 0x2, 0x3, 0x4, 0x8? */
|
/* XXXX what about all the other types?? 0x1, 0x2, 0x3, 0x4, 0x8? */
|
||||||
|
|
||||||
@ -60,10 +62,10 @@ enum netbios_reply_type_code { NMB_QUERY, NMB_STATUS, NMB_REG, NMB_REG_REFRESH,
|
|||||||
#define NB_ACTIVE 0x04
|
#define NB_ACTIVE 0x04
|
||||||
#define NB_CONFL 0x08
|
#define NB_CONFL 0x08
|
||||||
#define NB_DEREG 0x10
|
#define NB_DEREG 0x10
|
||||||
#define NB_BFLAG 0x00 /* Broadcast node type. */
|
#define NB_BFLAG 0x00 /* Broadcast node type. */
|
||||||
#define NB_PFLAG 0x20 /* Point-to-point node type. */
|
#define NB_PFLAG 0x20 /* Point-to-point node type. */
|
||||||
#define NB_MFLAG 0x40 /* Mixed bcast & p-p node type. */
|
#define NB_MFLAG 0x40 /* Mixed bcast & p-p node type. */
|
||||||
#define NB_HFLAG 0x60 /* Microsoft 'hybrid' node type. */
|
#define NB_HFLAG 0x60 /* Microsoft 'hybrid' node type. */
|
||||||
#define NB_NODETYPEMASK 0x60
|
#define NB_NODETYPEMASK 0x60
|
||||||
/* Mask applied to outgoing NetBIOS flags. */
|
/* Mask applied to outgoing NetBIOS flags. */
|
||||||
#define NB_FLGMSK 0xE0
|
#define NB_FLGMSK 0xE0
|
||||||
@ -81,13 +83,13 @@ enum netbios_reply_type_code { NMB_QUERY, NMB_STATUS, NMB_REG, NMB_REG_REFRESH,
|
|||||||
#define NAME_IS_DEREGISTERING(p) ((p)->data.nb_flags & NB_DEREG)
|
#define NAME_IS_DEREGISTERING(p) ((p)->data.nb_flags & NB_DEREG)
|
||||||
|
|
||||||
/* Error codes for NetBIOS requests. */
|
/* Error codes for NetBIOS requests. */
|
||||||
#define FMT_ERR 0x1 /* Packet format error. */
|
#define FMT_ERR 0x1 /* Packet format error. */
|
||||||
#define SRV_ERR 0x2 /* Internal server error. */
|
#define SRV_ERR 0x2 /* Internal server error. */
|
||||||
#define NAM_ERR 0x3 /* Name does not exist. */
|
#define NAM_ERR 0x3 /* Name does not exist. */
|
||||||
#define IMP_ERR 0x4 /* Request not implemented. */
|
#define IMP_ERR 0x4 /* Request not implemented. */
|
||||||
#define RFS_ERR 0x5 /* Request refused. */
|
#define RFS_ERR 0x5 /* Request refused. */
|
||||||
#define ACT_ERR 0x6 /* Active error - name owned by another host. */
|
#define ACT_ERR 0x6 /* Active error - name owned by another host. */
|
||||||
#define CFT_ERR 0x7 /* Name in conflict error. */
|
#define CFT_ERR 0x7 /* Name in conflict error. */
|
||||||
|
|
||||||
#define REFRESH_TIME (15*60)
|
#define REFRESH_TIME (15*60)
|
||||||
#define NAME_POLL_REFRESH_TIME (5*60)
|
#define NAME_POLL_REFRESH_TIME (5*60)
|
||||||
@ -123,47 +125,51 @@ 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,
|
enum name_source
|
||||||
DNSFAIL_NAME, PERMANENT_NAME, WINS_PROXY_NAME};
|
{ LMHOSTS_NAME, REGISTER_NAME, SELF_NAME, DNS_NAME,
|
||||||
enum node_type {B_NODE=0, P_NODE=1, M_NODE=2, NBDD_NODE=3};
|
DNSFAIL_NAME, PERMANENT_NAME, WINS_PROXY_NAME
|
||||||
enum packet_type {NMB_PACKET, DGRAM_PACKET};
|
};
|
||||||
|
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
|
enum master_state
|
||||||
{
|
{
|
||||||
MST_NONE,
|
MST_NONE,
|
||||||
MST_POTENTIAL,
|
MST_POTENTIAL,
|
||||||
MST_BACKUP,
|
MST_BACKUP,
|
||||||
MST_MSB,
|
MST_MSB,
|
||||||
MST_BROWSER,
|
MST_BROWSER,
|
||||||
MST_UNBECOMING_MASTER
|
MST_UNBECOMING_MASTER
|
||||||
};
|
};
|
||||||
|
|
||||||
enum domain_state
|
enum domain_state
|
||||||
{
|
{
|
||||||
DOMAIN_NONE,
|
DOMAIN_NONE,
|
||||||
DOMAIN_WAIT,
|
DOMAIN_WAIT,
|
||||||
DOMAIN_MST
|
DOMAIN_MST
|
||||||
};
|
};
|
||||||
|
|
||||||
enum logon_state
|
enum logon_state
|
||||||
{
|
{
|
||||||
LOGON_NONE,
|
LOGON_NONE,
|
||||||
LOGON_WAIT,
|
LOGON_WAIT,
|
||||||
LOGON_SRV
|
LOGON_SRV
|
||||||
};
|
};
|
||||||
|
|
||||||
struct subnet_record;
|
struct subnet_record;
|
||||||
|
|
||||||
struct nmb_data
|
struct nmb_data
|
||||||
{
|
{
|
||||||
uint16 nb_flags; /* Netbios flags. */
|
uint16 nb_flags; /* Netbios flags. */
|
||||||
int num_ips; /* Number of ip entries. */
|
int num_ips; /* Number of ip entries. */
|
||||||
struct in_addr *ip; /* The ip list for this name. */
|
struct in_addr *ip; /* The ip list for this name. */
|
||||||
|
|
||||||
enum name_source source; /* Where the name came from. */
|
enum name_source source; /* Where the name came from. */
|
||||||
|
|
||||||
time_t death_time; /* The time the record must be removed (do not remove if 0). */
|
time_t death_time; /* The time the record must be removed (do not remove if 0). */
|
||||||
time_t refresh_time; /* The time the record should be refreshed. */
|
time_t refresh_time; /* The time the record should be refreshed. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This is used to hold the list of servers in my domain, and is
|
/* This is used to hold the list of servers in my domain, and is
|
||||||
@ -171,71 +177,72 @@ struct nmb_data
|
|||||||
|
|
||||||
struct server_record
|
struct server_record
|
||||||
{
|
{
|
||||||
struct server_record *next;
|
struct server_record *next;
|
||||||
struct server_record *prev;
|
struct server_record *prev;
|
||||||
|
|
||||||
struct subnet_record *subnet;
|
struct subnet_record *subnet;
|
||||||
|
|
||||||
struct server_info_struct serv;
|
struct server_info_struct serv;
|
||||||
time_t death_time;
|
time_t death_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* A workgroup structure. It contains a list of servers. */
|
/* A workgroup structure. It contains a list of servers. */
|
||||||
struct work_record
|
struct work_record
|
||||||
{
|
{
|
||||||
struct work_record *next;
|
struct work_record *next;
|
||||||
struct work_record *prev;
|
struct work_record *prev;
|
||||||
|
|
||||||
struct subnet_record *subnet;
|
struct subnet_record *subnet;
|
||||||
|
|
||||||
struct server_record *serverlist;
|
struct server_record *serverlist;
|
||||||
|
|
||||||
/* Stage of development from non-local-master up to local-master browser. */
|
/* Stage of development from non-local-master up to local-master browser. */
|
||||||
enum master_state mst_state;
|
enum master_state mst_state;
|
||||||
|
|
||||||
/* Stage of development from non-domain-master to domain-master browser. */
|
/* Stage of development from non-domain-master to domain-master browser. */
|
||||||
enum domain_state dom_state;
|
enum domain_state dom_state;
|
||||||
|
|
||||||
/* Stage of development from non-logon-server to logon server. */
|
/* Stage of development from non-logon-server to logon server. */
|
||||||
enum logon_state log_state;
|
enum logon_state log_state;
|
||||||
|
|
||||||
/* Work group info. */
|
/* Work group info. */
|
||||||
fstring work_group;
|
fstring work_group;
|
||||||
int token; /* Used when communicating with backup browsers. */
|
int token; /* Used when communicating with backup browsers. */
|
||||||
fstring local_master_browser_name; /* Current local master browser. */
|
fstring local_master_browser_name; /* Current local master browser. */
|
||||||
|
|
||||||
/* Announce info. */
|
/* Announce info. */
|
||||||
time_t lastannounce_time;
|
time_t lastannounce_time;
|
||||||
int announce_interval;
|
int announce_interval;
|
||||||
BOOL needannounce;
|
BOOL needannounce;
|
||||||
|
|
||||||
/* Timeout time for this workgroup. 0 means permanent. */
|
/* Timeout time for this workgroup. 0 means permanent. */
|
||||||
time_t death_time;
|
time_t death_time;
|
||||||
|
|
||||||
/* Election info */
|
/* Election info */
|
||||||
BOOL RunningElection;
|
BOOL RunningElection;
|
||||||
BOOL needelection;
|
BOOL needelection;
|
||||||
int ElectionCount;
|
int ElectionCount;
|
||||||
uint32 ElectionCriterion;
|
uint32 ElectionCriterion;
|
||||||
|
|
||||||
/* Domain master browser info. Used for efficient syncs. */
|
/* Domain master browser info. Used for efficient syncs. */
|
||||||
struct nmb_name dmb_name;
|
struct nmb_name dmb_name;
|
||||||
struct in_addr dmb_addr;
|
struct in_addr dmb_addr;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* typedefs needed to define copy & free functions for userdata. */
|
/* typedefs needed to define copy & free functions for userdata. */
|
||||||
struct userdata_struct;
|
struct userdata_struct;
|
||||||
|
|
||||||
typedef struct userdata_struct * (*userdata_copy_fn)(struct userdata_struct *);
|
typedef struct userdata_struct *(*userdata_copy_fn) (struct userdata_struct *);
|
||||||
typedef void (*userdata_free_fn)(struct userdata_struct *);
|
typedef void (*userdata_free_fn) (struct userdata_struct *);
|
||||||
|
|
||||||
/* Structure to define any userdata passed around. */
|
/* Structure to define any userdata passed around. */
|
||||||
|
|
||||||
struct userdata_struct {
|
struct userdata_struct
|
||||||
userdata_copy_fn copy_fn;
|
{
|
||||||
userdata_free_fn free_fn;
|
userdata_copy_fn copy_fn;
|
||||||
unsigned int userdata_len;
|
userdata_free_fn free_fn;
|
||||||
char data[16]; /* 16 is to ensure alignment/padding on all systems */
|
unsigned int userdata_len;
|
||||||
|
char data[16]; /* 16 is to ensure alignment/padding on all systems */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct response_record;
|
struct response_record;
|
||||||
@ -243,99 +250,83 @@ struct packet_struct;
|
|||||||
struct res_rec;
|
struct res_rec;
|
||||||
|
|
||||||
/* typedef to define the function called when this response packet comes in. */
|
/* 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 *);
|
struct packet_struct *);
|
||||||
|
|
||||||
/* typedef to define the function called when this response record times out. */
|
/* typedef to define the function called when this response record times out. */
|
||||||
typedef void (*timeout_response_function)(struct subnet_record *,
|
typedef void (*timeout_response_function) (struct subnet_record *, struct response_record *);
|
||||||
struct response_record *);
|
|
||||||
|
|
||||||
/* typedef to define the function called when the request that caused this
|
/* typedef to define the function called when the request that caused this
|
||||||
response record to be created is successful. */
|
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
|
/* typedef to define the function called when the request that caused this
|
||||||
response record to be created is unsuccessful. */
|
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
|
/* List of typedefs for success and fail functions of the different query
|
||||||
types. Used to catch any compile time prototype errors. */
|
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 userdata_struct *,
|
||||||
struct nmb_name *,
|
struct nmb_name *, uint16, int, struct in_addr);
|
||||||
uint16,
|
typedef void (*register_name_fail_function) (struct subnet_record *,
|
||||||
int,
|
struct response_record *, struct nmb_name *);
|
||||||
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 *,
|
typedef void (*release_name_success_function) (struct subnet_record *,
|
||||||
struct userdata_struct *,
|
struct userdata_struct *,
|
||||||
struct nmb_name *,
|
struct nmb_name *, struct in_addr);
|
||||||
struct in_addr);
|
typedef void (*release_name_fail_function) (struct subnet_record *,
|
||||||
typedef void (*release_name_fail_function)( struct subnet_record *,
|
struct response_record *, struct nmb_name *);
|
||||||
struct response_record *,
|
|
||||||
struct nmb_name *);
|
|
||||||
|
|
||||||
typedef void (*refresh_name_success_function)( struct subnet_record *,
|
typedef void (*refresh_name_success_function) (struct subnet_record *,
|
||||||
struct userdata_struct *,
|
struct userdata_struct *,
|
||||||
struct nmb_name *,
|
struct nmb_name *, uint16, int, struct in_addr);
|
||||||
uint16,
|
typedef void (*refresh_name_fail_function) (struct subnet_record *,
|
||||||
int,
|
struct response_record *, struct nmb_name *);
|
||||||
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 *,
|
typedef void (*query_name_success_function) (struct subnet_record *,
|
||||||
struct userdata_struct *,
|
struct userdata_struct *,
|
||||||
struct nmb_name *,
|
struct nmb_name *,
|
||||||
struct in_addr,
|
struct in_addr, struct res_rec * answers);
|
||||||
struct res_rec *answers);
|
|
||||||
|
|
||||||
typedef void (*query_name_fail_function)( struct subnet_record *,
|
typedef void (*query_name_fail_function) (struct subnet_record *,
|
||||||
struct response_record *,
|
struct response_record *, struct nmb_name *, int);
|
||||||
struct nmb_name *,
|
|
||||||
int);
|
|
||||||
|
|
||||||
typedef void (*node_status_success_function)( struct subnet_record *,
|
typedef void (*node_status_success_function) (struct subnet_record *,
|
||||||
struct userdata_struct *,
|
struct userdata_struct *,
|
||||||
struct res_rec *,
|
struct res_rec *, struct in_addr);
|
||||||
struct in_addr);
|
typedef void (*node_status_fail_function) (struct subnet_record *, struct response_record *);
|
||||||
typedef void (*node_status_fail_function)( struct subnet_record *,
|
|
||||||
struct response_record *);
|
|
||||||
|
|
||||||
/* Initiated name queries are recorded in this list to track any responses. */
|
/* Initiated name queries are recorded in this list to track any responses. */
|
||||||
|
|
||||||
struct response_record
|
struct response_record
|
||||||
{
|
{
|
||||||
struct response_record *next;
|
struct response_record *next;
|
||||||
struct response_record *prev;
|
struct response_record *prev;
|
||||||
|
|
||||||
uint16 response_id;
|
uint16 response_id;
|
||||||
|
|
||||||
/* Callbacks for packets received or not. */
|
/* Callbacks for packets received or not. */
|
||||||
response_function resp_fn;
|
response_function resp_fn;
|
||||||
timeout_response_function timeout_fn;
|
timeout_response_function timeout_fn;
|
||||||
|
|
||||||
/* Callbacks for the request succeeding or not. */
|
/* Callbacks for the request succeeding or not. */
|
||||||
success_function success_fn;
|
success_function success_fn;
|
||||||
fail_function fail_fn;
|
fail_function fail_fn;
|
||||||
|
|
||||||
struct packet_struct *packet;
|
|
||||||
|
|
||||||
struct userdata_struct *userdata;
|
struct packet_struct *packet;
|
||||||
|
|
||||||
int num_msgs;
|
struct userdata_struct *userdata;
|
||||||
|
|
||||||
time_t repeat_time;
|
int num_msgs;
|
||||||
time_t repeat_interval;
|
|
||||||
int repeat_count;
|
|
||||||
|
|
||||||
/* Recursion protection. */
|
time_t repeat_time;
|
||||||
BOOL in_expiration_processing;
|
time_t repeat_interval;
|
||||||
|
int repeat_count;
|
||||||
|
|
||||||
|
/* Recursion protection. */
|
||||||
|
BOOL in_expiration_processing;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* A subnet structure. It contains a list of workgroups and netbios names. */
|
/* A subnet structure. It contains a list of workgroups and netbios names. */
|
||||||
@ -344,103 +335,112 @@ struct response_record
|
|||||||
B nodes will have their own, totally separate subnet record, with their
|
B nodes will have their own, totally separate subnet record, with their
|
||||||
own netbios name set. These do NOT interact with other subnet records'
|
own netbios name set. These do NOT interact with other subnet records'
|
||||||
netbios names.
|
netbios names.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum subnet_type {
|
enum subnet_type
|
||||||
NORMAL_SUBNET = 0, /* Subnet listed in interfaces list. */
|
{
|
||||||
UNICAST_SUBNET = 1, /* Subnet for unicast packets. */
|
NORMAL_SUBNET = 0, /* Subnet listed in interfaces list. */
|
||||||
REMOTE_BROADCAST_SUBNET = 2, /* Subnet for remote broadcasts. */
|
UNICAST_SUBNET = 1, /* Subnet for unicast packets. */
|
||||||
WINS_SERVER_SUBNET = 3 /* Only created if we are a WINS server. */
|
REMOTE_BROADCAST_SUBNET = 2, /* Subnet for remote broadcasts. */
|
||||||
|
WINS_SERVER_SUBNET = 3 /* Only created if we are a WINS server. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* A resource record. */
|
/* A resource record. */
|
||||||
struct res_rec {
|
struct res_rec
|
||||||
struct nmb_name rr_name;
|
{
|
||||||
int rr_type;
|
struct nmb_name rr_name;
|
||||||
int rr_class;
|
int rr_type;
|
||||||
int ttl;
|
int rr_class;
|
||||||
int rdlength;
|
int ttl;
|
||||||
char rdata[MAX_DGRAM_SIZE];
|
int rdlength;
|
||||||
|
char rdata[MAX_DGRAM_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* An nmb packet. */
|
/* An nmb packet. */
|
||||||
struct nmb_packet
|
struct nmb_packet
|
||||||
{
|
{
|
||||||
struct {
|
struct
|
||||||
int name_trn_id;
|
{
|
||||||
int opcode;
|
int name_trn_id;
|
||||||
BOOL response;
|
int opcode;
|
||||||
struct {
|
BOOL response;
|
||||||
BOOL bcast;
|
struct
|
||||||
BOOL recursion_available;
|
{
|
||||||
BOOL recursion_desired;
|
BOOL bcast;
|
||||||
BOOL trunc;
|
BOOL recursion_available;
|
||||||
BOOL authoritative;
|
BOOL recursion_desired;
|
||||||
} nm_flags;
|
BOOL trunc;
|
||||||
int rcode;
|
BOOL authoritative;
|
||||||
int qdcount;
|
} nm_flags;
|
||||||
int ancount;
|
int rcode;
|
||||||
int nscount;
|
int qdcount;
|
||||||
int arcount;
|
int ancount;
|
||||||
} header;
|
int nscount;
|
||||||
|
int arcount;
|
||||||
|
} header;
|
||||||
|
|
||||||
struct {
|
struct
|
||||||
struct nmb_name question_name;
|
{
|
||||||
int question_type;
|
struct nmb_name question_name;
|
||||||
int question_class;
|
int question_type;
|
||||||
} question;
|
int question_class;
|
||||||
|
} question;
|
||||||
|
|
||||||
struct res_rec *answers;
|
struct res_rec *answers;
|
||||||
struct res_rec *nsrecs;
|
struct res_rec *nsrecs;
|
||||||
struct res_rec *additional;
|
struct res_rec *additional;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* A datagram - this normally contains SMB data in the data[] array. */
|
/* A datagram - this normally contains SMB data in the data[] array. */
|
||||||
|
|
||||||
struct dgram_packet {
|
struct dgram_packet
|
||||||
struct {
|
{
|
||||||
int msg_type;
|
struct
|
||||||
struct {
|
{
|
||||||
enum node_type node_type;
|
int msg_type;
|
||||||
BOOL first;
|
struct
|
||||||
BOOL more;
|
{
|
||||||
} flags;
|
enum node_type node_type;
|
||||||
int dgm_id;
|
BOOL first;
|
||||||
struct in_addr source_ip;
|
BOOL more;
|
||||||
int source_port;
|
} flags;
|
||||||
int dgm_length;
|
int dgm_id;
|
||||||
int packet_offset;
|
struct in_addr source_ip;
|
||||||
} header;
|
int source_port;
|
||||||
struct nmb_name source_name;
|
int dgm_length;
|
||||||
struct nmb_name dest_name;
|
int packet_offset;
|
||||||
int datasize;
|
} header;
|
||||||
char data[MAX_DGRAM_SIZE];
|
struct nmb_name source_name;
|
||||||
|
struct nmb_name dest_name;
|
||||||
|
int datasize;
|
||||||
|
char data[MAX_DGRAM_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Define a structure used to queue packets. This will be a linked
|
/* Define a structure used to queue packets. This will be a linked
|
||||||
list of nmb packets. */
|
list of nmb packets. */
|
||||||
|
|
||||||
struct packet_struct
|
struct packet_struct
|
||||||
{
|
{
|
||||||
struct packet_struct *next;
|
struct packet_struct *next;
|
||||||
struct packet_struct *prev;
|
struct packet_struct *prev;
|
||||||
BOOL locked;
|
BOOL locked;
|
||||||
struct in_addr ip;
|
struct in_addr ip;
|
||||||
int port;
|
int port;
|
||||||
int fd;
|
int fd;
|
||||||
time_t timestamp;
|
time_t timestamp;
|
||||||
enum packet_type packet_type;
|
enum packet_type packet_type;
|
||||||
union {
|
union
|
||||||
struct nmb_packet nmb;
|
{
|
||||||
struct dgram_packet dgram;
|
struct nmb_packet nmb;
|
||||||
} packet;
|
struct dgram_packet dgram;
|
||||||
|
} packet;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* NETLOGON opcodes */
|
/* NETLOGON opcodes */
|
||||||
|
|
||||||
#define QUERYFORPDC 7 /* Query for PDC. */
|
#define QUERYFORPDC 7 /* Query for PDC. */
|
||||||
#define QUERYFORPDC_R 12 /* Response to Query for PDC. */
|
#define QUERYFORPDC_R 12 /* Response to Query for PDC. */
|
||||||
#define SAMLOGON 18
|
#define SAMLOGON 18
|
||||||
#define SAMLOGON_R 19
|
#define SAMLOGON_R 19
|
||||||
|
|
||||||
@ -462,11 +462,11 @@ struct packet_struct
|
|||||||
/* Broadcast packet announcement intervals, in minutes. */
|
/* Broadcast packet announcement intervals, in minutes. */
|
||||||
|
|
||||||
/* Attempt to add domain logon and domain master names. */
|
/* Attempt to add domain logon and domain master names. */
|
||||||
#define CHECK_TIME_ADD_DOM_NAMES 5
|
#define CHECK_TIME_ADD_DOM_NAMES 5
|
||||||
|
|
||||||
/* Search for master browsers of workgroups samba knows about,
|
/* Search for master browsers of workgroups samba knows about,
|
||||||
except default. */
|
except default. */
|
||||||
#define CHECK_TIME_MST_BROWSE 5
|
#define CHECK_TIME_MST_BROWSE 5
|
||||||
|
|
||||||
/* Request backup browser announcements from other servers. */
|
/* Request backup browser announcements from other servers. */
|
||||||
#define CHECK_TIME_ANNOUNCE_BACKUP 15
|
#define CHECK_TIME_ANNOUNCE_BACKUP 15
|
||||||
@ -501,5 +501,6 @@ extern struct subnet_record *remote_broadcast_subnet;
|
|||||||
#define NEXT_SUBNET_INCLUDING_UNICAST(x) (get_next_subnet_maybe_unicast((x)))
|
#define NEXT_SUBNET_INCLUDING_UNICAST(x) (get_next_subnet_maybe_unicast((x)))
|
||||||
|
|
||||||
/* To be removed. */
|
/* To be removed. */
|
||||||
enum state_type { TEST };
|
enum state_type
|
||||||
|
{ TEST };
|
||||||
#endif /* _NAMESERV_H_ */
|
#endif /* _NAMESERV_H_ */
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
|||||||
Unix SMB/Netbios implementation.
|
Unix SMB/Netbios implementation.
|
||||||
Version 1.9.
|
Version 1.9.
|
||||||
SMB transaction2 handling
|
SMB transaction2 handling
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TRANS2_H_
|
#ifndef _TRANS2_H_
|
||||||
#define _TRANS2_H_
|
#define _TRANS2_H_
|
||||||
@ -243,6 +243,3 @@ Byte offset Type name description
|
|||||||
#define TYPE_VIRTUAL 0x40
|
#define TYPE_VIRTUAL 0x40
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
#define CTRLZ 26
|
#define CTRLZ 26
|
||||||
@ -35,203 +35,243 @@ static BOOL mapsinited = 0;
|
|||||||
static char unix2dos[256];
|
static char unix2dos[256];
|
||||||
static char dos2unix[256];
|
static char dos2unix[256];
|
||||||
|
|
||||||
static void initmaps(void) {
|
static void
|
||||||
|
initmaps (void)
|
||||||
|
{
|
||||||
int k;
|
int k;
|
||||||
|
|
||||||
for (k = 0; k < 256; k++) unix2dos[k] = k;
|
for (k = 0; k < 256; k++)
|
||||||
for (k = 0; k < 256; k++) dos2unix[k] = k;
|
unix2dos[k] = k;
|
||||||
|
for (k = 0; k < 256; k++)
|
||||||
|
dos2unix[k] = k;
|
||||||
|
|
||||||
mapsinited = True;
|
mapsinited = True;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_map(const char * str) {
|
static void
|
||||||
|
update_map (const char *str)
|
||||||
|
{
|
||||||
const char *p;
|
const char *p;
|
||||||
|
|
||||||
for (p = str; *p; p++) {
|
for (p = str; *p; p++)
|
||||||
if (p[1]) {
|
{
|
||||||
unix2dos[(unsigned char)*p] = p[1];
|
if (p[1])
|
||||||
dos2unix[(unsigned char)p[1]] = *p;
|
{
|
||||||
|
unix2dos[(unsigned char) *p] = p[1];
|
||||||
|
dos2unix[(unsigned char) p[1]] = *p;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_iso8859_1(void) {
|
static void
|
||||||
|
init_iso8859_1 (void)
|
||||||
|
{
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
if (!mapsinited) initmaps();
|
if (!mapsinited)
|
||||||
|
initmaps ();
|
||||||
|
|
||||||
/* Do not map undefined characters to some accidental code */
|
/* Do not map undefined characters to some accidental code */
|
||||||
for (i = 128; i < 256; i++)
|
for (i = 128; i < 256; i++)
|
||||||
{
|
{
|
||||||
unix2dos[i] = CTRLZ;
|
unix2dos[i] = CTRLZ;
|
||||||
dos2unix[i] = CTRLZ;
|
dos2unix[i] = CTRLZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MSDOS Code Page 850 -> ISO-8859 */
|
/* 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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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");
|
update_map ("\370\233\371\227\372\243\373\226\374\201\375\354\376\347\377\230");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Init for eastern european languages. */
|
/* Init for eastern european languages. */
|
||||||
|
|
||||||
static void init_iso8859_2(void) {
|
static void
|
||||||
|
init_iso8859_2 (void)
|
||||||
|
{
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
if (!mapsinited) initmaps();
|
if (!mapsinited)
|
||||||
|
initmaps ();
|
||||||
|
|
||||||
/* Do not map undefined characters to some accidental code */
|
/* Do not map undefined characters to some accidental code */
|
||||||
for (i = 128; i < 256; i++)
|
for (i = 128; i < 256; i++)
|
||||||
{
|
{
|
||||||
unix2dos[i] = CTRLZ;
|
unix2dos[i] = CTRLZ;
|
||||||
dos2unix[i] = CTRLZ;
|
dos2unix[i] = CTRLZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tranlation table created by Petr Hubeny <psh@capitol.cz>
|
* Tranlation table created by Petr Hubeny <psh@capitol.cz>
|
||||||
* Requires client code page = 852
|
* Requires client code page = 852
|
||||||
* and character set = ISO8859-2 in smb.conf
|
* and character set = ISO8859-2 in smb.conf
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* MSDOS Code Page 852 -> ISO-8859-2 */
|
/* 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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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");
|
update_map ("\370\375\371\205\372\243\373\373\374\201\375\354\376\356\377\372");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Init for russian language (iso8859-5) */
|
/* Init for russian language (iso8859-5) */
|
||||||
|
|
||||||
/* Added by Max Khon <max@iclub.nsu.ru> */
|
/* Added by Max Khon <max@iclub.nsu.ru> */
|
||||||
|
|
||||||
static void init_iso8859_5(void)
|
static void
|
||||||
|
init_iso8859_5 (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
if (!mapsinited) initmaps();
|
if (!mapsinited)
|
||||||
|
initmaps ();
|
||||||
|
|
||||||
/* Do not map undefined characters to some accidental code */
|
/* Do not map undefined characters to some accidental code */
|
||||||
for (i = 128; i < 256; i++)
|
for (i = 128; i < 256; i++)
|
||||||
{
|
{
|
||||||
unix2dos[i] = CTRLZ;
|
unix2dos[i] = CTRLZ;
|
||||||
dos2unix[i] = CTRLZ;
|
dos2unix[i] = CTRLZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MSDOS Code Page 866 -> ISO8859-5 */
|
/* 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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\241\360\361\361\244\362\364\363\247\364\367\365\256\366\376\367");
|
||||||
update_map("\360\374\240\377");
|
update_map ("\360\374\240\377");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Init for russian language (koi8) */
|
/* 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 */
|
/* There aren't undefined characters between 128 and 255 */
|
||||||
|
|
||||||
/* MSDOS Code Page 866 -> KOI8-R */
|
/* 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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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 ("\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");
|
update_map ("\370\234\371\233\372\207\373\230\374\235\375\231\376\227\377\232");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert unix to dos
|
* Convert unix to dos
|
||||||
*/
|
*/
|
||||||
char *unix2dos_format(char *str,BOOL overwrite)
|
char *
|
||||||
|
unix2dos_format (char *str, BOOL overwrite)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
char *dp;
|
char *dp;
|
||||||
|
|
||||||
if (!mapsinited) initmaps();
|
if (!mapsinited)
|
||||||
|
initmaps ();
|
||||||
|
|
||||||
if (overwrite) {
|
if (overwrite)
|
||||||
for (p = str; *p; p++) *p = unix2dos[(unsigned char)*p];
|
{
|
||||||
return str;
|
for (p = str; *p; p++)
|
||||||
} else {
|
*p = unix2dos[(unsigned char) *p];
|
||||||
for (p = str, dp = cvtbuf; *p && dp < &(cvtbuf[sizeof(cvtbuf) - 1]); p++,dp++)
|
return str;
|
||||||
*dp = unix2dos[(unsigned char)*p];
|
}
|
||||||
*dp = 0;
|
else
|
||||||
return cvtbuf;
|
{
|
||||||
}
|
for (p = str, dp = cvtbuf; *p && dp < &(cvtbuf[sizeof (cvtbuf) - 1]); p++, dp++)
|
||||||
|
*dp = unix2dos[(unsigned char) *p];
|
||||||
|
*dp = 0;
|
||||||
|
return cvtbuf;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert dos to unix
|
* Convert dos to unix
|
||||||
*/
|
*/
|
||||||
char *dos2unix_format(char *str, BOOL overwrite)
|
char *
|
||||||
|
dos2unix_format (char *str, BOOL overwrite)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
char *dp;
|
char *dp;
|
||||||
|
|
||||||
if (!mapsinited) initmaps();
|
if (!mapsinited)
|
||||||
|
initmaps ();
|
||||||
|
|
||||||
if (overwrite) {
|
if (overwrite)
|
||||||
for (p = str; *p; p++) *p = dos2unix[(unsigned char)*p];
|
{
|
||||||
return str;
|
for (p = str; *p; p++)
|
||||||
} else {
|
*p = dos2unix[(unsigned char) *p];
|
||||||
for (p = str, dp = cvtbuf; *p && dp < &(cvtbuf[sizeof(cvtbuf) - 1]); p++,dp++)
|
return str;
|
||||||
*dp = dos2unix[(unsigned char)*p];
|
}
|
||||||
*dp = 0;
|
else
|
||||||
return cvtbuf;
|
{
|
||||||
}
|
for (p = str, dp = cvtbuf; *p && dp < &(cvtbuf[sizeof (cvtbuf) - 1]); p++, dp++)
|
||||||
|
*dp = dos2unix[(unsigned char) *p];
|
||||||
|
*dp = 0;
|
||||||
|
return cvtbuf;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Interpret character set.
|
* Interpret character set.
|
||||||
*/
|
*/
|
||||||
void interpret_character_set(const char *str)
|
void
|
||||||
|
interpret_character_set (const char *str)
|
||||||
{
|
{
|
||||||
if (strequal (str, "iso8859-1")) {
|
if (strequal (str, "iso8859-1"))
|
||||||
init_iso8859_1();
|
{
|
||||||
} else if (strequal (str, "iso8859-2")) {
|
init_iso8859_1 ();
|
||||||
init_iso8859_2();
|
}
|
||||||
} else if (strequal (str, "iso8859-5")) {
|
else if (strequal (str, "iso8859-2"))
|
||||||
init_iso8859_5();
|
{
|
||||||
} else if (strequal (str, "koi8-r")) {
|
init_iso8859_2 ();
|
||||||
init_koi8_r();
|
}
|
||||||
} else {
|
else if (strequal (str, "iso8859-5"))
|
||||||
DEBUG(0,("unrecognized character set %s\n", str));
|
{
|
||||||
|
init_iso8859_5 ();
|
||||||
|
}
|
||||||
|
else if (strequal (str, "koi8-r"))
|
||||||
|
{
|
||||||
|
init_koi8_r ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DEBUG (0, ("unrecognized character set %s\n", str));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define CHARSET_C
|
#define CHARSET_C
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
@ -37,75 +37,75 @@ extern int DEBUGLEVEL;
|
|||||||
#if !defined(KANJI)
|
#if !defined(KANJI)
|
||||||
/* lower->upper mapping for IBM Code Page 850 - MS-DOS Latin 1 */
|
/* lower->upper mapping for IBM Code Page 850 - MS-DOS Latin 1 */
|
||||||
unsigned char const cp_850[][4] = {
|
unsigned char const cp_850[][4] = {
|
||||||
/* dec col/row oct hex description */
|
/* dec col/row oct hex description */
|
||||||
/* 133 08/05 205 85 a grave */
|
/* 133 08/05 205 85 a grave */
|
||||||
/* 183 11/07 267 B7 A grave */ {0x85,0xB7,1,1},
|
/* 183 11/07 267 B7 A grave */ {0x85, 0xB7, 1, 1},
|
||||||
/* 160 10/00 240 A0 a acute */
|
/* 160 10/00 240 A0 a acute */
|
||||||
/* 181 11/05 265 B5 A acute */ {0xA0,0xB5,1,1},
|
/* 181 11/05 265 B5 A acute */ {0xA0, 0xB5, 1, 1},
|
||||||
/* 131 08/03 203 83 a circumflex */
|
/* 131 08/03 203 83 a circumflex */
|
||||||
/* 182 11/06 266 B6 A circumflex */ {0x83,0xB6,1,1},
|
/* 182 11/06 266 B6 A circumflex */ {0x83, 0xB6, 1, 1},
|
||||||
/* 198 12/06 306 C6 a tilde */
|
/* 198 12/06 306 C6 a tilde */
|
||||||
/* 199 12/07 307 C7 A tilde */ {0xC6,0xC7,1,1},
|
/* 199 12/07 307 C7 A tilde */ {0xC6, 0xC7, 1, 1},
|
||||||
/* 132 08/04 204 84 a diaeresis */
|
/* 132 08/04 204 84 a diaeresis */
|
||||||
/* 142 08/14 216 8E A diaeresis */ {0x84,0x8E,1,1},
|
/* 142 08/14 216 8E A diaeresis */ {0x84, 0x8E, 1, 1},
|
||||||
/* 134 08/06 206 86 a ring */
|
/* 134 08/06 206 86 a ring */
|
||||||
/* 143 08/15 217 8F A ring */ {0x86,0x8F,1,1},
|
/* 143 08/15 217 8F A ring */ {0x86, 0x8F, 1, 1},
|
||||||
/* 145 09/01 221 91 ae diphthong */
|
/* 145 09/01 221 91 ae diphthong */
|
||||||
/* 146 09/02 222 92 AE diphthong */ {0x91,0x92,1,1},
|
/* 146 09/02 222 92 AE diphthong */ {0x91, 0x92, 1, 1},
|
||||||
/* 135 08/07 207 87 c cedilla */
|
/* 135 08/07 207 87 c cedilla */
|
||||||
/* 128 08/00 200 80 C cedilla */ {0x87,0x80,1,1},
|
/* 128 08/00 200 80 C cedilla */ {0x87, 0x80, 1, 1},
|
||||||
/* 138 08/10 212 8A e grave */
|
/* 138 08/10 212 8A e grave */
|
||||||
/* 212 13/04 324 D4 E grave */ {0x8A,0xD4,1,1},
|
/* 212 13/04 324 D4 E grave */ {0x8A, 0xD4, 1, 1},
|
||||||
/* 130 08/02 202 82 e acute */
|
/* 130 08/02 202 82 e acute */
|
||||||
/* 144 09/00 220 90 E acute */ {0x82,0x90,1,1},
|
/* 144 09/00 220 90 E acute */ {0x82, 0x90, 1, 1},
|
||||||
/* 136 08/08 210 88 e circumflex */
|
/* 136 08/08 210 88 e circumflex */
|
||||||
/* 210 13/02 322 D2 E circumflex */ {0x88,0xD2,1,1},
|
/* 210 13/02 322 D2 E circumflex */ {0x88, 0xD2, 1, 1},
|
||||||
/* 137 08/09 211 89 e diaeresis */
|
/* 137 08/09 211 89 e diaeresis */
|
||||||
/* 211 13/03 323 D3 E diaeresis */ {0x89,0xD3,1,1},
|
/* 211 13/03 323 D3 E diaeresis */ {0x89, 0xD3, 1, 1},
|
||||||
/* 141 08/13 215 8D i grave */
|
/* 141 08/13 215 8D i grave */
|
||||||
/* 222 13/14 336 DE I grave */ {0x8D,0xDE,1,1},
|
/* 222 13/14 336 DE I grave */ {0x8D, 0xDE, 1, 1},
|
||||||
/* 161 10/01 241 A1 i acute */
|
/* 161 10/01 241 A1 i acute */
|
||||||
/* 214 13/06 326 D6 I acute */ {0xA1,0xD6,1,1},
|
/* 214 13/06 326 D6 I acute */ {0xA1, 0xD6, 1, 1},
|
||||||
/* 140 08/12 214 8C i circumflex */
|
/* 140 08/12 214 8C i circumflex */
|
||||||
/* 215 13/07 327 D7 I circumflex */ {0x8C,0xD7,1,1},
|
/* 215 13/07 327 D7 I circumflex */ {0x8C, 0xD7, 1, 1},
|
||||||
/* 139 08/11 213 8B i diaeresis */
|
/* 139 08/11 213 8B i diaeresis */
|
||||||
/* 216 13/08 330 D8 I diaeresis */ {0x8B,0xD8,1,1},
|
/* 216 13/08 330 D8 I diaeresis */ {0x8B, 0xD8, 1, 1},
|
||||||
/* 208 13/00 320 D0 Icelandic eth */
|
/* 208 13/00 320 D0 Icelandic eth */
|
||||||
/* 209 13/01 321 D1 Icelandic Eth */ {0xD0,0xD1,1,1},
|
/* 209 13/01 321 D1 Icelandic Eth */ {0xD0, 0xD1, 1, 1},
|
||||||
/* 164 10/04 244 A4 n tilde */
|
/* 164 10/04 244 A4 n tilde */
|
||||||
/* 165 10/05 245 A5 N tilde */ {0xA4,0xA5,1,1},
|
/* 165 10/05 245 A5 N tilde */ {0xA4, 0xA5, 1, 1},
|
||||||
/* 149 09/05 225 95 o grave */
|
/* 149 09/05 225 95 o grave */
|
||||||
/* 227 14/03 343 E3 O grave */ {0x95,0xE3,1,1},
|
/* 227 14/03 343 E3 O grave */ {0x95, 0xE3, 1, 1},
|
||||||
/* 162 10/02 242 A2 o acute */
|
/* 162 10/02 242 A2 o acute */
|
||||||
/* 224 14/00 340 E0 O acute */ {0xA2,0xE0,1,1},
|
/* 224 14/00 340 E0 O acute */ {0xA2, 0xE0, 1, 1},
|
||||||
/* 147 09/03 223 93 o circumflex */
|
/* 147 09/03 223 93 o circumflex */
|
||||||
/* 226 14/02 342 E2 O circumflex */ {0x93,0xE2,1,1},
|
/* 226 14/02 342 E2 O circumflex */ {0x93, 0xE2, 1, 1},
|
||||||
/* 228 14/04 344 E4 o tilde */
|
/* 228 14/04 344 E4 o tilde */
|
||||||
/* 229 14/05 345 E5 O tilde */ {0xE4,0xE5,1,1},
|
/* 229 14/05 345 E5 O tilde */ {0xE4, 0xE5, 1, 1},
|
||||||
/* 148 09/04 224 94 o diaeresis */
|
/* 148 09/04 224 94 o diaeresis */
|
||||||
/* 153 09/09 231 99 O diaeresis */ {0x94,0x99,1,1},
|
/* 153 09/09 231 99 O diaeresis */ {0x94, 0x99, 1, 1},
|
||||||
/* 155 09/11 233 9B o slash */
|
/* 155 09/11 233 9B o slash */
|
||||||
/* 157 09/13 235 9D O slash */ {0x9B,0x9D,1,1},
|
/* 157 09/13 235 9D O slash */ {0x9B, 0x9D, 1, 1},
|
||||||
/* 151 09/07 227 97 u grave */
|
/* 151 09/07 227 97 u grave */
|
||||||
/* 235 14/11 353 EB U grave */ {0x97,0xEB,1,1},
|
/* 235 14/11 353 EB U grave */ {0x97, 0xEB, 1, 1},
|
||||||
/* 163 10/03 243 A3 u acute */
|
/* 163 10/03 243 A3 u acute */
|
||||||
/* 233 14/09 351 E9 U acute */ {0xA3,0xE9,1,1},
|
/* 233 14/09 351 E9 U acute */ {0xA3, 0xE9, 1, 1},
|
||||||
/* 150 09/06 226 96 u circumflex */
|
/* 150 09/06 226 96 u circumflex */
|
||||||
/* 234 14/10 352 EA U circumflex */ {0x96,0xEA,1,1},
|
/* 234 14/10 352 EA U circumflex */ {0x96, 0xEA, 1, 1},
|
||||||
/* 129 08/01 201 81 u diaeresis */
|
/* 129 08/01 201 81 u diaeresis */
|
||||||
/* 154 09/10 232 9A U diaeresis */ {0x81,0x9A,1,1},
|
/* 154 09/10 232 9A U diaeresis */ {0x81, 0x9A, 1, 1},
|
||||||
/* 236 14/12 354 EC y acute */
|
/* 236 14/12 354 EC y acute */
|
||||||
/* 237 14/13 355 ED Y acute */ {0xEC,0xED,1,1},
|
/* 237 14/13 355 ED Y acute */ {0xEC, 0xED, 1, 1},
|
||||||
/* 231 14/07 347 E7 Icelandic thorn */
|
/* 231 14/07 347 E7 Icelandic thorn */
|
||||||
/* 232 14/08 350 E8 Icelandic Thorn */ {0xE7,0xE8,1,1},
|
/* 232 14/08 350 E8 Icelandic Thorn */ {0xE7, 0xE8, 1, 1},
|
||||||
|
|
||||||
{0x9C,0,0,0}, /* Pound */
|
{0x9C, 0, 0, 0}, /* Pound */
|
||||||
{0,0,0,0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
#else /* KANJI */
|
#else /* KANJI */
|
||||||
/* lower->upper mapping for IBM Code Page 932 - MS-DOS Japanese SJIS */
|
/* lower->upper mapping for IBM Code Page 932 - MS-DOS Japanese SJIS */
|
||||||
unsigned char const cp_932[][4] = {
|
unsigned char const cp_932[][4] = {
|
||||||
{0,0,0,0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
#endif /* KANJI */
|
#endif /* KANJI */
|
||||||
|
|
||||||
@ -128,60 +128,69 @@ char *lower_char_map = xx_lower_char_map;
|
|||||||
* mapping from lower to upper, but not upper to lower.
|
* mapping from lower to upper, but not upper to lower.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void add_dos_char(int lower, BOOL map_lower_to_upper,
|
static void
|
||||||
int upper, BOOL map_upper_to_lower)
|
add_dos_char (int lower, BOOL map_lower_to_upper, int upper, BOOL map_upper_to_lower)
|
||||||
{
|
{
|
||||||
lower &= 0xff;
|
lower &= 0xff;
|
||||||
upper &= 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,
|
lower, upper,
|
||||||
map_lower_to_upper ? "True" : "False",
|
map_lower_to_upper ? "True" : "False", map_upper_to_lower ? "True" : "False"));
|
||||||
map_upper_to_lower ? "True" : "False" ) );
|
if (lower)
|
||||||
if (lower) dos_char_map[lower] = 1;
|
dos_char_map[lower] = 1;
|
||||||
if (upper) dos_char_map[upper] = 1;
|
if (upper)
|
||||||
lower_char_map[lower] = (char)lower; /* Define tolower(lower) */
|
dos_char_map[upper] = 1;
|
||||||
upper_char_map[upper] = (char)upper; /* Define toupper(upper) */
|
lower_char_map[lower] = (char) lower; /* Define tolower(lower) */
|
||||||
if (lower && upper) {
|
upper_char_map[upper] = (char) upper; /* Define toupper(upper) */
|
||||||
if(map_upper_to_lower)
|
if (lower && upper)
|
||||||
lower_char_map[upper] = (char)lower;
|
{
|
||||||
if(map_lower_to_upper)
|
if (map_upper_to_lower)
|
||||||
upper_char_map[lower] = (char)upper;
|
lower_char_map[upper] = (char) lower;
|
||||||
}
|
if (map_lower_to_upper)
|
||||||
|
upper_char_map[lower] = (char) upper;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
initialise the charset arrays
|
initialise the charset arrays
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
void charset_initialise(void)
|
void
|
||||||
|
charset_initialise (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
#ifdef LC_ALL
|
#ifdef LC_ALL
|
||||||
/* include <locale.h> in includes.h if available for OS */
|
/* include <locale.h> in includes.h if available for OS */
|
||||||
/* we take only standard 7-bit ASCII definitions from ctype */
|
/* we take only standard 7-bit ASCII definitions from ctype */
|
||||||
setlocale(LC_ALL,"C");
|
setlocale (LC_ALL, "C");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (i= 0;i<=255;i++) {
|
for (i = 0; i <= 255; i++)
|
||||||
dos_char_map[i] = 0;
|
{
|
||||||
}
|
dos_char_map[i] = 0;
|
||||||
|
}
|
||||||
for (i=0;i<=127;i++) {
|
|
||||||
if (isalnum(i) || strchr("._^$~!#%&-{}()@'`",(char)i))
|
for (i = 0; i <= 127; i++)
|
||||||
add_dos_char(i,False,0,False);
|
{
|
||||||
}
|
if (isalnum (i) || strchr ("._^$~!#%&-{}()@'`", (char) i))
|
||||||
|
add_dos_char (i, False, 0, False);
|
||||||
for (i=0; i<=255; i++) {
|
}
|
||||||
char c = (char)i;
|
|
||||||
upper_char_map[i] = lower_char_map[i] = c;
|
for (i = 0; i <= 255; i++)
|
||||||
|
{
|
||||||
/* Some systems have buggy isupper/islower for characters
|
char c = (char) i;
|
||||||
above 127. Best not to rely on them. */
|
upper_char_map[i] = lower_char_map[i] = c;
|
||||||
if(i < 128) {
|
|
||||||
if (isupper((int)c)) lower_char_map[i] = tolower(c);
|
/* Some systems have buggy isupper/islower for characters
|
||||||
if (islower((int)c)) upper_char_map[i] = toupper(c);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -190,213 +199,211 @@ load the client codepage.
|
|||||||
|
|
||||||
typedef const unsigned char (*codepage_p)[4];
|
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;
|
pstring codepage_file_name;
|
||||||
unsigned char buf[8];
|
unsigned char buf[8];
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
SMB_OFF_T size;
|
SMB_OFF_T size;
|
||||||
codepage_p cp_p = NULL;
|
codepage_p cp_p = NULL;
|
||||||
SMB_STRUCT_STAT st;
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pstrcpy(codepage_file_name, CODEPAGEDIR);
|
pstrcpy (codepage_file_name, CODEPAGEDIR);
|
||||||
pstrcat(codepage_file_name, "/");
|
pstrcat (codepage_file_name, "/");
|
||||||
pstrcat(codepage_file_name, "codepage.");
|
pstrcat (codepage_file_name, "codepage.");
|
||||||
slprintf(&codepage_file_name[strlen(codepage_file_name)],
|
slprintf (&codepage_file_name[strlen (codepage_file_name)],
|
||||||
sizeof(pstring)-(strlen(codepage_file_name)+1),
|
sizeof (pstring) - (strlen (codepage_file_name) + 1), "%03d", client_codepage);
|
||||||
"%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",
|
DEBUG (0, ("load_client_codepage: filename %s does not exist.\n", codepage_file_name));
|
||||||
codepage_file_name));
|
return NULL;
|
||||||
return NULL;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if it is at least big enough to hold the required
|
/* Check if it is at least big enough to hold the required
|
||||||
data. Should be 2 byte version, 2 byte codepage, 4 byte length,
|
data. Should be 2 byte version, 2 byte codepage, 4 byte length,
|
||||||
plus zero or more bytes of data. Note that the data cannot be more
|
plus zero or more bytes of data. Note that the data cannot be more
|
||||||
than 4 * MAXCODEPAGELINES bytes.
|
than 4 * MAXCODEPAGELINES bytes.
|
||||||
*/
|
*/
|
||||||
size = st.st_size;
|
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 \
|
DEBUG (0, ("load_client_codepage: file %s is an incorrect size for a \
|
||||||
code page file (size=%d).\n", codepage_file_name, (int)size));
|
code page file (size=%d).\n", codepage_file_name, (int) size));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the first 8 bytes of the codepage file - check
|
/* Read the first 8 bytes of the codepage file - check
|
||||||
the version number and code page number. All the data
|
the version number and code page number. All the data
|
||||||
is held in little endian format.
|
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)));
|
codepage_file_name, unix_error_string (errno)));
|
||||||
return NULL;
|
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)));
|
codepage_file_name, unix_error_string (errno)));
|
||||||
goto clean_and_exit;
|
goto clean_and_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check the version value */
|
/* 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. \
|
DEBUG (0, ("load_client_codepage: filename %s has incorrect version id. \
|
||||||
Needed %hu, got %hu.\n",
|
Needed %hu, got %hu.\n", codepage_file_name, (uint16) CODEPAGE_FILE_VERSION_ID, SVAL (buf, CODEPAGE_VERSION_OFFSET)));
|
||||||
codepage_file_name, (uint16)CODEPAGE_FILE_VERSION_ID,
|
goto clean_and_exit;
|
||||||
SVAL(buf,CODEPAGE_VERSION_OFFSET)));
|
}
|
||||||
goto clean_and_exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check the codepage matches */
|
/* 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. \
|
DEBUG (0, ("load_client_codepage: filename %s has incorrect codepage. \
|
||||||
Needed %hu, got %hu.\n",
|
Needed %hu, got %hu.\n", codepage_file_name, (uint16) client_codepage, SVAL (buf, CODEPAGE_CLIENT_CODEPAGE_OFFSET)));
|
||||||
codepage_file_name, (uint16)client_codepage,
|
goto clean_and_exit;
|
||||||
SVAL(buf,CODEPAGE_CLIENT_CODEPAGE_OFFSET)));
|
}
|
||||||
goto clean_and_exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check the length is correct. */
|
/* 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. \
|
DEBUG (0, ("load_client_codepage: filename %s has incorrect size headers. \
|
||||||
Needed %u, got %u.\n", codepage_file_name, (uint32)(size - CODEPAGE_HEADER_SIZE),
|
Needed %u, got %u.\n", codepage_file_name, (uint32) (size - CODEPAGE_HEADER_SIZE), IVAL (buf, CODEPAGE_LENGTH_OFFSET)));
|
||||||
IVAL(buf,CODEPAGE_LENGTH_OFFSET)));
|
goto clean_and_exit;
|
||||||
goto clean_and_exit;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
size -= CODEPAGE_HEADER_SIZE; /* Remove header */
|
size -= CODEPAGE_HEADER_SIZE; /* Remove header */
|
||||||
|
|
||||||
/* Make sure the size is a multiple of 4. */
|
/* 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));
|
multiple of 4.\n", codepage_file_name));
|
||||||
goto clean_and_exit;
|
goto clean_and_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate space for the code page file and read it all in. */
|
/* 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;
|
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)));
|
codepage_file_name, unix_error_string (errno)));
|
||||||
goto clean_and_exit;
|
goto clean_and_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ensure array is correctly terminated. */
|
/* 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;
|
return cp_p;
|
||||||
|
|
||||||
clean_and_exit:
|
clean_and_exit:
|
||||||
|
|
||||||
/* pseudo destructor :-) */
|
/* pseudo destructor :-) */
|
||||||
|
|
||||||
if(fp != NULL)
|
if (fp != NULL)
|
||||||
fclose(fp);
|
fclose (fp);
|
||||||
if(cp_p)
|
if (cp_p)
|
||||||
free((char *)cp_p);
|
free ((char *) cp_p);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
initialise the client codepage.
|
initialise the client codepage.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
void codepage_initialise(int client_codepage)
|
void
|
||||||
|
codepage_initialise (int client_codepage)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
static codepage_p cp = NULL;
|
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",
|
("codepage_initialise: called twice - ignoring second client code page = %d\n",
|
||||||
client_codepage));
|
client_codepage));
|
||||||
return;
|
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.
|
* 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
|
#ifdef KANJI
|
||||||
DEBUG(6,("codepage_initialise: loading dynamic codepage file %s/codepage.%d \
|
DEBUG (6, ("codepage_initialise: loading dynamic codepage file %s/codepage.%d \
|
||||||
for code page %d failed. Using default client codepage 932\n",
|
for code page %d failed. Using default client codepage 932\n", CODEPAGEDIR, client_codepage, client_codepage));
|
||||||
CODEPAGEDIR, client_codepage, client_codepage));
|
cp = cp_932;
|
||||||
cp = cp_932;
|
client_codepage = KANJI_CODEPAGE;
|
||||||
client_codepage = KANJI_CODEPAGE;
|
|
||||||
#else /* KANJI */
|
#else /* KANJI */
|
||||||
DEBUG(6,("codepage_initialise: loading dynamic codepage file %s/codepage.%d \
|
DEBUG (6, ("codepage_initialise: loading dynamic codepage file %s/codepage.%d \
|
||||||
for code page %d failed. Using default client codepage 850\n",
|
for code page %d failed. Using default client codepage 850\n", CODEPAGEDIR, client_codepage, client_codepage));
|
||||||
CODEPAGEDIR, client_codepage, client_codepage));
|
cp = cp_850;
|
||||||
cp = cp_850;
|
client_codepage = MSDOS_LATIN_1_CODEPAGE;
|
||||||
client_codepage = MSDOS_LATIN_1_CODEPAGE;
|
|
||||||
#endif /* KANJI */
|
#endif /* KANJI */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup the function pointers for the loaded codepage.
|
* 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++)
|
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_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
|
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;
|
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")) {
|
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;
|
char c1 = 0, c2 = 0;
|
||||||
if (isdigit((unsigned char)*t) || (*t)=='-') {
|
int i1 = 0, i2 = 0;
|
||||||
sscanf(t,"%i:%i",&i1,&i2);
|
if (isdigit ((unsigned char) *t) || (*t) == '-')
|
||||||
add_dos_char(i1,True,i2,True);
|
{
|
||||||
} else {
|
sscanf (t, "%i:%i", &i1, &i2);
|
||||||
sscanf(t,"%c:%c",&c1,&c2);
|
add_dos_char (i1, True, i2, True);
|
||||||
add_dos_char((unsigned char)c1,True,(unsigned char)c2, 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);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
|
|
||||||
@ -84,10 +84,10 @@
|
|||||||
* levels higher than DEBUGLEVEL will not be processed.
|
* levels higher than DEBUGLEVEL will not be processed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
FILE *dbf = NULL;
|
FILE *dbf = NULL;
|
||||||
pstring debugf = "";
|
pstring debugf = "";
|
||||||
BOOL append_log = False;
|
BOOL append_log = False;
|
||||||
int DEBUGLEVEL = 1;
|
int DEBUGLEVEL = 1;
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- **
|
/* -------------------------------------------------------------------------- **
|
||||||
@ -108,9 +108,10 @@ int DEBUGLEVEL = 1;
|
|||||||
* format_pos - Marks the first free byte of the format_bufr.
|
* format_pos - Marks the first free byte of the format_bufr.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static BOOL stdout_logging = False;
|
static BOOL stdout_logging = False;
|
||||||
static pstring format_bufr = { '\0' };
|
static pstring format_bufr = { '\0' };
|
||||||
static size_t format_pos = 0;
|
|
||||||
|
static size_t format_pos = 0;
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- **
|
/* -------------------------------------------------------------------------- **
|
||||||
@ -121,15 +122,16 @@ static size_t format_pos = 0;
|
|||||||
* get ready for syslog stuff
|
* get ready for syslog stuff
|
||||||
* ************************************************************************** **
|
* ************************************************************************** **
|
||||||
*/
|
*/
|
||||||
void setup_logging( const char *pname, BOOL interactive )
|
void
|
||||||
{
|
setup_logging (const char *pname, BOOL interactive)
|
||||||
(void) pname;
|
{
|
||||||
if( interactive )
|
(void) pname;
|
||||||
|
if (interactive)
|
||||||
{
|
{
|
||||||
stdout_logging = True;
|
stdout_logging = True;
|
||||||
dbf = stderr;
|
dbf = stderr;
|
||||||
}
|
}
|
||||||
} /* setup_logging */
|
} /* setup_logging */
|
||||||
|
|
||||||
/* ************************************************************************** **
|
/* ************************************************************************** **
|
||||||
* Write an debug message on the debugfile.
|
* Write an debug message on the debugfile.
|
||||||
@ -137,68 +139,70 @@ void setup_logging( const char *pname, BOOL interactive )
|
|||||||
* ************************************************************************** **
|
* ************************************************************************** **
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_STDARG_H
|
#ifdef HAVE_STDARG_H
|
||||||
int Debug1( const char *format_str, ... )
|
int
|
||||||
|
Debug1 (const char *format_str, ...)
|
||||||
{
|
{
|
||||||
#else
|
#else
|
||||||
int Debug1(va_alist)
|
int
|
||||||
va_dcl
|
Debug1 (va_alist)
|
||||||
{
|
va_dcl
|
||||||
const char *format_str;
|
{
|
||||||
|
const char *format_str;
|
||||||
#endif
|
#endif
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int old_errno = errno;
|
int old_errno = errno;
|
||||||
|
|
||||||
if( stdout_logging )
|
if (stdout_logging)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_STDARG_H
|
#ifdef HAVE_STDARG_H
|
||||||
va_start( ap, format_str );
|
va_start (ap, format_str);
|
||||||
#else
|
#else
|
||||||
va_start( ap );
|
va_start (ap);
|
||||||
format_str = va_arg( ap, const char * );
|
format_str = va_arg (ap, const char *);
|
||||||
#endif
|
#endif
|
||||||
(void)vfprintf( dbf, format_str, ap );
|
(void) vfprintf (dbf, format_str, ap);
|
||||||
va_end( ap );
|
va_end (ap);
|
||||||
errno = old_errno;
|
|
||||||
return( 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !dbf && *debugf)
|
|
||||||
{
|
|
||||||
mode_t oldumask = umask( 022 );
|
|
||||||
|
|
||||||
if( append_log )
|
|
||||||
dbf = sys_fopen( debugf, "a" );
|
|
||||||
else
|
|
||||||
dbf = sys_fopen( debugf, "w" );
|
|
||||||
(void)umask( oldumask );
|
|
||||||
if( dbf )
|
|
||||||
{
|
|
||||||
setbuf( dbf, NULL );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
errno = old_errno;
|
errno = old_errno;
|
||||||
return(0);
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dbf && *debugf)
|
||||||
|
{
|
||||||
|
mode_t oldumask = umask (022);
|
||||||
|
|
||||||
|
if (append_log)
|
||||||
|
dbf = sys_fopen (debugf, "a");
|
||||||
|
else
|
||||||
|
dbf = sys_fopen (debugf, "w");
|
||||||
|
(void) umask (oldumask);
|
||||||
|
if (dbf)
|
||||||
|
{
|
||||||
|
setbuf (dbf, NULL);
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
errno = old_errno;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (dbf)
|
if (dbf)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_STDARG_H
|
#ifdef HAVE_STDARG_H
|
||||||
va_start( ap, format_str );
|
va_start (ap, format_str);
|
||||||
#else
|
#else
|
||||||
va_start( ap );
|
va_start (ap);
|
||||||
format_str = va_arg( ap, const char * );
|
format_str = va_arg (ap, const char *);
|
||||||
#endif
|
#endif
|
||||||
(void)vfprintf( dbf, format_str, ap );
|
(void) vfprintf (dbf, format_str, ap);
|
||||||
va_end( ap );
|
va_end (ap);
|
||||||
(void)fflush( dbf );
|
(void) fflush (dbf);
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = old_errno;
|
errno = old_errno;
|
||||||
|
|
||||||
return( 0 );
|
return (0);
|
||||||
} /* Debug1 */
|
} /* Debug1 */
|
||||||
|
|
||||||
|
|
||||||
/* ************************************************************************** **
|
/* ************************************************************************** **
|
||||||
@ -209,12 +213,13 @@ va_dcl
|
|||||||
*
|
*
|
||||||
* ************************************************************************** **
|
* ************************************************************************** **
|
||||||
*/
|
*/
|
||||||
static void bufr_print( void )
|
static void
|
||||||
{
|
bufr_print (void)
|
||||||
format_bufr[format_pos] = '\0';
|
{
|
||||||
(void)Debug1( "%s", format_bufr );
|
format_bufr[format_pos] = '\0';
|
||||||
format_pos = 0;
|
(void) Debug1 ("%s", format_bufr);
|
||||||
} /* bufr_print */
|
format_pos = 0;
|
||||||
|
} /* bufr_print */
|
||||||
|
|
||||||
/* ************************************************************************** **
|
/* ************************************************************************** **
|
||||||
* Format the debug message text.
|
* Format the debug message text.
|
||||||
@ -233,42 +238,42 @@ static void bufr_print( void )
|
|||||||
*
|
*
|
||||||
* ************************************************************************** **
|
* ************************************************************************** **
|
||||||
*/
|
*/
|
||||||
static void format_debug_text( char *msg )
|
static void
|
||||||
{
|
format_debug_text (char *msg)
|
||||||
size_t i;
|
{
|
||||||
BOOL timestamp = (!stdout_logging && (lp_timestamp_logs() ||
|
size_t i;
|
||||||
!(lp_loaded())));
|
BOOL timestamp = (!stdout_logging && (lp_timestamp_logs () || !(lp_loaded ())));
|
||||||
|
|
||||||
for( i = 0; msg[i]; i++ )
|
for (i = 0; msg[i]; i++)
|
||||||
{
|
{
|
||||||
/* Indent two spaces at each new line. */
|
/* Indent two spaces at each new line. */
|
||||||
if(timestamp && 0 == format_pos)
|
if (timestamp && 0 == format_pos)
|
||||||
{
|
{
|
||||||
format_bufr[0] = format_bufr[1] = ' ';
|
format_bufr[0] = format_bufr[1] = ' ';
|
||||||
format_pos = 2;
|
format_pos = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If there's room, copy the character to the format buffer. */
|
/* If there's room, copy the character to the format buffer. */
|
||||||
if( format_pos < FORMAT_BUFR_MAX )
|
if (format_pos < FORMAT_BUFR_MAX)
|
||||||
format_bufr[format_pos++] = msg[i];
|
format_bufr[format_pos++] = msg[i];
|
||||||
|
|
||||||
/* If a newline is encountered, print & restart. */
|
/* If a newline is encountered, print & restart. */
|
||||||
if( '\n' == msg[i] )
|
if ('\n' == msg[i])
|
||||||
bufr_print();
|
bufr_print ();
|
||||||
|
|
||||||
/* If the buffer is full dump it out, reset it, and put out a line
|
/* If the buffer is full dump it out, reset it, and put out a line
|
||||||
* continuation indicator.
|
* continuation indicator.
|
||||||
*/
|
*/
|
||||||
if( format_pos >= FORMAT_BUFR_MAX )
|
if (format_pos >= FORMAT_BUFR_MAX)
|
||||||
{
|
{
|
||||||
bufr_print();
|
bufr_print ();
|
||||||
(void)Debug1( " +>\n" );
|
(void) Debug1 (" +>\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Just to be safe... */
|
/* Just to be safe... */
|
||||||
format_bufr[format_pos] = '\0';
|
format_bufr[format_pos] = '\0';
|
||||||
} /* format_debug_text */
|
} /* format_debug_text */
|
||||||
|
|
||||||
/* ************************************************************************** **
|
/* ************************************************************************** **
|
||||||
* Flush debug output, including the format buffer content.
|
* Flush debug output, including the format buffer content.
|
||||||
@ -278,11 +283,12 @@ static void format_debug_text( char *msg )
|
|||||||
*
|
*
|
||||||
* ************************************************************************** **
|
* ************************************************************************** **
|
||||||
*/
|
*/
|
||||||
void dbgflush( void )
|
void
|
||||||
{
|
dbgflush (void)
|
||||||
bufr_print();
|
{
|
||||||
(void)fflush( dbf );
|
bufr_print ();
|
||||||
} /* dbgflush */
|
(void) fflush (dbf);
|
||||||
|
} /* dbgflush */
|
||||||
|
|
||||||
/* ************************************************************************** **
|
/* ************************************************************************** **
|
||||||
* Print a Debug Header.
|
* Print a Debug Header.
|
||||||
@ -306,38 +312,38 @@ void dbgflush( void )
|
|||||||
*
|
*
|
||||||
* ************************************************************************** **
|
* ************************************************************************** **
|
||||||
*/
|
*/
|
||||||
BOOL dbghdr( int level, const char *file, const char *func, int line )
|
BOOL
|
||||||
{
|
dbghdr (int level, const char *file, const char *func, int line)
|
||||||
if( format_pos )
|
{
|
||||||
|
if (format_pos)
|
||||||
{
|
{
|
||||||
/* This is a fudge. If there is stuff sitting in the format_bufr, then
|
/* This is a fudge. If there is stuff sitting in the format_bufr, then
|
||||||
* the *right* thing to do is to call
|
* the *right* thing to do is to call
|
||||||
* format_debug_text( "\n" );
|
* format_debug_text( "\n" );
|
||||||
* to write the remainder, and then proceed with the new header.
|
* to write the remainder, and then proceed with the new header.
|
||||||
* Unfortunately, there are several places in the code at which
|
* Unfortunately, there are several places in the code at which
|
||||||
* the DEBUG() macro is used to build partial lines. That in mind,
|
* the DEBUG() macro is used to build partial lines. That in mind,
|
||||||
* we'll work under the assumption that an incomplete line indicates
|
* we'll work under the assumption that an incomplete line indicates
|
||||||
* that a new header is *not* desired.
|
* that a new header is *not* desired.
|
||||||
|
*/
|
||||||
|
return (True);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Don't print a header if we're logging to stdout. */
|
||||||
|
if (stdout_logging)
|
||||||
|
return (True);
|
||||||
|
|
||||||
|
/* Print the header if timestamps are turned on. If parameters are
|
||||||
|
* not yet loaded, then default to timestamps on.
|
||||||
*/
|
*/
|
||||||
return( True );
|
if (lp_timestamp_logs () || !(lp_loaded ()))
|
||||||
}
|
|
||||||
|
|
||||||
/* Don't print a header if we're logging to stdout. */
|
|
||||||
if( stdout_logging )
|
|
||||||
return( True );
|
|
||||||
|
|
||||||
/* Print the header if timestamps are turned on. If parameters are
|
|
||||||
* not yet loaded, then default to timestamps on.
|
|
||||||
*/
|
|
||||||
if( lp_timestamp_logs() || !(lp_loaded()) )
|
|
||||||
{
|
{
|
||||||
/* Print it all out at once to prevent split syslog output. */
|
/* Print it all out at once to prevent split syslog output. */
|
||||||
(void)Debug1( "[%s, %d] %s:%s(%d)\n",
|
(void) Debug1 ("[%s, %d] %s:%s(%d)\n", timestring (), level, file, func, line);
|
||||||
timestring(), level, file, func, line );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return( True );
|
return (True);
|
||||||
} /* dbghdr */
|
} /* dbghdr */
|
||||||
|
|
||||||
/* ************************************************************************** **
|
/* ************************************************************************** **
|
||||||
* Add text to the body of the "current" debug message via the format buffer.
|
* Add text to the body of the "current" debug message via the format buffer.
|
||||||
@ -353,37 +359,39 @@ BOOL dbghdr( int level, const char *file, const char *func, int line )
|
|||||||
* ************************************************************************** **
|
* ************************************************************************** **
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_STDARG_H
|
#ifdef HAVE_STDARG_H
|
||||||
BOOL dbgtext( const char *format_str, ... )
|
BOOL
|
||||||
{
|
dbgtext (const char *format_str, ...)
|
||||||
va_list ap;
|
{
|
||||||
pstring msgbuf;
|
va_list ap;
|
||||||
|
pstring msgbuf;
|
||||||
|
|
||||||
va_start( ap, format_str );
|
va_start (ap, format_str);
|
||||||
vslprintf( msgbuf, sizeof(msgbuf)-1, format_str, ap );
|
vslprintf (msgbuf, sizeof (msgbuf) - 1, format_str, ap);
|
||||||
va_end( ap );
|
va_end (ap);
|
||||||
|
|
||||||
format_debug_text( msgbuf );
|
format_debug_text (msgbuf);
|
||||||
|
|
||||||
return( True );
|
return (True);
|
||||||
} /* dbgtext */
|
} /* dbgtext */
|
||||||
|
|
||||||
#else
|
#else
|
||||||
BOOL dbgtext( va_alist )
|
BOOL
|
||||||
va_dcl
|
dbgtext (va_alist)
|
||||||
{
|
va_dcl
|
||||||
char *format_str;
|
{
|
||||||
va_list ap;
|
char *format_str;
|
||||||
pstring msgbuf;
|
va_list ap;
|
||||||
|
pstring msgbuf;
|
||||||
|
|
||||||
va_start( ap );
|
va_start (ap);
|
||||||
format_str = va_arg( ap, char * );
|
format_str = va_arg (ap, char *);
|
||||||
vslprintf( msgbuf, sizeof(msgbuf)-1, format_str, ap );
|
vslprintf (msgbuf, sizeof (msgbuf) - 1, format_str, ap);
|
||||||
va_end( ap );
|
va_end (ap);
|
||||||
|
|
||||||
format_debug_text( msgbuf );
|
format_debug_text (msgbuf);
|
||||||
|
|
||||||
return( True );
|
return (True);
|
||||||
} /* dbgtext */
|
} /* dbgtext */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
|
|
||||||
@ -34,11 +34,11 @@ struct in_addr loopback_ip;
|
|||||||
static struct in_addr default_ip;
|
static struct in_addr default_ip;
|
||||||
static struct in_addr default_bcast;
|
static struct in_addr default_bcast;
|
||||||
static struct in_addr default_nmask;
|
static struct in_addr default_nmask;
|
||||||
static BOOL got_ip=False;
|
static BOOL got_ip = False;
|
||||||
static BOOL got_bcast=False;
|
static BOOL got_bcast = False;
|
||||||
static BOOL got_nmask=False;
|
static BOOL got_nmask = False;
|
||||||
|
|
||||||
static struct interface *local_interfaces = NULL;
|
static struct interface *local_interfaces = NULL;
|
||||||
|
|
||||||
struct interface *last_iface;
|
struct interface *last_iface;
|
||||||
|
|
||||||
@ -47,31 +47,33 @@ struct interface *last_iface;
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
calculate the default netmask for an address
|
calculate the default netmask for an address
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
static void default_netmask(struct in_addr *inm, struct in_addr *iad)
|
static void
|
||||||
|
default_netmask (struct in_addr *inm, struct in_addr *iad)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
** Guess a netmask based on the class of the IP address given.
|
** Guess a netmask based on the class of the IP address given.
|
||||||
*/
|
*/
|
||||||
switch((ntohl(iad->s_addr) & 0xE0000000)) {
|
switch ((ntohl (iad->s_addr) & 0xE0000000))
|
||||||
case 0x00000000: /* Class A addr */
|
{
|
||||||
case 0x20000000:
|
case 0x00000000: /* Class A addr */
|
||||||
case 0x40000000:
|
case 0x20000000:
|
||||||
case 0x60000000:
|
case 0x40000000:
|
||||||
inm->s_addr = htonl(0xFF000000);
|
case 0x60000000:
|
||||||
break;
|
inm->s_addr = htonl (0xFF000000);
|
||||||
|
break;
|
||||||
case 0x80000000: /* Class B addr */
|
|
||||||
case 0xA0000000:
|
case 0x80000000: /* Class B addr */
|
||||||
inm->s_addr = htonl(0xFFFF0000);
|
case 0xA0000000:
|
||||||
break;
|
inm->s_addr = htonl (0xFFFF0000);
|
||||||
|
break;
|
||||||
case 0xC0000000: /* Class C addr */
|
|
||||||
inm->s_addr = htonl(0xFFFFFF00);
|
case 0xC0000000: /* Class C addr */
|
||||||
break;
|
inm->s_addr = htonl (0xFFFFFF00);
|
||||||
|
break;
|
||||||
default: /* ??? */
|
|
||||||
inm->s_addr = htonl(0xFFFFFFF0);
|
default: /* ??? */
|
||||||
}
|
inm->s_addr = htonl (0xFFFFFFF0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -79,48 +81,52 @@ static void default_netmask(struct in_addr *inm, struct in_addr *iad)
|
|||||||
get the broadcast address for our address
|
get the broadcast address for our address
|
||||||
(troyer@saifr00.ateng.az.honeywell.com)
|
(troyer@saifr00.ateng.az.honeywell.com)
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
static void get_broadcast(struct in_addr *if_ipaddr,
|
static void
|
||||||
struct in_addr *if_bcast,
|
get_broadcast (struct in_addr *if_ipaddr, struct in_addr *if_bcast, struct in_addr *if_nmask)
|
||||||
struct in_addr *if_nmask)
|
{
|
||||||
{
|
uint32 nm;
|
||||||
uint32 nm;
|
short onbc;
|
||||||
short onbc;
|
short offbc;
|
||||||
short offbc;
|
|
||||||
|
|
||||||
/* get a default netmask and broadcast */
|
/* get a default netmask and broadcast */
|
||||||
default_netmask(if_nmask, if_ipaddr);
|
default_netmask (if_nmask, if_ipaddr);
|
||||||
|
|
||||||
get_netmask(if_ipaddr, if_nmask);
|
get_netmask (if_ipaddr, if_nmask);
|
||||||
|
|
||||||
/* sanity check on the netmask */
|
/* sanity check on the netmask */
|
||||||
nm = ntohl(if_nmask->s_addr);
|
nm = ntohl (if_nmask->s_addr);
|
||||||
onbc = 0;
|
onbc = 0;
|
||||||
offbc = 0;
|
offbc = 0;
|
||||||
while((onbc + offbc) < 32) {
|
while ((onbc + offbc) < 32)
|
||||||
if(nm & 0x80000000) {
|
{
|
||||||
onbc++;
|
if (nm & 0x80000000)
|
||||||
if(offbc) {
|
{
|
||||||
/* already found an off bit, so mask
|
onbc++;
|
||||||
is wrong */
|
if (offbc)
|
||||||
onbc = 34;
|
{
|
||||||
}
|
/* already found an off bit, so mask
|
||||||
} else {
|
is wrong */
|
||||||
offbc++;
|
onbc = 34;
|
||||||
}
|
}
|
||||||
nm <<= 1;
|
}
|
||||||
}
|
else
|
||||||
if ((onbc < 8)||(onbc == 34)) {
|
{
|
||||||
DEBUG(0,("Impossible netmask %s - using defaults\n",
|
offbc++;
|
||||||
inet_ntoa(*if_nmask)));
|
}
|
||||||
default_netmask(if_nmask, if_ipaddr);
|
nm <<= 1;
|
||||||
}
|
}
|
||||||
|
if ((onbc < 8) || (onbc == 34))
|
||||||
|
{
|
||||||
|
DEBUG (0, ("Impossible netmask %s - using defaults\n", inet_ntoa (*if_nmask)));
|
||||||
|
default_netmask (if_nmask, if_ipaddr);
|
||||||
|
}
|
||||||
|
|
||||||
/* derive the broadcast assuming a 1's broadcast, as this is what
|
/* derive the broadcast assuming a 1's broadcast, as this is what
|
||||||
all MS operating systems do, we have to comply even if the unix
|
all MS operating systems do, we have to comply even if the unix
|
||||||
box is setup differently */
|
box is setup differently */
|
||||||
if_bcast->s_addr = MKBCADDR(if_ipaddr->s_addr, if_nmask->s_addr);
|
if_bcast->s_addr = MKBCADDR (if_ipaddr->s_addr, if_nmask->s_addr);
|
||||||
|
|
||||||
DEBUG(4,("Derived broadcast address %s\n", inet_ntoa(*if_bcast)));
|
DEBUG (4, ("Derived broadcast address %s\n", inet_ntoa (*if_bcast)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -128,220 +134,258 @@ static void get_broadcast(struct in_addr *if_ipaddr,
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
load a list of network interfaces
|
load a list of network interfaces
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
static void interpret_interfaces(char *s, struct interface **interfaces,
|
static void
|
||||||
const char *description)
|
interpret_interfaces (char *s, struct interface **interfaces, const char *description)
|
||||||
{
|
{
|
||||||
char *ptr;
|
char *ptr;
|
||||||
fstring token;
|
fstring token;
|
||||||
struct interface *iface;
|
struct interface *iface;
|
||||||
struct in_addr ip;
|
struct in_addr ip;
|
||||||
|
|
||||||
ptr = s;
|
ptr = s;
|
||||||
ipzero = *interpret_addr2("0.0.0.0");
|
ipzero = *interpret_addr2 ("0.0.0.0");
|
||||||
allones_ip = *interpret_addr2("255.255.255.255");
|
allones_ip = *interpret_addr2 ("255.255.255.255");
|
||||||
loopback_ip = *interpret_addr2("127.0.0.1");
|
loopback_ip = *interpret_addr2 ("127.0.0.1");
|
||||||
|
|
||||||
while (next_token(&ptr,token,NULL,sizeof(token))) {
|
while (next_token (&ptr, token, NULL, sizeof (token)))
|
||||||
/* parse it into an IP address/netmasklength pair */
|
|
||||||
char *p = strchr(token,'/');
|
|
||||||
if (p) *p++ = 0;
|
|
||||||
|
|
||||||
ip = *interpret_addr2(token);
|
|
||||||
|
|
||||||
/* maybe we already have it listed */
|
|
||||||
{
|
{
|
||||||
struct interface *i;
|
/* parse it into an IP address/netmasklength pair */
|
||||||
for (i=(*interfaces);i;i=i->next)
|
char *p = strchr (token, '/');
|
||||||
if (ip_equal(ip,i->ip)) break;
|
if (p)
|
||||||
if (i) continue;
|
*p++ = 0;
|
||||||
|
|
||||||
|
ip = *interpret_addr2 (token);
|
||||||
|
|
||||||
|
/* maybe we already have it listed */
|
||||||
|
{
|
||||||
|
struct interface *i;
|
||||||
|
for (i = (*interfaces); i; i = i->next)
|
||||||
|
if (ip_equal (ip, i->ip))
|
||||||
|
break;
|
||||||
|
if (i)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
iface = (struct interface *) malloc (sizeof (*iface));
|
||||||
|
if (!iface)
|
||||||
|
return;
|
||||||
|
|
||||||
|
iface->ip = ip;
|
||||||
|
|
||||||
|
if (p)
|
||||||
|
{
|
||||||
|
if (strlen (p) > 2)
|
||||||
|
iface->nmask = *interpret_addr2 (p);
|
||||||
|
else
|
||||||
|
iface->nmask.s_addr = htonl (((ALLONES >> atoi (p)) ^ ALLONES));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
default_netmask (&iface->nmask, &iface->ip);
|
||||||
|
}
|
||||||
|
iface->bcast.s_addr = MKBCADDR (iface->ip.s_addr, iface->nmask.s_addr);
|
||||||
|
iface->next = NULL;
|
||||||
|
|
||||||
|
if (!(*interfaces))
|
||||||
|
{
|
||||||
|
(*interfaces) = iface;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
last_iface->next = iface;
|
||||||
|
}
|
||||||
|
last_iface = iface;
|
||||||
|
DEBUG (2, ("Added %s ip=%s ", description, inet_ntoa (iface->ip)));
|
||||||
|
DEBUG (2, ("bcast=%s ", inet_ntoa (iface->bcast)));
|
||||||
|
DEBUG (2, ("nmask=%s\n", inet_ntoa (iface->nmask)));
|
||||||
}
|
}
|
||||||
|
|
||||||
iface = (struct interface *)malloc(sizeof(*iface));
|
if (*interfaces)
|
||||||
if (!iface) return;
|
return;
|
||||||
|
|
||||||
iface->ip = ip;
|
/* setup a default interface */
|
||||||
|
iface = (struct interface *) malloc (sizeof (*iface));
|
||||||
|
if (!iface)
|
||||||
|
return;
|
||||||
|
|
||||||
if (p) {
|
|
||||||
if (strlen(p) > 2)
|
|
||||||
iface->nmask = *interpret_addr2(p);
|
|
||||||
else
|
|
||||||
iface->nmask.s_addr = htonl(((ALLONES >> atoi(p)) ^ ALLONES));
|
|
||||||
} else {
|
|
||||||
default_netmask(&iface->nmask,&iface->ip);
|
|
||||||
}
|
|
||||||
iface->bcast.s_addr = MKBCADDR(iface->ip.s_addr, iface->nmask.s_addr);
|
|
||||||
iface->next = NULL;
|
iface->next = NULL;
|
||||||
|
|
||||||
if (!(*interfaces)) {
|
if (got_ip)
|
||||||
(*interfaces) = iface;
|
{
|
||||||
} else {
|
iface->ip = default_ip;
|
||||||
last_iface->next = iface;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
get_myname (NULL, &iface->ip);
|
||||||
}
|
}
|
||||||
last_iface = iface;
|
|
||||||
DEBUG(2,("Added %s ip=%s ",description,inet_ntoa(iface->ip)));
|
|
||||||
DEBUG(2,("bcast=%s ",inet_ntoa(iface->bcast)));
|
|
||||||
DEBUG(2,("nmask=%s\n",inet_ntoa(iface->nmask)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*interfaces) return;
|
if (got_bcast)
|
||||||
|
{
|
||||||
|
iface->bcast = default_bcast;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
get_broadcast (&iface->ip, &iface->bcast, &iface->nmask);
|
||||||
|
}
|
||||||
|
|
||||||
/* setup a default interface */
|
if (got_nmask)
|
||||||
iface = (struct interface *)malloc(sizeof(*iface));
|
{
|
||||||
if (!iface) return;
|
iface->nmask = default_nmask;
|
||||||
|
iface->bcast.s_addr = MKBCADDR (iface->ip.s_addr, iface->nmask.s_addr);
|
||||||
|
}
|
||||||
|
|
||||||
iface->next = NULL;
|
if (iface->bcast.s_addr != MKBCADDR (iface->ip.s_addr, iface->nmask.s_addr))
|
||||||
|
{
|
||||||
|
DEBUG (2, ("Warning: inconsistant interface %s\n", inet_ntoa (iface->ip)));
|
||||||
|
}
|
||||||
|
|
||||||
if (got_ip) {
|
iface->next = NULL;
|
||||||
iface->ip = default_ip;
|
(*interfaces) = last_iface = iface;
|
||||||
} else {
|
|
||||||
get_myname(NULL,&iface->ip);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (got_bcast) {
|
DEBUG (2, ("Added interface ip=%s ", inet_ntoa (iface->ip)));
|
||||||
iface->bcast = default_bcast;
|
DEBUG (2, ("bcast=%s ", inet_ntoa (iface->bcast)));
|
||||||
} else {
|
DEBUG (2, ("nmask=%s\n", inet_ntoa (iface->nmask)));
|
||||||
get_broadcast(&iface->ip,&iface->bcast,&iface->nmask);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (got_nmask) {
|
|
||||||
iface->nmask = default_nmask;
|
|
||||||
iface->bcast.s_addr = MKBCADDR(iface->ip.s_addr, iface->nmask.s_addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (iface->bcast.s_addr != MKBCADDR(iface->ip.s_addr, iface->nmask.s_addr)) {
|
|
||||||
DEBUG(2,("Warning: inconsistant interface %s\n",inet_ntoa(iface->ip)));
|
|
||||||
}
|
|
||||||
|
|
||||||
iface->next = NULL;
|
|
||||||
(*interfaces) = last_iface = iface;
|
|
||||||
|
|
||||||
DEBUG(2,("Added interface ip=%s ",inet_ntoa(iface->ip)));
|
|
||||||
DEBUG(2,("bcast=%s ",inet_ntoa(iface->bcast)));
|
|
||||||
DEBUG(2,("nmask=%s\n",inet_ntoa(iface->nmask)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
load the remote and local interfaces
|
load the remote and local interfaces
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
void load_interfaces(void)
|
void
|
||||||
|
load_interfaces (void)
|
||||||
{
|
{
|
||||||
/* add the machine's interfaces to local interface structure*/
|
/* add the machine's interfaces to local interface structure */
|
||||||
interpret_interfaces(lp_interfaces(), &local_interfaces,"interface");
|
interpret_interfaces (lp_interfaces (), &local_interfaces, "interface");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
override the defaults
|
override the defaults
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
void iface_set_default(char *ip,char *bcast,char *nmask)
|
void
|
||||||
|
iface_set_default (char *ip, char *bcast, char *nmask)
|
||||||
{
|
{
|
||||||
if (ip) {
|
if (ip)
|
||||||
got_ip = True;
|
{
|
||||||
default_ip = *interpret_addr2(ip);
|
got_ip = True;
|
||||||
}
|
default_ip = *interpret_addr2 (ip);
|
||||||
|
}
|
||||||
|
|
||||||
if (bcast) {
|
if (bcast)
|
||||||
got_bcast = True;
|
{
|
||||||
default_bcast = *interpret_addr2(bcast);
|
got_bcast = True;
|
||||||
}
|
default_bcast = *interpret_addr2 (bcast);
|
||||||
|
}
|
||||||
|
|
||||||
if (nmask) {
|
if (nmask)
|
||||||
got_nmask = True;
|
{
|
||||||
default_nmask = *interpret_addr2(nmask);
|
got_nmask = True;
|
||||||
}
|
default_nmask = *interpret_addr2 (nmask);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
check if an IP is one of mine
|
check if an IP is one of mine
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
BOOL ismyip(struct in_addr ip)
|
BOOL
|
||||||
|
ismyip (struct in_addr ip)
|
||||||
{
|
{
|
||||||
struct interface *i;
|
struct interface *i;
|
||||||
for (i=local_interfaces;i;i=i->next)
|
for (i = local_interfaces; i; i = i->next)
|
||||||
if (ip_equal(i->ip,ip)) return True;
|
if (ip_equal (i->ip, ip))
|
||||||
return False;
|
return True;
|
||||||
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
check if a packet is from a local (known) net
|
check if a packet is from a local (known) net
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
BOOL is_local_net(struct in_addr from)
|
BOOL
|
||||||
|
is_local_net (struct in_addr from)
|
||||||
{
|
{
|
||||||
struct interface *i;
|
struct interface *i;
|
||||||
for (i=local_interfaces;i;i=i->next)
|
for (i = local_interfaces; i; i = i->next)
|
||||||
if((from.s_addr & i->nmask.s_addr) == (i->ip.s_addr & i->nmask.s_addr))
|
if ((from.s_addr & i->nmask.s_addr) == (i->ip.s_addr & i->nmask.s_addr))
|
||||||
return True;
|
return True;
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
how many interfaces do we have
|
how many interfaces do we have
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
int iface_count(void)
|
int
|
||||||
|
iface_count (void)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct interface *i;
|
struct interface *i;
|
||||||
|
|
||||||
for (i=local_interfaces;i;i=i->next)
|
for (i = local_interfaces; i; i = i->next)
|
||||||
ret++;
|
ret++;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
True if we have two or more interfaces.
|
True if we have two or more interfaces.
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
BOOL we_are_multihomed(void)
|
BOOL
|
||||||
|
we_are_multihomed (void)
|
||||||
{
|
{
|
||||||
static int multi = -1;
|
static int multi = -1;
|
||||||
|
|
||||||
if(multi == -1)
|
if (multi == -1)
|
||||||
multi = (iface_count() > 1 ? True : False);
|
multi = (iface_count () > 1 ? True : False);
|
||||||
|
|
||||||
return multi;
|
return multi;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
return the Nth interface
|
return the Nth interface
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
struct interface *get_interface(int n)
|
struct interface *
|
||||||
{
|
get_interface (int n)
|
||||||
struct interface *i;
|
{
|
||||||
|
struct interface *i;
|
||||||
for (i=local_interfaces;i && n;i=i->next)
|
|
||||||
n--;
|
|
||||||
|
|
||||||
if (i) return i;
|
for (i = local_interfaces; i && n; i = i->next)
|
||||||
return NULL;
|
n--;
|
||||||
|
|
||||||
|
if (i)
|
||||||
|
return i;
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
return IP of the Nth interface
|
return IP of the Nth interface
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
struct in_addr *iface_n_ip(int n)
|
struct in_addr *
|
||||||
|
iface_n_ip (int n)
|
||||||
{
|
{
|
||||||
struct interface *i;
|
struct interface *i;
|
||||||
|
|
||||||
for (i=local_interfaces;i && n;i=i->next)
|
|
||||||
n--;
|
|
||||||
|
|
||||||
if (i) return &i->ip;
|
for (i = local_interfaces; i && n; i = i->next)
|
||||||
return NULL;
|
n--;
|
||||||
|
|
||||||
|
if (i)
|
||||||
|
return &i->ip;
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
Try and find an interface that matches an ip. If we cannot, return NULL
|
Try and find an interface that matches an ip. If we cannot, return NULL
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
static struct interface *iface_find(struct in_addr ip)
|
static struct interface *
|
||||||
|
iface_find (struct in_addr ip)
|
||||||
{
|
{
|
||||||
struct interface *i;
|
struct interface *i;
|
||||||
if (zero_ip(ip)) return local_interfaces;
|
if (zero_ip (ip))
|
||||||
|
return local_interfaces;
|
||||||
|
|
||||||
for (i=local_interfaces;i;i=i->next)
|
for (i = local_interfaces; i; i = i->next)
|
||||||
if (same_net(i->ip,ip,i->nmask)) return i;
|
if (same_net (i->ip, ip, i->nmask))
|
||||||
|
return i;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -351,18 +395,20 @@ used to detect a change in interfaces to tell us whether to discard
|
|||||||
the current wins.dat file.
|
the current wins.dat file.
|
||||||
Note that the result is independent of the order of the interfaces
|
Note that the result is independent of the order of the interfaces
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
unsigned iface_hash(void)
|
unsigned
|
||||||
|
iface_hash (void)
|
||||||
{
|
{
|
||||||
unsigned ret = 0;
|
unsigned ret = 0;
|
||||||
struct interface *i;
|
struct interface *i;
|
||||||
|
|
||||||
for (i=local_interfaces;i;i=i->next) {
|
for (i = local_interfaces; i; i = i->next)
|
||||||
unsigned x1 = (unsigned)str_checksum(inet_ntoa(i->ip));
|
{
|
||||||
unsigned x2 = (unsigned)str_checksum(inet_ntoa(i->nmask));
|
unsigned x1 = (unsigned) str_checksum (inet_ntoa (i->ip));
|
||||||
ret ^= (x1 ^ x2);
|
unsigned x2 = (unsigned) str_checksum (inet_ntoa (i->nmask));
|
||||||
}
|
ret ^= (x1 ^ x2);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -371,17 +417,16 @@ unsigned iface_hash(void)
|
|||||||
an appropriate interface they return the requested field of the
|
an appropriate interface they return the requested field of the
|
||||||
first known interface. */
|
first known interface. */
|
||||||
|
|
||||||
struct in_addr *iface_bcast(struct in_addr ip)
|
struct in_addr *
|
||||||
|
iface_bcast (struct in_addr ip)
|
||||||
{
|
{
|
||||||
struct interface *i = iface_find(ip);
|
struct interface *i = iface_find (ip);
|
||||||
return(i ? &i->bcast : &local_interfaces->bcast);
|
return (i ? &i->bcast : &local_interfaces->bcast);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct in_addr *iface_ip(struct in_addr ip)
|
struct in_addr *
|
||||||
|
iface_ip (struct in_addr ip)
|
||||||
{
|
{
|
||||||
struct interface *i = iface_find(ip);
|
struct interface *i = iface_find (ip);
|
||||||
return(i ? &i->ip : &local_interfaces->ip);
|
return (i ? &i->ip : &local_interfaces->ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -22,36 +22,40 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
|
|
||||||
/* NOTE: This code makes no attempt to be fast!
|
/* NOTE: This code makes no attempt to be fast!
|
||||||
|
|
||||||
It assumes that a int is at least 32 bits long
|
It assumes that a int is at least 32 bits long
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static uint32 A, B, C, D;
|
static uint32 A, B, C, D;
|
||||||
|
|
||||||
static uint32 F(uint32 X, uint32 Y, uint32 Z)
|
static uint32
|
||||||
|
F (uint32 X, uint32 Y, uint32 Z)
|
||||||
{
|
{
|
||||||
return (X&Y) | ((~X)&Z);
|
return (X & Y) | ((~X) & Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32 G(uint32 X, uint32 Y, uint32 Z)
|
static uint32
|
||||||
|
G (uint32 X, uint32 Y, uint32 Z)
|
||||||
{
|
{
|
||||||
return (X&Y) | (X&Z) | (Y&Z);
|
return (X & Y) | (X & Z) | (Y & Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32 H(uint32 X, uint32 Y, uint32 Z)
|
static uint32
|
||||||
|
H (uint32 X, uint32 Y, uint32 Z)
|
||||||
{
|
{
|
||||||
return X^Y^Z;
|
return X ^ Y ^ Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32 lshift(uint32 x, int s)
|
static uint32
|
||||||
|
lshift (uint32 x, int s)
|
||||||
{
|
{
|
||||||
x &= 0xFFFFFFFF;
|
x &= 0xFFFFFFFF;
|
||||||
return ((x<<s)&0xFFFFFFFF) | (x>>(32-s));
|
return ((x << s) & 0xFFFFFFFF) | (x >> (32 - s));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ROUND1(a,b,c,d,k,s) a = lshift(a + F(b,c,d) + X[k], s)
|
#define ROUND1(a,b,c,d,k,s) a = lshift(a + F(b,c,d) + X[k], s)
|
||||||
@ -59,117 +63,155 @@ static uint32 lshift(uint32 x, int s)
|
|||||||
#define ROUND3(a,b,c,d,k,s) a = lshift(a + H(b,c,d) + X[k] + (uint32)0x6ED9EBA1,s)
|
#define ROUND3(a,b,c,d,k,s) a = lshift(a + H(b,c,d) + X[k] + (uint32)0x6ED9EBA1,s)
|
||||||
|
|
||||||
/* this applies md4 to 64 byte chunks */
|
/* this applies md4 to 64 byte chunks */
|
||||||
static void mdfour64(uint32 *M)
|
static void
|
||||||
|
mdfour64 (uint32 * M)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
uint32 AA, BB, CC, DD;
|
uint32 AA, BB, CC, DD;
|
||||||
uint32 X[16];
|
uint32 X[16];
|
||||||
|
|
||||||
for (j=0;j<16;j++)
|
for (j = 0; j < 16; j++)
|
||||||
X[j] = M[j];
|
X[j] = M[j];
|
||||||
|
|
||||||
AA = A; BB = B; CC = C; DD = D;
|
AA = A;
|
||||||
|
BB = B;
|
||||||
|
CC = C;
|
||||||
|
DD = D;
|
||||||
|
|
||||||
ROUND1(A,B,C,D, 0, 3); ROUND1(D,A,B,C, 1, 7);
|
ROUND1 (A, B, C, D, 0, 3);
|
||||||
ROUND1(C,D,A,B, 2, 11); ROUND1(B,C,D,A, 3, 19);
|
ROUND1 (D, A, B, C, 1, 7);
|
||||||
ROUND1(A,B,C,D, 4, 3); ROUND1(D,A,B,C, 5, 7);
|
ROUND1 (C, D, A, B, 2, 11);
|
||||||
ROUND1(C,D,A,B, 6, 11); ROUND1(B,C,D,A, 7, 19);
|
ROUND1 (B, C, D, A, 3, 19);
|
||||||
ROUND1(A,B,C,D, 8, 3); ROUND1(D,A,B,C, 9, 7);
|
ROUND1 (A, B, C, D, 4, 3);
|
||||||
ROUND1(C,D,A,B, 10, 11); ROUND1(B,C,D,A, 11, 19);
|
ROUND1 (D, A, B, C, 5, 7);
|
||||||
ROUND1(A,B,C,D, 12, 3); ROUND1(D,A,B,C, 13, 7);
|
ROUND1 (C, D, A, B, 6, 11);
|
||||||
ROUND1(C,D,A,B, 14, 11); ROUND1(B,C,D,A, 15, 19);
|
ROUND1 (B, C, D, A, 7, 19);
|
||||||
|
ROUND1 (A, B, C, D, 8, 3);
|
||||||
|
ROUND1 (D, A, B, C, 9, 7);
|
||||||
|
ROUND1 (C, D, A, B, 10, 11);
|
||||||
|
ROUND1 (B, C, D, A, 11, 19);
|
||||||
|
ROUND1 (A, B, C, D, 12, 3);
|
||||||
|
ROUND1 (D, A, B, C, 13, 7);
|
||||||
|
ROUND1 (C, D, A, B, 14, 11);
|
||||||
|
ROUND1 (B, C, D, A, 15, 19);
|
||||||
|
|
||||||
ROUND2(A,B,C,D, 0, 3); ROUND2(D,A,B,C, 4, 5);
|
ROUND2 (A, B, C, D, 0, 3);
|
||||||
ROUND2(C,D,A,B, 8, 9); ROUND2(B,C,D,A, 12, 13);
|
ROUND2 (D, A, B, C, 4, 5);
|
||||||
ROUND2(A,B,C,D, 1, 3); ROUND2(D,A,B,C, 5, 5);
|
ROUND2 (C, D, A, B, 8, 9);
|
||||||
ROUND2(C,D,A,B, 9, 9); ROUND2(B,C,D,A, 13, 13);
|
ROUND2 (B, C, D, A, 12, 13);
|
||||||
ROUND2(A,B,C,D, 2, 3); ROUND2(D,A,B,C, 6, 5);
|
ROUND2 (A, B, C, D, 1, 3);
|
||||||
ROUND2(C,D,A,B, 10, 9); ROUND2(B,C,D,A, 14, 13);
|
ROUND2 (D, A, B, C, 5, 5);
|
||||||
ROUND2(A,B,C,D, 3, 3); ROUND2(D,A,B,C, 7, 5);
|
ROUND2 (C, D, A, B, 9, 9);
|
||||||
ROUND2(C,D,A,B, 11, 9); ROUND2(B,C,D,A, 15, 13);
|
ROUND2 (B, C, D, A, 13, 13);
|
||||||
|
ROUND2 (A, B, C, D, 2, 3);
|
||||||
|
ROUND2 (D, A, B, C, 6, 5);
|
||||||
|
ROUND2 (C, D, A, B, 10, 9);
|
||||||
|
ROUND2 (B, C, D, A, 14, 13);
|
||||||
|
ROUND2 (A, B, C, D, 3, 3);
|
||||||
|
ROUND2 (D, A, B, C, 7, 5);
|
||||||
|
ROUND2 (C, D, A, B, 11, 9);
|
||||||
|
ROUND2 (B, C, D, A, 15, 13);
|
||||||
|
|
||||||
ROUND3(A,B,C,D, 0, 3); ROUND3(D,A,B,C, 8, 9);
|
ROUND3 (A, B, C, D, 0, 3);
|
||||||
ROUND3(C,D,A,B, 4, 11); ROUND3(B,C,D,A, 12, 15);
|
ROUND3 (D, A, B, C, 8, 9);
|
||||||
ROUND3(A,B,C,D, 2, 3); ROUND3(D,A,B,C, 10, 9);
|
ROUND3 (C, D, A, B, 4, 11);
|
||||||
ROUND3(C,D,A,B, 6, 11); ROUND3(B,C,D,A, 14, 15);
|
ROUND3 (B, C, D, A, 12, 15);
|
||||||
ROUND3(A,B,C,D, 1, 3); ROUND3(D,A,B,C, 9, 9);
|
ROUND3 (A, B, C, D, 2, 3);
|
||||||
ROUND3(C,D,A,B, 5, 11); ROUND3(B,C,D,A, 13, 15);
|
ROUND3 (D, A, B, C, 10, 9);
|
||||||
ROUND3(A,B,C,D, 3, 3); ROUND3(D,A,B,C, 11, 9);
|
ROUND3 (C, D, A, B, 6, 11);
|
||||||
ROUND3(C,D,A,B, 7, 11); ROUND3(B,C,D,A, 15, 15);
|
ROUND3 (B, C, D, A, 14, 15);
|
||||||
|
ROUND3 (A, B, C, D, 1, 3);
|
||||||
|
ROUND3 (D, A, B, C, 9, 9);
|
||||||
|
ROUND3 (C, D, A, B, 5, 11);
|
||||||
|
ROUND3 (B, C, D, A, 13, 15);
|
||||||
|
ROUND3 (A, B, C, D, 3, 3);
|
||||||
|
ROUND3 (D, A, B, C, 11, 9);
|
||||||
|
ROUND3 (C, D, A, B, 7, 11);
|
||||||
|
ROUND3 (B, C, D, A, 15, 15);
|
||||||
|
|
||||||
A += AA; B += BB; C += CC; D += DD;
|
A += AA;
|
||||||
|
B += BB;
|
||||||
A &= 0xFFFFFFFF; B &= 0xFFFFFFFF;
|
C += CC;
|
||||||
C &= 0xFFFFFFFF; D &= 0xFFFFFFFF;
|
D += DD;
|
||||||
|
|
||||||
for (j=0;j<16;j++)
|
A &= 0xFFFFFFFF;
|
||||||
X[j] = 0;
|
B &= 0xFFFFFFFF;
|
||||||
|
C &= 0xFFFFFFFF;
|
||||||
|
D &= 0xFFFFFFFF;
|
||||||
|
|
||||||
|
for (j = 0; j < 16; j++)
|
||||||
|
X[j] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void copy64(uint32 *M, unsigned char *in)
|
static void
|
||||||
|
copy64 (uint32 * M, unsigned char *in)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i=0;i<16;i++)
|
for (i = 0; i < 16; i++)
|
||||||
M[i] = (in[i*4+3]<<24) | (in[i*4+2]<<16) |
|
M[i] = (in[i * 4 + 3] << 24) | (in[i * 4 + 2] << 16) |
|
||||||
(in[i*4+1]<<8) | (in[i*4+0]<<0);
|
(in[i * 4 + 1] << 8) | (in[i * 4 + 0] << 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void copy4(unsigned char *out,uint32 x)
|
static void
|
||||||
|
copy4 (unsigned char *out, uint32 x)
|
||||||
{
|
{
|
||||||
out[0] = x&0xFF;
|
out[0] = x & 0xFF;
|
||||||
out[1] = (x>>8)&0xFF;
|
out[1] = (x >> 8) & 0xFF;
|
||||||
out[2] = (x>>16)&0xFF;
|
out[2] = (x >> 16) & 0xFF;
|
||||||
out[3] = (x>>24)&0xFF;
|
out[3] = (x >> 24) & 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* produce a md4 message digest from data of length n bytes */
|
/* produce a md4 message digest from data of length n bytes */
|
||||||
void mdfour(unsigned char *out, unsigned char *in, int n)
|
void
|
||||||
|
mdfour (unsigned char *out, unsigned char *in, int n)
|
||||||
{
|
{
|
||||||
unsigned char buf[128];
|
unsigned char buf[128];
|
||||||
uint32 M[16];
|
uint32 M[16];
|
||||||
uint32 b = n * 8;
|
uint32 b = n * 8;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
A = 0x67452301;
|
A = 0x67452301;
|
||||||
B = 0xefcdab89;
|
B = 0xefcdab89;
|
||||||
C = 0x98badcfe;
|
C = 0x98badcfe;
|
||||||
D = 0x10325476;
|
D = 0x10325476;
|
||||||
|
|
||||||
while (n > 64) {
|
while (n > 64)
|
||||||
copy64(M, in);
|
{
|
||||||
mdfour64(M);
|
copy64 (M, in);
|
||||||
in += 64;
|
mdfour64 (M);
|
||||||
n -= 64;
|
in += 64;
|
||||||
}
|
n -= 64;
|
||||||
|
}
|
||||||
|
|
||||||
for (i=0;i<128;i++)
|
for (i = 0; i < 128; i++)
|
||||||
buf[i] = 0;
|
buf[i] = 0;
|
||||||
memcpy(buf, in, n);
|
memcpy (buf, in, n);
|
||||||
buf[n] = 0x80;
|
buf[n] = 0x80;
|
||||||
|
|
||||||
if (n <= 55) {
|
|
||||||
copy4(buf+56, b);
|
|
||||||
copy64(M, buf);
|
|
||||||
mdfour64(M);
|
|
||||||
} else {
|
|
||||||
copy4(buf+120, b);
|
|
||||||
copy64(M, buf);
|
|
||||||
mdfour64(M);
|
|
||||||
copy64(M, buf+64);
|
|
||||||
mdfour64(M);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i=0;i<128;i++)
|
if (n <= 55)
|
||||||
buf[i] = 0;
|
{
|
||||||
copy64(M, buf);
|
copy4 (buf + 56, b);
|
||||||
|
copy64 (M, buf);
|
||||||
|
mdfour64 (M);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
copy4 (buf + 120, b);
|
||||||
|
copy64 (M, buf);
|
||||||
|
mdfour64 (M);
|
||||||
|
copy64 (M, buf + 64);
|
||||||
|
mdfour64 (M);
|
||||||
|
}
|
||||||
|
|
||||||
copy4(out, A);
|
for (i = 0; i < 128; i++)
|
||||||
copy4(out+4, B);
|
buf[i] = 0;
|
||||||
copy4(out+8, C);
|
copy64 (M, buf);
|
||||||
copy4(out+12, D);
|
|
||||||
|
|
||||||
A = B = C = D = 0;
|
copy4 (out, A);
|
||||||
|
copy4 (out + 4, B);
|
||||||
|
copy4 (out + 8, C);
|
||||||
|
copy4 (out + 12, D);
|
||||||
|
|
||||||
|
A = B = C = D = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/* working out the netmask for an interface is an incredibly non-portable
|
/* working out the netmask for an interface is an incredibly non-portable
|
||||||
@ -34,7 +34,7 @@
|
|||||||
this code cannot use any of the normal Samba debug stuff or defines.
|
this code cannot use any of the normal Samba debug stuff or defines.
|
||||||
This is standalone code.
|
This is standalone code.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef AUTOCONF
|
#ifndef AUTOCONF
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -63,84 +63,89 @@
|
|||||||
* Prototype for gcc in fussy mode.
|
* Prototype for gcc in fussy mode.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int get_netmask(struct in_addr *ipaddr, struct in_addr *nmask);
|
int get_netmask (struct in_addr *ipaddr, struct in_addr *nmask);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
get the netmask address for a local interface
|
get the netmask address for a local interface
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
int get_netmask(struct in_addr *ipaddr, struct in_addr *nmask)
|
int
|
||||||
{
|
get_netmask (struct in_addr *ipaddr, struct in_addr *nmask)
|
||||||
struct ifconf ifc;
|
{
|
||||||
char buff[2048];
|
struct ifconf ifc;
|
||||||
int fd, i, n;
|
char buff[2048];
|
||||||
struct ifreq *ifr=NULL;
|
int fd, i, n;
|
||||||
|
struct ifreq *ifr = NULL;
|
||||||
|
|
||||||
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
|
if ((fd = socket (AF_INET, SOCK_DGRAM, 0)) == -1)
|
||||||
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"socket failed\n");
|
fprintf (stderr, "socket failed\n");
|
||||||
#endif
|
#endif
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ifc.ifc_len = sizeof(buff);
|
|
||||||
ifc.ifc_buf = buff;
|
|
||||||
if (ioctl(fd, SIOCGIFCONF, &ifc) != 0) {
|
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stderr,"SIOCGIFCONF failed\n");
|
|
||||||
#endif
|
|
||||||
close(fd);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ifr = ifc.ifc_req;
|
ifc.ifc_len = sizeof (buff);
|
||||||
|
ifc.ifc_buf = buff;
|
||||||
n = ifc.ifc_len / sizeof(struct ifreq);
|
if (ioctl (fd, SIOCGIFCONF, &ifc) != 0)
|
||||||
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"%d interfaces - looking for %s\n",
|
fprintf (stderr, "SIOCGIFCONF failed\n");
|
||||||
n, inet_ntoa(*ipaddr));
|
|
||||||
#endif
|
#endif
|
||||||
|
close (fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Loop through interfaces, looking for given IP address */
|
ifr = ifc.ifc_req;
|
||||||
for (i=n-1;i>=0;i--) {
|
|
||||||
if (ioctl(fd, SIOCGIFADDR, &ifr[i]) != 0) {
|
n = ifc.ifc_len / sizeof (struct ifreq);
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stderr,"SIOCGIFADDR failed\n");
|
|
||||||
#endif
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"interface %s\n",
|
fprintf (stderr, "%d interfaces - looking for %s\n", n, inet_ntoa (*ipaddr));
|
||||||
inet_ntoa((*(struct sockaddr_in *)&ifr[i].ifr_addr).sin_addr));
|
|
||||||
#endif
|
|
||||||
if (ipaddr->s_addr !=
|
|
||||||
(*(struct sockaddr_in *)&ifr[i].ifr_addr).sin_addr.s_addr) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ioctl(fd, SIOCGIFNETMASK, &ifr[i]) != 0) {
|
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stderr,"SIOCGIFNETMASK failed\n");
|
|
||||||
#endif
|
|
||||||
close(fd);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
close(fd);
|
|
||||||
(*nmask) = ((struct sockaddr_in *)&ifr[i].ifr_addr)->sin_addr;
|
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stderr,"netmask %s\n", inet_ntoa(*nmask));
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stderr,"interface not found\n");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
close(fd);
|
/* Loop through interfaces, looking for given IP address */
|
||||||
return -1;
|
for (i = n - 1; i >= 0; i--)
|
||||||
}
|
{
|
||||||
|
if (ioctl (fd, SIOCGIFADDR, &ifr[i]) != 0)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
fprintf (stderr, "SIOCGIFADDR failed\n");
|
||||||
|
#endif
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
fprintf (stderr, "interface %s\n",
|
||||||
|
inet_ntoa ((*(struct sockaddr_in *) &ifr[i].ifr_addr).sin_addr));
|
||||||
|
#endif
|
||||||
|
if (ipaddr->s_addr != (*(struct sockaddr_in *) &ifr[i].ifr_addr).sin_addr.s_addr)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ioctl (fd, SIOCGIFNETMASK, &ifr[i]) != 0)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
fprintf (stderr, "SIOCGIFNETMASK failed\n");
|
||||||
|
#endif
|
||||||
|
close (fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
close (fd);
|
||||||
|
(*nmask) = ((struct sockaddr_in *) &ifr[i].ifr_addr)->sin_addr;
|
||||||
|
#ifdef DEBUG
|
||||||
|
fprintf (stderr, "netmask %s\n", inet_ntoa (*nmask));
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
fprintf (stderr, "interface not found\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
close (fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
#elif defined(HAVE_NETMASK_IFREQ)
|
#elif defined(HAVE_NETMASK_IFREQ)
|
||||||
|
|
||||||
@ -165,84 +170,90 @@ int get_netmask(struct in_addr *ipaddr, struct in_addr *nmask)
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
this should cover most of the rest of systems
|
this should cover most of the rest of systems
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
int get_netmask(struct in_addr *ipaddr, struct in_addr *nmask)
|
int
|
||||||
|
get_netmask (struct in_addr *ipaddr, struct in_addr *nmask)
|
||||||
{
|
{
|
||||||
struct ifreq ifreq;
|
struct ifreq ifreq;
|
||||||
struct strioctl strioctl;
|
struct strioctl strioctl;
|
||||||
struct ifconf *ifc;
|
struct ifconf *ifc;
|
||||||
char buff[2048];
|
char buff[2048];
|
||||||
int fd, i, n;
|
int fd, i, n;
|
||||||
struct ifreq *ifr=NULL;
|
struct ifreq *ifr = NULL;
|
||||||
|
|
||||||
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
|
if ((fd = socket (AF_INET, SOCK_DGRAM, 0)) == -1)
|
||||||
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"socket failed\n");
|
fprintf (stderr, "socket failed\n");
|
||||||
#endif
|
#endif
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ifc = (struct ifconf *)buff;
|
|
||||||
ifc->ifc_len = BUFSIZ - sizeof(struct ifconf);
|
|
||||||
strioctl.ic_cmd = SIOCGIFCONF;
|
|
||||||
strioctl.ic_dp = (char *)ifc;
|
|
||||||
strioctl.ic_len = sizeof(buff);
|
|
||||||
if (ioctl(fd, I_STR, &strioctl) < 0) {
|
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stderr,"SIOCGIFCONF failed\n");
|
|
||||||
#endif
|
|
||||||
close(fd);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ifr = (struct ifreq *)ifc->ifc_req;
|
|
||||||
|
|
||||||
/* Loop through interfaces, looking for given IP address */
|
ifc = (struct ifconf *) buff;
|
||||||
n = ifc->ifc_len / sizeof(struct ifreq);
|
ifc->ifc_len = BUFSIZ - sizeof (struct ifconf);
|
||||||
|
strioctl.ic_cmd = SIOCGIFCONF;
|
||||||
for (i = 0; i<n; i++, ifr++) {
|
strioctl.ic_dp = (char *) ifc;
|
||||||
|
strioctl.ic_len = sizeof (buff);
|
||||||
|
if (ioctl (fd, I_STR, &strioctl) < 0)
|
||||||
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"interface %s\n",
|
fprintf (stderr, "SIOCGIFCONF failed\n");
|
||||||
inet_ntoa((*(struct sockaddr_in *)&ifr->ifr_addr).sin_addr.s_addr));
|
|
||||||
#endif
|
#endif
|
||||||
if (ipaddr->s_addr ==
|
close (fd);
|
||||||
(*(struct sockaddr_in *) &ifr->ifr_addr).sin_addr.s_addr) {
|
return -1;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
}
|
ifr = (struct ifreq *) ifc->ifc_req;
|
||||||
|
|
||||||
|
/* Loop through interfaces, looking for given IP address */
|
||||||
|
n = ifc->ifc_len / sizeof (struct ifreq);
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++, ifr++)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
fprintf (stderr, "interface %s\n",
|
||||||
|
inet_ntoa ((*(struct sockaddr_in *) &ifr->ifr_addr).sin_addr.s_addr));
|
||||||
|
#endif
|
||||||
|
if (ipaddr->s_addr == (*(struct sockaddr_in *) &ifr->ifr_addr).sin_addr.s_addr)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (i == n) {
|
if (i == n)
|
||||||
fprintf(stderr,"interface not found\n");
|
{
|
||||||
close(fd);
|
fprintf (stderr, "interface not found\n");
|
||||||
return -1;
|
close (fd);
|
||||||
}
|
return -1;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ifreq = *ifr;
|
ifreq = *ifr;
|
||||||
|
|
||||||
strioctl.ic_cmd = SIOCGIFNETMASK;
|
|
||||||
strioctl.ic_dp = (char *)&ifreq;
|
|
||||||
strioctl.ic_len = sizeof(struct ifreq);
|
|
||||||
if (ioctl(fd, I_STR, &strioctl) != 0) {
|
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stderr,"Failed SIOCGIFNETMASK\n");
|
|
||||||
#endif
|
|
||||||
close(fd);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
close(fd);
|
strioctl.ic_cmd = SIOCGIFNETMASK;
|
||||||
*nmask = ((struct sockaddr_in *)&ifreq.ifr_addr)->sin_addr;
|
strioctl.ic_dp = (char *) &ifreq;
|
||||||
|
strioctl.ic_len = sizeof (struct ifreq);
|
||||||
|
if (ioctl (fd, I_STR, &strioctl) != 0)
|
||||||
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"netmask %s\n", inet_ntoa(*nmask));
|
fprintf (stderr, "Failed SIOCGIFNETMASK\n");
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
close (fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
close (fd);
|
||||||
|
*nmask = ((struct sockaddr_in *) &ifreq.ifr_addr)->sin_addr;
|
||||||
|
#ifdef DEBUG
|
||||||
|
fprintf (stderr, "netmask %s\n", inet_ntoa (*nmask));
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(HAVE_NETMASK_AIX)
|
#elif defined(HAVE_NETMASK_AIX)
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h> /* close() declaration for gcc in fussy mode */
|
#include <unistd.h> /* close() declaration for gcc in fussy mode */
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
@ -259,87 +270,93 @@ this should cover most of the rest of systems
|
|||||||
* Prototype for gcc in fussy mode.
|
* Prototype for gcc in fussy mode.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int get_netmask(struct in_addr *ipaddr, struct in_addr *nmask);
|
int get_netmask (struct in_addr *ipaddr, struct in_addr *nmask);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
this one is for AIX
|
this one is for AIX
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int get_netmask(struct in_addr *ipaddr, struct in_addr *nmask)
|
int
|
||||||
|
get_netmask (struct in_addr *ipaddr, struct in_addr *nmask)
|
||||||
{
|
{
|
||||||
char buff[2048];
|
char buff[2048];
|
||||||
int fd, i;
|
int fd, i;
|
||||||
struct ifconf ifc;
|
struct ifconf ifc;
|
||||||
struct ifreq *ifr=NULL;
|
struct ifreq *ifr = NULL;
|
||||||
|
|
||||||
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
|
if ((fd = socket (AF_INET, SOCK_DGRAM, 0)) == -1)
|
||||||
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"socket failed\n");
|
fprintf (stderr, "socket failed\n");
|
||||||
#endif
|
#endif
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ifc.ifc_len = sizeof(buff);
|
ifc.ifc_len = sizeof (buff);
|
||||||
ifc.ifc_buf = buff;
|
ifc.ifc_buf = buff;
|
||||||
|
|
||||||
if (ioctl(fd, SIOCGIFCONF, &ifc) != 0) {
|
if (ioctl (fd, SIOCGIFCONF, &ifc) != 0)
|
||||||
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"SIOCGIFCONF failed\n");
|
fprintf (stderr, "SIOCGIFCONF failed\n");
|
||||||
#endif
|
#endif
|
||||||
close(fd);
|
close (fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ifr = ifc.ifc_req;
|
ifr = ifc.ifc_req;
|
||||||
/* Loop through interfaces, looking for given IP address */
|
/* Loop through interfaces, looking for given IP address */
|
||||||
i = ifc.ifc_len;
|
i = ifc.ifc_len;
|
||||||
while (i > 0) {
|
while (i > 0)
|
||||||
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"interface %s\n",
|
fprintf (stderr, "interface %s\n",
|
||||||
inet_ntoa((*(struct sockaddr_in *)&ifr->ifr_addr).sin_addr));
|
inet_ntoa ((*(struct sockaddr_in *) &ifr->ifr_addr).sin_addr));
|
||||||
#endif
|
#endif
|
||||||
if (ipaddr->s_addr ==
|
if (ipaddr->s_addr == (*(struct sockaddr_in *) &ifr->ifr_addr).sin_addr.s_addr)
|
||||||
(*(struct sockaddr_in *) &ifr->ifr_addr).sin_addr.s_addr) {
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i -= ifr->ifr_addr.sa_len + IFNAMSIZ;
|
i -= ifr->ifr_addr.sa_len + IFNAMSIZ;
|
||||||
ifr = (struct ifreq*) ((char*) ifr + ifr->ifr_addr.sa_len +
|
ifr = (struct ifreq *) ((char *) ifr + ifr->ifr_addr.sa_len + IFNAMSIZ);
|
||||||
IFNAMSIZ);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (i <= 0) {
|
if (i <= 0)
|
||||||
fprintf(stderr,"interface not found\n");
|
{
|
||||||
close(fd);
|
fprintf (stderr, "interface not found\n");
|
||||||
return -1;
|
close (fd);
|
||||||
}
|
return -1;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (ioctl(fd, SIOCGIFNETMASK, ifr) != 0) {
|
if (ioctl (fd, SIOCGIFNETMASK, ifr) != 0)
|
||||||
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"SIOCGIFNETMASK failed\n");
|
fprintf (stderr, "SIOCGIFNETMASK failed\n");
|
||||||
#endif
|
#endif
|
||||||
close(fd);
|
close (fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
close(fd);
|
close (fd);
|
||||||
|
|
||||||
(*nmask) = ((struct sockaddr_in *)&ifr->ifr_addr)->sin_addr;
|
(*nmask) = ((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"netmask %s\n", inet_ntoa(*nmask));
|
fprintf (stderr, "netmask %s\n", inet_ntoa (*nmask));
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* a dummy version */
|
#else /* a dummy version */
|
||||||
struct in_addr; /* it may not have been declared before */
|
struct in_addr; /* it may not have been declared before */
|
||||||
int get_netmask(struct in_addr *ipaddr, struct in_addr *nmask);
|
int get_netmask (struct in_addr *ipaddr, struct in_addr *nmask);
|
||||||
int get_netmask(struct in_addr *ipaddr, struct in_addr *nmask)
|
int
|
||||||
|
get_netmask (struct in_addr *ipaddr, struct in_addr *nmask)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -347,29 +364,32 @@ int get_netmask(struct in_addr *ipaddr, struct in_addr *nmask);
|
|||||||
#ifdef AUTOCONF
|
#ifdef AUTOCONF
|
||||||
/* this is the autoconf driver to test get_netmask() */
|
/* this is the autoconf driver to test get_netmask() */
|
||||||
|
|
||||||
main()
|
main ()
|
||||||
{
|
{
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
struct hostent *hp;
|
struct hostent *hp;
|
||||||
struct in_addr ip, nmask;
|
struct in_addr ip, nmask;
|
||||||
|
|
||||||
if (gethostname(buf, sizeof(buf)-1) != 0) {
|
if (gethostname (buf, sizeof (buf) - 1) != 0)
|
||||||
fprintf(stderr,"gethostname failed\n");
|
{
|
||||||
exit(1);
|
fprintf (stderr, "gethostname failed\n");
|
||||||
}
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
hp = gethostbyname(buf);
|
hp = gethostbyname (buf);
|
||||||
|
|
||||||
if (!hp) {
|
if (!hp)
|
||||||
fprintf(stderr,"gethostbyname failed\n");
|
{
|
||||||
exit(1);
|
fprintf (stderr, "gethostbyname failed\n");
|
||||||
}
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
memcpy((char *)&ip, (char *)hp->h_addr, hp->h_length);
|
memcpy ((char *) &ip, (char *) hp->h_addr, hp->h_length);
|
||||||
|
|
||||||
if (get_netmask(&ip, &nmask) == 0) exit(0);
|
if (get_netmask (&ip, &nmask) == 0)
|
||||||
|
exit (0);
|
||||||
|
|
||||||
fprintf(stderr,"get_netmask failed\n");
|
fprintf (stderr, "get_netmask failed\n");
|
||||||
exit(1);
|
exit (1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
|
|
||||||
@ -32,40 +32,44 @@ extern int DEBUGLEVEL;
|
|||||||
/* this is like vsnprintf but the 'n' limit does not include
|
/* this is like vsnprintf but the 'n' limit does not include
|
||||||
the terminating null. So if you have a 1024 byte buffer then
|
the terminating null. So if you have a 1024 byte buffer then
|
||||||
pass 1023 for n */
|
pass 1023 for n */
|
||||||
int vslprintf(char *str, int n, const char *format, va_list ap)
|
int
|
||||||
|
vslprintf (char *str, int n, const char *format, va_list ap)
|
||||||
{
|
{
|
||||||
int ret = vsnprintf(str, n, format, ap);
|
int ret = vsnprintf (str, n, format, ap);
|
||||||
if (ret > n || ret < 0) {
|
if (ret > n || ret < 0)
|
||||||
str[n] = 0;
|
{
|
||||||
return -1;
|
str[n] = 0;
|
||||||
}
|
return -1;
|
||||||
str[ret] = 0;
|
}
|
||||||
return ret;
|
str[ret] = 0;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_STDARG_H
|
#ifdef HAVE_STDARG_H
|
||||||
int slprintf(char *str, int n, const char *format, ...)
|
int
|
||||||
|
slprintf (char *str, int n, const char *format, ...)
|
||||||
{
|
{
|
||||||
#else
|
#else
|
||||||
int slprintf(va_alist)
|
int
|
||||||
va_dcl
|
slprintf (va_alist)
|
||||||
|
va_dcl
|
||||||
{
|
{
|
||||||
char *str, *format;
|
char *str, *format;
|
||||||
int n;
|
int n;
|
||||||
#endif
|
#endif
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
#ifdef HAVE_STDARG_H
|
#ifdef HAVE_STDARG_H
|
||||||
va_start(ap, format);
|
va_start (ap, format);
|
||||||
#else
|
#else
|
||||||
va_start(ap);
|
va_start (ap);
|
||||||
str = va_arg(ap,char *);
|
str = va_arg (ap, char *);
|
||||||
n = va_arg(ap,int);
|
n = va_arg (ap, int);
|
||||||
format = va_arg(ap,char *);
|
format = va_arg (ap, char *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ret = vslprintf(str,n,format,ap);
|
ret = vslprintf (str, n, format, ap);
|
||||||
va_end(ap);
|
va_end (ap);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
|
|
||||||
@ -39,9 +39,9 @@ extern int DEBUGLEVEL;
|
|||||||
- to allow easier integration of things like the japanese extensions
|
- to allow easier integration of things like the japanese extensions
|
||||||
|
|
||||||
- to support the philosophy of Samba to expose the features of
|
- to support the philosophy of Samba to expose the features of
|
||||||
the OS within the SMB model. In general whatever file/printer/variable
|
the OS within the SMB model. In general whatever file/printer/variable
|
||||||
expansions/etc make sense to the OS should be acceptable to Samba.
|
expansions/etc make sense to the OS should be acceptable to Samba.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
@ -50,96 +50,109 @@ return if some data has arrived on one of the file descriptors
|
|||||||
return -1 means error
|
return -1 means error
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
#ifndef HAVE_SELECT
|
#ifndef HAVE_SELECT
|
||||||
static int pollfd(int fd)
|
static int
|
||||||
|
pollfd (int fd)
|
||||||
{
|
{
|
||||||
int r=0;
|
int r = 0;
|
||||||
|
|
||||||
#ifdef HAS_RDCHK
|
#ifdef HAS_RDCHK
|
||||||
r = rdchk(fd);
|
r = rdchk (fd);
|
||||||
#elif defined(TCRDCHK)
|
#elif defined(TCRDCHK)
|
||||||
(void)ioctl(fd, TCRDCHK, &r);
|
(void) ioctl (fd, TCRDCHK, &r);
|
||||||
#else
|
#else
|
||||||
(void)ioctl(fd, FIONREAD, &r);
|
(void) ioctl (fd, FIONREAD, &r);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return(r);
|
return (r);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sys_select(int maxfd, fd_set *fds,struct timeval *tval)
|
int
|
||||||
|
sys_select (int maxfd, fd_set * fds, struct timeval *tval)
|
||||||
{
|
{
|
||||||
fd_set fds2;
|
fd_set fds2;
|
||||||
int counter=0;
|
int counter = 0;
|
||||||
int found=0;
|
int found = 0;
|
||||||
|
|
||||||
FD_ZERO(&fds2);
|
FD_ZERO (&fds2);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i=0;i<maxfd;i++) {
|
for (i = 0; i < maxfd; i++)
|
||||||
if (FD_ISSET(i,fds) && pollfd(i)>0) {
|
{
|
||||||
found++;
|
if (FD_ISSET (i, fds) && pollfd (i) > 0)
|
||||||
FD_SET(i,&fds2);
|
{
|
||||||
}
|
found++;
|
||||||
|
FD_SET (i, &fds2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found)
|
||||||
|
{
|
||||||
|
memcpy ((void *) fds, (void *) &fds2, sizeof (fds2));
|
||||||
|
return (found);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tval && tval->tv_sec < counter)
|
||||||
|
return (0);
|
||||||
|
sleep (1);
|
||||||
|
counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found) {
|
|
||||||
memcpy((void *)fds,(void *)&fds2,sizeof(fds2));
|
|
||||||
return(found);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tval && tval->tv_sec < counter) return(0);
|
|
||||||
sleep(1);
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* !NO_SELECT */
|
#else /* !NO_SELECT */
|
||||||
int sys_select(int maxfd, fd_set *fds,struct timeval *tval)
|
int
|
||||||
|
sys_select (int maxfd, fd_set * fds, struct timeval *tval)
|
||||||
{
|
{
|
||||||
#ifdef USE_POLL
|
#ifdef USE_POLL
|
||||||
struct pollfd pfd[256];
|
struct pollfd pfd[256];
|
||||||
int i;
|
int i;
|
||||||
int maxpoll;
|
int maxpoll;
|
||||||
int timeout;
|
int timeout;
|
||||||
int pollrtn;
|
int pollrtn;
|
||||||
|
|
||||||
maxpoll = 0;
|
maxpoll = 0;
|
||||||
for( i = 0; i < maxfd; i++) {
|
for (i = 0; i < maxfd; i++)
|
||||||
if(FD_ISSET(i,fds)) {
|
{
|
||||||
struct pollfd *pfdp = &pfd[maxpoll++];
|
if (FD_ISSET (i, fds))
|
||||||
pfdp->fd = i;
|
{
|
||||||
pfdp->events = POLLIN;
|
struct pollfd *pfdp = &pfd[maxpoll++];
|
||||||
pfdp->revents = 0;
|
pfdp->fd = i;
|
||||||
|
pfdp->events = POLLIN;
|
||||||
|
pfdp->revents = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
timeout = (tval != NULL) ? (tval->tv_sec * 1000) + (tval->tv_usec/1000) :
|
timeout = (tval != NULL) ? (tval->tv_sec * 1000) + (tval->tv_usec / 1000) : -1;
|
||||||
-1;
|
errno = 0;
|
||||||
errno = 0;
|
do
|
||||||
do {
|
{
|
||||||
pollrtn = poll( &pfd[0], maxpoll, timeout);
|
pollrtn = poll (&pfd[0], maxpoll, timeout);
|
||||||
} while (pollrtn<0 && errno == EINTR);
|
}
|
||||||
|
while (pollrtn < 0 && errno == EINTR);
|
||||||
|
|
||||||
FD_ZERO(fds);
|
FD_ZERO (fds);
|
||||||
|
|
||||||
for( i = 0; i < maxpoll; i++)
|
for (i = 0; i < maxpoll; i++)
|
||||||
if( pfd[i].revents & POLLIN )
|
if (pfd[i].revents & POLLIN)
|
||||||
FD_SET(pfd[i].fd,fds);
|
FD_SET (pfd[i].fd, fds);
|
||||||
|
|
||||||
return pollrtn;
|
return pollrtn;
|
||||||
#else /* USE_POLL */
|
#else /* USE_POLL */
|
||||||
|
|
||||||
struct timeval t2;
|
struct timeval t2;
|
||||||
int selrtn;
|
int selrtn;
|
||||||
|
|
||||||
do {
|
do
|
||||||
if (tval) memcpy((void *)&t2,(void *)tval,sizeof(t2));
|
{
|
||||||
errno = 0;
|
if (tval)
|
||||||
selrtn = select(maxfd,SELECT_CAST fds,NULL,NULL,tval?&t2:NULL);
|
memcpy ((void *) &t2, (void *) tval, sizeof (t2));
|
||||||
} while (selrtn<0 && errno == EINTR);
|
errno = 0;
|
||||||
|
selrtn = select (maxfd, SELECT_CAST fds, NULL, NULL, tval ? &t2 : NULL);
|
||||||
|
}
|
||||||
|
while (selrtn < 0 && errno == EINTR);
|
||||||
|
|
||||||
return(selrtn);
|
return (selrtn);
|
||||||
}
|
}
|
||||||
#endif /* USE_POLL */
|
#endif /* USE_POLL */
|
||||||
#endif /* NO_SELECT */
|
#endif /* NO_SELECT */
|
||||||
@ -148,75 +161,84 @@ int sys_select(int maxfd, fd_set *fds,struct timeval *tval)
|
|||||||
A stat() wrapper that will deal with 64 bit filesizes.
|
A stat() wrapper that will deal with 64 bit filesizes.
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
int sys_stat(const char *fname,SMB_STRUCT_STAT *sbuf)
|
int
|
||||||
|
sys_stat (const char *fname, SMB_STRUCT_STAT * sbuf)
|
||||||
{
|
{
|
||||||
return stat(fname, sbuf);
|
return stat (fname, sbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
An lstat() wrapper that will deal with 64 bit filesizes.
|
An lstat() wrapper that will deal with 64 bit filesizes.
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
#if 0
|
#if 0
|
||||||
int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf)
|
int
|
||||||
|
sys_lstat (const char *fname, SMB_STRUCT_STAT * sbuf)
|
||||||
{
|
{
|
||||||
return lstat(fname, sbuf);
|
return lstat (fname, sbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
An fseek() wrapper that will deal with 64 bit filesizes.
|
An fseek() wrapper that will deal with 64 bit filesizes.
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
int sys_fseek(FILE *fp, SMB_OFF_T offset, int whence)
|
int
|
||||||
|
sys_fseek (FILE * fp, SMB_OFF_T offset, int whence)
|
||||||
{
|
{
|
||||||
return fseek(fp, offset, whence);
|
return fseek (fp, offset, whence);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
An ftell() wrapper that will deal with 64 bit filesizes.
|
An ftell() wrapper that will deal with 64 bit filesizes.
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
SMB_OFF_T sys_ftell(FILE *fp)
|
SMB_OFF_T
|
||||||
|
sys_ftell (FILE * fp)
|
||||||
{
|
{
|
||||||
return (SMB_OFF_T)ftell(fp);
|
return (SMB_OFF_T) ftell (fp);
|
||||||
}
|
}
|
||||||
#endif /* 0 */
|
#endif /* 0 */
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
An open() wrapper that will deal with 64 bit filesizes.
|
An open() wrapper that will deal with 64 bit filesizes.
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
int sys_open(const char *path, int oflag, mode_t mode)
|
int
|
||||||
|
sys_open (const char *path, int oflag, mode_t mode)
|
||||||
{
|
{
|
||||||
return open(path, oflag, mode);
|
return open (path, oflag, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
An fopen() wrapper that will deal with 64 bit filesizes.
|
An fopen() wrapper that will deal with 64 bit filesizes.
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
FILE *sys_fopen(const char *path, const char *type)
|
FILE *
|
||||||
|
sys_fopen (const char *path, const char *type)
|
||||||
{
|
{
|
||||||
return fopen(path, type);
|
return fopen (path, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
A readdir wrapper that will deal with 64 bit filesizes.
|
A readdir wrapper that will deal with 64 bit filesizes.
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
SMB_STRUCT_DIRENT *sys_readdir(DIR *dirp)
|
SMB_STRUCT_DIRENT *
|
||||||
|
sys_readdir (DIR * dirp)
|
||||||
{
|
{
|
||||||
return readdir(dirp);
|
return readdir (dirp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
system wrapper for getwd
|
system wrapper for getwd
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
char *sys_getwd(char *s)
|
char *
|
||||||
|
sys_getwd (char *s)
|
||||||
{
|
{
|
||||||
char *wd;
|
char *wd;
|
||||||
#ifdef HAVE_GETCWD
|
#ifdef HAVE_GETCWD
|
||||||
wd = (char *)getcwd(s, sizeof (pstring));
|
wd = (char *) getcwd (s, sizeof (pstring));
|
||||||
#else
|
#else
|
||||||
wd = (char *)getwd(s);
|
wd = (char *) getwd (s);
|
||||||
#endif
|
#endif
|
||||||
return wd;
|
return wd;
|
||||||
}
|
}
|
||||||
@ -225,16 +247,18 @@ char *sys_getwd(char *s)
|
|||||||
chown isn't used much but OS/2 doesn't have it
|
chown isn't used much but OS/2 doesn't have it
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
int sys_chown(const char *fname,uid_t uid,gid_t gid)
|
int
|
||||||
|
sys_chown (const char *fname, uid_t uid, gid_t gid)
|
||||||
{
|
{
|
||||||
#ifndef HAVE_CHOWN
|
#ifndef HAVE_CHOWN
|
||||||
static int done;
|
static int done;
|
||||||
if (!done) {
|
if (!done)
|
||||||
DEBUG(1,("WARNING: no chown!\n"));
|
{
|
||||||
done=1;
|
DEBUG (1, ("WARNING: no chown!\n"));
|
||||||
}
|
done = 1;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
return(chown(fname,uid,gid));
|
return (chown (fname, uid, gid));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif /* 0 */
|
#endif /* 0 */
|
||||||
@ -243,39 +267,40 @@ A wrapper for gethostbyname() that tries avoids looking up hostnames
|
|||||||
in the root domain, which can cause dial-on-demand links to come up for no
|
in the root domain, which can cause dial-on-demand links to come up for no
|
||||||
apparent reason.
|
apparent reason.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
struct hostent *sys_gethostbyname(const char *name)
|
struct hostent *
|
||||||
|
sys_gethostbyname (const char *name)
|
||||||
{
|
{
|
||||||
#ifdef REDUCE_ROOT_DNS_LOOKUPS
|
#ifdef REDUCE_ROOT_DNS_LOOKUPS
|
||||||
char query[256], hostname[256];
|
char query[256], hostname[256];
|
||||||
char *domain;
|
char *domain;
|
||||||
|
|
||||||
/* Does this name have any dots in it? If so, make no change */
|
/* Does this name have any dots in it? If so, make no change */
|
||||||
|
|
||||||
if (strchr(name, '.'))
|
if (strchr (name, '.'))
|
||||||
return(gethostbyname(name));
|
return (gethostbyname (name));
|
||||||
|
|
||||||
/* Get my hostname, which should have domain name
|
/* Get my hostname, which should have domain name
|
||||||
attached. If not, just do the gethostname on the
|
attached. If not, just do the gethostname on the
|
||||||
original string.
|
original string.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
gethostname(hostname, sizeof(hostname) - 1);
|
gethostname (hostname, sizeof (hostname) - 1);
|
||||||
hostname[sizeof(hostname) - 1] = 0;
|
hostname[sizeof (hostname) - 1] = 0;
|
||||||
if ((domain = strchr(hostname, '.')) == NULL)
|
if ((domain = strchr (hostname, '.')) == NULL)
|
||||||
return(gethostbyname(name));
|
return (gethostbyname (name));
|
||||||
|
|
||||||
/* Attach domain name to query and do modified query.
|
/* Attach domain name to query and do modified query.
|
||||||
If names too large, just do gethostname on the
|
If names too large, just do gethostname on the
|
||||||
original string.
|
original string.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if((strlen(name) + strlen(domain)) >= sizeof(query))
|
if ((strlen (name) + strlen (domain)) >= sizeof (query))
|
||||||
return(gethostbyname(name));
|
return (gethostbyname (name));
|
||||||
|
|
||||||
slprintf(query, sizeof(query)-1, "%s%s", name, domain);
|
slprintf (query, sizeof (query) - 1, "%s%s", name, domain);
|
||||||
return(gethostbyname(query));
|
return (gethostbyname (query));
|
||||||
#else /* REDUCE_ROOT_DNS_LOOKUPS */
|
#else /* REDUCE_ROOT_DNS_LOOKUPS */
|
||||||
return(gethostbyname(name));
|
return (gethostbyname (name));
|
||||||
#endif /* REDUCE_ROOT_DNS_LOOKUPS */
|
#endif /* REDUCE_ROOT_DNS_LOOKUPS */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,15 +308,16 @@ struct hostent *sys_gethostbyname(const char *name)
|
|||||||
Wrapper for random().
|
Wrapper for random().
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#if 0
|
#if 0
|
||||||
long sys_random(void)
|
long
|
||||||
|
sys_random (void)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_RANDOM)
|
#if defined(HAVE_RANDOM)
|
||||||
return (long)random();
|
return (long) random ();
|
||||||
#elif defined(HAVE_RAND)
|
#elif defined(HAVE_RAND)
|
||||||
return (long)rand();
|
return (long) rand ();
|
||||||
#else
|
#else
|
||||||
DEBUG(0,("Error - no random function available !\n"));
|
DEBUG (0, ("Error - no random function available !\n"));
|
||||||
exit(1);
|
exit (1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,15 +325,16 @@ long sys_random(void)
|
|||||||
Wrapper for srandom().
|
Wrapper for srandom().
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void sys_srandom(unsigned int seed)
|
void
|
||||||
|
sys_srandom (unsigned int seed)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_SRANDOM)
|
#if defined(HAVE_SRANDOM)
|
||||||
srandom(seed);
|
srandom (seed);
|
||||||
#elif defined(HAVE_SRAND)
|
#elif defined(HAVE_SRAND)
|
||||||
srand(seed);
|
srand (seed);
|
||||||
#else
|
#else
|
||||||
DEBUG(0,("Error - no srandom function available !\n"));
|
DEBUG (0, ("Error - no srandom function available !\n"));
|
||||||
exit(1);
|
exit (1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif /* 0 */
|
#endif /* 0 */
|
||||||
|
@ -22,17 +22,17 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This stuff was largely rewritten by Paul Eggert <eggert@twinsun.com>
|
This stuff was largely rewritten by Paul Eggert <eggert@twinsun.com>
|
||||||
in May 1996
|
in May 1996
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
int serverzone=0;
|
int serverzone = 0;
|
||||||
int extra_time_offset = 0;
|
int extra_time_offset = 0;
|
||||||
|
|
||||||
extern int DEBUGLEVEL;
|
extern int DEBUGLEVEL;
|
||||||
@ -54,12 +54,13 @@ extern int DEBUGLEVEL;
|
|||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
a gettimeofday wrapper
|
a gettimeofday wrapper
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
void GetTimeOfDay(struct timeval *tval)
|
void
|
||||||
|
GetTimeOfDay (struct timeval *tval)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_GETTIMEOFDAY_TZ
|
#ifdef HAVE_GETTIMEOFDAY_TZ
|
||||||
gettimeofday(tval,NULL);
|
gettimeofday (tval, NULL);
|
||||||
#else
|
#else
|
||||||
gettimeofday(tval);
|
gettimeofday (tval);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,35 +69,36 @@ void GetTimeOfDay(struct timeval *tval)
|
|||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
yield the difference between *A and *B, in seconds, ignoring leap seconds
|
yield the difference between *A and *B, in seconds, ignoring leap seconds
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static int tm_diff(struct tm *a, struct tm *b)
|
static int
|
||||||
|
tm_diff (struct tm *a, struct tm *b)
|
||||||
{
|
{
|
||||||
int ay = a->tm_year + (TM_YEAR_BASE - 1);
|
int ay = a->tm_year + (TM_YEAR_BASE - 1);
|
||||||
int by = b->tm_year + (TM_YEAR_BASE - 1);
|
int by = b->tm_year + (TM_YEAR_BASE - 1);
|
||||||
int intervening_leap_days =
|
int intervening_leap_days = (ay / 4 - by / 4) - (ay / 100 - by / 100) + (ay / 400 - by / 400);
|
||||||
(ay/4 - by/4) - (ay/100 - by/100) + (ay/400 - by/400);
|
int years = ay - by;
|
||||||
int years = ay - by;
|
int days = 365 * years + intervening_leap_days + (a->tm_yday - b->tm_yday);
|
||||||
int days = 365*years + intervening_leap_days + (a->tm_yday - b->tm_yday);
|
int hours = 24 * days + (a->tm_hour - b->tm_hour);
|
||||||
int hours = 24*days + (a->tm_hour - b->tm_hour);
|
int minutes = 60 * hours + (a->tm_min - b->tm_min);
|
||||||
int minutes = 60*hours + (a->tm_min - b->tm_min);
|
int seconds = 60 * minutes + (a->tm_sec - b->tm_sec);
|
||||||
int seconds = 60*minutes + (a->tm_sec - b->tm_sec);
|
|
||||||
|
|
||||||
return seconds;
|
return seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
return the UTC offset in seconds west of UTC, or 0 if it cannot be determined
|
return the UTC offset in seconds west of UTC, or 0 if it cannot be determined
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
static int TimeZone(time_t t)
|
static int
|
||||||
|
TimeZone (time_t t)
|
||||||
{
|
{
|
||||||
struct tm *tm = gmtime(&t);
|
struct tm *tm = gmtime (&t);
|
||||||
struct tm tm_utc;
|
struct tm tm_utc;
|
||||||
if (!tm)
|
if (!tm)
|
||||||
return 0;
|
return 0;
|
||||||
tm_utc = *tm;
|
tm_utc = *tm;
|
||||||
tm = localtime(&t);
|
tm = localtime (&t);
|
||||||
if (!tm)
|
if (!tm)
|
||||||
return 0;
|
return 0;
|
||||||
return tm_diff(&tm_utc,tm);
|
return tm_diff (&tm_utc, tm);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,15 +106,17 @@ static int TimeZone(time_t t)
|
|||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
init the time differences
|
init the time differences
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
void TimeInit(void)
|
void
|
||||||
|
TimeInit (void)
|
||||||
{
|
{
|
||||||
serverzone = TimeZone(time(NULL));
|
serverzone = TimeZone (time (NULL));
|
||||||
|
|
||||||
if ((serverzone % 60) != 0) {
|
if ((serverzone % 60) != 0)
|
||||||
DEBUG(1,("WARNING: Your timezone is not a multiple of 1 minute.\n"));
|
{
|
||||||
}
|
DEBUG (1, ("WARNING: Your timezone is not a multiple of 1 minute.\n"));
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG(4,("Serverzone is %d\n",serverzone));
|
DEBUG (4, ("Serverzone is %d\n", serverzone));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -124,86 +128,99 @@ call of this function. This saves a LOT of time on many unixes.
|
|||||||
|
|
||||||
Updated by Paul Eggert <eggert@twinsun.com>
|
Updated by Paul Eggert <eggert@twinsun.com>
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static int TimeZoneFaster(time_t t)
|
static int
|
||||||
|
TimeZoneFaster (time_t t)
|
||||||
{
|
{
|
||||||
static struct dst_table {time_t start,end; int zone;} *dst_table = NULL;
|
static struct dst_table
|
||||||
static int table_size = 0;
|
{
|
||||||
int i;
|
time_t start, end;
|
||||||
int zone = 0;
|
int zone;
|
||||||
|
} *dst_table = NULL;
|
||||||
|
static int table_size = 0;
|
||||||
|
int i;
|
||||||
|
int zone = 0;
|
||||||
|
|
||||||
if (t == 0) t = time(NULL);
|
if (t == 0)
|
||||||
|
t = time (NULL);
|
||||||
|
|
||||||
/* Tunis has a 8 day DST region, we need to be careful ... */
|
/* Tunis has a 8 day DST region, we need to be careful ... */
|
||||||
#define MAX_DST_WIDTH (365*24*60*60)
|
#define MAX_DST_WIDTH (365*24*60*60)
|
||||||
#define MAX_DST_SKIP (7*24*60*60)
|
#define MAX_DST_SKIP (7*24*60*60)
|
||||||
|
|
||||||
for (i=0;i<table_size;i++)
|
for (i = 0; i < table_size; i++)
|
||||||
if (t >= dst_table[i].start && t <= dst_table[i].end) break;
|
if (t >= dst_table[i].start && t <= dst_table[i].end)
|
||||||
|
break;
|
||||||
|
|
||||||
if (i<table_size) {
|
if (i < table_size)
|
||||||
zone = dst_table[i].zone;
|
{
|
||||||
} else {
|
zone = dst_table[i].zone;
|
||||||
time_t low,high;
|
|
||||||
|
|
||||||
zone = TimeZone(t);
|
|
||||||
dst_table = (struct dst_table *)Realloc(dst_table,
|
|
||||||
sizeof(dst_table[0])*(i+1));
|
|
||||||
if (!dst_table) {
|
|
||||||
table_size = 0;
|
|
||||||
} else {
|
|
||||||
table_size++;
|
|
||||||
|
|
||||||
dst_table[i].zone = zone;
|
|
||||||
dst_table[i].start = dst_table[i].end = t;
|
|
||||||
|
|
||||||
/* no entry will cover more than 6 months */
|
|
||||||
low = t - MAX_DST_WIDTH/2;
|
|
||||||
if (t < low)
|
|
||||||
low = TIME_T_MIN;
|
|
||||||
|
|
||||||
high = t + MAX_DST_WIDTH/2;
|
|
||||||
if (high < t)
|
|
||||||
high = TIME_T_MAX;
|
|
||||||
|
|
||||||
/* widen the new entry using two bisection searches */
|
|
||||||
while (low+60*60 < dst_table[i].start) {
|
|
||||||
if (dst_table[i].start - low > MAX_DST_SKIP*2)
|
|
||||||
t = dst_table[i].start - MAX_DST_SKIP;
|
|
||||||
else
|
|
||||||
t = low + (dst_table[i].start-low)/2;
|
|
||||||
if (TimeZone(t) == zone)
|
|
||||||
dst_table[i].start = t;
|
|
||||||
else
|
|
||||||
low = t;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (high-60*60 > dst_table[i].end) {
|
|
||||||
if (high - dst_table[i].end > MAX_DST_SKIP*2)
|
|
||||||
t = dst_table[i].end + MAX_DST_SKIP;
|
|
||||||
else
|
|
||||||
t = high - (high-dst_table[i].end)/2;
|
|
||||||
if (TimeZone(t) == zone)
|
|
||||||
dst_table[i].end = t;
|
|
||||||
else
|
|
||||||
high = t;
|
|
||||||
}
|
|
||||||
#if 0
|
|
||||||
DEBUG(1,("Added DST entry from %s ",
|
|
||||||
asctime(localtime(&dst_table[i].start))));
|
|
||||||
DEBUG(1,("to %s (%d)\n",asctime(localtime(&dst_table[i].end)),
|
|
||||||
dst_table[i].zone));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
return zone;
|
{
|
||||||
|
time_t low, high;
|
||||||
|
|
||||||
|
zone = TimeZone (t);
|
||||||
|
dst_table = (struct dst_table *) Realloc (dst_table, sizeof (dst_table[0]) * (i + 1));
|
||||||
|
if (!dst_table)
|
||||||
|
{
|
||||||
|
table_size = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
table_size++;
|
||||||
|
|
||||||
|
dst_table[i].zone = zone;
|
||||||
|
dst_table[i].start = dst_table[i].end = t;
|
||||||
|
|
||||||
|
/* no entry will cover more than 6 months */
|
||||||
|
low = t - MAX_DST_WIDTH / 2;
|
||||||
|
if (t < low)
|
||||||
|
low = TIME_T_MIN;
|
||||||
|
|
||||||
|
high = t + MAX_DST_WIDTH / 2;
|
||||||
|
if (high < t)
|
||||||
|
high = TIME_T_MAX;
|
||||||
|
|
||||||
|
/* widen the new entry using two bisection searches */
|
||||||
|
while (low + 60 * 60 < dst_table[i].start)
|
||||||
|
{
|
||||||
|
if (dst_table[i].start - low > MAX_DST_SKIP * 2)
|
||||||
|
t = dst_table[i].start - MAX_DST_SKIP;
|
||||||
|
else
|
||||||
|
t = low + (dst_table[i].start - low) / 2;
|
||||||
|
if (TimeZone (t) == zone)
|
||||||
|
dst_table[i].start = t;
|
||||||
|
else
|
||||||
|
low = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (high - 60 * 60 > dst_table[i].end)
|
||||||
|
{
|
||||||
|
if (high - dst_table[i].end > MAX_DST_SKIP * 2)
|
||||||
|
t = dst_table[i].end + MAX_DST_SKIP;
|
||||||
|
else
|
||||||
|
t = high - (high - dst_table[i].end) / 2;
|
||||||
|
if (TimeZone (t) == zone)
|
||||||
|
dst_table[i].end = t;
|
||||||
|
else
|
||||||
|
high = t;
|
||||||
|
}
|
||||||
|
#if 0
|
||||||
|
DEBUG (1, ("Added DST entry from %s ", asctime (localtime (&dst_table[i].start))));
|
||||||
|
DEBUG (1, ("to %s (%d)\n", asctime (localtime (&dst_table[i].end)), dst_table[i].zone));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return zone;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
return the UTC offset in seconds west of UTC, adjusted for extra time offset
|
return the UTC offset in seconds west of UTC, adjusted for extra time offset
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
int TimeDiff(time_t t)
|
int
|
||||||
|
TimeDiff (time_t t)
|
||||||
{
|
{
|
||||||
return TimeZoneFaster(t) + 60*extra_time_offset;
|
return TimeZoneFaster (t) + 60 * extra_time_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -214,31 +231,33 @@ int TimeDiff(time_t t)
|
|||||||
daylight savings transitions because some local times are ambiguous.
|
daylight savings transitions because some local times are ambiguous.
|
||||||
LocTimeDiff(t) equals TimeDiff(t) except near daylight savings transitions.
|
LocTimeDiff(t) equals TimeDiff(t) except near daylight savings transitions.
|
||||||
+**************************************************************************/
|
+**************************************************************************/
|
||||||
static int LocTimeDiff(time_t lte)
|
static int
|
||||||
|
LocTimeDiff (time_t lte)
|
||||||
{
|
{
|
||||||
time_t lt = lte - 60*extra_time_offset;
|
time_t lt = lte - 60 * extra_time_offset;
|
||||||
int d = TimeZoneFaster(lt);
|
int d = TimeZoneFaster (lt);
|
||||||
time_t t = lt + d;
|
time_t t = lt + d;
|
||||||
|
|
||||||
/* if overflow occurred, ignore all the adjustments so far */
|
/* if overflow occurred, ignore all the adjustments so far */
|
||||||
if (((lte < lt) ^ (extra_time_offset < 0)) | ((t < lt) ^ (d < 0)))
|
if (((lte < lt) ^ (extra_time_offset < 0)) | ((t < lt) ^ (d < 0)))
|
||||||
t = lte;
|
t = lte;
|
||||||
|
|
||||||
/* now t should be close enough to the true UTC to yield the right answer */
|
/* now t should be close enough to the true UTC to yield the right answer */
|
||||||
return TimeDiff(t);
|
return TimeDiff (t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
try to optimise the localtime call, it can be quite expensive on some machines
|
try to optimise the localtime call, it can be quite expensive on some machines
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
struct tm *LocalTime(time_t *t)
|
struct tm *
|
||||||
|
LocalTime (time_t * t)
|
||||||
{
|
{
|
||||||
time_t t2 = *t;
|
time_t t2 = *t;
|
||||||
|
|
||||||
t2 -= TimeDiff(t2);
|
t2 -= TimeDiff (t2);
|
||||||
|
|
||||||
return(gmtime(&t2));
|
return (gmtime (&t2));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TIME_FIXUP_CONSTANT (369.0*365.25*24*60*60-(3.0*24*60*60+6.0*60*60))
|
#define TIME_FIXUP_CONSTANT (369.0*365.25*24*60*60-(3.0*24*60*60+6.0*60*60))
|
||||||
@ -252,34 +271,36 @@ its the GMT you get by taking a localtime and adding the
|
|||||||
serverzone. This is NOT the same as GMT in some cases. This routine
|
serverzone. This is NOT the same as GMT in some cases. This routine
|
||||||
converts this to real GMT.
|
converts this to real GMT.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
time_t nt_time_to_unix(NTTIME *nt)
|
time_t
|
||||||
|
nt_time_to_unix (NTTIME * nt)
|
||||||
{
|
{
|
||||||
double d;
|
double d;
|
||||||
time_t ret;
|
time_t ret;
|
||||||
/* The next two lines are a fix needed for the
|
/* The next two lines are a fix needed for the
|
||||||
broken SCO compiler. JRA. */
|
broken SCO compiler. JRA. */
|
||||||
time_t l_time_min = TIME_T_MIN;
|
time_t l_time_min = TIME_T_MIN;
|
||||||
time_t l_time_max = TIME_T_MAX;
|
time_t l_time_max = TIME_T_MAX;
|
||||||
|
|
||||||
if (nt->high == 0) return(0);
|
if (nt->high == 0)
|
||||||
|
return (0);
|
||||||
|
|
||||||
d = ((double)nt->high)*4.0*(double)(1<<30);
|
d = ((double) nt->high) * 4.0 * (double) (1 << 30);
|
||||||
d += (nt->low&0xFFF00000);
|
d += (nt->low & 0xFFF00000);
|
||||||
d *= 1.0e-7;
|
d *= 1.0e-7;
|
||||||
|
|
||||||
/* now adjust by 369 years to make the secs since 1970 */
|
|
||||||
d -= TIME_FIXUP_CONSTANT;
|
|
||||||
|
|
||||||
if (!(l_time_min <= d && d <= l_time_max))
|
/* now adjust by 369 years to make the secs since 1970 */
|
||||||
return(0);
|
d -= TIME_FIXUP_CONSTANT;
|
||||||
|
|
||||||
ret = (time_t)(d+0.5);
|
if (!(l_time_min <= d && d <= l_time_max))
|
||||||
|
return (0);
|
||||||
|
|
||||||
/* this takes us from kludge-GMT to real GMT */
|
ret = (time_t) (d + 0.5);
|
||||||
ret -= serverzone;
|
|
||||||
ret += LocTimeDiff(ret);
|
|
||||||
|
|
||||||
return(ret);
|
/* this takes us from kludge-GMT to real GMT */
|
||||||
|
ret -= serverzone;
|
||||||
|
ret += LocTimeDiff (ret);
|
||||||
|
|
||||||
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -287,38 +308,40 @@ time_t nt_time_to_unix(NTTIME *nt)
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
interprets an nt time into a unix time_t
|
interprets an nt time into a unix time_t
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
time_t interpret_long_date(char *p)
|
time_t
|
||||||
|
interpret_long_date (char *p)
|
||||||
{
|
{
|
||||||
NTTIME nt;
|
NTTIME nt;
|
||||||
nt.low = IVAL(p,0);
|
nt.low = IVAL (p, 0);
|
||||||
nt.high = IVAL(p,4);
|
nt.high = IVAL (p, 4);
|
||||||
return nt_time_to_unix(&nt);
|
return nt_time_to_unix (&nt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
put a 8 byte filetime from a time_t
|
put a 8 byte filetime from a time_t
|
||||||
This takes real GMT as input and converts to kludge-GMT
|
This takes real GMT as input and converts to kludge-GMT
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
void unix_to_nt_time(NTTIME *nt, time_t t)
|
void
|
||||||
|
unix_to_nt_time (NTTIME * nt, time_t t)
|
||||||
{
|
{
|
||||||
double d;
|
double d;
|
||||||
|
|
||||||
if (t==0)
|
if (t == 0)
|
||||||
{
|
{
|
||||||
nt->low = 0;
|
nt->low = 0;
|
||||||
nt->high = 0;
|
nt->high = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this converts GMT to kludge-GMT */
|
/* this converts GMT to kludge-GMT */
|
||||||
t -= LocTimeDiff(t) - serverzone;
|
t -= LocTimeDiff (t) - serverzone;
|
||||||
|
|
||||||
d = (double)(t);
|
d = (double) (t);
|
||||||
d += TIME_FIXUP_CONSTANT;
|
d += TIME_FIXUP_CONSTANT;
|
||||||
d *= 1.0e7;
|
d *= 1.0e7;
|
||||||
|
|
||||||
nt->high = (uint32)(d * (1.0/(4.0*(double)(1<<30))));
|
nt->high = (uint32) (d * (1.0 / (4.0 * (double) (1 << 30))));
|
||||||
nt->low = (uint32)(d - ((double)nt->high)*4.0*(double)(1<<30));
|
nt->low = (uint32) (d - ((double) nt->high) * 4.0 * (double) (1 << 30));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -326,84 +349,91 @@ void unix_to_nt_time(NTTIME *nt, time_t t)
|
|||||||
take an NTTIME structure, containing high / low time. convert to unix time.
|
take an NTTIME structure, containing high / low time. convert to unix time.
|
||||||
lkclXXXX this may need 2 SIVALs not a memcpy. we'll see...
|
lkclXXXX this may need 2 SIVALs not a memcpy. we'll see...
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
void put_long_date(char *p,time_t t)
|
void
|
||||||
|
put_long_date (char *p, time_t t)
|
||||||
{
|
{
|
||||||
NTTIME nt;
|
NTTIME nt;
|
||||||
unix_to_nt_time(&nt, t);
|
unix_to_nt_time (&nt, t);
|
||||||
SIVAL(p, 0, nt.low);
|
SIVAL (p, 0, nt.low);
|
||||||
SIVAL(p, 4, nt.high);
|
SIVAL (p, 4, nt.high);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
check if it's a null mtime
|
check if it's a null mtime
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
BOOL null_mtime(time_t mtime)
|
BOOL
|
||||||
|
null_mtime (time_t mtime)
|
||||||
{
|
{
|
||||||
if (mtime == (time_t)0 || mtime == (time_t)0xFFFFFFFF || mtime == (time_t)-1)
|
if (mtime == (time_t) 0 || mtime == (time_t) 0xFFFFFFFF || mtime == (time_t) - 1)
|
||||||
return(True);
|
return (True);
|
||||||
return(False);
|
return (False);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
create a 16 bit dos packed date
|
create a 16 bit dos packed date
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static uint16 make_dos_date1(struct tm *t)
|
static uint16
|
||||||
|
make_dos_date1 (struct tm *t)
|
||||||
{
|
{
|
||||||
uint16 ret=0;
|
uint16 ret = 0;
|
||||||
ret = (((unsigned)(t->tm_mon+1)) >> 3) | ((t->tm_year-80) << 1);
|
ret = (((unsigned) (t->tm_mon + 1)) >> 3) | ((t->tm_year - 80) << 1);
|
||||||
ret = ((ret&0xFF)<<8) | (t->tm_mday | (((t->tm_mon+1) & 0x7) << 5));
|
ret = ((ret & 0xFF) << 8) | (t->tm_mday | (((t->tm_mon + 1) & 0x7) << 5));
|
||||||
return(ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
create a 16 bit dos packed time
|
create a 16 bit dos packed time
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static uint16 make_dos_time1(struct tm *t)
|
static uint16
|
||||||
|
make_dos_time1 (struct tm *t)
|
||||||
{
|
{
|
||||||
uint16 ret=0;
|
uint16 ret = 0;
|
||||||
ret = ((((unsigned)t->tm_min >> 3)&0x7) | (((unsigned)t->tm_hour) << 3));
|
ret = ((((unsigned) t->tm_min >> 3) & 0x7) | (((unsigned) t->tm_hour) << 3));
|
||||||
ret = ((ret&0xFF)<<8) | ((t->tm_sec/2) | ((t->tm_min & 0x7) << 5));
|
ret = ((ret & 0xFF) << 8) | ((t->tm_sec / 2) | ((t->tm_min & 0x7) << 5));
|
||||||
return(ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
create a 32 bit dos packed date/time from some parameters
|
create a 32 bit dos packed date/time from some parameters
|
||||||
This takes a GMT time and returns a packed localtime structure
|
This takes a GMT time and returns a packed localtime structure
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static uint32 make_dos_date(time_t unixdate)
|
static uint32
|
||||||
|
make_dos_date (time_t unixdate)
|
||||||
{
|
{
|
||||||
struct tm *t;
|
struct tm *t;
|
||||||
uint32 ret=0;
|
uint32 ret = 0;
|
||||||
|
|
||||||
t = LocalTime(&unixdate);
|
t = LocalTime (&unixdate);
|
||||||
if (!t)
|
if (!t)
|
||||||
return 0xFFFFFFFF;
|
return 0xFFFFFFFF;
|
||||||
|
|
||||||
ret = make_dos_date1(t);
|
ret = make_dos_date1 (t);
|
||||||
ret = ((ret&0xFFFF)<<16) | make_dos_time1(t);
|
ret = ((ret & 0xFFFF) << 16) | make_dos_time1 (t);
|
||||||
|
|
||||||
return(ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
put a dos date into a buffer (time/date format)
|
put a dos date into a buffer (time/date format)
|
||||||
This takes GMT time and puts local time in the buffer
|
This takes GMT time and puts local time in the buffer
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
void put_dos_date(char *buf,int offset,time_t unixdate)
|
void
|
||||||
|
put_dos_date (char *buf, int offset, time_t unixdate)
|
||||||
{
|
{
|
||||||
uint32 x = make_dos_date(unixdate);
|
uint32 x = make_dos_date (unixdate);
|
||||||
SIVAL(buf,offset,x);
|
SIVAL (buf, offset, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
put a dos date into a buffer (date/time format)
|
put a dos date into a buffer (date/time format)
|
||||||
This takes GMT time and puts local time in the buffer
|
This takes GMT time and puts local time in the buffer
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
void put_dos_date2(char *buf,int offset,time_t unixdate)
|
void
|
||||||
|
put_dos_date2 (char *buf, int offset, time_t unixdate)
|
||||||
{
|
{
|
||||||
uint32 x = make_dos_date(unixdate);
|
uint32 x = make_dos_date (unixdate);
|
||||||
x = ((x&0xFFFF)<<16) | ((x&0xFFFF0000)>>16);
|
x = ((x & 0xFFFF) << 16) | ((x & 0xFFFF0000) >> 16);
|
||||||
SIVAL(buf,offset,x);
|
SIVAL (buf, offset, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
@ -411,95 +441,105 @@ put a dos 32 bit "unix like" date into a buffer. This routine takes
|
|||||||
GMT and converts it to LOCAL time before putting it (most SMBs assume
|
GMT and converts it to LOCAL time before putting it (most SMBs assume
|
||||||
localtime for this sort of date)
|
localtime for this sort of date)
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
void put_dos_date3(char *buf,int offset,time_t unixdate)
|
void
|
||||||
|
put_dos_date3 (char *buf, int offset, time_t unixdate)
|
||||||
{
|
{
|
||||||
if (!null_mtime(unixdate))
|
if (!null_mtime (unixdate))
|
||||||
unixdate -= TimeDiff(unixdate);
|
unixdate -= TimeDiff (unixdate);
|
||||||
SIVAL(buf,offset,unixdate);
|
SIVAL (buf, offset, unixdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
interpret a 32 bit dos packed date/time to some parameters
|
interpret a 32 bit dos packed date/time to some parameters
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static void interpret_dos_date(uint32 date,int *year,int *month,int *day,int *hour,int *minute,int *second)
|
static void
|
||||||
|
interpret_dos_date (uint32 date, int *year, int *month, int *day, int *hour, int *minute,
|
||||||
|
int *second)
|
||||||
{
|
{
|
||||||
uint32 p0,p1,p2,p3;
|
uint32 p0, p1, p2, p3;
|
||||||
|
|
||||||
p0=date&0xFF; p1=((date&0xFF00)>>8)&0xFF;
|
p0 = date & 0xFF;
|
||||||
p2=((date&0xFF0000)>>16)&0xFF; p3=((date&0xFF000000)>>24)&0xFF;
|
p1 = ((date & 0xFF00) >> 8) & 0xFF;
|
||||||
|
p2 = ((date & 0xFF0000) >> 16) & 0xFF;
|
||||||
|
p3 = ((date & 0xFF000000) >> 24) & 0xFF;
|
||||||
|
|
||||||
*second = 2*(p0 & 0x1F);
|
*second = 2 * (p0 & 0x1F);
|
||||||
*minute = ((p0>>5)&0xFF) + ((p1&0x7)<<3);
|
*minute = ((p0 >> 5) & 0xFF) + ((p1 & 0x7) << 3);
|
||||||
*hour = (p1>>3)&0xFF;
|
*hour = (p1 >> 3) & 0xFF;
|
||||||
*day = (p2&0x1F);
|
*day = (p2 & 0x1F);
|
||||||
*month = ((p2>>5)&0xFF) + ((p3&0x1)<<3) - 1;
|
*month = ((p2 >> 5) & 0xFF) + ((p3 & 0x1) << 3) - 1;
|
||||||
*year = ((p3>>1)&0xFF) + 80;
|
*year = ((p3 >> 1) & 0xFF) + 80;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
create a unix date (int GMT) from a dos date (which is actually in
|
create a unix date (int GMT) from a dos date (which is actually in
|
||||||
localtime)
|
localtime)
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
time_t make_unix_date(void *date_ptr)
|
time_t
|
||||||
|
make_unix_date (void *date_ptr)
|
||||||
{
|
{
|
||||||
uint32 dos_date=0;
|
uint32 dos_date = 0;
|
||||||
struct tm t;
|
struct tm t;
|
||||||
time_t ret;
|
time_t ret;
|
||||||
|
|
||||||
dos_date = IVAL(date_ptr,0);
|
dos_date = IVAL (date_ptr, 0);
|
||||||
|
|
||||||
if (dos_date == 0) return(0);
|
if (dos_date == 0)
|
||||||
|
return (0);
|
||||||
interpret_dos_date(dos_date,&t.tm_year,&t.tm_mon,
|
|
||||||
&t.tm_mday,&t.tm_hour,&t.tm_min,&t.tm_sec);
|
|
||||||
t.tm_isdst = -1;
|
|
||||||
|
|
||||||
/* mktime() also does the local to GMT time conversion for us */
|
|
||||||
ret = mktime(&t);
|
|
||||||
|
|
||||||
return(ret);
|
interpret_dos_date (dos_date, &t.tm_year, &t.tm_mon,
|
||||||
|
&t.tm_mday, &t.tm_hour, &t.tm_min, &t.tm_sec);
|
||||||
|
t.tm_isdst = -1;
|
||||||
|
|
||||||
|
/* mktime() also does the local to GMT time conversion for us */
|
||||||
|
ret = mktime (&t);
|
||||||
|
|
||||||
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
like make_unix_date() but the words are reversed
|
like make_unix_date() but the words are reversed
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
time_t make_unix_date2(void *date_ptr)
|
time_t
|
||||||
|
make_unix_date2 (void *date_ptr)
|
||||||
{
|
{
|
||||||
uint32 x,x2;
|
uint32 x, x2;
|
||||||
|
|
||||||
x = IVAL(date_ptr,0);
|
x = IVAL (date_ptr, 0);
|
||||||
x2 = ((x&0xFFFF)<<16) | ((x&0xFFFF0000)>>16);
|
x2 = ((x & 0xFFFF) << 16) | ((x & 0xFFFF0000) >> 16);
|
||||||
SIVAL(&x,0,x2);
|
SIVAL (&x, 0, x2);
|
||||||
|
|
||||||
return(make_unix_date((void *)&x));
|
return (make_unix_date ((void *) &x));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
create a unix GMT date from a dos date in 32 bit "unix like" format
|
create a unix GMT date from a dos date in 32 bit "unix like" format
|
||||||
these generally arrive as localtimes, with corresponding DST
|
these generally arrive as localtimes, with corresponding DST
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
time_t make_unix_date3(void *date_ptr)
|
time_t
|
||||||
|
make_unix_date3 (void *date_ptr)
|
||||||
{
|
{
|
||||||
time_t t = (time_t)IVAL(date_ptr,0);
|
time_t t = (time_t) IVAL (date_ptr, 0);
|
||||||
if (!null_mtime(t))
|
if (!null_mtime (t))
|
||||||
t += LocTimeDiff(t);
|
t += LocTimeDiff (t);
|
||||||
return(t);
|
return (t);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
return a HTTP/1.0 time string
|
return a HTTP/1.0 time string
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
char *http_timestring(time_t t)
|
char *
|
||||||
|
http_timestring (time_t t)
|
||||||
{
|
{
|
||||||
static fstring buf;
|
static fstring buf;
|
||||||
struct tm *tm = LocalTime(&t);
|
struct tm *tm = LocalTime (&t);
|
||||||
|
|
||||||
if (!tm)
|
if (!tm)
|
||||||
slprintf(buf,sizeof(buf)-1,"%ld seconds since the Epoch",(long)t);
|
slprintf (buf, sizeof (buf) - 1, "%ld seconds since the Epoch", (long) t);
|
||||||
else
|
else
|
||||||
strftime(buf, sizeof(buf)-1, "%a, %d %b %Y %H:%M:%S %Z", tm);
|
strftime (buf, sizeof (buf) - 1, "%a, %d %b %Y %H:%M:%S %Z", tm);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
#endif /*0 */
|
#endif /*0 */
|
||||||
|
|
||||||
@ -507,18 +547,22 @@ char *http_timestring(time_t t)
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
return the date and time as a string
|
return the date and time as a string
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
char *timestring(void )
|
char *
|
||||||
|
timestring (void)
|
||||||
{
|
{
|
||||||
static fstring TimeBuf;
|
static fstring TimeBuf;
|
||||||
time_t t = time(NULL);
|
time_t t = time (NULL);
|
||||||
struct tm *tm = LocalTime(&t);
|
struct tm *tm = LocalTime (&t);
|
||||||
|
|
||||||
if (!tm) {
|
if (!tm)
|
||||||
slprintf(TimeBuf,sizeof(TimeBuf)-1,"%ld seconds since the Epoch",(long)t);
|
{
|
||||||
} else {
|
slprintf (TimeBuf, sizeof (TimeBuf) - 1, "%ld seconds since the Epoch", (long) t);
|
||||||
strftime(TimeBuf,100,"%Y/%m/%d %H:%M:%S",tm);
|
}
|
||||||
}
|
else
|
||||||
return(TimeBuf);
|
{
|
||||||
|
strftime (TimeBuf, 100, "%Y/%m/%d %H:%M:%S", tm);
|
||||||
|
}
|
||||||
|
return (TimeBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -526,23 +570,23 @@ char *timestring(void )
|
|||||||
structure.
|
structure.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
time_t get_create_time(SMB_STRUCT_STAT *st,BOOL fake_dirs)
|
time_t
|
||||||
|
get_create_time (SMB_STRUCT_STAT * st, BOOL fake_dirs)
|
||||||
{
|
{
|
||||||
time_t ret, ret1;
|
time_t ret, ret1;
|
||||||
|
|
||||||
if(S_ISDIR(st->st_mode) && fake_dirs)
|
if (S_ISDIR (st->st_mode) && fake_dirs)
|
||||||
return (time_t)315493200L; /* 1/1/1980 */
|
return (time_t) 315493200L; /* 1/1/1980 */
|
||||||
|
|
||||||
ret = MIN(st->st_ctime, st->st_mtime);
|
|
||||||
ret1 = MIN(ret, st->st_atime);
|
|
||||||
|
|
||||||
if(ret1 != (time_t)0)
|
ret = MIN (st->st_ctime, st->st_mtime);
|
||||||
return ret1;
|
ret1 = MIN (ret, st->st_atime);
|
||||||
|
|
||||||
/*
|
if (ret1 != (time_t) 0)
|
||||||
* One of ctime, mtime or atime was zero (probably atime).
|
return ret1;
|
||||||
* Just return MIN(ctime, mtime).
|
|
||||||
*/
|
/*
|
||||||
return ret;
|
* One of ctime, mtime or atime was zero (probably atime).
|
||||||
|
* Just return MIN(ctime, mtime).
|
||||||
|
*/
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,30 +22,34 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
extern int DEBUGLEVEL;
|
extern int DEBUGLEVEL;
|
||||||
|
|
||||||
/* internal functions */
|
/* internal functions */
|
||||||
static struct passwd *uname_string_combinations(char *s, struct passwd * (*fn) (const char *), int N);
|
static struct passwd *uname_string_combinations (char *s, struct passwd *(*fn) (const char *),
|
||||||
static struct passwd *uname_string_combinations2(char *s, int offset, struct passwd * (*fn) (const char *), int N);
|
int N);
|
||||||
|
static struct passwd *uname_string_combinations2 (char *s, int offset,
|
||||||
|
struct passwd *(*fn) (const char *), int N);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
get a users home directory.
|
get a users home directory.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
const char *get_home_dir(char *user)
|
const char *
|
||||||
|
get_home_dir (char *user)
|
||||||
{
|
{
|
||||||
struct passwd *pass;
|
struct passwd *pass;
|
||||||
|
|
||||||
pass = Get_Pwnam(user);
|
pass = Get_Pwnam (user);
|
||||||
|
|
||||||
if (!pass) return(NULL);
|
if (!pass)
|
||||||
return(pass->pw_dir);
|
return (NULL);
|
||||||
|
return (pass->pw_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0 /* Fix possible buffer overflow in sscanf(unixname,"%s",user) if uncomment */
|
#if 0 /* Fix possible buffer overflow in sscanf(unixname,"%s",user) if uncomment */
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
map a username from a dos name to a unix name by looking in the username
|
map a username from a dos name to a unix name by looking in the username
|
||||||
map. Note that this modifies the name in place.
|
map. Note that this modifies the name in place.
|
||||||
@ -56,123 +60,133 @@ function. Previously, the map_username was being called
|
|||||||
every time Get_Pwnam was called.
|
every time Get_Pwnam was called.
|
||||||
Returns True if username was changed, false otherwise.
|
Returns True if username was changed, false otherwise.
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
BOOL map_username(const char *user)
|
BOOL
|
||||||
|
map_username (const char *user)
|
||||||
{
|
{
|
||||||
static BOOL initialised=False;
|
static BOOL initialised = False;
|
||||||
static fstring last_from,last_to;
|
static fstring last_from, last_to;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char *mapfile = lp_username_map();
|
char *mapfile = lp_username_map ();
|
||||||
char *s;
|
char *s;
|
||||||
pstring buf;
|
pstring buf;
|
||||||
BOOL mapped_user = False;
|
BOOL mapped_user = False;
|
||||||
|
|
||||||
if (!*user)
|
if (!*user)
|
||||||
return False;
|
return False;
|
||||||
|
|
||||||
if (!*mapfile)
|
if (!*mapfile)
|
||||||
return False;
|
return False;
|
||||||
|
|
||||||
if (!initialised) {
|
|
||||||
*last_from = *last_to = 0;
|
|
||||||
initialised = True;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strequal(user,last_to))
|
|
||||||
return False;
|
|
||||||
|
|
||||||
if (strequal(user,last_from)) {
|
|
||||||
DEBUG(3,("Mapped user %s to %s\n",user,last_to));
|
|
||||||
fstrcpy(user,last_to);
|
|
||||||
return True;
|
|
||||||
}
|
|
||||||
|
|
||||||
f = sys_fopen(mapfile,"r");
|
|
||||||
if (!f) {
|
|
||||||
DEBUG(0,("can't open username map %s\n",mapfile));
|
|
||||||
return False;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEBUG(4,("Scanning username map %s\n",mapfile));
|
|
||||||
|
|
||||||
while((s=fgets_slash(buf,sizeof(buf),f))!=NULL) {
|
|
||||||
char *unixname = s;
|
|
||||||
char *dosname = strchr(unixname,'=');
|
|
||||||
BOOL return_if_mapped = False;
|
|
||||||
|
|
||||||
if (!dosname)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
*dosname++ = 0;
|
|
||||||
|
|
||||||
while (isspace(*unixname))
|
|
||||||
unixname++;
|
|
||||||
if ('!' == *unixname) {
|
|
||||||
return_if_mapped = True;
|
|
||||||
unixname++;
|
|
||||||
while (*unixname && isspace(*unixname))
|
|
||||||
unixname++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!*unixname || strchr("#;",*unixname))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
|
if (!initialised)
|
||||||
{
|
{
|
||||||
int l = strlen(unixname);
|
*last_from = *last_to = 0;
|
||||||
while (l && isspace(unixname[l-1])) {
|
initialised = True;
|
||||||
unixname[l-1] = 0;
|
|
||||||
l--;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strchr(dosname,'*') || user_in_list(user,dosname)) {
|
if (strequal (user, last_to))
|
||||||
DEBUG(3,("Mapped user %s to %s\n",user,unixname));
|
return False;
|
||||||
mapped_user = True;
|
|
||||||
fstrcpy(last_from,user);
|
if (strequal (user, last_from))
|
||||||
sscanf(unixname,"%s",user);
|
{
|
||||||
fstrcpy(last_to,user);
|
DEBUG (3, ("Mapped user %s to %s\n", user, last_to));
|
||||||
if(return_if_mapped) {
|
fstrcpy (user, last_to);
|
||||||
fclose(f);
|
|
||||||
return True;
|
return True;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fclose(f);
|
f = sys_fopen (mapfile, "r");
|
||||||
|
if (!f)
|
||||||
|
{
|
||||||
|
DEBUG (0, ("can't open username map %s\n", mapfile));
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
DEBUG (4, ("Scanning username map %s\n", mapfile));
|
||||||
* Setup the last_from and last_to as an optimization so
|
|
||||||
* that we don't scan the file again for the same user.
|
|
||||||
*/
|
|
||||||
fstrcpy(last_from,user);
|
|
||||||
fstrcpy(last_to,user);
|
|
||||||
|
|
||||||
return mapped_user;
|
while ((s = fgets_slash (buf, sizeof (buf), f)) != NULL)
|
||||||
|
{
|
||||||
|
char *unixname = s;
|
||||||
|
char *dosname = strchr (unixname, '=');
|
||||||
|
BOOL return_if_mapped = False;
|
||||||
|
|
||||||
|
if (!dosname)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
*dosname++ = 0;
|
||||||
|
|
||||||
|
while (isspace (*unixname))
|
||||||
|
unixname++;
|
||||||
|
if ('!' == *unixname)
|
||||||
|
{
|
||||||
|
return_if_mapped = True;
|
||||||
|
unixname++;
|
||||||
|
while (*unixname && isspace (*unixname))
|
||||||
|
unixname++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!*unixname || strchr ("#;", *unixname))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
{
|
||||||
|
int l = strlen (unixname);
|
||||||
|
while (l && isspace (unixname[l - 1]))
|
||||||
|
{
|
||||||
|
unixname[l - 1] = 0;
|
||||||
|
l--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strchr (dosname, '*') || user_in_list (user, dosname))
|
||||||
|
{
|
||||||
|
DEBUG (3, ("Mapped user %s to %s\n", user, unixname));
|
||||||
|
mapped_user = True;
|
||||||
|
fstrcpy (last_from, user);
|
||||||
|
sscanf (unixname, "%s", user);
|
||||||
|
fstrcpy (last_to, user);
|
||||||
|
if (return_if_mapped)
|
||||||
|
{
|
||||||
|
fclose (f);
|
||||||
|
return True;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose (f);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Setup the last_from and last_to as an optimization so
|
||||||
|
* that we don't scan the file again for the same user.
|
||||||
|
*/
|
||||||
|
fstrcpy (last_from, user);
|
||||||
|
fstrcpy (last_to, user);
|
||||||
|
|
||||||
|
return mapped_user;
|
||||||
}
|
}
|
||||||
#endif /* 0 */
|
#endif /* 0 */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
Get_Pwnam wrapper
|
Get_Pwnam wrapper
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
static struct passwd *_Get_Pwnam(const char *s)
|
static struct passwd *
|
||||||
|
_Get_Pwnam (const char *s)
|
||||||
{
|
{
|
||||||
struct passwd *ret;
|
struct passwd *ret;
|
||||||
|
|
||||||
ret = getpwnam(s);
|
ret = getpwnam (s);
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_GETPWANAM
|
#ifdef HAVE_GETPWANAM
|
||||||
struct passwd_adjunct *pwret;
|
struct passwd_adjunct *pwret;
|
||||||
pwret = getpwanam(s);
|
pwret = getpwanam (s);
|
||||||
if (pwret)
|
if (pwret)
|
||||||
{
|
{
|
||||||
free(ret->pw_passwd);
|
free (ret->pw_passwd);
|
||||||
ret->pw_passwd = pwret->pwa_passwd;
|
ret->pw_passwd = pwret->pwa_passwd;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -180,191 +194,198 @@ static struct passwd *_Get_Pwnam(const char *s)
|
|||||||
a wrapper for getpwnam() that tries with all lower and all upper case
|
a wrapper for getpwnam() that tries with all lower and all upper case
|
||||||
if the initial name fails. Also tried with first letter capitalised
|
if the initial name fails. Also tried with first letter capitalised
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
struct passwd *Get_Pwnam(const char *a_user)
|
struct passwd *
|
||||||
|
Get_Pwnam (const char *a_user)
|
||||||
{
|
{
|
||||||
fstring user;
|
fstring user;
|
||||||
int last_char;
|
int last_char;
|
||||||
int usernamelevel = lp_usernamelevel();
|
int usernamelevel = lp_usernamelevel ();
|
||||||
|
|
||||||
struct passwd *ret;
|
struct passwd *ret;
|
||||||
|
|
||||||
if (!a_user || !(*a_user))
|
if (!a_user || !(*a_user))
|
||||||
return(NULL);
|
return (NULL);
|
||||||
|
|
||||||
StrnCpy(user,a_user,sizeof(user)-1);
|
StrnCpy (user, a_user, sizeof (user) - 1);
|
||||||
|
|
||||||
ret = _Get_Pwnam(user);
|
ret = _Get_Pwnam (user);
|
||||||
if (ret) return(ret);
|
if (ret)
|
||||||
|
return (ret);
|
||||||
|
|
||||||
strlower(user);
|
strlower (user);
|
||||||
ret = _Get_Pwnam(user);
|
ret = _Get_Pwnam (user);
|
||||||
if (ret) return(ret);
|
if (ret)
|
||||||
|
return (ret);
|
||||||
|
|
||||||
strupper(user);
|
strupper (user);
|
||||||
ret = _Get_Pwnam(user);
|
ret = _Get_Pwnam (user);
|
||||||
if (ret) return(ret);
|
if (ret)
|
||||||
|
return (ret);
|
||||||
|
|
||||||
/* try with first letter capitalised */
|
/* try with first letter capitalised */
|
||||||
if (strlen(user) > 1)
|
if (strlen (user) > 1)
|
||||||
strlower(user+1);
|
strlower (user + 1);
|
||||||
ret = _Get_Pwnam(user);
|
ret = _Get_Pwnam (user);
|
||||||
if (ret) return(ret);
|
if (ret)
|
||||||
|
return (ret);
|
||||||
|
|
||||||
/* try with last letter capitalised */
|
/* try with last letter capitalised */
|
||||||
strlower(user);
|
strlower (user);
|
||||||
last_char = strlen(user)-1;
|
last_char = strlen (user) - 1;
|
||||||
user[last_char] = toupper(user[last_char]);
|
user[last_char] = toupper (user[last_char]);
|
||||||
ret = _Get_Pwnam(user);
|
ret = _Get_Pwnam (user);
|
||||||
if (ret) return(ret);
|
if (ret)
|
||||||
|
return (ret);
|
||||||
|
|
||||||
/* try all combinations up to usernamelevel */
|
/* try all combinations up to usernamelevel */
|
||||||
strlower(user);
|
strlower (user);
|
||||||
ret = uname_string_combinations(user, _Get_Pwnam, usernamelevel);
|
ret = uname_string_combinations (user, _Get_Pwnam, usernamelevel);
|
||||||
if (ret) return(ret);
|
if (ret)
|
||||||
|
return (ret);
|
||||||
|
|
||||||
return(NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
check if a user is in a netgroup user list
|
check if a user is in a netgroup user list
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
static BOOL user_in_netgroup_list(char *user,char *ngname)
|
static BOOL
|
||||||
|
user_in_netgroup_list (char *user, char *ngname)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_NETGROUP
|
#ifdef HAVE_NETGROUP
|
||||||
static char *mydomain = NULL;
|
static char *mydomain = NULL;
|
||||||
if (mydomain == NULL)
|
if (mydomain == NULL)
|
||||||
yp_get_default_domain(&mydomain);
|
yp_get_default_domain (&mydomain);
|
||||||
|
|
||||||
if(mydomain == NULL)
|
if (mydomain == NULL)
|
||||||
{
|
{
|
||||||
DEBUG(5,("Unable to get default yp domain\n"));
|
DEBUG (5, ("Unable to get default yp domain\n"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DEBUG(5,("looking for user %s of domain %s in netgroup %s\n",
|
DEBUG (5, ("looking for user %s of domain %s in netgroup %s\n", user, mydomain, ngname));
|
||||||
user, mydomain, ngname));
|
DEBUG (5, ("innetgr is %s\n", innetgr (ngname, NULL, user, mydomain) ? "TRUE" : "FALSE"));
|
||||||
DEBUG(5,("innetgr is %s\n",
|
|
||||||
innetgr(ngname, NULL, user, mydomain)
|
|
||||||
? "TRUE" : "FALSE"));
|
|
||||||
|
|
||||||
if (innetgr(ngname, NULL, user, mydomain))
|
if (innetgr (ngname, NULL, user, mydomain))
|
||||||
return (True);
|
return (True);
|
||||||
}
|
}
|
||||||
#endif /* HAVE_NETGROUP */
|
#endif /* HAVE_NETGROUP */
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
check if a user is in a UNIX user list
|
check if a user is in a UNIX user list
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
static BOOL user_in_group_list(char *user,char *gname)
|
static BOOL
|
||||||
|
user_in_group_list (char *user, char *gname)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_GETGRNAM
|
#ifdef HAVE_GETGRNAM
|
||||||
struct group *gptr;
|
struct group *gptr;
|
||||||
char **member;
|
char **member;
|
||||||
struct passwd *pass = Get_Pwnam(user,False);
|
struct passwd *pass = Get_Pwnam (user, False);
|
||||||
|
|
||||||
if (pass)
|
if (pass)
|
||||||
{
|
|
||||||
gptr = getgrgid(pass->pw_gid);
|
|
||||||
if (gptr && strequal(gptr->gr_name,gname))
|
|
||||||
return(True);
|
|
||||||
}
|
|
||||||
|
|
||||||
gptr = (struct group *)getgrnam(gname);
|
|
||||||
|
|
||||||
if (gptr)
|
|
||||||
{
|
|
||||||
member = gptr->gr_mem;
|
|
||||||
while (member && *member)
|
|
||||||
{
|
{
|
||||||
if (strequal(*member,user))
|
gptr = getgrgid (pass->pw_gid);
|
||||||
return(True);
|
if (gptr && strequal (gptr->gr_name, gname))
|
||||||
member++;
|
return (True);
|
||||||
|
}
|
||||||
|
|
||||||
|
gptr = (struct group *) getgrnam (gname);
|
||||||
|
|
||||||
|
if (gptr)
|
||||||
|
{
|
||||||
|
member = gptr->gr_mem;
|
||||||
|
while (member && *member)
|
||||||
|
{
|
||||||
|
if (strequal (*member, user))
|
||||||
|
return (True);
|
||||||
|
member++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif /* HAVE_GETGRNAM */
|
#endif /* HAVE_GETGRNAM */
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
check if a user is in a user list - can check combinations of UNIX
|
check if a user is in a user list - can check combinations of UNIX
|
||||||
and netgroup lists.
|
and netgroup lists.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
BOOL user_in_list(char *user,char *list)
|
BOOL
|
||||||
|
user_in_list (char *user, char *list)
|
||||||
{
|
{
|
||||||
pstring tok;
|
pstring tok;
|
||||||
char *p=list;
|
char *p = list;
|
||||||
|
|
||||||
while (next_token(&p,tok,LIST_SEP, sizeof(tok)))
|
while (next_token (&p, tok, LIST_SEP, sizeof (tok)))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Check raw username.
|
* Check raw username.
|
||||||
*/
|
*/
|
||||||
if (strequal(user,tok))
|
if (strequal (user, tok))
|
||||||
return(True);
|
return (True);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now check to see if any combination
|
* Now check to see if any combination
|
||||||
* of UNIX and netgroups has been specified.
|
* of UNIX and netgroups has been specified.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if(*tok == '@')
|
if (*tok == '@')
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Old behaviour. Check netgroup list
|
* Old behaviour. Check netgroup list
|
||||||
* followed by UNIX list.
|
* followed by UNIX list.
|
||||||
*/
|
*/
|
||||||
if(user_in_netgroup_list(user,&tok[1]))
|
if (user_in_netgroup_list (user, &tok[1]))
|
||||||
return True;
|
return True;
|
||||||
if(user_in_group_list(user,&tok[1]))
|
if (user_in_group_list (user, &tok[1]))
|
||||||
return True;
|
return True;
|
||||||
|
}
|
||||||
|
else if (*tok == '+')
|
||||||
|
{
|
||||||
|
if (tok[1] == '&')
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Search UNIX list followed by netgroup.
|
||||||
|
*/
|
||||||
|
if (user_in_group_list (user, &tok[2]))
|
||||||
|
return True;
|
||||||
|
if (user_in_netgroup_list (user, &tok[2]))
|
||||||
|
return True;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Just search UNIX list.
|
||||||
|
*/
|
||||||
|
if (user_in_group_list (user, &tok[1]))
|
||||||
|
return True;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (*tok == '&')
|
||||||
|
{
|
||||||
|
if (tok[1] == '&')
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Search netgroup list followed by UNIX list.
|
||||||
|
*/
|
||||||
|
if (user_in_netgroup_list (user, &tok[2]))
|
||||||
|
return True;
|
||||||
|
if (user_in_group_list (user, &tok[2]))
|
||||||
|
return True;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Just search netgroup list.
|
||||||
|
*/
|
||||||
|
if (user_in_netgroup_list (user, &tok[1]))
|
||||||
|
return True;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (*tok == '+')
|
return (False);
|
||||||
{
|
|
||||||
if(tok[1] == '&')
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Search UNIX list followed by netgroup.
|
|
||||||
*/
|
|
||||||
if(user_in_group_list(user,&tok[2]))
|
|
||||||
return True;
|
|
||||||
if(user_in_netgroup_list(user,&tok[2]))
|
|
||||||
return True;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Just search UNIX list.
|
|
||||||
*/
|
|
||||||
if(user_in_group_list(user,&tok[1]))
|
|
||||||
return True;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (*tok == '&')
|
|
||||||
{
|
|
||||||
if(tok[1] == '&')
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Search netgroup list followed by UNIX list.
|
|
||||||
*/
|
|
||||||
if(user_in_netgroup_list(user,&tok[2]))
|
|
||||||
return True;
|
|
||||||
if(user_in_group_list(user,&tok[2]))
|
|
||||||
return True;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Just search netgroup list.
|
|
||||||
*/
|
|
||||||
if(user_in_netgroup_list(user,&tok[1]))
|
|
||||||
return True;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(False);
|
|
||||||
}
|
}
|
||||||
#endif /* 0 */
|
#endif /* 0 */
|
||||||
|
|
||||||
@ -376,31 +397,34 @@ try all combinations with N uppercase letters.
|
|||||||
offset is the first char to try and change (start with 0)
|
offset is the first char to try and change (start with 0)
|
||||||
it assumes the string starts lowercased
|
it assumes the string starts lowercased
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
static struct passwd *uname_string_combinations2(char *s,int offset,struct passwd *(*fn)(const char *),int N)
|
static struct passwd *
|
||||||
|
uname_string_combinations2 (char *s, int offset, struct passwd *(*fn) (const char *), int N)
|
||||||
{
|
{
|
||||||
int len = strlen(s);
|
int len = strlen (s);
|
||||||
int i;
|
int i;
|
||||||
struct passwd *ret;
|
struct passwd *ret;
|
||||||
|
|
||||||
#ifdef PASSWORD_LENGTH
|
#ifdef PASSWORD_LENGTH
|
||||||
len = MIN(len,PASSWORD_LENGTH);
|
len = MIN (len, PASSWORD_LENGTH);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (N <= 0 || offset >= len)
|
if (N <= 0 || offset >= len)
|
||||||
return(fn(s));
|
return (fn (s));
|
||||||
|
|
||||||
|
|
||||||
for (i=offset;i<(len-(N-1));i++)
|
for (i = offset; i < (len - (N - 1)); i++)
|
||||||
|
|
||||||
{
|
{
|
||||||
char c = s[i];
|
char c = s[i];
|
||||||
if (!islower(c)) continue;
|
if (!islower (c))
|
||||||
s[i] = toupper(c);
|
continue;
|
||||||
ret = uname_string_combinations2(s,i+1,fn,N-1);
|
s[i] = toupper (c);
|
||||||
if(ret) return(ret);
|
ret = uname_string_combinations2 (s, i + 1, fn, N - 1);
|
||||||
s[i] = c;
|
if (ret)
|
||||||
|
return (ret);
|
||||||
|
s[i] = c;
|
||||||
}
|
}
|
||||||
return(NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -410,15 +434,17 @@ try all combinations with up to N uppercase letters.
|
|||||||
offset is the first char to try and change (start with 0)
|
offset is the first char to try and change (start with 0)
|
||||||
it assumes the string starts lowercased
|
it assumes the string starts lowercased
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
static struct passwd * uname_string_combinations(char *s,struct passwd * (*fn)(const char *),int N)
|
static struct passwd *
|
||||||
|
uname_string_combinations (char *s, struct passwd *(*fn) (const char *), int N)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
struct passwd *ret;
|
struct passwd *ret;
|
||||||
|
|
||||||
for (n=1;n<=N;n++)
|
for (n = 1; n <= N; n++)
|
||||||
{
|
{
|
||||||
ret = uname_string_combinations2(s,0,fn,n);
|
ret = uname_string_combinations2 (s, 0, fn, n);
|
||||||
if(ret) return(ret);
|
if (ret)
|
||||||
}
|
return (ret);
|
||||||
return(NULL);
|
}
|
||||||
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
@ -33,9 +33,10 @@ static int gotalarm;
|
|||||||
Signal function to tell us we timed out.
|
Signal function to tell us we timed out.
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
static void gotalarm_sig(void)
|
static void
|
||||||
|
gotalarm_sig (void)
|
||||||
{
|
{
|
||||||
gotalarm = 1;
|
gotalarm = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************
|
/***************************************************************
|
||||||
@ -43,74 +44,78 @@ static void gotalarm_sig(void)
|
|||||||
seconds.
|
seconds.
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
BOOL do_file_lock(int fd, int waitsecs, int type)
|
BOOL
|
||||||
|
do_file_lock (int fd, int waitsecs, int type)
|
||||||
{
|
{
|
||||||
SMB_STRUCT_FLOCK lock;
|
SMB_STRUCT_FLOCK lock;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
gotalarm = 0;
|
gotalarm = 0;
|
||||||
CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig);
|
CatchSignal (SIGALRM, SIGNAL_CAST gotalarm_sig);
|
||||||
|
|
||||||
lock.l_type = type;
|
lock.l_type = type;
|
||||||
lock.l_whence = SEEK_SET;
|
lock.l_whence = SEEK_SET;
|
||||||
lock.l_start = 0;
|
lock.l_start = 0;
|
||||||
lock.l_len = 1;
|
lock.l_len = 1;
|
||||||
lock.l_pid = 0;
|
lock.l_pid = 0;
|
||||||
|
|
||||||
alarm(waitsecs);
|
alarm (waitsecs);
|
||||||
ret = fcntl(fd, SMB_F_SETLKW, &lock);
|
ret = fcntl (fd, SMB_F_SETLKW, &lock);
|
||||||
alarm(0);
|
alarm (0);
|
||||||
CatchSignal(SIGALRM, SIGNAL_CAST SIG_DFL);
|
CatchSignal (SIGALRM, SIGNAL_CAST SIG_DFL);
|
||||||
|
|
||||||
if (gotalarm) {
|
if (gotalarm)
|
||||||
DEBUG(0, ("do_file_lock: failed to %s file.\n",
|
{
|
||||||
type == F_UNLCK ? "unlock" : "lock"));
|
DEBUG (0, ("do_file_lock: failed to %s file.\n", type == F_UNLCK ? "unlock" : "lock"));
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (ret == 0);
|
return (ret == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************
|
/***************************************************************
|
||||||
Lock an fd. Abandon after waitsecs seconds.
|
Lock an fd. Abandon after waitsecs seconds.
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
BOOL file_lock(int fd, int type, int secs, int *plock_depth)
|
BOOL
|
||||||
|
file_lock (int fd, int type, int secs, int *plock_depth)
|
||||||
{
|
{
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return False;
|
return False;
|
||||||
|
|
||||||
(*plock_depth)++;
|
(*plock_depth)++;
|
||||||
|
|
||||||
if ((*plock_depth) == 0)
|
if ((*plock_depth) == 0)
|
||||||
{
|
{
|
||||||
if (!do_file_lock(fd, secs, type)) {
|
if (!do_file_lock (fd, secs, type))
|
||||||
DEBUG(10,("file_lock: locking file failed, error = %s.\n",
|
{
|
||||||
unix_error_string (errno)));
|
DEBUG (10, ("file_lock: locking file failed, error = %s.\n",
|
||||||
return False;
|
unix_error_string (errno)));
|
||||||
|
return False;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************
|
/***************************************************************
|
||||||
Unlock an fd. Abandon after waitsecs seconds.
|
Unlock an fd. Abandon after waitsecs seconds.
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
BOOL file_unlock(int fd, int *plock_depth)
|
BOOL
|
||||||
|
file_unlock (int fd, int *plock_depth)
|
||||||
{
|
{
|
||||||
BOOL ret=True;
|
BOOL ret = True;
|
||||||
|
|
||||||
if(*plock_depth == 1)
|
if (*plock_depth == 1)
|
||||||
ret = do_file_lock(fd, 5, F_UNLCK);
|
ret = do_file_lock (fd, 5, F_UNLCK);
|
||||||
|
|
||||||
(*plock_depth)--;
|
(*plock_depth)--;
|
||||||
|
|
||||||
if(!ret)
|
if (!ret)
|
||||||
DEBUG(10,("file_unlock: unlocking file failed, error = %s.\n",
|
DEBUG (10, ("file_unlock: unlocking file failed, error = %s.\n",
|
||||||
unix_error_string (errno)));
|
unix_error_string (errno)));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************
|
/***************************************************************
|
||||||
@ -118,52 +123,54 @@ BOOL file_unlock(int fd, int *plock_depth)
|
|||||||
update to be set = True if modification is required.
|
update to be set = True if modification is required.
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
void *startfilepwent(char *pfile, char *s_readbuf, int bufsize,
|
void *
|
||||||
int *file_lock_depth, BOOL update)
|
startfilepwent (char *pfile, char *s_readbuf, int bufsize, int *file_lock_depth, BOOL update)
|
||||||
{
|
{
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
|
|
||||||
if (!*pfile)
|
if (!*pfile)
|
||||||
{
|
{
|
||||||
DEBUG(0, ("startfilepwent: No file set\n"));
|
DEBUG (0, ("startfilepwent: No file set\n"));
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
DEBUG(10, ("startfilepwent: opening file %s\n", pfile));
|
DEBUG (10, ("startfilepwent: opening file %s\n", pfile));
|
||||||
|
|
||||||
fp = sys_fopen(pfile, update ? "r+b" : "rb");
|
fp = sys_fopen (pfile, update ? "r+b" : "rb");
|
||||||
|
|
||||||
if (fp == NULL) {
|
if (fp == NULL)
|
||||||
DEBUG(0, ("startfilepwent: unable to open file %s\n", pfile));
|
{
|
||||||
return NULL;
|
DEBUG (0, ("startfilepwent: unable to open file %s\n", pfile));
|
||||||
}
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Set a buffer to do more efficient reads */
|
/* Set a buffer to do more efficient reads */
|
||||||
setvbuf(fp, s_readbuf, _IOFBF, bufsize);
|
setvbuf (fp, s_readbuf, _IOFBF, bufsize);
|
||||||
|
|
||||||
if (!file_lock(fileno(fp), (update ? F_WRLCK : F_RDLCK), 5, file_lock_depth))
|
if (!file_lock (fileno (fp), (update ? F_WRLCK : F_RDLCK), 5, file_lock_depth))
|
||||||
{
|
{
|
||||||
DEBUG(0, ("startfilepwent: unable to lock file %s\n", pfile));
|
DEBUG (0, ("startfilepwent: unable to lock file %s\n", pfile));
|
||||||
fclose(fp);
|
fclose (fp);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure it is only rw by the owner */
|
/* Make sure it is only rw by the owner */
|
||||||
chmod(pfile, 0600);
|
chmod (pfile, 0600);
|
||||||
|
|
||||||
/* We have a lock on the file. */
|
/* We have a lock on the file. */
|
||||||
return (void *)fp;
|
return (void *) fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************
|
/***************************************************************
|
||||||
End enumeration of the file.
|
End enumeration of the file.
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
void endfilepwent(void *vp, int *file_lock_depth)
|
void
|
||||||
|
endfilepwent (void *vp, int *file_lock_depth)
|
||||||
{
|
{
|
||||||
FILE *fp = (FILE *)vp;
|
FILE *fp = (FILE *) vp;
|
||||||
|
|
||||||
file_unlock(fileno(fp), file_lock_depth);
|
file_unlock (fileno (fp), file_lock_depth);
|
||||||
fclose(fp);
|
fclose (fp);
|
||||||
DEBUG(7, ("endfilepwent: closed file.\n"));
|
DEBUG (7, ("endfilepwent: closed file.\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -171,18 +178,20 @@ void endfilepwent(void *vp, int *file_lock_depth)
|
|||||||
Return the current position in the file list as an SMB_BIG_UINT.
|
Return the current position in the file list as an SMB_BIG_UINT.
|
||||||
This must be treated as an opaque token.
|
This must be treated as an opaque token.
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
SMB_BIG_UINT getfilepwpos(void *vp)
|
SMB_BIG_UINT
|
||||||
|
getfilepwpos (void *vp)
|
||||||
{
|
{
|
||||||
return (SMB_BIG_UINT)sys_ftell((FILE *)vp);
|
return (SMB_BIG_UINT) sys_ftell ((FILE *) vp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
Set the current position in the file list from an SMB_BIG_UINT.
|
Set the current position in the file list from an SMB_BIG_UINT.
|
||||||
This must be treated as an opaque token.
|
This must be treated as an opaque token.
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
BOOL setfilepwpos(void *vp, SMB_BIG_UINT tok)
|
BOOL
|
||||||
|
setfilepwpos (void *vp, SMB_BIG_UINT tok)
|
||||||
{
|
{
|
||||||
return !sys_fseek((FILE *)vp, (SMB_OFF_T)tok, SEEK_SET);
|
return !sys_fseek ((FILE *) vp, (SMB_OFF_T) tok, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@ -190,146 +199,149 @@ BOOL setfilepwpos(void *vp, SMB_BIG_UINT tok)
|
|||||||
line is of format "xxxx:xxxxxx:xxxxx:".
|
line is of format "xxxx:xxxxxx:xxxxx:".
|
||||||
lines with "#" at the front are ignored.
|
lines with "#" at the front are ignored.
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
int getfileline(void *vp, char *linebuf, int linebuf_size)
|
int
|
||||||
|
getfileline (void *vp, char *linebuf, int linebuf_size)
|
||||||
{
|
{
|
||||||
/* Static buffers we will return. */
|
/* Static buffers we will return. */
|
||||||
FILE *fp = (FILE *)vp;
|
FILE *fp = (FILE *) vp;
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
unsigned char *p;
|
unsigned char *p;
|
||||||
size_t linebuf_len;
|
size_t linebuf_len;
|
||||||
|
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
{
|
{
|
||||||
DEBUG(0,("getfileline: Bad file pointer.\n"));
|
DEBUG (0, ("getfileline: Bad file pointer.\n"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Scan the file, a line at a time.
|
* Scan the file, a line at a time.
|
||||||
*/
|
*/
|
||||||
while (!feof(fp))
|
while (!feof (fp))
|
||||||
{
|
{
|
||||||
linebuf[0] = '\0';
|
linebuf[0] = '\0';
|
||||||
|
|
||||||
fgets(linebuf, linebuf_size, fp);
|
fgets (linebuf, linebuf_size, fp);
|
||||||
if (ferror(fp))
|
if (ferror (fp))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if the string is terminated with a newline - if not
|
* Check if the string is terminated with a newline - if not
|
||||||
* then we must keep reading and discard until we get one.
|
* then we must keep reading and discard until we get one.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
linebuf_len = strlen(linebuf);
|
linebuf_len = strlen (linebuf);
|
||||||
if (linebuf[linebuf_len - 1] != '\n')
|
if (linebuf[linebuf_len - 1] != '\n')
|
||||||
{
|
{
|
||||||
c = '\0';
|
c = '\0';
|
||||||
while (!ferror(fp) && !feof(fp))
|
while (!ferror (fp) && !feof (fp))
|
||||||
{
|
{
|
||||||
c = fgetc(fp);
|
c = fgetc (fp);
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
linebuf[linebuf_len - 1] = '\0';
|
linebuf[linebuf_len - 1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_PASSWORD
|
#ifdef DEBUG_PASSWORD
|
||||||
DEBUG(100, ("getfileline: got line |%s|\n", linebuf));
|
DEBUG (100, ("getfileline: got line |%s|\n", linebuf));
|
||||||
#endif
|
#endif
|
||||||
if ((linebuf[0] == 0) && feof(fp))
|
if ((linebuf[0] == 0) && feof (fp))
|
||||||
{
|
{
|
||||||
DEBUG(4, ("getfileline: end of file reached\n"));
|
DEBUG (4, ("getfileline: end of file reached\n"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (linebuf[0] == '#' || linebuf[0] == '\0')
|
if (linebuf[0] == '#' || linebuf[0] == '\0')
|
||||||
{
|
{
|
||||||
DEBUG(6, ("getfileline: skipping comment or blank line\n"));
|
DEBUG (6, ("getfileline: skipping comment or blank line\n"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = (unsigned char *) strchr(linebuf, ':');
|
p = (unsigned char *) strchr (linebuf, ':');
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
{
|
{
|
||||||
DEBUG(0, ("getfileline: malformed line entry (no :)\n"));
|
DEBUG (0, ("getfileline: malformed line entry (no :)\n"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
return linebuf_len;
|
return linebuf_len;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif /* 0 */
|
#endif /* 0 */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
read a line from a file with possible \ continuation chars.
|
read a line from a file with possible \ continuation chars.
|
||||||
Blanks at the start or end of a line are stripped.
|
Blanks at the start or end of a line are stripped.
|
||||||
The string will be allocated if s2 is NULL
|
The string will be allocated if s2 is NULL
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
char *fgets_slash(char *s2,int maxlen,FILE *f)
|
char *
|
||||||
|
fgets_slash (char *s2, int maxlen, FILE * f)
|
||||||
{
|
{
|
||||||
char *s=s2;
|
char *s = s2;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int c;
|
int c;
|
||||||
BOOL start_of_line = True;
|
BOOL start_of_line = True;
|
||||||
|
|
||||||
if (feof(f))
|
if (feof (f))
|
||||||
return(NULL);
|
return (NULL);
|
||||||
|
|
||||||
if (!s2)
|
if (!s2)
|
||||||
{
|
{
|
||||||
maxlen = MIN(maxlen,8);
|
maxlen = MIN (maxlen, 8);
|
||||||
s = (char *)Realloc(s,maxlen);
|
s = (char *) Realloc (s, maxlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!s || maxlen < 2) return(NULL);
|
if (!s || maxlen < 2)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
*s = 0;
|
*s = 0;
|
||||||
|
|
||||||
while (len < maxlen-1)
|
while (len < maxlen - 1)
|
||||||
{
|
{
|
||||||
c = getc(f);
|
c = getc (f);
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case '\r':
|
case '\r':
|
||||||
break;
|
break;
|
||||||
case '\n':
|
case '\n':
|
||||||
while (len > 0 && s[len-1] == ' ')
|
while (len > 0 && s[len - 1] == ' ')
|
||||||
{
|
{
|
||||||
s[--len] = 0;
|
s[--len] = 0;
|
||||||
}
|
}
|
||||||
if (len > 0 && s[len-1] == '\\')
|
if (len > 0 && s[len - 1] == '\\')
|
||||||
{
|
{
|
||||||
s[--len] = 0;
|
s[--len] = 0;
|
||||||
start_of_line = True;
|
start_of_line = True;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return(s);
|
return (s);
|
||||||
case EOF:
|
case EOF:
|
||||||
if (len <= 0 && !s2)
|
if (len <= 0 && !s2)
|
||||||
free(s);
|
free (s);
|
||||||
return(len>0?s:NULL);
|
return (len > 0 ? s : NULL);
|
||||||
case ' ':
|
case ' ':
|
||||||
if (start_of_line)
|
if (start_of_line)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
start_of_line = False;
|
start_of_line = False;
|
||||||
s[len++] = c;
|
s[len++] = c;
|
||||||
s[len] = 0;
|
s[len] = 0;
|
||||||
}
|
}
|
||||||
if (!s2 && len > maxlen-3)
|
if (!s2 && len > maxlen - 3)
|
||||||
{
|
{
|
||||||
maxlen *= 2;
|
maxlen *= 2;
|
||||||
s = (char *)Realloc(s,maxlen);
|
s = (char *) Realloc (s, maxlen);
|
||||||
if (!s) return(NULL);
|
if (!s)
|
||||||
}
|
return (NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return(s);
|
return (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user