2 * lufs interface module misc functions for libcaptive
3 * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; exactly version 2 of June 1991 is required
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "captivefs-misc.h" /* self */
23 #include <glib/gmessages.h>
24 #include "captivefs-vfs.h"
26 #include <captive/client-vfs.h>
29 /* module-scope lock for _any_ libcaptive access */
30 G_LOCK_DEFINE(libcaptive);
33 /* Resolve a link (if the info was not added to the dir cache when
34 * reading the parent dir)
36 int captivefs_readlink(struct captivefs_vfs *captivefs_vfs,const char *link,char *buf,int buflen)
38 g_return_val_if_fail(captivefs_vfs_validate(captivefs_vfs),-1);
39 g_return_val_if_fail(link!=NULL,-1);
40 g_return_val_if_fail(buf!=NULL,-1);
41 g_return_val_if_fail(buflen>0,-1);
43 if (captivefs_vfs->options.debug_messages)
44 g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"captivefs_readlink: link=%s,buflen=%d",link,buflen);
46 return -1; /* unsupported by W32 */
52 int captivefs_link(struct captivefs_vfs *captivefs_vfs,const char *target,const char *lnk)
54 g_return_val_if_fail(captivefs_vfs_validate(captivefs_vfs),-1);
55 g_return_val_if_fail(target!=NULL,-1);
56 g_return_val_if_fail(lnk!=NULL,-1);
58 if (captivefs_vfs->options.debug_messages)
59 g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"captivefs_link: target=%s,lnk=%s",target,lnk);
61 return -1; /* unsupported by W32 */
67 int captivefs_symlink(struct captivefs_vfs *captivefs_vfs,const char *target,const char *link)
69 g_return_val_if_fail(captivefs_vfs_validate(captivefs_vfs),-1);
70 g_return_val_if_fail(target!=NULL,-1);
71 g_return_val_if_fail(link!=NULL,-1);
73 if (captivefs_vfs->options.debug_messages)
74 g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"captivefs_symlink: target=%s,link=%s",target,link);
76 return -1; /* unsupported by W32 */
80 char *captivefs_filename_to_utf8_malloc_errorchecking(const char *name)
85 g_return_val_if_fail(name!=NULL,NULL);
89 name, /* opsysstring */
90 -1, /* len; '\0'-terminated */
91 NULL, /* bytes_read */
92 NULL, /* bytes_written */
95 g_log(G_LOG_DOMAIN,G_LOG_LEVEL_WARNING,
96 _("captivefs %s(): name=\"%s\": %s (see locale(7) and mount(8) environment variables)"),
97 "g_filename_to_utf8",name,error->message);
98 g_clear_error(&error);
104 char *captivefs_filename_from_utf8_malloc_errorchecking(const char *name)
109 g_return_val_if_fail(name!=NULL,NULL);
112 r=g_filename_from_utf8(
113 name, /* utf8string */
114 -1, /* len; '\0'-terminated */
115 NULL, /* bytes_read */
116 NULL, /* bytes_written */
119 g_log(G_LOG_DOMAIN,G_LOG_LEVEL_WARNING,"captivefs %s(): name=\"%s\"; g_get_charset()=\"%s\", %s: %s",
120 "g_filename_from_utf8",name,charset,
121 _("see environment variables - locale(7), mount(8) and locale(1) commands \"locale\" and \"locale -a\""),
123 g_clear_error(&error);