示例#1
0
文件: punch.c 项目: arkamar/wdtools
int
main(int argc, char *argv[]) {
	FILE *fp = stdin;
	static char *buf = NULL;
	static size_t size = 0;
	int label, day = 0;

	ARGBEGIN {
	case 'b':
		options.flags |= F_PRINT_BOTH;
		break;
	case 'c':
		columns = atoi(EARGF(usage()));
		break;
	case 'h':
		options.inhour = atoi(EARGF(usage()));
		break;
	case 'm':
		options.inmin = atoi(EARGF(usage()));
		break;
	case 'n':
		options.flags |= F_PRINT_NUM;
		break;
	case 's':
		options.insec = atoi(EARGF(usage()));
		break;
	case 't':
		options.flags |= F_PRINT_TIME;
		break;
	default:
		usage();
	} ARGEND;

	initdata();

	while (getline(&buf, &size, fp) > 0) {
		char * time;
		struct interval interval;
		if ((time = istask(buf, &interval))) {
			label = getlabelid(buf);
			set(day, &interval, label);
			continue;
		}
		int rd;
		if ((rd = getdayid(buf)) >= 0) {
			day = rd;
			memset(data + day * arrsize * LENGTH(convert), 0, arrsize * LENGTH(convert) * sizeof(unsigned short));
			daycounter[day] = 1;
		}
	}

	initcolumnsinterval();

	maketablehdr();
	if (options.flags & (F_PRINT_NUM | F_PRINT_BOTH))
		maketable(label, numtable);
	if ((options.flags & (F_PRINT_NUM | F_PRINT_BOTH)) ^ F_PRINT_NUM)
		maketable(label, marktable);

	free(data);
	free(buf);
	return EXIT_SUCCESS;
}
示例#2
0
/*{
** Name: main()	- collation compiler
**
** Description:
**      Top level of collation compiler.
**
** Inputs:
**	argc			argument count
**	argv			argument vector
**
** Outputs:
**	none
**
** History:
**      03-may-89 (anton)
**          Created.
**	17-Jun-89 (anton)
**	    Moved to ADU from CL
**	21-Dec-89 (anton)
**	    Fixed usage message - removed magic number - bug 9193
**    	01-jun-92 (andys)
**          Correct spelling of 'language'. [bug 44495]
**	21-jun-93 (geri)
**	    PCexit with FAIL if error encountered; added CMset_attr call
**	    to intialize CM attribute table; chaged read-in char set
**	    to use II_CHARSET symbol. These were in the 6.4 version.
**	14-mar-2001 (stephenb)
**	    Add optional unicode indicator.
**	06-sep-2002 (hanch04)
**	    The 32 and 64 bit version need to be run so call PCspawnlp64.
**	14-Jun-2004 (schka24)
**	    Use (safe) canned charmap setting routine.
**	04-Mar-2005 (hanje04)
**	    SIR 114034
**	    Add support for reverse hybrid builds, i.e. 64bit exe needs to
** 	    call 32bit version.
**	09-Mar-2007 (gupsh01)
**	    Add support for upper/lower case operations.
**	20-Jun-2009 (kschendel) SIR 122138
**	    Hybrid add-on symbol changed, fix here.
*/
main(
int	argc,
char	*argv[])
{
    ADULTABLE	*tbl;
    ADUUCETAB	*utbl;
    STATUS   	stat;
    CL_ERR_DESC cl_err;
    bool	unicode = FALSE;
#if defined(conf_BUILD_ARCH_32_64) && defined(BUILD_ARCH32)
    char        *lp64enabled;
#endif

    _VOID_ MEadvise(ME_INGRES_ALLOC);

#if defined(conf_BUILD_ARCH_32_64) && defined(BUILD_ARCH32)

    /*
    ** Try to exec the 64-bit version
    */
    NMgtAt("II_LP64_ENABLED", &lp64enabled);
    if ( (lp64enabled && *lp64enabled) &&
       ( !(STbcompare(lp64enabled, 0, "ON", 0, TRUE)) ||
         !(STbcompare(lp64enabled, 0, "TRUE", 0, TRUE))))
    {
        PCspawnlp64(argc, argv);
    }
#endif  /* hybrid */
#if defined(conf_BUILD_ARCH_64_32) && defined(BUILD_ARCH64)
    {
	char        *lp32enabled;
	/*
	** Try to exec the 32-bit version
	*/
	NMgtAt("II_LP32_ENABLED", &lp32enabled);
	if ( (lp32enabled && *lp32enabled) &&
	( !(STbcompare(lp32enabled, 0, "ON", 0, TRUE)) ||
	!(STbcompare(lp32enabled, 0, "TRUE", 0, TRUE))))
	    PCspawnlp32(argc, argv);
    }
#endif  /* reverse hybrid */

    /* Set CM character set stuff */

    stat = CMset_charset(&cl_err);
    if (stat != OK)
    {
	SIprintf("Error while processing character set attribute file.\n");
	PCexit(FAIL);
    }

    _VOID_ SIeqinit();

    if (argc != 3 && argc != 4)
    {
        SIprintf("Usage: aducompile description-file language-file [-u]\n");
        PCexit(FAIL);
    }

    if (argc == 4)
    {
	/* must be -u flag for unicode */
	if (STbcompare(argv[3], 0, "-u", 0, TRUE))
	{
	    SIprintf("Usage: aducompile description-file language-file [-u]\n");
	    PCexit(FAIL);
	}
	unicode = TRUE;
    }

    if (unicode)
    {
	utbl = makeutable(argv[1]);
	if (!utbl)
	{
	    SIprintf("aducompile: description-file syntax error\n");
	    PCexit(FAIL);
	}

	stat = dumputbl(utbl, argv[2]);
	if (stat)
	    SIprintf("aducompile: dumptbl %s failed with %x\n", argv[2], stat);
    }
    else
    {
	tbl = maketable(argv[1]);
	if (!tbl)
	{
	    SIprintf("aducompile: description-file syntax error\n");
	    PCexit(FAIL);
	}

	stat = dumptbl(tbl, argv[2]);
	if (stat)
	    SIprintf("aducompile: dumptbl %s failed with %x\n", argv[2], stat);
    }
    PCexit(stat ? FAIL : OK);
}