#include <string.h>
#include <ctype.h>
#include <errno.h>
+#include <netdb.h>
#if (HAVE_WCTYPE_H && HAVE_WCHAR_H)
# include <wchar.h>
return str_array;
}
+gchar *get_abbrev_newsgroup_name(const gchar *group)
+{
+ gchar *abbrev_group;
+ gchar *ap;
+ const gchar *p = group;
+
+ abbrev_group = ap = g_malloc(strlen(group) + 1);
+
+ while (*p) {
+ while (*p == '.')
+ *ap++ = *p++;
+ if (strchr(p, '.')) {
+ *ap++ = *p++;
+ while (*p != '.') p++;
+ *ap++ = *p++;
+ } else {
+ strcpy(ap, p);
+ return abbrev_group;
+ }
+ }
+
+ *ap = '\0';
+ return abbrev_group;
+}
+
GList *uri_list_extract_filenames(const gchar *uri_list)
{
GList *result = NULL;
return template_dir;
}
+gchar *get_header_cache_dir(void)
+{
+ static gchar *header_dir = NULL;
+
+ if (!header_dir)
+ header_dir = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
+ HEADER_CACHE_DIR, NULL);
+
+ return header_dir;
+}
+
gchar *get_tmp_file(void)
{
static gchar *tmp_file = NULL;
gchar *get_domain_name(void)
{
static gchar *domain_name = NULL;
+ struct hostent *myfqdn = NULL;
if (!domain_name) {
gchar buf[BUFFSIZE] = "";
if (gethostname(buf, sizeof(buf)) < 0) {
perror("gethostname");
strcpy(buf, "unknown");
- }
+ } else {
+ myfqdn = gethostbyname(buf);
+ if (myfqdn != NULL) {
+ memset(buf, '\0', strlen(buf));
+ strcpy(buf, myfqdn->h_name);
+ } else {
+ perror("gethostbyname");
+ strcpy(buf, "unknown");
+ }
+ }
domain_name = g_strdup(buf);
}
off_t size = 0;
gchar buf[BUFFSIZE];
- if ((fp = fopen(file, "r")) == NULL) {
+ if ((fp = fopen(file, "rb")) == NULL) {
FILE_OP_ERROR(file, "fopen");
return -1;
}
gchar *dest_bak = NULL;
gboolean err = FALSE;
- if ((src_fp = fopen(src, "r")) == NULL) {
+ if ((src_fp = fopen(src, "rb")) == NULL) {
FILE_OP_ERROR(src, "fopen");
return -1;
}
}
}
- if ((dest_fp = fopen(dest, "w")) == NULL) {
+ if ((dest_fp = fopen(dest, "wb")) == NULL) {
FILE_OP_ERROR(dest, "fopen");
fclose(src_fp);
if (dest_bak) {
void set_log_file(const gchar *filename)
{
if (log_fp) return;
- log_fp = fopen(filename, "w");
+ log_fp = fopen(filename, "wb");
if (!log_fp)
FILE_OP_ERROR(filename, "fopen");
}