File: islang.c

package info (click to toggle)
w3m 0.5.3%2Bgit20230121-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 11,520 kB
  • sloc: ansic: 59,204; sh: 4,331; perl: 4,217; javascript: 2,315; makefile: 913; cpp: 869; ruby: 776; awk: 78; sed: 16
file content (40 lines) | stat: -rw-r--r-- 748 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * Copyright (c) 2000, NBG01720@nifty.ne.jp
 *
 * To compile this program:
 *      gcc -Zomf -Zcrtdll -O2 -Wall -s islang.c
 */
#define INCL_DOSNLS
#include <os2.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int
main(int argc, char **argv)
{
    if (argc <= 1)
	return 1;

    if (isdigit((int)*argv[1])) {
	unsigned long CpList[8], CpSize;
	APIRET rc = DosQueryCp(sizeof(CpList), CpList, &CpSize);
	if (rc)
	    return rc;
	while (--argc > 0)
	    if (*CpList == atoi(argv[argc]))
		return 0;
    }
    else {
	char *lang = getenv("LANG");
	if (!lang || !*lang) {
	    lang = getenv("LANGUAGE");
	    if (!lang || !*lang)
		return 1;
	}
	if (!strnicmp(lang, argv[1], 2))
	    return 0;
    }
    return 1;
}