print.c (43093983) print.c (ed7f0ec9)
1/* $NetBSD: print.c,v 1.19 2011/09/15 17:52:53 plunky Exp $ */
1/* $NetBSD: print.c,v 1.20 2013/10/18 20:47:06 christos Exp $ */
2
3/*-
4 * Copyright (c) 2009 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Iain Hibbert.
9 *

--- 15 unchanged lines hidden (view full) ---

25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#include <sys/cdefs.h>
2
3/*-
4 * Copyright (c) 2009 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Iain Hibbert.
9 *

--- 15 unchanged lines hidden (view full) ---

25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#include <sys/cdefs.h>
33__RCSID("$NetBSD: print.c,v 1.19 2011/09/15 17:52:53 plunky Exp $");
33__RCSID("$NetBSD: print.c,v 1.20 2013/10/18 20:47:06 christos Exp $");
34
35#include <ctype.h>
36#include <iconv.h>
37#include <langinfo.h>
38#include <sdp.h>
39#include <stdbool.h>
40#include <stdio.h>
41#include <stdlib.h>

--- 786 unchanged lines hidden (view full) ---

828 printf("v%d.%d\n", (v >> 8), (v & 0xff));
829}
830
831static void
832print_codeset_string(const char *src, size_t srclen, const char *codeset)
833{
834 char buf[50], *dst;
835 iconv_t ih;
34
35#include <ctype.h>
36#include <iconv.h>
37#include <langinfo.h>
38#include <sdp.h>
39#include <stdbool.h>
40#include <stdio.h>
41#include <stdlib.h>

--- 786 unchanged lines hidden (view full) ---

828 printf("v%d.%d\n", (v >> 8), (v & 0xff));
829}
830
831static void
832print_codeset_string(const char *src, size_t srclen, const char *codeset)
833{
834 char buf[50], *dst;
835 iconv_t ih;
836 size_t n, dstlen;
836 size_t dstlen;
837
838 dst = buf;
839 dstlen = sizeof(buf);
840
841 ih = iconv_open(nl_langinfo(CODESET), codeset);
842 if (ih == (iconv_t)-1) {
843 printf("Can't convert %s string\n", codeset);
844 return;
845 }
846
837
838 dst = buf;
839 dstlen = sizeof(buf);
840
841 ih = iconv_open(nl_langinfo(CODESET), codeset);
842 if (ih == (iconv_t)-1) {
843 printf("Can't convert %s string\n", codeset);
844 return;
845 }
846
847 n = iconv(ih, &src, &srclen, &dst, &dstlen);
847 (void)iconv(ih, &src, &srclen, &dst, &dstlen);
848
849 iconv_close(ih);
850
851 printf("\"%.*s%s\n", (int)(sizeof(buf) - dstlen), buf,
852 (srclen > 0 ? " ..." : "\""));
853}
854
855/*

--- 828 unchanged lines hidden ---
848
849 iconv_close(ih);
850
851 printf("\"%.*s%s\n", (int)(sizeof(buf) - dstlen), buf,
852 (srclen > 0 ? " ..." : "\""));
853}
854
855/*

--- 828 unchanged lines hidden ---