From 20554c224bb8e4dfec150889ebd91c6494fb92ce Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 9 Dec 2004 07:53:21 +0000 Subject: [PATCH] Implemented commands negcharset and displaycharset that specifies character set for negotiation and display respectively. Command charset works as usual and is implemented using the two. --- client/client.c | 79 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 54 insertions(+), 25 deletions(-) diff --git a/client/client.c b/client/client.c index 6b52688..b46b330 100644 --- a/client/client.c +++ b/client/client.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2004, Index Data * See the file LICENSE for details. * - * $Id: client.c,v 1.258 2004-12-02 14:04:17 adam Exp $ + * $Id: client.c,v 1.259 2004-12-09 07:53:21 adam Exp $ */ #include @@ -2995,50 +2995,77 @@ int cmd_marccharset(const char *arg) return 1; } -int cmd_charset(const char* arg) +int cmd_displaycharset(const char *arg) { - char l1[30], l2[30]; + char l1[30]; - *l1 = *l2 = 0; - if (sscanf(arg, "%29s %29s", l1, l2) < 1) + *l1 = 0; + if (sscanf(arg, "%29s", l1) < 1) { - printf("Current negotiation character set is `%s'\n", - negotiationCharset ? negotiationCharset: "none"); - printf("Current output character set is `%s'\n", + printf("Display character set is `%s'\n", outputCharset ? outputCharset: "none"); - return 1; - } - xfree (negotiationCharset); - negotiationCharset = NULL; - if (*l1 && strcmp(l1, "-")) - { - negotiationCharset = xstrdup(l1); - printf ("Character set negotiation : %s\n", negotiationCharset); } else - printf ("Character set negotiation disabled\n"); - if (*l2) { xfree (outputCharset); outputCharset = 0; - if (!strcmp(l2, "auto") && codeset) + if (!strcmp(l1, "auto") && codeset) { if (codeset) { - printf ("output charset: %s\n", codeset); + printf ("Display character set: %s\n", codeset); outputCharset = xstrdup(codeset); - - } else printf ("No codeset found on this system\n"); } - else if (strcmp(l2, "-")) - outputCharset = xstrdup(l2); + else if (strcmp(l1, "-") && strcmp(l1, "none")) + outputCharset = xstrdup(l1); else - printf ("Output charset conversion disabled\n"); + printf ("Display character set conversion disabled\n"); } + return 1; +} +int cmd_negcharset(const char *arg) +{ + char l1[30]; + + *l1 = 0; + if (sscanf(arg, "%29s", l1) < 1) + { + printf("Current negotiation character set is `%s'\n", + negotiationCharset ? negotiationCharset: "none"); + return 1; + } + xfree (negotiationCharset); + negotiationCharset = NULL; + if (*l1 && strcmp(l1, "-") && strcmp(l1, "none")) + { + negotiationCharset = xstrdup(l1); + printf ("Character set negotiation : %s\n", negotiationCharset); + } + else + printf ("Character set negotiation disabled\n"); + return 1; +} + +int cmd_charset(const char* arg) +{ + char l1[30], l2[30]; + + *l1 = *l2 = 0; + if (sscanf(arg, "%29s %29s", l1, l2) < 1) + { + cmd_negcharset(""); + cmd_displaycharset(""); + } + else + { + cmd_negcharset(l1); + if (*l2) + cmd_displaycharset(l2); + } return 1; } @@ -3919,6 +3946,8 @@ static struct { {"packagename", cmd_packagename, "",NULL,0,NULL}, {"proxy", cmd_proxy, "[('tcp'|'ssl')][':']",NULL,0,NULL}, {"charset", cmd_charset, " ",NULL,0,NULL}, + {"negcharset", cmd_negcharset, "",NULL,0,NULL}, + {"displaycharset", cmd_displaycharset, "",NULL,0,NULL}, {"marccharset", cmd_marccharset, "",NULL,0,NULL}, {"lang", cmd_lang, "",NULL,0,NULL}, {".", cmd_source_echo, "",NULL,1,NULL}, -- 1.7.10.4