main.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1995 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <libgen.h>
#include <libintl.h>
#include <locale.h>
#include <unistd.h>
#include "genmsg.h"
#define MSG_SUFFIX ".msg"
#define NEW_SUFFIX ".new"
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "genmsg"
#endif
/*
* External functions.
*/
extern void write_msgfile(char *); /* from util.c */
extern int read_projfile(char *); /* from util.c */
extern void write_projfile(char *); /* from util.c */
extern void read_msgfile(char *); /* from util.c */
extern int is_writable(char *); /* from util.c */
extern void init_lex(void); /* from genmsg.l */
extern void init_linemsgid(void); /* from genmsg.l */
/* Program name. */
char *program;
/* File pointer for auto-message-numbering. */
/* Input source file. */
char *srcfile;
/* Tag for message comments. */
/* Tag for set number comments. */
/* Mode mask to define the genmsg tasks. */
/*
* This flag will be TRUE if a catgets() call is found
* in the input file.
*/
int is_cat_found = FALSE;
/* Suppress an error message if this flag is TRUE. */
int suppress_error = FALSE;
/* Prefix and suffix of messages for testing. */
static void usage(void);
static void validate_options(void);
int
{
int c;
extern char *optarg; /* from getopt */
extern int optind; /* from getopt */
extern int yyparse(void);
char *newprojfile = NULL;
int do_msgfile = FALSE;
int tmpfd = -1;
(void) textdomain(TEXT_DOMAIN);
switch (c) {
case 'o':
break;
case 'a':
break;
case 'l':
break;
case 'r':
break;
case 'p':
break;
case 'g':
break;
case 'c':
break;
case 's':
break;
case 'b':
break;
case 'n':
break;
case 'm':
break;
case 'M':
break;
case 't':
break;
case 'd':
break;
case 'f':
break;
case 'x':
break;
case 'v':
break;
default:
usage();
break;
}
}
usage();
}
if (IsActiveMode(AutoNumMode)) {
int len;
char *tmp;
if (read_projfile(projfile)) {
== NULL) {
}
} else {
}
}
}
}
if (!msgfile) {
== NULL) {
}
}
}
if (IsActiveMode(PreProcessMode)) {
char cmd[MAXPATHLEN];
gettext("fatal: cannot execute \"%s\""),
cpppath);
}
} else {
prg_err(/* stupid cstyle */
goto end;
}
}
init_lex();
yyparse();
if (IsActiveMode(PreProcessMode)) {
goto end;
}
}
if (is_cat_found == FALSE) {
if (!IsActiveMode(PreProcessMode)) {
}
goto end;
}
if (!do_msgfile) {
do_msgfile = TRUE;
}
char newfile[MAXPATHLEN];
char tmpfile[32];
if (IsActiveMode(OverwriteMode)) {
} else {
tmp, NEW_SUFFIX);
}
gettext("cannot create \"%s\": permission denied"),
newfile);
goto end;
}
prg_err(/* stupid cstyle */
if (!IsActiveMode(PreProcessMode)) {
}
goto end;
}
prg_err(/* stupid cstyle */
if (!IsActiveMode(PreProcessMode)) {
}
goto end;
}
if (IsActiveMode(PreProcessMode)) {
prg_err(/* stupid cstyle */
goto end;
}
} else {
}
init_lex();
yyparse();
goto end;
}
if (!IsActiveMode(PreProcessMode)) {
}
end:
optind++;
}
if (!do_msgfile) { /* no more business. */
return (EXIT_SUCCESS);
}
}
projfile : newprojfile);
}
return (EXIT_SUCCESS);
}
static void
validate_options(void)
{
/* -r doesn't work with either -a or -l. */
if (IsActiveMode(ReverseMode) &&
usage();
}
/* -b should be accompanied with -c, -s, -d, and -n. */
if (IsActiveMode(BackCommentMode) &&
(!IsActiveMode(MsgCommentMode) &&
!IsActiveMode(LineInfoMode))) {
usage();
}
if (IsActiveMode(ProjectMode) &&
usage();
}
}
static void
usage(void)
{
gettext("Usage: %s [-o message-file] [-a] [-d] [-p preprocessor]\n"
" [-s set-tag] [-c message-tag] [-b] [-n]\n"
" [-l project-file] [-r] [-f] [-g project-file]\n"
" [-m prefix] [-M suffix] [-t] [-x] files ...\n"),
program);
}