Example #1
0
void plugin_exit_mpd(void)
{
    if (plugin_enabled == 1) {
	debug("[MPD] disconnect from mpd");
	if (currentSong != NULL)
	    mpd_song_free(currentSong);
    }
    if (conn != NULL)
	mpd_connection_free(conn);
    charset_close();
}
Example #2
0
void charset_init_output(const charset_t *charset_out, FILE *output_file)
{
  if (state != closed) {
    WARNING("Charset initialized, closing it now");
    charset_close();
  }

  open_iconv(charset_out->iconv_name, CHARSET_INTERNAL_ENC);
  file = output_file;
  state = output;

  DEBUG("charset_init_output() executed");
}
Example #3
0
static int charset_set(const char *to, const char *from)
{
    if (char_conv_to && strcmp(to, char_conv_to) == 0 && char_conv_from && strcmp(from, char_conv_from) == 0)
	return 0;

    charset_close();

    if ((char_conv_iconv = iconv_open(to, from)) == (iconv_t) (-1))
	return -1;

    char_conv_to = strdup(to);
    char_conv_from = strdup(from);
    return 0;
}
Example #4
0
void charset_init_input(const charset_t *charset_in, FILE *input_file)
{
  if (state != closed) {
    WARNING("Charset initialized, closing it now");
    charset_close();
  }

  open_iconv(CHARSET_INTERNAL_ENC, charset_in->iconv_name);
  bufferpos = buffer;
  avail = 0;
  file = input_file;
  state = input;

  DEBUG("charset_init_input() executed");
}
Example #5
0
char *charset_init_preload(FILE *input_file, size_t *bytes_read)
{
  if (state != closed) {
    WARNING("Charset initialized, closing it now");
    charset_close();
  }

  file = input_file;
  bufferpos = buffer;
  avail = 0;
  read_block();
  *bytes_read = avail;

  state = preload;
  return buffer;
}
Example #6
0
void charset_deinit(void)
{
	charset_close();

	free(locale_charset);
}
Example #7
0
int main(int argc,char **argv)
{
  size_t preload_read;
  const char *preload_buffer;
  int yyparse_result;

  tree_init();

#ifdef WITH_CGI
  cgi_check_request();
  if (cgi_status < 0) {
    cgi_write_error_bad_req();
    return 0;
  }
#endif

  params_set_defaults();

#ifdef WITH_CGI
  if (!cgi_status)
    process_parameters(argc, argv);

  preload_buffer = charset_init_preload(param_inputf, &preload_read);

  if (cgi_status > 0)
    cgi_process_parameters(&preload_buffer, &preload_read);

  charset_auto_detect(preload_read);
  charset_preload_to_input(param_charset_in, preload_read);
  if (cgi_status == CGI_ST_MULTIPART)
    charset_cgi_boundary(boundary, boundary_len);
#else
  /* process command line arguments */
  process_parameters(argc, argv); 
  charset_init_preload(param_inputf, &preload_read);
  charset_auto_detect(preload_read);
  charset_preload_to_input(param_charset_in, preload_read);
#endif

  /* intialize the converter */
  saxStartDocument();
  if (param_inputf != stdin)
    parser_set_input(param_inputf);

  /* parse the input file and convert it */
  yyparse_result = yyparse();

  if (yyparse_result) {
    EXIT("Unrecoverable parse error");
  }

  charset_close();
  saxEndDocument();

#ifdef WITH_CGI
  if (!cgi_status) {
    /* write the output */
    if (writeOutput()) 
      EXIT("Bad state in writeOutput()");

    /* close de output file */
    if (param_outputf != stdout)
      fclose(param_outputf);
  } else {
    cgi_write_output();
  }
#else
  /* write the output */
  if (writeOutput()) 
    EXIT("Bad state in writeOutput()");
  
  /* close de output file */
  if (param_outputf != stdout)
    fclose(param_outputf);
#endif

  /* show final messages */
  write_end_messages();
  freeMemory();

  return 0;
}