Beispiel #1
0
/*
 * KodeMsgTag, add the tagline to the reply message.
 */
static void
KodeMsgTag(void)
{
    /*@only@*/ byte CONSPTR base_ptr = get_CurTag();

    if (base_ptr != NULL) {
	const byte *ptr = base_ptr;
	const atp_CODE_T chrset = get_charset();

	/*@-strictops */
	while (*ptr != (byte) NUL_CHAR) {
	    if (chrset == ISOLAT1)	/*@=strictops */
		/* translate ISO Latin1 to DOS chars */
		*tamp = codepc[(unsigned) *ptr];
	    else
		*tamp = *ptr;
	    tamp++;
	    ptr++;
	    CountRecordChars++;
	    CountTotalChars++;
	    if (CountRecordChars > block_SIZE) {
		CountBlocks++;
		CountRecordChars = 1;
	    }
	}
	free_string((char *) base_ptr);
    }
}
Beispiel #2
0
/*
 * KodeXlat, translate the message from host to MSDOS character set.
 */
static void
KodeXlat(FILE * TmpaFile)
{
    byte ch;
    unsigned LinCt = 0;		/* counts line length */
    const atp_CODE_T chrset = get_charset();
    rewind(TmpaFile);
    while (fread(&ch, (size_t)1, one_record, TmpaFile) == one_record) {
	if (LinCt >= REPLY_LINE_LEN)
	    ch = '\n'; 
	/*@-strictops */                            /*@-usedef */
	LinCt = (ch == (byte)'\n') ? 0 : LinCt + 1; /*@=usedef */

	if (chrset == ISOLAT1 && ch >= HIGH_ASCII) 
	    ch = codepc[(unsigned)ch];	/* translate back to DOS set */
	ch = (byte)((ch == DOS_SPACE || ch == (byte)CNTRL_Z) ? SPC_CHAR : ch);

	/* skip ^M carriage returns */
	if (ch != (byte)CR) {		 /*@=strictops */
	    *tamp = ch;
	    tamp++;
	    CountRecordChars++;
	    CountTotalChars++;
	    if (CountRecordChars > block_SIZE) {
		CountBlocks++;
		CountRecordChars = 1;
	    }
	}
    }
}
Beispiel #3
0
static int
xml_getencodingr( xml *node )
{
	newstr *s;
	int n = CHARSET_UNKNOWN, m;
	if ( xml_tagexact( node, "xml" ) ) {
		s = xml_getattrib( node, "encoding" );
		if ( s && s->data ) {
			if ( !strcasecmp( s->data, "UTF-8" ) ) 
				n = CHARSET_UNICODE;
			else n = get_charset( s->data );
			if ( n==CHARSET_UNKNOWN ) {
				fprintf( stderr, "Warning: did not recognize "
					"encoding '%s'\n", s->data );
			}
		}
	}
        if ( node->down ) {
		m = xml_getencodingr( node->down );
		if ( m!=CHARSET_UNKNOWN ) n = m;
	}
        if ( node->next ) {
		m = xml_getencodingr( node->next );
		if ( m!=CHARSET_UNKNOWN ) n = m;
	}
	return n;
}
	TITANIUM_PROPERTY_GETTER(Buffer, type)
	{
		if (value__.IsString()) {
			return get_context().CreateString(Titanium::Codec::Constants::to_string(get_charset()));
		} else {
			return get_context().CreateString(Titanium::Codec::Constants::to_string(get_type()));
		}
	}
Beispiel #5
0
bool set_iconv(smb_iconv_t* t, const char* to, const char* from)
{
	smb_iconv_t cd = (smb_iconv_t)-1;

	if (to && from) {
		to   = get_charset(to);
		from = get_charset(from);
		cd   = smb_iconv_open(to, from);
		if (cd == ((smb_iconv_t)-1)) {
			return false;
		}
	}
	if ((*t != (smb_iconv_t)NULL) && (*t != (smb_iconv_t)-1)) {
		smb_iconv_close(*t);
	}
	*t = cd;
	return true;
}
CharsetMap::RecodeStatus CharsetMap::recode(Int32 *lengths, int From, int To, 
                                            const void *void_src, 
                                            void *void_dest) const
{    
    Int32 &total_read = lengths[0];     // IN/OUT
    Int32 &total_written = lengths[1];  // IN/OUT
    my_wc_t wide;
    my_wc_t mystery_char = '?';  // used in place of unmappable characters
    const unsigned char * src = (const unsigned char *) void_src;
    unsigned char * dest = (unsigned char *) void_dest;
    CHARSET_INFO * csFrom = get_charset(From, MYF(0));
    CHARSET_INFO * csTo  =  get_charset(To, MYF(0));
    
    if(! (csTo && csFrom)) return RECODE_BAD_CHARSET;

    Int32 src_len = lengths[0];
    Int32 dest_len = lengths[1];
    const unsigned char * src_end = src + src_len;
    unsigned char * dest_end = dest + dest_len;
    total_read = 0 ;            // i.e. lengths[0] = 0;
    total_written = 0;          // i.e. lengths[1] = 0;

    while(src < src_end) {
        /* First recode from source character to 32-bit wide character */
        int nread = csFrom->cset->mb_wc(csFrom, &wide, src, src_end);
        if(nread < 0) return RECODE_BUFF_TOO_SMALL; 
        if(nread == 0) return RECODE_BAD_SRC;
        
        /* Then recode from wide character to target character */
        int nwritten = csTo->cset->wc_mb(csTo, wide, dest, dest_end);
        if(nwritten == MY_CS_ILUNI) {
            /* Character does not exist in target charset */
            nwritten = csTo->cset->wc_mb(csTo, mystery_char, dest, dest_end);
        }
        if(nwritten < 0) return RECODE_BUFF_TOO_SMALL;

        total_read += nread;            src  += nread;    
        total_written += nwritten;      dest += nwritten;
    }
    
    return RECODE_OK;  
}
Beispiel #7
0
void print_charset( UINT cp, int w, char *tt)
{
  char buf[100];
  const char *t = tt;
  if (cp)
  	t=get_charset (cp);
  sprintf (buf,"\"%s\"", t);
  if (strlen(t))
	  print_w(buf, w);
	else
		print_w(" NULL",w);
}
Beispiel #8
0
void _gale_charsets(void) {
	struct gale_global_data *G = gale_global;
	struct gale_encoding *fallback;

	/* Set up character encodings. */

	fallback = get_charset(G_("GALE_CHARSET"),NULL);
	if (NULL == fallback) fallback = gale_make_default_encoding();
	if (NULL == fallback) fallback = get_charset(G_("CHARSET"),NULL);
	if (NULL == fallback) fallback = gale_make_encoding(G_("ASCII"));

	G->enc_console = get_charset(G_("GALE_CHARSET_CONSOLE"),fallback);
	G->enc_filesys = get_charset(G_("GALE_CHARSET_FILESYSTEM"),fallback);
	G->enc_environ = get_charset(G_("GALE_CHARSET_ENVIRON"),fallback);
	G->enc_cmdline = get_charset(G_("GALE_CHARSET_CMDLINE"),fallback);
	G->enc_sys = get_charset(G_("GALE_CHARSET_SYSTEM"),fallback);
}
Beispiel #9
0
/*
 * Title - prints opening ATP banner.
 */
