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
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
+#undef realloc
static int
-process_block (smb_iconv_t cd, char *addr, size_t len, FILE *output)
+process_block (smb_iconv_t cd, const char *addr, size_t len, FILE *output)
{
#define OUTBUF_SIZE 32768
const char *start = addr;
{
outptr = outbuf;
outlen = OUTBUF_SIZE;
- n = smb_iconv (cd, &addr, &len, &outptr, &outlen);
+ n = smb_iconv (cd, &addr, &len, &outptr, &outlen);
if (outptr != outbuf)
{
static int
-process_fd (iconv_t cd, int fd, FILE *output)
+process_fd (smb_iconv_t cd, int fd, FILE *output)
{
/* we have a problem with reading from a descriptor since we must not
provide the iconv() function an incomplete character or shift
int main(int argc, char *argv[])
{
const char *file = NULL;
- char *from = "";
- char *to = "";
+ const char *from = "";
+ const char *to = "";
char *output = NULL;
- char *preload = NULL;
+ const char *preload_modules[] = {NULL, NULL};
FILE *out = stdout;
int fd;
smb_iconv_t cd;
{ "from-code", 'f', POPT_ARG_STRING, &from, 0, "Encoding of original text" },
{ "to-code", 't', POPT_ARG_STRING, &to, 0, "Encoding for output" },
{ "output", 'o', POPT_ARG_STRING, &output, 0, "Write output to this file" },
- { "preload-modules", 'p', POPT_ARG_STRING, &preload, 0, "Modules to load" },
+ { "preload-modules", 'p', POPT_ARG_STRING, &preload_modules[0], 0, "Modules to load" },
POPT_COMMON_SAMBA
POPT_TABLEEND
};
while(poptGetNextOpt(pc) != -1);
- if(preload)smb_load_modules(str_list_make(preload, NULL));
+ /* the following functions are part of the Samba debugging
+ facilities. See lib/debug.c */
+ setup_logging("smbiconv", True);
+
+ if (preload_modules[0]) smb_load_modules(preload_modules);
if(output) {
- output = fopen(output, "w");
+ out = fopen(output, "w");
- if(!output) {
+ if(!out) {
DEBUG(0, ("Can't open output file '%s': %s, exiting...\n", output, strerror(errno)));
return 1;
}
}
- /* the following functions are part of the Samba debugging
- facilities. See lib/debug.c */
- setup_logging("smbiconv", True);
-
cd = smb_iconv_open(to, from);
- if((int)cd == -1) {
+ if (cd == (smb_iconv_t)-1) {
DEBUG(0,("unable to find from or to encoding, exiting...\n"));
return 1;
}
}
/* Loop thru all arguments */
- process_fd(cd, fd, stdout);
+ process_fd(cd, fd, out);
close(fd);
}