cfl.c

来自「CForms, by Lars Berntzon (Stockholm, Swe」· C语言 代码 · 共 107 行

C
107
字号
#include "config.h"#include "cforms.h"#include "../patchlevel.h"#ifndef lintstatic volatile char *SccsId = "@(#) cfl.c,v 1.4 1993/01/08 16:31:22 lasse Exp";#endifstatic char *prog;/****************************************************************** *		M A I N *		------- * Description: *	Main routine for the cforms linker, cfl. * * Arguments: *	filenames of forms * ******************************************************************/intmain(int argc, char **argv){    FILE *out;    char module[200];    char *p;    int i;    int comma = 0;    /*     * Get name of program.     */    if ((prog = strrchr(argv[0], SLASH)) != NULL) prog++;    else prog = argv[0];    /*     * Check args.     */    if (argc < 2) {	(void)fprintf(stderr, "usage: %s file ...\n", prog);	exit(1);    }    /*     * Print version if required.     */    if (strcmp(argv[1], "-v") == 0) {	(void)printf("CForms linker version %s\n", PATCHLEVEL);	exit(0);    }    /*     * Open the output.     */    if ((out = fopen("cforms.c", "w")) == NULL) {	(void)fprintf(stderr, "%s: failed to open output file: cforms.c", prog);	exit(1);    }    /*     * Print head.     */    (void)fprintf(out, "#include <stdio.h>\n");    (void)fprintf(out, "#include <cforms.h>\n");    /*     * Print external declarations.     */    for(i = 1; i < argc; i++)    {            /* Strip path */        if (p = strrchr(argv[i], SLASH)) p++;        else p = argv[i];            /* Strip extension */        strncpy(module, p, sizeof module);        if (p = strrchr(module, '.')) *p = 0;	(void)fprintf(out, "extern struct module _cf_module_%s;\n", module);    }    /*      * Make the list of modules.     */    (void)fprintf(out, "struct module *_cf_modules[] = {\n");    for(i = 1; i < argc; i++)    {	if (comma) {	    (void)fprintf(out, ",\n");	}	comma = 1;	    /* Strip path */	if (p = strrchr(argv[i], SLASH)) p++;	else p = argv[i];	    /* Strip extension */	strncpy(module, p, sizeof module);	if (p = strrchr(module, '.')) *p = 0;	(void)fprintf(out, "    &_cf_module_%s", module);    }    (void)fprintf(out, ",\n    NULL\n};\n");    fclose(out);    return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?