void 
Title(void)
{
white(); 
high();
printf("\n\n\n");

#define grBGN1 "\t   \016x%s%s"
#define grBGN2 "\t   \016x\017%s%s"
#define grBGN3 "\t   \016x%s%s  %s"
#define grEND1 "\016x\017\n"
#define grEND2 "\016xaa\017\n"

#if 0
#define grON    "\016"
#define grOFF   "\017"
#define grX1     grON "x" 
#define grX2     grON "x"  grOFF
#define grX3     grON "xaa" grOFF
#define grBGN1 "\t   " grX1
#define grBGN2 "\t   " grX2
#define grEND1 grX1  "\n"
#define grEND2 grX3  "\n"
#endif

if(graphics){
printf("\t   \016lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk\017\n");
printf(grBGN3 , "   lqqqqqqqk  lqqqqqqqk  lqqqqqqqk   \017Ver.", ATPVER , grEND1 );
printf(grBGN1 , "   x lqqqk xa mqqk lqqja x lqqqk xa              ", grEND1 ); 
printf(grBGN1 , "   x xa  x xa  aax xaaaa x xa  x xa              ", grEND2 ); 
printf(grBGN1 , "   x mqqqj xa    x xa    x mqqqj xa              ", grEND2 );
printf(grBGN1 , "   x lqqqk xa    x xa    x lqqqqqja              ", grEND2 );
printf(grBGN1 , "   x xaaax xa    x xa    x xaaaaaaa              ", grEND2 ); 
printf(grBGN1 , "   mqja  mqja    mqja    mqja                    ", grEND2 );
printf(grBGN1 , "     aa    aa      aa      aa \017QWK PACKET READER  ", grEND2 );
printf(grBGN2 , "                                                 ", grEND2 );
printf(grBGN2 , "                                                 ", grEND2 );
printf(grBGN2 , " Copyright 1992,1993,1997 (c) Thomas McWilliams  ", grEND2 ); 
printf(grBGN2 , "                                                 ", grEND2 ); 
printf(grBGN2 , "   Free Software subject to terms of Free Soft-  ", grEND2 ); 
printf(grBGN2 , "   ware Foundation GNU General Public License.   ", grEND2 ); 
printf(grBGN2 , "   ABSOLUTELY NO WARRANTY,  type `show terms'    ", grEND2 ); 
printf("\t   \016mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqjaa\017\n");
printf("\t   \016   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\017\n");
/*@-strictops */
}else if(get_charset() != CHRDOS) { /* latin1 or 7bit character set without VT102 graphics */
/*@=strictops */

printf("\t   +-------------------------------------------------+\n");
printf("\t   |    ======    =========   ========    Ver.%s |\n", ATPVER);
printf("\t   |   ===  ===   =========   ==     ==              |\n"); 
printf("\t   |   ==    ==      ===      ==     ==              |\n"); 
printf("\t   |   ========      ===      ========               |\n");
printf("\t   |   ==    ==      ===      ==                     |\n");
printf("\t   |   ==    ==      ===      ==                     |\n");       
printf("\t   |   ==    ==      ===      ==  QWK PACKET READER  |\n");
printf("\t   |                                                 |\n");
printf("\t   |                                                 |\n");
printf("\t   | Copyright 1992,1993,1997 (c) Thomas McWilliams  |\n"); 
printf("\t   |                                                 |\n"); 
printf("\t   |   Free Software subject to terms of Free Soft-  |\n"); 
printf("\t   |   ware Foundation GNU General Public License.   |\n"); 
printf("\t   |   ABSOLUTELY NO WARRANTY,  type `show terms'    |\n"); 
printf("\t   +-------------------------------------------------+\n\n");
} else {  /* msdos character set */
printf("\t   ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿\n");
printf("\t   ³   ÚÄÄÄÄÄÄÄ¿  ÚÄÄÄÄÄÄÄ¿  ÚÄÄÄÄÄÄÄ¿    Ver.%s ³\n", ATPVER );
printf("\t   ³   ³ ÚÄÄÄ¿ ³± ÀÄÄ¿ ÚÄÄÙ± ³ ÚÄÄÄ¿ ³±              ³\n");
printf("\t   ³   ³ ³±  ³ ³±  ±±³ ³±±±± ³ ³±  ³ ³±              ³±±\n");
printf("\t   ³   ³ ÀÄÄÄÙ ³±    ³ ³±    ³ ÀÄÄÄÙ ³±              ³±±\n");
printf("\t   ³   ³ ÚÄÄÄ  ³±    ³ ³±    ³ ÚÄÄÄÄÄÙ±              ³±±\n");
printf("\t   ³   ³ ³±±±³ ³±    ³ ³±    ³ ³±±±±±±±              ³±±\n");
printf("\t   ³   ÀÄÙ±  ÀÄÙ±    ÀÄÙ±    ÀÄÙ±                    ³±±\n");
printf("\t   ³     ±±    ±±      ±±      ±±  QWK PACKET READER ³±±\n");
printf("\t   ³                                                 ³±±\n");
printf("\t   ³                                                 ³±±\n");
printf("\t   ³  Copyright 1992,1993,1997 (c) Thomas McWilliams ³±±\n");
printf("\t   ³                                                 ³±±\n");
printf("\t   ³   Free Software subject to terms of Free Soft-  ³±±\n");
printf("\t   ³   ware Foundation GNU General Public License.   ³±±\n");
printf("\t   ³   ABSOLUTELY NO WARRANTY,  type `show terms'    ³±±\n");
printf("\t   ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ±±\n");
printf("\t      ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±\n");
}
  clear();
}
Beispiel #10
0
static void
helper_toolbar_prop_list_update(GtkWidget *widget, gchar **lines)
{
    GtkWidget *button = NULL;
    guint i;
    gchar **cols;
    gchar *charset;
    const gchar *indication_id, *iconic_label, *label, *tooltip_str;
    const gchar *action_id, *is_selected;
    GList *prop_buttons, *tool_buttons;
    GtkSizeGroup *sg;
    char *display_time;
    gboolean is_hidden;
    GtkWidget *toplevel;

    if (prop_menu_showing)
        return;

    charset = get_charset(lines[1]);

    prop_buttons = g_object_get_data(G_OBJECT(widget), OBJECT_DATA_PROP_BUTTONS);
    tool_buttons = g_object_get_data(G_OBJECT(widget), OBJECT_DATA_TOOL_BUTTONS);
    sg  = g_object_get_data(G_OBJECT(widget), OBJECT_DATA_SIZE_GROUP);

    if (prop_buttons) {
        g_list_foreach(prop_buttons, prop_button_destroy, NULL);
        g_list_free(prop_buttons);
        g_object_set_data(G_OBJECT(widget), OBJECT_DATA_PROP_BUTTONS, NULL);
    }

    if (tool_buttons) {
        g_list_foreach(tool_buttons, tool_button_destroy, NULL);
        g_list_free(tool_buttons);
        g_object_set_data(G_OBJECT(widget), OBJECT_DATA_TOOL_BUTTONS, NULL);
    }

    display_time
        = uim_scm_c_symbol( uim_scm_symbol_value( "toolbar-display-time" ) );
    is_hidden = strcmp(display_time, "mode");
    for (i = 0; lines[i] && strcmp("", lines[i]); i++) {
        gchar *utf8_str = convert_charset(charset, lines[i]);

        if (utf8_str != NULL) {
            cols = g_strsplit(utf8_str, "\t", 0);
            g_free(utf8_str);
        } else {
            cols = g_strsplit(lines[i], "\t", 0);
        }

        if (cols && cols[0]) {
            if (!strcmp("branch", cols[0]) && has_n_strs(cols, 4)) {
                indication_id = cols[1];
                iconic_label  = safe_gettext(cols[2]);
                tooltip_str   = safe_gettext(cols[3]);
                button = prop_button_create(widget,
                                            indication_id, iconic_label, tooltip_str);
                append_prop_button(widget, button);

                if (!is_hidden && (!strcmp(indication_id, "direct")
                                   || g_str_has_suffix(indication_id, "_direct"))) {
                    is_hidden = TRUE;
                }
            } else if (!strcmp("leaf", cols[0]) && has_n_strs(cols, 7)) {
                indication_id = cols[1];
                iconic_label  = safe_gettext(cols[2]);
                label         = safe_gettext(cols[3]);
                tooltip_str   = safe_gettext(cols[4]);
                action_id     = cols[5];
                is_selected   = cols[6];
                prop_button_append_menu(button,
                                        indication_id, label, tooltip_str, action_id,
                                        is_selected);
            }
            g_strfreev(cols);
        }
    }
    toplevel = gtk_widget_get_toplevel(widget);
    is_hidden = (is_hidden && strcmp(display_time, "always"));
#if GTK_CHECK_VERSION(2, 18, 0)
    if (gtk_widget_get_visible(toplevel) == is_hidden) {
#else
    if (GTK_WIDGET_VISIBLE(toplevel) == is_hidden) {
#endif
        if (is_hidden) {
            gtk_widget_hide(toplevel);
        } else {
            gint x = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(toplevel),
                                     "position_x"));
            gint y = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(toplevel),
                                     "position_y"));
            gtk_window_move(GTK_WINDOW(toplevel), x, y);
            gtk_widget_show(toplevel);
        }
    }

    /* create tool buttons */
    /* FIXME! command menu and buttons should be customizable. */
    for (i = 0; i < command_entry_len; i++) {
        GtkWidget *tool_button;
        GtkWidget *img;

        if (!command_entry[i].show_button)
            continue;

        tool_button = gtk_button_new();

        set_button_style(tool_button,
                         GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget),
                                         OBJECT_DATA_TOOLBAR_TYPE)));

        g_object_set_data(G_OBJECT(tool_button), OBJECT_DATA_BUTTON_TYPE,
                          GINT_TO_POINTER(BUTTON_TOOL));
        g_object_set_data(G_OBJECT(tool_button), OBJECT_DATA_COMMAND,
                          (gpointer)command_entry[i].command);
        if (command_entry[i].icon)
            img = gtk_image_new_from_stock(command_entry[i].icon,
                                           GTK_ICON_SIZE_MENU);
        else {
            img = gtk_label_new("");
            gtk_label_set_markup(GTK_LABEL(img), command_entry[i].label);
        }
        if (img)
            gtk_container_add(GTK_CONTAINER(tool_button), img);
        gtk_button_set_relief(GTK_BUTTON(tool_button), GTK_RELIEF_NONE);
        gtk_size_group_add_widget(sg, tool_button);
        g_signal_connect(G_OBJECT(tool_button), "button-press-event",
                         G_CALLBACK(button_pressed), widget);
        g_signal_connect(G_OBJECT(tool_button), "clicked",
                         G_CALLBACK(tool_button_clicked_cb), widget);

        /* tooltip */
        gtk_widget_set_tooltip_text(tool_button, _(command_entry[i].desc));

        append_tool_button(widget, tool_button);
    }

    gtk_widget_show_all(widget);
    g_free(charset);
}

