update to 0.9.1 release tarball
this update is performed by extracting the release tarball into this directory and adding any missing files. likely some of these are not intended to be checked into the source, but only generated as part of the release process. tarball from: <https://sourceforge.net/projects/curlftpfs/files/curlftpfs/0.9.1/curlftpfs-0.9.1.tar.gz>
This commit is contained in:
58
charset_utils.c
Normal file
58
charset_utils.c
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
FTP file system
|
||||
Copyright (C) 2007 Robson Braga Araujo <robsonbraga@gmail.com>
|
||||
|
||||
This program can be distributed under the terms of the GNU GPL.
|
||||
See the file COPYING.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <iconv.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "ftpfs.h"
|
||||
|
||||
int convert_charsets(const char* from, const char* to, char** str) {
|
||||
iconv_t cd;
|
||||
char* s = *str;
|
||||
|
||||
if (!s || !*s)
|
||||
return 0;
|
||||
|
||||
if (to && from && (cd = iconv_open(to, from)) != (iconv_t)-1) {
|
||||
ICONV_CONST char* ib;
|
||||
char* buf;
|
||||
char* ob;
|
||||
size_t ibl, obl;
|
||||
|
||||
ibl = strlen(s) + 1;
|
||||
ib = s;
|
||||
obl = MB_LEN_MAX * ibl;
|
||||
buf = (char*)malloc(obl * sizeof(char));
|
||||
ob = buf;
|
||||
|
||||
do {
|
||||
if (iconv(cd, &ib, &ibl, &ob, &obl) == (size_t)-1) {
|
||||
DEBUG(2, "iconv return error %d\n", errno);
|
||||
if (obl) {
|
||||
*ob++ = *ib++;
|
||||
ibl--;
|
||||
obl--;
|
||||
}
|
||||
}
|
||||
} while (ibl && obl);
|
||||
*ob = 0;
|
||||
DEBUG(2, "iconv return %s\n", buf);
|
||||
iconv_close (cd);
|
||||
free(*str);
|
||||
*str = buf;
|
||||
} else {
|
||||
DEBUG(2, "iconv_open return error %d\n", errno);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user