sync with main (forgotten in last commit)
* src/common/utils.c
* src/common/utils.h
check_line_length(): new.
is_dir_exist()
is_file_entry_exist()
dirent_is_regular_file()
dirent_is_directory(): use g_file_test() instead of stat().
+2005-07-04 [paul] 1.9.12cvs17
+
+ sync with main (forgotten in last commit)
+
+ * src/common/utils.c
+ * src/common/utils.h
+ check_line_length(): new.
+ is_dir_exist()
+ is_file_entry_exist()
+ dirent_is_regular_file()
+ dirent_is_directory(): use g_file_test() instead of stat().
+
2005-07-04 [paul] 1.9.12cvs16
sync with main:
2005-07-04 [paul] 1.9.12cvs16
sync with main:
( cvs diff -u -r 1.179.2.44 -r 1.179.2.45 src/imap.c; ) > 1.9.12cvs14.patchset
( cvs diff -u -r 1.25.2.13 -r 1.25.2.14 src/stock_pixmap.c; ) > 1.9.12cvs15.patchset
( cvs diff -u -r 1.382.2.139 -r 1.382.2.140 src/compose.c; cvs diff -u -r 1.18.2.8 -r 1.18.2.9 src/jpilot.c; cvs diff -u -r 1.47.2.21 -r 1.47.2.22 src/procheader.c; cvs diff -u -r 1.14.2.2 -r 1.14.2.3 src/vcard.c; ) > 1.9.12cvs16.patchset
( cvs diff -u -r 1.179.2.44 -r 1.179.2.45 src/imap.c; ) > 1.9.12cvs14.patchset
( cvs diff -u -r 1.25.2.13 -r 1.25.2.14 src/stock_pixmap.c; ) > 1.9.12cvs15.patchset
( cvs diff -u -r 1.382.2.139 -r 1.382.2.140 src/compose.c; cvs diff -u -r 1.18.2.8 -r 1.18.2.9 src/jpilot.c; cvs diff -u -r 1.47.2.21 -r 1.47.2.22 src/procheader.c; cvs diff -u -r 1.14.2.2 -r 1.14.2.3 src/vcard.c; ) > 1.9.12cvs16.patchset
+( cvs diff -u -r 1.36.2.35 -r 1.36.2.36 src/common/utils.c; cvs diff -u -r 1.20.2.18 -r 1.20.2.19 src/common/utils.h; ) > 1.9.12cvs17.patchset
MICRO_VERSION=12
INTERFACE_AGE=0
BINARY_AGE=0
MICRO_VERSION=12
INTERFACE_AGE=0
BINARY_AGE=0
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
+gint check_line_length(const gchar *str, gint max_chars, gint *line)
+{
+ const gchar *p = str, *q;
+ gint cur_line = 0, len;
+
+ while ((q = strchr(p, '\n')) != NULL) {
+ len = q - p + 1;
+ if (len > max_chars) {
+ if (line)
+ *line = cur_line;
+ return -1;
+ }
+ p = q + 1;
+ ++cur_line;
+ }
+
+ len = strlen(p);
+ if (len > max_chars) {
+ if (line)
+ *line = cur_line;
+ return -1;
+ }
+
+ return 0;
+}
+
const gchar * line_has_quote_char(const gchar * str, const gchar *quote_chars)
{
gchar * position = NULL;
const gchar * line_has_quote_char(const gchar * str, const gchar *quote_chars)
{
gchar * position = NULL;
gboolean is_dir_exist(const gchar *dir)
{
gboolean is_dir_exist(const gchar *dir)
{
if (dir == NULL)
return FALSE;
if (dir == NULL)
return FALSE;
- if (stat(dir, &s) < 0) {
- if (ENOENT != errno) FILE_OP_ERROR(dir, "stat");
- return FALSE;
- }
-
- if (S_ISDIR(s.st_mode))
- return TRUE;
-
- return FALSE;
+ return g_file_test(dir, G_FILE_TEST_IS_DIR);
}
gboolean is_file_entry_exist(const gchar *file)
{
}
gboolean is_file_entry_exist(const gchar *file)
{
if (file == NULL)
return FALSE;
if (file == NULL)
return FALSE;
- if (stat(file, &s) < 0) {
- if (ENOENT != errno) FILE_OP_ERROR(file, "stat");
- return FALSE;
- }
-
- return TRUE;
+ return g_file_test(file, G_FILE_TEST_EXISTS);
}
gboolean dirent_is_regular_file(struct dirent *d)
{
}
gboolean dirent_is_regular_file(struct dirent *d)
{
#ifdef HAVE_DIRENT_D_TYPE
if (d->d_type == DT_REG)
return TRUE;
#ifdef HAVE_DIRENT_D_TYPE
if (d->d_type == DT_REG)
return TRUE;
- return (stat(d->d_name, &s) == 0 && S_ISREG(s.st_mode));
+ return g_file_test(d->d_name, G_FILE_TEST_IS_REGULAR);
}
gboolean dirent_is_directory(struct dirent *d)
{
}
gboolean dirent_is_directory(struct dirent *d)
{
#ifdef HAVE_DIRENT_D_TYPE
if (d->d_type == DT_DIR)
return TRUE;
#ifdef HAVE_DIRENT_D_TYPE
if (d->d_type == DT_DIR)
return TRUE;
- return (stat(d->d_name, &s) == 0 && S_ISDIR(s.st_mode));
+ return g_file_test(d->d_name, G_FILE_TEST_IS_DIR);
}
gint change_dir(const gchar *dir)
}
gint change_dir(const gchar *dir)
day, dd, mon, yyyy, hh, mm, ss, tzoffset(&t));
}
day, dd, mon, yyyy, hh, mm, ss, tzoffset(&t));
}
+/* just a wrapper to suppress the warning of gcc about %c */
+size_t my_strftime(gchar *s, size_t max, const gchar *format,
+ const struct tm *tm)
+{
+ return strftime(s, max, format, tm);
+}
+
void debug_set_mode(gboolean mode)
{
debug_mode = mode;
void debug_set_mode(gboolean mode)
{
debug_mode = mode;
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
gboolean is_ascii_str (const guchar *str);
gint get_quote_level (const gchar *str,
const gchar *quote_chars);
gboolean is_ascii_str (const guchar *str);
gint get_quote_level (const gchar *str,
const gchar *quote_chars);
+gint check_line_length (const gchar *str,
+ gint max_chars,
+ gint *line);
+
gchar *strstr_with_skip_quote (const gchar *haystack,
const gchar *needle);
gchar *strchr_parenthesis_close (const gchar *str,
gchar *strstr_with_skip_quote (const gchar *haystack,
const gchar *needle);
gchar *strchr_parenthesis_close (const gchar *str,
void get_rfc822_date (gchar *buf,
gint len);
void get_rfc822_date (gchar *buf,
gint len);
+size_t my_strftime (gchar *s,
+ size_t max,
+ const gchar *format,
+ const struct tm *tm);
+
/* debugging */
void debug_print_real (const gchar *format, ...) G_GNUC_PRINTF(1, 2);
/* debugging */
void debug_print_real (const gchar *format, ...) G_GNUC_PRINTF(1, 2);