static void
helper_toolbar_check_custom()
{
    guint i;

    for (i = 0; i < command_entry_len; i++)
        command_entry[i].show_button =
            uim_scm_symbol_value_bool(command_entry[i].custom_button_show_symbol);

    with_dark_bg =
        uim_scm_symbol_value_bool("toolbar-icon-for-dark-background?");
}
Beispiel #11
0
bool ParserImpl::open(Param *param) {
  close();

  std::string rcfile = param->get<std::string>("rcfile");
  if (rcfile.empty()) {
    rcfile = get_default_rc();
  }

  if (!param->load(rcfile.c_str())) {
    WHAT << param->what();
    close();
    return false;
  }

  std::string rcpath = rcfile;
  remove_filename(&rcpath);

  REPLACE_PROFILE(param, rcpath, "parser-model");
  REPLACE_PROFILE(param, rcpath, "chunker-model");
  REPLACE_PROFILE(param, rcpath, "ne-model");
  REPLACE_PROFILE(param, rcpath, "chasenrc");

  close();

  input_layer_   =
      static_cast<InputLayerType>(param->get<int>("input-layer"));
  output_layer_  =
      static_cast<OutputLayerType>(param->get<int>("output-layer"));
  output_format_ =
      static_cast<FormatType>(param->get<int>("output-format"));

  const int action = param->get<int>("action-mode");
  const int ne     = param->get<int>("ne");
  if (action == TRAINING_MODE) {
    output_format_ = FORMAT_NONE;
  }

  if (output_layer_ != OUTPUT_DEP) {
    output_format_ = FORMAT_LATTICE;
  }

  charset_ = get_charset(*param, rcpath);
  posset_ = decode_posset(param->get<std::string>("posset").c_str());

  CHECK_FALSE(charset_ != -1);
  CHECK_FALSE(posset_ != -1);

  switch (input_layer_) {
    case INPUT_RAW_SENTENCE:  // case 1
      {
        switch (output_layer_) {
          case OUTPUT_POS:
            PUSH_ANALYZER(MorphAnalyzer);
            if (ne) PUSH_ANALYZER(NE);
            break;
          case OUTPUT_CHUNK:
            PUSH_ANALYZER(MorphAnalyzer);
            if (ne) PUSH_ANALYZER(NE);
            PUSH_ANALYZER(Chunker);
            break;
          case OUTPUT_SELECTION:
            PUSH_ANALYZER(MorphAnalyzer);
            if (ne) PUSH_ANALYZER(NE);
            PUSH_ANALYZER(Chunker);
            PUSH_ANALYZER(Selector);
            break;
          case OUTPUT_DEP:
            PUSH_ANALYZER(MorphAnalyzer);
            if (ne) PUSH_ANALYZER(NE);
            PUSH_ANALYZER(Chunker);
            PUSH_ANALYZER(Selector);
            PUSH_ANALYZER(DependencyParser);
            break;
          default:
            break;
        }
        break;
      }

    case INPUT_POS:  // case 2
      {
        if (ne) PUSH_ANALYZER(NE);
        switch (output_layer_) {
          case OUTPUT_POS:
            break;
          case OUTPUT_CHUNK:
            PUSH_ANALYZER(Chunker);
            break;
          case OUTPUT_SELECTION:
            PUSH_ANALYZER(Chunker);
            PUSH_ANALYZER(Selector);
            break;
          case OUTPUT_DEP:
            PUSH_ANALYZER(Chunker);
            PUSH_ANALYZER(Selector);
            PUSH_ANALYZER(DependencyParser);
            break;
          default:
            break;
        }
        break;
      }

    case INPUT_CHUNK:  // case 3
      {
        switch (output_layer_) {
          case OUTPUT_POS:
          case OUTPUT_CHUNK:
            break;
          case OUTPUT_SELECTION:
            PUSH_ANALYZER(Selector);
            break;
          case OUTPUT_DEP:
            PUSH_ANALYZER(Selector);
            PUSH_ANALYZER(DependencyParser);
            break;
          default:
            break;
        }
        break;
      }

    case  INPUT_SELECTION:  // case 4
      {
        switch (output_layer_) {
          case OUTPUT_POS:
          case OUTPUT_CHUNK:
          case OUTPUT_SELECTION:
            break;
          case OUTPUT_DEP:
            PUSH_ANALYZER(DependencyParser);
            break;
          default:
            break;
        }
        break;
      }

    default:
      break;
  }

  return true;
}
Beispiel #12
0
/* This function parses the header of an email that
 * can be read from an open file handle.
 * Note, T2D: There are a few short cuts that should be fixed.
 */
