time_t SpaceDbResultOldFormat::get_my_time (char *dbloca)
{
  char strbuf[BUFFER_MAX_LEN];
  char volname[PATH_MAX] = { '\0' };
  time_t mytime = time (NULL);;
  struct stat statbuf;

  for (int i = 0; i < volumes.size(); i++)
    {
      if (uStringEqual (volumes[i].purpose, "DATA")
          || uStringEqual (volumes[i].purpose, "INDEX"))
        {
          strcpy (volname, volumes[i].vol_name);
          snprintf (strbuf, BUFFER_MAX_LEN, "%s/%s", dbloca, volname);
          if (!stat (strbuf, &statbuf))
            {
              mytime = statbuf.st_mtime;
            }
        }
    }

  return mytime;
}
示例#2
0
static Bool
parseArgs(int argc, char *argv[])
{
register int i;

    args.copies=	1;
    args.grid=		0;
    args.level1=	True;
    args.scaleToFit=	True;
    args.wantColor=	False;
    args.wantSymbols=	COMMON_SYMBOLS;
    args.wantKeycodes=	True;
    args.wantDiffs=	False;
    args.wantEPS=	False;
    args.label=		LABEL_AUTO;
    args.baseLabelGroup=0;
    args.nLabelGroups=	1;
    args.nTotalGroups=	0;
    args.nKBPerPage=	0;
    args.labelLevel=	0;
    for (i=1;i<argc;i++) {
	if ((argv[i][0]!='-')||(uStringEqual(argv[i],"-"))) {
	    if (inputFile==NULL) {
		inputFile= argv[i];
	    }
	    else if (outputFile==NULL) {
		outputFile= argv[i];
	    }
	    else {
		uWarning("Too many file names on command line\n");
		uAction("Compiling %s, writing to %s, ignoring %s\n",
					inputFile,outputFile,argv[i]);
	    }
	}
	else if ((strcmp(argv[i],"-?")==0)||(strcmp(argv[i],"-help")==0)) {
	    Usage(argc,argv);
	    exit(0);
	}
	else if (strcmp(argv[i],"-color")==0) {
	    args.wantColor= True;
	}
#ifdef DEBUG
	else if (strcmp(argv[i],"-d")==0) {
	    if ((i>=(argc-1))||(!isdigit(argv[i+1][0]))) {
		debugFlags= 1;
	    }
	    else {
		sscanf(argv[++i],"%i",&debugFlags);
	    }
	    uInformation("Setting debug flags to %d\n",debugFlags);
	}
#endif
	else if (strcmp(argv[i],"-dflts")==0) {
#ifdef NOTYET
	    computeDflts= True;
#endif
	    uWarning("Compute defaults not implemented yet\n");
	}
	else if (strcmp(argv[i],"-diffs")==0) {
	    args.wantDiffs= True;
	}
	else if (strcmp(argv[i],"-eps")==0) {
	    args.wantEPS= True;
	}
	else if (strcmp(argv[i],"-fit")==0) {
	    args.scaleToFit= True;
	}
	else if (strcmp(argv[i],"-full")==0) {
	    args.scaleToFit= False;
	}
	else if (strcmp(argv[i],"-grid")==0) {
	    int tmp;
	    if (++i>=argc) {
		uWarning("Grid frequency not specified\n");
		uAction("Trailing \"-grid\" option ignored\n");
	    }
	    else if ((sscanf(argv[i],"%i",&tmp)!=1)||(tmp<1)) {
		uWarning("Grid frequency must be an integer > zero\n");
		uAction("Illegal frequency %d ignored\n",tmp);
	    }	 
	    else args.grid= tmp;
	}
#ifdef NOTYET
	else if (strncmp(argv[i],"-I",2)==0) {
	    if (!XkbAddDirectoryToPath(&argv[i][2])) {
		uAction("Exiting\n");
		exit(1);
	    }
	    uInternalError("Includes not implemented yet\n");
	}
#endif
	else if (strcmp(argv[i],"-if")==0) {
	    if (++i>=argc) {
		uWarning("Internal Font name not specified\n");
		uAction("Trailing \"-if\" option ignored\n");
	    }
	    else outputFont= argv[i];
	}
	else if (strcmp(argv[i],"-kc")==0) {
	    args.wantKeycodes= True;
	}
	else if (strcmp(argv[i],"-label")==0) {
	    if (++i>=argc) {
		uWarning("Label type not specified\n");
		uAction("Trailing \"-label\" option ignored\n");
	    }
	    else if (uStrCaseEqual(argv[i],"none")) 
		args.label= LABEL_NONE;
	    else if (uStrCaseEqual(argv[i],"name")) 
		args.label= LABEL_KEYNAME;
	    else if (uStrCaseEqual(argv[i],"code")) 
		args.label= LABEL_KEYCODE;
	    else if (uStrCaseEqual(argv[i],"symbols")) 
		args.label= LABEL_SYMBOLS;
	    else {
		uWarning("Unknown label type \"%s\" specified\n",argv[i]);
		uAction("Ignored\n");
	    }
	}
	else if (strcmp(argv[i],"-lc")==0) {
	    if (++i>=argc) {
		uWarning("Locale not specified\n");
		uAction("Trailing \"-lc\" option ignored\n");
	    }
	    else wantLocale= argv[i];
	}
	else if (strcmp(argv[i],"-lg")==0) {
	    int tmp;
	    if (++i>=argc) {
		uWarning("Label group not specified\n");
		uAction("Trailing \"-lg\" option ignored\n");
	    }
	    else if ((sscanf(argv[i],"%i",&tmp)!=1)||(tmp<1)||(tmp>4)) {
		uWarning("Label group must be an integer in the range 1..4\n");
		uAction("Illegal group %d ignored\n",tmp);
	    }	 
	    else args.baseLabelGroup= tmp-1;
	}
	else if (strcmp(argv[i],"-ll")==0) {
	    int tmp;
	    if (++i>=argc) {
		uWarning("Label level not specified\n");
		uAction("Trailing \"-ll\" option ignored\n");
	    }
	    else if ((sscanf(argv[i],"%i",&tmp)!=1)||(tmp<1)||(tmp>255)) {
		uWarning("Label level must be in the range 1..255\n");
		uAction("Illegal level %d ignored\n",tmp);
	    }	 
	    else args.labelLevel= tmp-1;
	}
	else if (strcmp(argv[i],"-level1")==0)
	    args.level1= True;
	else if (strcmp(argv[i],"-level2")==0)
	    args.level1= False;
	else if (strcmp(argv[i],"-mono")==0) {
	    args.wantColor= False;
	}
	else if (strcmp(argv[i],"-n")==0) {
	    int tmp;
	    if (++i>=argc) {
		uWarning("Number of copies not specified\n");
		uAction("Trailing \"-n\" option ignored\n");
	    }
	    else if ((sscanf(argv[i],"%i",&tmp)!=1)||(tmp<1)) {
		uWarning("Number of copies must be an integer > zero\n");
		uAction("Illegal count %d ignored\n",tmp);
	    }	 
	    else args.copies= tmp;
	}
	else if (strcmp(argv[i],"-nokc")==0) {
	    args.wantKeycodes= False;
	}
	else if (strcmp(argv[i],"-nkg")==0) {
	    int tmp;
	    if (++i>=argc) {
		uWarning("Number of groups per key not specified\n");
		uAction("Trailing \"-nkg\" option ignored\n");
	    }
	    else if ((sscanf(argv[i],"%i",&tmp)!=1)||(tmp<1)||(tmp>2)) {
		uWarning("Groups per key must be in the range 1..2\n");
		uAction("Illegal number of groups %d ignored\n",tmp);
	    }	 
	    else args.nLabelGroups= tmp;
	}
	else if (strcmp(argv[i],"-npk")==0) {
	    int tmp;
	    if (++i>=argc) {
		uWarning("Number of keyboards per page not specified\n");
		uAction("Trailing \"-npk\" option ignored\n");
	    }
	    else if ((sscanf(argv[i],"%i",&tmp)!=1)||(tmp<1)||(tmp>2)) {
		uWarning("Keyboards per page must be in the range 1..2\n");
		uAction("Illegal number of keyboards %d ignored\n",tmp);
	    }	 
	    else args.nKBPerPage= tmp;
	}
	else if (strcmp(argv[i],"-ntg")==0) {
	    int tmp;
	    if (++i>=argc) {
		uWarning("Total number of groups not specified\n");
		uAction("Trailing \"-ntg\" option ignored\n");
	    }
	    else if ((sscanf(argv[i],"%i",&tmp)!=1)||(tmp<1)||(tmp>4)) {
		uWarning("Total number of groups must be in the range 1..4\n");
		uAction("Illegal number of groups %d ignored\n",tmp);
	    }	 
	    else args.nTotalGroups= tmp;
	}
	else if (strcmp(argv[i],"-o")==0) {
	    if (++i>=argc) {
		uWarning("No output file specified\n");
		uAction("Trailing \"-o\" option ignored\n");
	    }
	    else if (outputFile!=NULL) {
		uWarning("Multiple output files specified\n");
		uAction("Compiling %s, ignoring %s\n",outputFile,argv[i]);
	    }
	    else outputFile= argv[i];
	}
	else if (strncmp(argv[i],"-R",2)==0) {
	    if (argv[i][2]=='\0') {
		uWarning("No root directory specified\n");
		uAction("Ignoring -R option\n");
	    }
	    else if (rootDir!=NULL) {
		uWarning("Multiple root directories specified\n");
		uAction("Using %s, ignoring %s\n",rootDir,argv[i]);
	    }
	    else rootDir= &argv[i][2];
	}
	else if (strcmp(argv[i],"-pict")==0) {
	    if (++i>=argc) {
		uWarning("No level of pictographs specified\n");
		uAction("Trailing \"-pict\" option ignored\n");
	    }
	    else if (strcmp(argv[i],"none")==0)
		args.wantSymbols= NO_SYMBOLS;
	    else if (strcmp(argv[i],"common")==0)
		args.wantSymbols= COMMON_SYMBOLS;
	    else if (strcmp(argv[i],"all")==0)
		args.wantSymbols= ALL_SYMBOLS;
	    else if (outputFile!=NULL) {
		uWarning("Unknown pictograph level specified\n");
		uAction("Ignoring illegal value %s\n",argv[i]);
	    }
	}
	else if ((strcmp(argv[i],"-synch")==0)||(strcmp(argv[i],"-s")==0)) {
	    synch= True;
	}
	else if (strcmp(argv[i],"-w")==0) {
	    if ((i>=(argc-1))||(!isdigit(argv[i+1][0]))) {
		warningLevel= 0;
	    }
	    else {
		int itmp;
		if (sscanf(argv[++i],"%i",&itmp))
		    warningLevel = itmp;
	    }
	}
	else {
	    uError("Unknown flag \"%s\" on command line\n",argv[i]);
	    Usage(argc,argv);
	    return False;
	}
    }
    if (rootDir) {
	if (warningLevel>8) {
	    uWarning("Changing root directory to \"%s\"\n",rootDir);
	}
	if ((chdir(rootDir)<0) && (warningLevel>0)) {
	    uWarning("Couldn't change root directory to \"%s\"\n",rootDir);
	    uAction("Root directory (-R) option ignored\n");
	}
    }
    if (outputFont!=NULL) {
	Bool  ok;
	FILE *file= NULL;

	if (outputFile==NULL) {
	    outputFile= uAlloc(strlen(outputFont)+5);
	    sprintf(outputFile,"%s.pfa",outputFont);
	}
	else if (uStringEqual(outputFile,"-"))
	    file= stdout;

	if (file==NULL)
	    file= fopen(outputFile,"w");
	   	 
	if (!file) {
	    uError("Couldn't open \"%s\" to dump internal font \"%s\"\n",
						outputFile,outputFont);
	    uAction("Exiting\n");
	    exit(1);
	}
	ok= DumpInternalFont(file,outputFont);
	if (file!=stdout)
	    fclose(file);
	if (!ok) {
	    uWarning("No internal font to dump\n");
	    if (file!=stdout) {
		uAction("Removing \"%s\"\n",outputFile);
		unlink(outputFile);
	    }
	}
	exit((ok!=0));
    }
    if (inputFile==NULL) {
	uError("No input file specified\n");
	Usage(argc,argv);
	return False;
    }
    else if (uStringEqual(inputFile,"-")) {
	/* Nothing */
    }
    else if (strchr(inputFile,':')==NULL) {
	int	len= strlen(inputFile);
	if ((len>4)&&(strcmp(&inputFile[len-4],".xkm")==0)) {
	    /* Nothing */
	}
	else {
	    FILE *file;
	    file= fopen(inputFile,"r");
	    if (file) {
		fclose(file);
	    }
	    else {
		fprintf(stderr,"Cannot open \"%s\" for reading\n",inputFile);
		return False;
	    }
	}
    }
    else {
	inDpyName= inputFile;
	inputFile= NULL;
    }

    if (outputFormat==WANT_DEFAULT)
	outputFormat= WANT_PS_FILE;
    if ((outputFile==NULL)&&(inputFile!=NULL)&&uStringEqual(inputFile,"-")) {
	int len;
	len= strlen("stdin.eps")+2;
	outputFile= uTypedCalloc(len,char);
	if (outputFile==NULL) {
	    uInternalError("Cannot allocate space for output file name\n");
	    uAction("Exiting\n");
	    exit(1);
	}
	if (args.wantEPS)	sprintf(outputFile,"stdin.eps");
	else			sprintf(outputFile,"stdin.ps");
    }
示例#3
0
static Bool
parseArgs(int argc, char *argv[])
{
    register int i, tmp;

    i = strlen(argv[0]);
    tmp = strlen("xkblist");
    if ((i >= tmp) && (strcmp(&argv[0][i - tmp], "xkblist") == 0))
    {
        xkblist = True;
    }
    for (i = 1; i < argc; i++)
    {
        int itmp;
        if ((argv[i][0] != '-') || (uStringEqual(argv[i], "-")))
        {
            if (!xkblist)
            {
                if (inputFile == NULL)
                    inputFile = argv[i];
                else if (outputFile == NULL)
                    outputFile = argv[i];
                else if (warningLevel > 0)
                {
                    WARN("Too many file names on command line\n");
                    ACTION3
                        ("Compiling %s, writing to %s, ignoring %s\n",
                         inputFile, outputFile, argv[i]);
                }
            }
            else if (!AddMatchingFiles(argv[i]))
                return False;
        }
        else if ((strcmp(argv[i], "-?") == 0)
                 || (strcmp(argv[i], "-help") == 0))
        {
            Usage(argc, argv);
            exit(0);
        }
        else if ((strcmp(argv[i], "-a") == 0) && (!xkblist))
        {
            showImplicit = True;
        }
        else if ((strcmp(argv[i], "-C") == 0) && (!xkblist))
        {
            if ((outputFormat != WANT_DEFAULT)
                && (outputFormat != WANT_C_HDR))
            {
                if (warningLevel > 0)
                {
                    WARN("Multiple output file formats specified\n");
                    ACTION1("\"%s\" flag ignored\n", argv[i]);
                }
            }
            else
                outputFormat = WANT_C_HDR;
        }
#ifdef DEBUG
        else if (strcmp(argv[i], "-d") == 0)
        {
            if ((i >= (argc - 1)) || (!isdigit(argv[i + 1][0])))
            {
                debugFlags = 1;
            }
            else
            {
                if (sscanf(argv[++i], "%i", &itmp) == 1)
                    debugFlags = itmp;
            }
            INFO1("Setting debug flags to %d\n", debugFlags);
        }
#endif
        else if ((strcmp(argv[i], "-dflts") == 0) && (!xkblist))
        {
            computeDflts = True;
        }
        else if (strcmp(argv[i], "-em1") == 0)
        {
            if (++i >= argc)
            {
                if (warningLevel > 0)
                {
                    WARN("No pre-error message specified\n");
                    ACTION("Trailing \"-em1\" option ignored\n");
                }
            }
            else if (preErrorMsg != NULL)
            {
                if (warningLevel > 0)
                {
                    WARN("Multiple pre-error messsages specified\n");
                    ACTION2("Compiling %s, ignoring %s\n",
                            preErrorMsg, argv[i]);
                }
            }
            else
                preErrorMsg = argv[i];
        }
        else if (strcmp(argv[i], "-emp") == 0)
        {
            if (++i >= argc)
            {
                if (warningLevel > 0)
                {
                    WARN("No error prefix specified\n");
                    ACTION("Trailing \"-emp\" option ignored\n");
                }
            }
            else if (errorPrefix != NULL)
            {
                if (warningLevel > 0)
                {
                    WARN("Multiple error prefixes specified\n");
                    ACTION2("Compiling %s, ignoring %s\n",
                            errorPrefix, argv[i]);
                }
            }
            else
                errorPrefix = argv[i];
        }
        else if (strcmp(argv[i], "-eml") == 0)
        {
            if (++i >= argc)
            {
                if (warningLevel > 0)
                {
                    WARN("No post-error message specified\n");
                    ACTION("Trailing \"-eml\" option ignored\n");
                }
            }
            else if (postErrorMsg != NULL)
            {
                if (warningLevel > 0)
                {
                    WARN("Multiple post-error messages specified\n");
                    ACTION2("Compiling %s, ignoring %s\n",
                            postErrorMsg, argv[i]);
                }
            }
            else
                postErrorMsg = argv[i];
        }
        else if ((strncmp(argv[i], "-I", 2) == 0) && (!xkblist))
        {
            if (!XkbAddDirectoryToPath(&argv[i][2]))
            {
                ACTION("Exiting\n");
                exit(1);
            }
        }
        else if ((strncmp(argv[i], "-i", 2) == 0) && (!xkblist))
        {
            if (++i >= argc)
            {
                if (warningLevel > 0)
                    WARN("No device ID specified\n");
            }
            device_id = atoi(argv[i]);
        }
        else if ((strncmp(argv[i], "-l", 2) == 0) && (!xkblist))
        {
            if (outputFormat != WANT_DEFAULT)
            {
                if (warningLevel > 0)
                {
                    WARN("Multiple output file formats specified\n");
                    ACTION1("\"%s\" flag ignored\n", argv[i]);
                }
            }
            else
            {
                if (argv[i][2] != '\0')
                    setVerboseFlags(&argv[i][2]);
                xkblist = True;
                if ((inputFile) && (!AddMatchingFiles(inputFile)))
                    return False;
                else
                    inputFile = NULL;
                if ((outputFile) && (!AddMatchingFiles(outputFile)))
                    return False;
                else
                    outputFile = NULL;
            }
        }
        else if ((strcmp(argv[i], "-m") == 0)
                 || (strcmp(argv[i], "-map") == 0))
        {
            if (++i >= argc)
            {
                if (warningLevel > 0)
                {
                    WARN("No map name specified\n");
                    ACTION1("Trailing \"%s\" option ignored\n", argv[i - 1]);
                }
            }
            else if (xkblist)
            {
                if (!AddMapOnly(argv[i]))
                    return False;
            }
            else if (inputMap != NULL)
            {
                if (warningLevel > 0)
                {
                    WARN("Multiple map names specified\n");
                    ACTION2("Compiling %s, ignoring %s\n", inputMap, argv[i]);
                }
            }
            else
                inputMap = argv[i];
        }
        else if ((strcmp(argv[i], "-merge") == 0) && (!xkblist))
        {
            /* Ignored */
        }
        else if (strcmp(argv[i], "-o") == 0)
        {
            if (++i >= argc)
            {
                if (warningLevel > 0)
                {
                    WARN("No output file specified\n");
                    ACTION("Trailing \"-o\" option ignored\n");
                }
            }
            else if (outputFile != NULL)
            {
                if (warningLevel > 0)
                {
                    WARN("Multiple output files specified\n");
                    ACTION2("Compiling %s, ignoring %s\n", outputFile,
                            argv[i]);
                }
            }
            else
                outputFile = argv[i];
        }
        else if (((strcmp(argv[i], "-opt") == 0)
                  || (strcmp(argv[i], "optional") == 0)) && (!xkblist))
        {
            if (++i >= argc)
            {
                if (warningLevel > 0)
                {
                    WARN("No optional components specified\n");
                    ACTION1("Trailing \"%s\" option ignored\n", argv[i - 1]);
                }
            }
            else
            {
                char *tmp2;
                for (tmp2 = argv[i]; (*tmp2 != '\0'); tmp2++)
                {
                    switch (*tmp2)
                    {
                    case 'c':
                    case 'C':
                        optionalParts |= XkmCompatMapMask;
                        break;
                    case 'g':
                    case 'G':
                        optionalParts |= XkmGeometryMask;
                        break;
                    case 'k':
                    case 'K':
                        optionalParts |= XkmKeyNamesMask;
                        break;
                    case 's':
                    case 'S':
                        optionalParts |= XkmSymbolsMask;
                        break;
                    case 't':
                    case 'T':
                        optionalParts |= XkmTypesMask;
                        break;
                    default:
                        if (warningLevel > 0)
                        {
                            WARN1
                                ("Illegal component for %s option\n",
                                 argv[i - 1]);
                            ACTION1
                                ("Ignoring unknown specifier \"%c\"\n",
                                 (unsigned int) *tmp2);
                        }
                        break;
                    }
                }
            }
        }
        else if (strncmp(argv[i], "-p", 2) == 0)
        {
            if (isdigit(argv[i][2]))
            {
                if (sscanf(&argv[i][2], "%i", &itmp) == 1)
                    dirsToStrip = itmp;
            }
            else if ((i < (argc - 1)) && (isdigit(argv[i + 1][0])))
            {
                if (sscanf(argv[++i], "%i", &itmp) == 1)
                    dirsToStrip = itmp;
            }
            else
            {
                dirsToStrip = 0;
            }
            if (warningLevel > 5)
                INFO1("Setting path count to %d\n", dirsToStrip);
        }
        else if (strncmp(argv[i], "-R", 2) == 0)
        {
            if (argv[i][2] == '\0')
            {
                if (warningLevel > 0)
                {
                    WARN("No root directory specified\n");
                    ACTION("Ignoring -R option\n");
                }
            }
            else if (rootDir != NULL)
            {
                if (warningLevel > 0)
                {
                    WARN("Multiple root directories specified\n");
                    ACTION2("Using %s, ignoring %s\n", rootDir, argv[i]);
                }
            }
            else
            {
                rootDir = &argv[i][2];
                if (warningLevel > 8)
                {
                    WARN1("Changing root directory to \"%s\"\n", rootDir);
                }
                if ((chdir(rootDir) < 0) && (warningLevel > 0))
                {
                    WARN1("Couldn't change directory to \"%s\"\n", rootDir);
                    ACTION("Root directory (-R) option ignored\n");
                    rootDir = NULL;
                }
            }
        }
        else if ((strcmp(argv[i], "-synch") == 0)
                 || (strcmp(argv[i], "-s") == 0))
        {
            synch = True;
        }
        else if (strncmp(argv[i], "-v", 2) == 0)
        {
            char *str;
            if (argv[i][2] != '\0')
                str = &argv[i][2];
            else if ((i < (argc - 1)) && (argv[i + 1][0] != '-'))
                str = argv[++i];
            else
                str = NULL;
            if (str)
                setVerboseFlags(str);
        }
        else if (strncmp(argv[i], "-w", 2) == 0)
        {
            if ((i >= (argc - 1)) || (!isdigit(argv[i + 1][0])))
            {
                warningLevel = 0;
                if (isdigit(argv[i][1]))
                    if (sscanf(&argv[i][1], "%i", &itmp) == 1)
                        warningLevel = itmp;
            }
            else
            {
                if (sscanf(argv[++i], "%i", &itmp) == 1)
                    warningLevel = itmp;
            }
        }
        else if ((strcmp(argv[i], "-xkb") == 0) && (!xkblist))
        {
            if ((outputFormat != WANT_DEFAULT)
                && (outputFormat != WANT_XKB_FILE))
            {
                if (warningLevel > 0)
                {
                    WARN("Multiple output file formats specified\n");
                    ACTION1("\"%s\" flag ignored\n", argv[i]);
                }
            }
            else
                outputFormat = WANT_XKB_FILE;
        }
        else if ((strcmp(argv[i], "-xkm") == 0) && (!xkblist))
        {
            if ((outputFormat != WANT_DEFAULT)
                && (outputFormat != WANT_XKM_FILE))
            {
                if (warningLevel > 0)
                {
                    WARN("Multiple output file formats specified\n");
                    ACTION1("\"%s\" flag ignored\n", argv[i]);
                }
            }
            else
                outputFormat = WANT_XKM_FILE;
        }
        else
        {
            ERROR1("Unknown flag \"%s\" on command line\n", argv[i]);
            Usage(argc, argv);
            return False;
        }
    }
    if (xkblist)
        inputFormat = INPUT_XKB;
    else if (inputFile == NULL)
    {
        ERROR("No input file specified\n");
        return False;
    }
    else if (uStringEqual(inputFile, "-"))
    {
        inputFormat = INPUT_XKB;
    }
#ifndef WIN32
    else if (strchr(inputFile, ':') == NULL)
    {
#else
    else if ((strchr(inputFile, ':') == NULL) || (strlen(inputFile) > 2 &&
                                               isalpha(inputFile[0]) &&
                                               inputFile[1] == ':'
                                               && strchr(inputFile + 2,
                                                         ':') == NULL))
    {
#endif
        int len;
        len = strlen(inputFile);
        if (inputFile[len - 1] == ')')
        {
            char *tmp;
            if ((tmp = strchr(inputFile, '(')) != NULL)
            {
                *tmp = '\0';
                inputFile[len - 1] = '\0';
                tmp++;
                if (*tmp == '\0')
                {
                    WARN("Empty map in filename\n");
                    ACTION("Ignored\n");
                }
                else if (inputMap == NULL)
                {
                    inputMap = uStringDup(tmp);
                }
                else
                {
                    WARN("Map specified in filename and with -m flag\n");
                    ACTION1("map from name (\"%s\") ignored\n", tmp);
                }
            }
            else
            {
                ERROR1("Illegal name \"%s\" for input file\n", inputFile);
                return False;
            }
        }
        if ((len > 4) && (strcmp(&inputFile[len - 4], ".xkm") == 0))
        {
            inputFormat = INPUT_XKM;
        }
        else
        {
            FILE *file;
            file = fopen(inputFile, "r");
            if (file)
            {
                if (XkmProbe(file))
                    inputFormat = INPUT_XKM;
                else
                    inputFormat = INPUT_XKB;
                fclose(file);
            }
            else
            {
                fprintf(stderr, "Cannot open \"%s\" for reading\n",
                        inputFile);
                return False;
            }
        }
    }
    else
    {
        inDpyName = inputFile;
        inputFile = NULL;
        inputFormat = INPUT_XKM;
    }

    if (outputFormat == WANT_DEFAULT)
    {
        if (xkblist)
            outputFormat = WANT_LISTING;
        else if (inputFormat == INPUT_XKB)
            outputFormat = WANT_XKM_FILE;
        else
            outputFormat = WANT_XKB_FILE;
    }
    if ((outputFormat == WANT_LISTING) && (inputFormat != INPUT_XKB))
    {
        if (inputFile)
            ERROR("Cannot generate a listing from a .xkm file (yet)\n");
        else
            ERROR("Cannot generate a listing from an X connection (yet)\n");
        return False;
    }
    if (xkblist)
    {
        if (outputFile == NULL)
            outputFile = uStringDup("-");
        else if (strchr(outputFile, ':') != NULL)
        {
            ERROR("Cannot write a listing to an X connection\n");
            return False;
        }
    }
    else if ((!outputFile) && (inputFile) && uStringEqual(inputFile, "-"))
    {
        int len = strlen("stdin") + strlen(fileTypeExt[outputFormat]) + 2;
        outputFile = uTypedCalloc(len, char);
        if (outputFile == NULL)
        {
            WSGO("Cannot allocate space for output file name\n");
            ACTION("Exiting\n");
            exit(1);
        }
        sprintf(outputFile, "stdin.%s", fileTypeExt[outputFormat]);
    }
    else if ((outputFile == NULL) && (inputFile != NULL))
示例#4
0
文件: evargs.c 项目: aosm/X11
static char *
AppendActionMessageArg(char *sink, char *arg, XkbEvent *ev)
{
    if (uStringEqual(arg,"device")||uStringEqual(arg,"D"))
	sprintf(sink,"%d",ev->message.device);
    else if (uStringEqual(arg,"message")||uStringEqual(arg,"m")) 
	sprintf(sink,"%s",ev->message.message);
    else if (uStringEqual(arg,"keycode")||uStringEqual(arg,"key")||
						  uStringEqual(arg,"k"))
	sprintf(sink,"%d",ev->message.keycode);
    else if (uStringEqual(arg,"press")||uStringEqual(arg,"p"))
	sprintf(sink,"%s",(ev->message.press?"press":"release"));
    else if (uStringEqual(arg,"event")||uStringEqual(arg,"e"))
	sprintf(sink,"%s",(ev->message.key_event_follows?"event":"no_event"));
    return sink;
}
示例#5
0
文件: evargs.c 项目: aosm/X11
static char *
AppendAccessXNotifyArg(char *sink, char *arg, XkbEvent *ev)
{
    if (uStringEqual(arg,"device")||uStringEqual(arg,"D"))
	sprintf(sink,"%d",ev->accessx.device);
    else if (uStringEqual(arg,"detail")||uStringEqual(arg,"d")) {
	sprintf(sink,"%s",XkbAccessXDetailText(ev->accessx.detail,XkbMessage));
    }
    else if (uStringEqual(arg,"keycode")||uStringEqual(arg,"key")||
						  uStringEqual(arg,"k"))
	sprintf(sink,"%d",ev->accessx.keycode);
    else if (uStringEqual(arg,"skdelay")||uStringEqual(arg,"s"))
	sprintf(sink,"%d",ev->accessx.sk_delay);
    else if (uStringEqual(arg,"bkdelay")||uStringEqual(arg,"b"))
	sprintf(sink,"%d",ev->accessx.debounce_delay);
    return sink;
}
示例#6
0
文件: evargs.c 项目: aosm/X11
static char *
AppendBellNotifyArg(char *sink, char *arg, XkbEvent *ev)
{
    if (uStringEqual(arg,"device")||uStringEqual(arg,"D"))
	sprintf(sink,"%d",ev->bell.device);
    else if (uStringEqual(arg,"volume")||uStringEqual(arg,"v"))
	sprintf(sink,"%d",ev->bell.percent);
    else if (uStringEqual(arg,"pitch")||uStringEqual(arg,"p"))
	sprintf(sink,"%d",ev->bell.pitch);
    else if (uStringEqual(arg,"duration")||uStringEqual(arg,"d"))
	sprintf(sink,"%d",ev->bell.duration);
    else if (uStringEqual(arg,"class")||uStringEqual(arg,"c"))
	sprintf(sink,"%d",ev->bell.bell_class);
    else if (uStringEqual(arg,"id")||uStringEqual(arg,"i"))
	sprintf(sink,"%d",ev->bell.bell_id);
    else if (uStringEqual(arg,"window")||uStringEqual(arg,"w"))
	sprintf(sink,"0x%x",(unsigned int)ev->bell.window);
    else if (uStringEqual(arg,"name")||uStringEqual(arg,"n"))
	sprintf(sink,"%s",XkbAtomText(dpy,ev->bell.name,XkbMessage));
    return sink;
}
int
ts_validate_user (nvplist *req, nvplist *res, char *_dbmt_error)
{
  char *id, *passwd;
  char strbuf[1024];
  int retval, i;
  T_DBMT_USER dbmt_user;

  id = nv_get_val (req, "id");
  passwd = nv_get_val (req, "password");

  nv_update_val (res, "task", "authenticate");
  /* id, passwd checking */
  if (id == NULL)
    {
      sprintf (_dbmt_error, "%s", "parameter(id) is missing in request.");
      ut_error_log (req, "ID not specified in the request");
      return ERR_PARAM_MISSING;
    }

  if (passwd == NULL)
    {
      sprintf (_dbmt_error, "%s",
               "parameter(password) is missing in request.");
      ut_error_log (req, "password not specified in the request.");
      return ERR_PARAM_MISSING;
    }

  if (dbmt_user_read (&dbmt_user, strbuf) != ERR_NO_ERROR)
    {
      sprintf (_dbmt_error, "%s", "password file open error");
      ut_error_log (req, "Failed to read user info");
      return ERR_WITH_MSG;
    }

  retval = -1;
  for (i = 0; i < dbmt_user.num_dbmt_user; i++)
    {
      if (strcmp (dbmt_user.user_info[i].user_name, id) == 0)
        {
          char decrypted[PASSWD_LENGTH + 1];

          uDecrypt (PASSWD_LENGTH, dbmt_user.user_info[i].user_passwd,
                    decrypted);
          if (uStringEqual (passwd, decrypted))
            {
              nv_update_val (res, "status", "success");
              retval = ERR_NO_ERROR;
            }
          else
            {
              ut_error_log (req, "Incorrect password");
              sprintf (_dbmt_error, "Incorrect password");
              retval = ERR_WITH_MSG;
            }
          break;
        }
    }
  dbmt_user_free (&dbmt_user);

  if (retval < 0)
    {
      sprintf (_dbmt_error, "%s", "user not found.");
      ut_error_log (req, "User not found.");
      return ERR_WITH_MSG;
    }

  return retval;
}
示例#8
0
/**
 * Open the file given in the include statement and parse it's content.
 * If the statement defines a specific map to use, this map is returned in
 * file_rtrn. Otherwise, the default map is returned.
 *
 * @param stmt The include statement, specifying the file name to look for.
 * @param file_type Type of file (XkmKeyNamesIdx, etc.)
 * @param file_rtrn Returns the key map to be used.
 * @param merge_rtrn Always returns stmt->merge.
 *
 * @return True on success or False otherwise.
 */
Bool
ProcessIncludeFile(IncludeStmt * stmt,
                   unsigned file_type,
                   XkbFile ** file_rtrn, unsigned *merge_rtrn)
{
    FILE *file;
    XkbFile *rtrn, *mapToUse;
    char oldFile[1024] = {0};
    int oldLine = lineNum;

    rtrn = XkbFindFileInCache(stmt->file, file_type, &stmt->path);
    if (rtrn == NULL)
    {
        /* file not in cache, open it, parse it and store it in cache for next
           time. */
        file = XkbFindFileInPath(stmt->file, file_type, &stmt->path);
        if (file == NULL)
        {
            ERROR("Can't find file \"%s\" for %s include\n", stmt->file,
                   XkbDirectoryForInclude(file_type));
            return False;
        }
        strcpy(oldFile, scanFile);
        oldLine = lineNum;
        setScanState(stmt->file, 1);
        if (debugFlags & 2)
            INFO("About to parse include file %s\n", stmt->file);
        /* parse the file */
        if ((XKBParseFile(file, &rtrn) == 0) || (rtrn == NULL))
        {
            setScanState(oldFile, oldLine);
            ERROR("Error interpreting include file \"%s\"\n", stmt->file);
            fclose(file);
            return False;
        }
        fclose(file);
        XkbAddFileToCache(stmt->file, file_type, stmt->path, rtrn);
    }
    mapToUse = rtrn;
    if (stmt->map != NULL)
    {
        while ((mapToUse) && ((!uStringEqual(mapToUse->name, stmt->map)) ||
                              (mapToUse->type != file_type)))
        {
            mapToUse = (XkbFile *) mapToUse->common.next;
        }
        if (!mapToUse)
        {
            ERROR("No %s named \"%s\" in the include file \"%s\"\n",
                   XkbcConfigText(file_type), stmt->map, stmt->file);
            return False;
        }
    }
    else if ((rtrn->common.next != NULL) && (warningLevel > 5))
    {
        WARN("No map in include statement, but \"%s\" contains several\n",
              stmt->file);
        ACTION("Using first defined map, \"%s\"\n", rtrn->name);
    }
    setScanState(oldFile, oldLine);
    if (mapToUse->type != file_type)
    {
        ERROR("Include file wrong type (expected %s, got %s)\n",
               XkbcConfigText(file_type), XkbcConfigText(mapToUse->type));
        ACTION("Include file \"%s\" ignored\n", stmt->file);
        return False;
    }
    /* FIXME: we have to check recursive includes here (or somewhere) */

    mapToUse->compiled = True;
    *file_rtrn = mapToUse;
    *merge_rtrn = stmt->merge;
    return True;
}