int
parse_header(FILE *fp, email_hdr_t *eh, char *errstr)
{
	int len;
	int blank;

  /* various flags to indicate what header parts were already seen */
	int header= 0;
	int gotsubj= 0;
	int gotenc= 0;
	int gotset= 0;
	int waitbound= 0;

	char *p;
	char *s;
	char buf[CDDBBUFSIZ];
	char buf2[CDDBBUFSIZ];
	char set[CDDBBUFSIZ];
	char enc[CDDBBUFSIZ];

	eh->eh_flags = 0;
	eh->eh_class = EC_NONE;
	eh->eh_charset = CC_US_ASCII;
	eh->eh_encoding = CE_7BIT;

	while(get_hdr_line(buf, sizeof(buf), fp)) {
		strcpy(buf2, buf); /* pointless copy */
		blank = (buf[0] == '\n' ||
			 (buf[0] == '\r' && buf[1] == '\n'));

		if(!strncmp(buf, from, strlen(from)) ||
		    !strncmp(buf, x_cddbd_from, strlen(rpath)) ||
		    (!header && !strncmp(buf, rpath, strlen(rpath)))) {
			p = buf;
			while(*p != '\0' && !isspace(*p))
				p++;
			while(*p != '\0' && isspace(*p))
				p++;

			if(*p != '\0') {
				cpy_sender(p, eh->eh_rcpt, eh->eh_to,
				    eh->eh_host);

				eh->eh_flags |= EH_RCPT;
				header++;
			}

			continue;
		}

		if(!header)
			continue;

		if(!strncmp(buf, subj, strlen(subj))) {
			p = buf;
			while(*p != '\0' && !isspace(*p))
				p++;
			while(*p != '\0' && isspace(*p))
				p++;

			if(sscanf(p, cmd_send_subj, eh->eh_serial))
				eh->eh_class = EC_COMMAND;
			else if(sscanf(p, sub_send_subj, eh->eh_category,
			    &eh->eh_discid) == 2)
				eh->eh_class = EC_SUBMIT;
			else {
				strcpy(errstr, "Malformed subject in header");
				return EE_ERROR;
			}

			strip_crlf(p);
			strncpy(eh->eh_subj, p, sizeof(eh->eh_subj));
			eh->eh_subj[sizeof(eh->eh_subj) - 1] = '\0';

			gotsubj++;
			eh->eh_flags |= EH_SUBJECT;
		}
		else if(!cddbd_strncasecmp(buf, x_cddbd_crc,
		    strlen(x_cddbd_crc))) {
			/* Skip junk. */
			p = buf + strlen(x_cddbd_crc) + 1;
			while(*p != '\0' && !isxdigit(*p))
				p++;

			/* Find the crc. */
			if(sscanf(p, "%255[a-zA-Z0-9]", buf2) != 1 ||
			    strlen(buf2) != CDDBXCRCLEN) {
				cddbd_snprintf(errstr, CDDBBUFSIZ,
				    "Malformed %s in header", x_cddbd_crc);

				return EE_ERROR;
			}

			strcpy(eh->eh_crc, buf2);
			eh->eh_flags |= EH_CRC;
		}
		else if(!cddbd_strncasecmp(buf, x_cddbd_echo,
		    strlen(x_cddbd_echo))) {
			/* Skip junk. */
			p = buf + strlen(x_cddbd_echo) + 1;
			while(*p != '\0' && isspace(*p))
				p++;

			/* Find the echo string. */
			if(sscanf(p, "%255[^\n\r]", buf2) != 1 ||
			    strlen(buf2) > CDDBXECHOLEN) {
				cddbd_snprintf(errstr, CDDBBUFSIZ,
				    "Invalid %s in header", x_cddbd_echo);

				return EE_ERROR;
			}

			strcpy(eh->eh_echo, buf2);
			eh->eh_flags |= EH_ECHO;
		}
		else if(!cddbd_strncasecmp(buf, x_cddbd_note,
		    strlen(x_cddbd_note))) {
			/* Skip junk. */
			p = buf + strlen(x_cddbd_note) + 1;
			while(*p != '\0' && isspace(*p))
				p++;

			/* Find the note string. */
			if(sscanf(p, "%255[^\n\r]", buf2) != 1 ||
			    strlen(buf2) > CDDBXNOTELEN) {
				cddbd_snprintf(errstr, CDDBBUFSIZ,
				    "Invalid %s in header", x_cddbd_note);

				return EE_ERROR;
			}

			strcpy(eh->eh_note, buf2);
			eh->eh_flags |= EH_NOTE;
		}
		else if(!cddbd_strncasecmp(buf, content_type,
		    strlen(content_type))) {
			if((p = cddbd_strcasestr(buf, charset)) != 0) {
				/* Skip junk. */
				p += strlen(charset);
				while(*p != '\0' && !isalpha(*p) &&
				    !isdigit(*p))
					p++;

				/* Find the charset. */
				if(sscanf(p, "%255[a-zA-Z0-9_-]", set) != 1) {
					cddbd_snprintf(errstr, CDDBBUFSIZ,
					    "Malformed %s in header",
					    content_type);
					return EE_ERROR;
				}

				gotset++;
			}

			if((p = cddbd_strcasestr(buf, boundary)) != 0) {
				/* Skip junk. */
				p += strlen(boundary);
				while(*p != '\0') {
					if(*p == '=') {
						p++;
						break;
					}
					p++;
				}

				if(*p ==  '"') {
					p++;
					s = "%255[^\"]";
				}
				else
					s = "%255s";

				/* Find the boundary string. */
				if(sscanf(p, s, eh->eh_boundary) != 1) {
					cddbd_snprintf(errstr, CDDBBUFSIZ,
					    "Malformed %s in header",
					    content_type);
					return EE_ERROR;
				}

				len = strlen(eh->eh_boundary);
				if(eh->eh_boundary[len - 1] == '"' ||
				    eh->eh_boundary[len - 1] == ';')
					eh->eh_boundary[len - 1] = '\0';

				eh->eh_flags |= EH_BOUNDARY;

				waitbound++;
			}
		}
		else if(!cddbd_strncasecmp(buf, content_encoding,
		    strlen(content_encoding))) {
			/* Skip junk. */
			p = buf + strlen(content_encoding);
			while(*p != '\0' && !isalpha(*p) && !isdigit(*p))
				p++;

			/* Find the encoding. */
			if(sscanf(p, "%[a-zA-Z0-9_-]", enc) != 1) {
				cddbd_snprintf(errstr, CDDBBUFSIZ,
				    "Malformed %s in header", content_encoding);

				return EE_ERROR;
			}

			gotenc++;
		}
		else if(waitbound && strstr(buf, eh->eh_boundary) != NULL) {
			waitbound = 0;
		}
		else if(blank && !waitbound) {
			get_rmt_hostname(-1, eh->eh_host, rhost);

			if(!gotsubj) {
				strcpy(errstr, "Missing subject in header");
				return EE_ERROR;
			}

			if(gotenc && !get_encoding(enc, eh, errstr))
				return EE_ERROR;

			if(gotset && !get_charset(set, eh, errstr))
				return EE_ERROR;

			return EE_OK;
		}
	}

	if(waitbound)
		strcpy(errstr, "Missing boundary string");
	else
		strcpy(errstr, "Malformed email header");

	return EE_ERROR;
}
Beispiel #13
0
static void do_verify_prepare_field(MYSQL_RES *result,
unsigned int no, const char *name,
const char *org_name,
enum enum_field_types type,
const char *table,
const char *org_table, const char *db,
unsigned long length, const char *def,
const char *file, int line)
{
 MYSQL_FIELD *field;
 CHARSET_INFO *cs;
 ulonglong expected_field_length;

 if (!(field= mysql_fetch_field_direct(result, no)))
 {
   fprintf(stdout, "\n *** ERROR: FAILED TO GET THE RESULT ***");
   exit(1);
 }
 cs= get_charset(field->charsetnr, 0);
 DIE_UNLESS(cs);
 if ((expected_field_length= length * cs->mbmaxlen) > UINT_MAX32)
 expected_field_length= UINT_MAX32;
 if (!opt_silent)
 {
   fprintf(stdout, "\n field[%d]:", no);
   fprintf(stdout, "\n    name     :`%s`\t(expected: `%s`)", field->name, name);
   fprintf(stdout, "\n    org_name :`%s`\t(expected: `%s`)",
   field->org_name, org_name);
   fprintf(stdout, "\n    type     :`%d`\t(expected: `%d`)", field->type, type);
   if (table)
   fprintf(stdout, "\n    table    :`%s`\t(expected: `%s`)",
   field->table, table);
   if (org_table)	      
   fprintf(stdout, "\n    org_table:`%s`\t(expected: `%s`)",
   field->org_table, org_table);
   fprintf(stdout, "\n    database :`%s`\t(expected: `%s`)", field->db, db);
   fprintf(stdout, "\n    length   :`%lu`\t(expected: `%llu`)",
   field->length, expected_field_length);
   fprintf(stdout, "\n    maxlength:`%ld`", field->max_length);
   fprintf(stdout, "\n    charsetnr:`%d`", field->charsetnr);
   fprintf(stdout, "\n    default  :`%s`\t(expected: `%s`)",
   field->def ? field->def : "(null)", def ? def: "(null)");
   fprintf(stdout, "\n");
 }
 DIE_UNLESS(strcmp(field->name, name) == 0);
 DIE_UNLESS(strcmp(field->org_name, org_name) == 0);
 /*
 XXX: silent column specification change works based on number of
 bytes a column occupies. So CHAR -> VARCHAR upgrade is possible even
 for CHAR(2) column if its character set is multibyte.
 VARCHAR -> CHAR downgrade won't work for VARCHAR(3) as one would
 expect.
 */
 if (cs->mbmaxlen == 1)
 {
   if (field->type != type)
   {
     fprintf(stderr,
     "Expected field type: %d,  got type: %d in file %s, line %d\n",
     (int) type, (int) field->type, file, line);
     DIE_UNLESS(field->type == type);
   }
 }
 if (table)
 DIE_UNLESS(strcmp(field->table, table) == 0);
 if (org_table)
 DIE_UNLESS(strcmp(field->org_table, org_table) == 0);
 DIE_UNLESS(strcmp(field->db, db) == 0);
 /*
 Character set should be taken into account for multibyte encodings, such
 as utf8. Field length is calculated as number of characters * maximum
 number of bytes a character can occupy.
 */
 if (length && (field->length != expected_field_length))
 {
   fprintf(stderr, "Expected field length: %llu,  got length: %lu\n",
   expected_field_length, field->length);
   DIE_UNLESS(field->length == expected_field_length);
 }
 if (def)
 DIE_UNLESS(strcmp(field->def, def) == 0);
}
Beispiel #14
0
int
main(int argc,
     char** argv)
{
  FT_Face     face;
  long        max_bytes = CACHE_SIZE * 1024;
  char*       test_string = NULL;
  int         size = FACE_SIZE;
  int         max_iter = 0;
  double      max_time = BENCH_TIME;
  int         compare_cached = 0;
  int         i;

  while ( 1 )
  {
    int  opt;


    opt = getopt( argc, argv, "Cc:f:m:pr:s:t:b:" );

    if ( opt == -1 )
      break;

    switch ( opt )
    {
    case 'C':
      compare_cached = 1;
      break;
    case 'c':
      max_iter = atoi( optarg );
      break;
    case 'f':
      load_flags = strtol( optarg, NULL, 16 );
      break;
    case 'm':
      max_bytes = atoi( optarg );
      max_bytes *= 1024;
      break;
    case 'p':
      preload = 1;
      break;
    case 'r':
      render_mode = (FT_Render_Mode)atoi( optarg );
      if ( render_mode >= FT_RENDER_MODE_MAX )
        render_mode = FT_RENDER_MODE_NORMAL;
      break;
    case 's':
      size = atoi( optarg );
      if ( size <= 0 )
        size = 1;
      else if ( size > 500 )
        size = 500;
      break;
    case 't':
      max_time = atof( optarg );
      break;
    case 'b':
      test_string = optarg;
      break;
    default:
      usage();
      break;
    }
  }

  argc -= optind;
  argv += optind;

  if ( argc != 1 )
    usage();

  if ( FT_Init_FreeType( &lib ) )
  {
    fprintf( stderr, "could not initialize font library\n" );

    return 1;
  }

  filename = *argv;

  if ( get_face( &face ) )
    goto Exit;

  if ( FT_IS_SCALABLE( face ) )
  {

    if ( FT_Set_Pixel_Sizes( face, size, size ) )
    {
      fprintf( stderr, "failed to set pixel size to %d\n", size );

      return 1;
    }
  }
  else
    size = face->available_sizes[0].width;

  FTC_Manager_New( lib, 0, 0, max_bytes, face_requester, face, &cache_man );

  font_type.face_id = (FTC_FaceID) 1;
  font_type.width   = (short) size;
  font_type.height  = (short) size;
  font_type.flags   = load_flags;

  for ( i = 0; i < N_FT_BENCH; i++ )
  {
    btest_t   test;
    FT_ULong  flags;


    if ( !TEST( 'a' + i ) )
      continue;

    test.title       = NULL;
    test.bench       = NULL;
    test.cache_first = 0;
    test.user_data   = NULL;

    switch ( i )
    {
    case FT_BENCH_LOAD_GLYPH:
      test.title = "Load";
      test.bench = test_load;
      benchmark( face, &test, max_iter, max_time );

      if ( compare_cached )
      {
        test.cache_first = 1;

        test.title = "Load (image cached)";
        test.bench = test_image_cache;
        benchmark( face, &test, max_iter, max_time );

        test.title = "Load (sbit cached)";
        test.bench = test_sbit_cache;
        benchmark( face, &test, max_iter, max_time );
      }
      break;
    case FT_BENCH_LOAD_ADVANCES:
      test.user_data = &flags;

      test.title = "Load_Advances (Normal)";
      test.bench = test_load_advances;
      flags      = FT_LOAD_DEFAULT;
      benchmark( face, &test, max_iter, max_time );

      test.title  = "Load_Advances (Fast)";
      test.bench  = test_load_advances;
      flags       = FT_LOAD_TARGET_LIGHT;
      benchmark( face, &test, max_iter, max_time );
      break;
    case FT_BENCH_RENDER:
      test.title = "Render";
      test.bench = test_render;
      benchmark( face, &test, max_iter, max_time );
      break;
    case FT_BENCH_GET_GLYPH:
      test.title = "Get_Glyph";
      test.bench = test_get_glyph;
      benchmark( face, &test, max_iter, max_time );
      break;
    case FT_BENCH_GET_CBOX:
      test.title = "Get_CBox";
      test.bench = test_get_cbox;
      benchmark( face, &test, max_iter, max_time );
      break;
    case FT_BENCH_CMAP:
      {
        bcharset_t  charset;


        get_charset( face, &charset );
        if ( charset.code )
        {
          test.user_data = (void*)&charset;


          test.title = "Get_Char_Index";
          test.bench = test_get_char_index;

          benchmark( face, &test, max_iter, max_time );

          if ( compare_cached )
          {
            test.cache_first = 1;

            test.title = "Get_Char_Index (cached)";
            test.bench = test_cmap_cache;
            benchmark( face, &test, max_iter, max_time );
          }

          free( charset.code );
        }
      }
      break;
    case FT_BENCH_CMAP_ITER:
      test.title = "Iterate CMap";
      test.bench = test_cmap_iter;
      benchmark( face, &test, max_iter, max_time );
      break;
    case FT_BENCH_NEW_FACE:
      test.title = "New_Face";
      test.bench = test_new_face;
      benchmark( face, &test, max_iter, max_time );
      break;
    case FT_BENCH_EMBOLDEN:
      test.title = "Embolden";
      test.bench = test_embolden;
      benchmark( face, &test, max_iter, max_time );
      break;
    }
  }

Exit:
  /* The following is a bit subtle: When we call FTC_Manager_Done, this
   * normally destroys all FT_Face objects that the cache might have created
   * by calling the face requester.
   *
   * However, this little benchmark uses a tricky face requester that
   * doesn't create a new FT_Face through FT_New_Face but simply pass a
   * pointer to the one that was previously created.
   *
   * If the cache manager has been used before, the call to FTC_Manager_Done
   * discards our single FT_Face.
   *
   * In the case where no cache manager is in place, or if no test was run,
   * the call to FT_Done_FreeType releases any remaining FT_Face object
   * anyway.
   */
  if ( cache_man )
    FTC_Manager_Done( cache_man );

  FT_Done_FreeType( lib );

  return 0;
}
Beispiel #15
0
void http_mime_node::load_param(const char* path)
{
	ifstream in;
	if (in.open_read(path) == false)
	{
		logger_error("open file %s error(%s)", path, last_serror());
		return;
	}
	off_t begin = get_bodyBegin();
	off_t end = get_bodyEnd();
	if (begin < 0 || end < 0 || begin >= end)
	{
		logger_error("invalid file offset, begin: %d, end: %d",
			(int) begin, (int) end);
		return;
	}

	if (in.fseek(begin, SEEK_SET) == -1)
	{
		logger_error("fseek file %s error(%s), begin: %d",
			path, last_serror(), (int) begin);
		return;
	}

	size_t len = end - begin;
	char* buf = (char*) acl_mymalloc(len + 1);
	if (in.read(buf, len) == -1)
	{
		acl_myfree(buf);
		logger_error("read file %s error(%s)", path, last_serror());
		return;
	}
	buf[len] = 0;
	char* ptr = buf + len - 1;
	while (ptr >= buf)
	{
		if (*ptr == '\r' || *ptr == '\n'
			|| *ptr == ' ' || *ptr == '\t')
		{
			*ptr-- = 0;
			continue;
		}
		break;
	}
	if (*buf == 0)
	{
		acl_myfree(buf);
		return;
	}

	char* value = acl_url_decode(buf);
	if (value == NULL)
		value = buf;
	else
		acl_myfree(buf);

	const char* fromCharset = get_charset();
	const char* toCharset = get_toCharset();
	if (fromCharset && *fromCharset && toCharset && *toCharset
		&& strcasecmp(fromCharset, toCharset))
	{
		charset_conv conv;
		string tmp;
		if (conv.convert(fromCharset, toCharset,
			value, strlen(value), &tmp) == true)
		{
			param_value_ = acl_mystrdup(tmp.c_str());
			acl_myfree(value);
		}
		else
			param_value_ = value;
	}
	else
		param_value_ = value;
}
LibMuttng::LibMuttng () {
  if (!debugObj) {

    core_init();

    /* before we have all library-internal options, get other stuff */
    get_userinfo();
    get_hostinfo();

    debugObj = new Debug (Homedir, NULL, Umask);

    /* register all options for library globally */
    Option* d = new IntOption("debug_level","0",&DebugLevel,0,5);
    connectSignal<LibMuttng,Option*>(d->sigOptionChange,this,
                                     &LibMuttng::setDebugLevel);
    ConfigManager::regOption(d);
    ConfigManager::regOption(new StringOption("send_charset",
                                        "us-ascii:iso-8859-1:iso-8859-15:utf-8",
                                        &SendCharset));
    ConfigManager::regOption(new StringOption("charset",
                                        get_charset(),
                                        &Charset));

    ConfigManager::regOption(new SysOption("muttng_core_version","\""CORE_VERSION"\""));
    ConfigManager::regOption(new SysOption("muttng_libmuttng_version",
                                     "\""LIBMUTTNG_VERSION"\""));
    ConfigManager::regOption(new SysOption("muttng_hostname",Hostname));
    ConfigManager::regOption(new SysOption("muttng_system",OSName));
    ConfigManager::regOption(new SysOption("muttng_dnsname",Fqdn.str));

    /* register all options within library modules */
    LocalMailbox::reg();
#ifdef LIBMUTTNG_POP3
    POP3Mailbox::reg();
#endif
#ifdef LIBMUTTNG_NNTP
    NNTPMailbox::reg();
#endif
#ifdef LIBMUTTNG_IMAP
    ImapMailbox::reg();
#endif
    MboxMailbox::reg();
    MmdfMailbox::reg();
    MHMailbox::reg();
    MaildirMailbox::reg();

    SubjectHeader::reg();

    Connection::reg();
#ifdef LIBMUTTNG_SSL_OPENSSL
    SSLConnection::reg();
#endif
#ifdef LIBMUTTNG_SSL_GNUTLS
    TLSConnection::reg();
#endif

#ifdef LIBMUTTNG_CACHE_QDBM
    Cache::reg();
#endif

#ifdef CORE_LIBICONV
    ConfigManager::regFeature("iconv");
#endif
#ifdef CORE_INTL
    ConfigManager::regFeature("intl");
#endif
#ifdef CORE_PCRE
    ConfigManager::regFeature("pcre");
#endif
#ifdef CORE_LIBIDN
    ConfigManager::regFeature("idna");
#endif

    buffer_init(&AttachMarker);
    buffer_add_str(&AttachMarker,"\033]9;",3);
    buffer_add_snum(&AttachMarker,time(NULL),-1);
    buffer_add_ch(&AttachMarker,'\a');

    connectSignal(displayMessage,this,&LibMuttng::debugMessage);
    connectSignal(displayProgress,this,&LibMuttng::debugProgress);
    connectSignal(displayWarning,this,&LibMuttng::debugWarning);
    connectSignal(displayError,this,&LibMuttng::debugError);
  }

  this->debug = debugObj;
}
Beispiel #17
0
static my_bool mrn_snippet_prepare(st_mrn_snip_info *snip_info, UDF_ARGS *args,
                                   char *message, grn_snip **snippet)
{
  unsigned int i;
  CHARSET_INFO *cs;
  grn_ctx *ctx = &snip_info->ctx;
  long long snip_max_len;
  long long snip_max_num;
  long long skip_leading_spaces;
  long long html_escape;
  int flags = GRN_SNIP_COPY_TAG;
  grn_snip_mapping *mapping = NULL;
  grn_rc rc;
  String *result_str = &snip_info->result_str;

  *snippet = NULL;
  snip_max_len = *((long long *) args->args[1]);
  snip_max_num = *((long long *) args->args[2]);

  if (args->arg_type[3] == STRING_RESULT) {
    if (!(cs = get_charset_by_name(args->args[3], MYF(0)))) {
      snprintf(message, MYSQL_ERRMSG_SIZE,
               "Unknown charset: <%s>", args->args[3]);
      goto error;
    }
  } else {
    uint charset_id = static_cast<uint>(*((long long *) args->args[3]));
    if (!(cs = get_charset(charset_id, MYF(0)))) {
      snprintf(message, MYSQL_ERRMSG_SIZE,
               "Unknown charset ID: <%u>", charset_id);
      goto error;
    }
  }
  if (!mrn::encoding::set(ctx, cs)) {
    snprintf(message, MYSQL_ERRMSG_SIZE,
             "Unsupported charset: <%s>", cs->name);
    goto error;
  }

  if (!(cs->state & (MY_CS_BINSORT | MY_CS_CSSORT))) {
    flags |= GRN_SNIP_NORMALIZE;
  }

  skip_leading_spaces = *((long long *) args->args[4]);
  if (skip_leading_spaces) {
    flags |= GRN_SNIP_SKIP_LEADING_SPACES;
  }

  html_escape = *((long long *) args->args[5]);
  if (html_escape) {
    mapping = (grn_snip_mapping *) -1;
  }

  *snippet = grn_snip_open(ctx, flags, static_cast<unsigned int>(snip_max_len),
                           static_cast<unsigned int>(snip_max_num),
                           "", 0, "", 0, mapping);
  if (ctx->rc) {
    snprintf(message, MYSQL_ERRMSG_SIZE,
             "Failed to open grn_snip: <%s>", ctx->errbuf);
    goto error;
  }

  for (i = 8; i < args->arg_count; i += 3) {
    rc = grn_snip_add_cond(ctx, *snippet,
                           args->args[i], args->lengths[i],
                           args->args[i + 1], args->lengths[i + 1],
                           args->args[i + 2], args->lengths[i + 2]);
    if (rc) {
      snprintf(message, MYSQL_ERRMSG_SIZE,
               "Failed to add a condition to grn_snip: <%s>", ctx->errbuf);
      goto error;
    }
  }

  result_str->set_charset(cs);
  return FALSE;

error:
  if (*snippet) {
    grn_snip_close(ctx, *snippet);
  }
  return TRUE;
}
const bool * CharsetMap::isMultibyte(int cs_number) const
{
  CHARSET_INFO * cset = get_charset(cs_number, MYF(0));
  if(cset == 0) return 0;
  return use_mb(cset) ? & m_true_result : & m_false_result;
}
const char * CharsetMap::getMysqlName(int csnum) const 
{
    CHARSET_INFO *cs = get_charset(csnum, MYF(0));
    return cs ? cs->csname : 0;
}
Beispiel #20
0
int main(int argc, const char** argv)
{
	int is_utf8;
#if defined HAVE_LIBPOPT
	int rc = 0;
	poptContext poptCtx;
	poptCtx = poptGetContext("natspec", argc, (const char **)argv, options, 0);
	poptSetOtherOptionHelp(poptCtx, "[OPTION...]");
	while (rc >= 0) {
		if((rc = poptGetNextOpt(poptCtx)) < -1) {
			fprintf(stderr, "Error on option %s: %s.\nRun '%s --help' to see a full list of available command line options.\n",
				poptBadOption(poptCtx, 0),
				poptStrerror(rc),
				argv[0]);
			exit(1);
		}
	}
/*
  { int flag_help=1;
  if (argv) {
      while (poptPeekArg(poptCtx))
		flag_help=0;
		//locale = (char *)poptGetArg(poptCtx);
      poptFreeContext(poptCtx);
	}
*/	
	if(flag_help)
	{
		poptPrintHelp(poptCtx, stdout, 0);
		exit(0);
	}

#else
	fprintf(stderr, "Compiled without popt. Exit\n");
	exit(1);
#endif

        /* Print overall information by default */
	if (argc == 1)
		info = 1;

	if (version || info)
	{
		printf("%s, compiled %s\n", PACKAGE_STRING,__DATE__);
		if (!info)
			exit(0);
	}
	if (transliterate)
	{
		char *str = NULL;
		if (argv) {
#if defined HAVE_LIBPOPT
			while (poptPeekArg(poptCtx))
				str = (char *)poptGetArg(poptCtx);
			poptFreeContext(poptCtx);
#else
			fprintf(stderr, "Compiled without popt. Exit\n");
			exit(1);
#endif
		}
		if ( str != NULL)
		{
			setlocale(LC_ALL,"");
			str = natspec_convert_with_translit(str, "", transliterate);
			puts(str);
		}
		exit(0);
	}
	if (info)
	{
		printf(" === Overall locale information ===\n");
		verbose = 1;
	}
	locale = natspec_get_current_locale();
	if (get_user_locale || info)
	{
		VERBOSE("Current user locale: ");
		printf("%s", locale);
		if (verbose && !natspec_internal_get_locale_from_env())
			printf(" (got from system locale)");
		puts("");
	}
	if (get_system_locale || info)
	{
		VERBOSE("System locale: ");
		printf("%s\n", natspec_get_system_locale());
		if (!info)
			exit(0);
	}
	if (fsenc || info)
	{
		const char *buf;
		VERBOSE("Filename encoding in iconv/nls form: ");
		buf = natspec_get_filename_encoding("");
		printf("%s\n",buf);
		if (!info)
			exit(0);
	}
	if (country_id || info)
	{
		int id;
		VERBOSE("Country ID (for DOS): ");
		id = -1; /* natspec_get_country_id(); */
		printf("%d\n", id);
		if (!info)
			exit(0);
	}
	if (fcodepage || info)
	{
		int cp;
		VERBOSE("Codepage of DOS: ");
		cp = natspec_get_codepage_by_charset(
			natspec_get_charset_by_locale(NATSPEC_DOSCS, locale));
		printf("%d\n", cp);
		if (!info)
			exit(0);
	}

	if (info)
	{
		char *types[]={"UNIX","WIN","DOS","MAC"};
		int i;
		for (i=0; i<sizeof(types)/sizeof(char*);i++)
			get_charset(types[i]);
		setlocale(LC_ALL,"");
		printf("After setlocale:\n");
#ifdef HAVE_LANGINFO_H
		printf("\tnl_langinfo(CODESET): %s\n",nl_langinfo(CODESET));
#endif
		printf("\tnatspec_get_charset: %s\n",natspec_get_charset());
	}

	if (charset_type)
		get_charset(charset_type);
	is_utf8 = natspec_locale_is_utf8("");

	if (utf8 || info)
	{
		VERBOSE("Current locale is%sin UTF8 encoding\n",(is_utf8 ? " " : " NOT "));
		if (!info)
			return is_utf8 ? 0 : 1;
	}
	return 0;
}