Пример #1
0
void cvs_diff(CvsServerCtx * ctx, 
	       const char * rep, const char * file, 
	       const char * rev1, const char * rev2, const char * opts)
{
    char argstr[BUFSIZ], *p = argstr;
    char arg[32];
    char file_buff[PATH_MAX], *basename;

    strzncpy(argstr, opts, BUFSIZ);
    while (parse_patch_arg(arg, &p))
	send_string(ctx, "Argument %s\n", arg);

    send_string(ctx, "Argument -r\n");
    send_string(ctx, "Argument %s\n", rev1);
    send_string(ctx, "Argument -r\n");
    send_string(ctx, "Argument %s\n", rev2);

    /* 
     * we need to separate the 'basename' of file in order to 
     * generate the Directory directive(s)
     */
    strzncpy(file_buff, file, PATH_MAX);
    if ((basename = strrchr(file_buff, '/')))
    {
	*basename = 0;
	send_string(ctx, "Directory %s/%s\n", rep, file_buff);
	send_string(ctx, "%s/%s/%s\n", ctx->root, rep, file_buff);
    }
    else
    {
	send_string(ctx, "Directory %s\n", rep, file_buff);
	send_string(ctx, "%s/%s\n", ctx->root, rep);
    }

    send_string(ctx, "Directory .\n");
    send_string(ctx, "%s\n", ctx->root);
    send_string(ctx, "Argument %s/%s\n", rep, file);
    send_string(ctx, "diff\n");

    ctx_to_fp(ctx, stdout);
}
Пример #2
0
/** Browser Menu
        Display:         PAL/NTSC
        Emulated System: PAL/NTSC
        Center Screen
        Configure Save Path: (browse to path)
        Configure Elf Path: (browse to path)
        Exit to Elf Path
        Exit to PS2Browser
**/
int Browser_Menu(void)
{
    char *temp;
    char cnfpath[2048];
    int i,selection = 0;
    oldselect = -1;
    int option_changed = 0;

    int menu_x1 = gsGlobal->Width*0.25;
    int menu_y1 = gsGlobal->Height*0.15;
    int menu_x2 = gsGlobal->Width*0.75;
    int menu_y2 = gsGlobal->Height*0.85+FONT_HEIGHT;
    int text_line = menu_y1 + 4;

    char options[12][39] = {
        { "Display: " },
        { "Interlacing: " },
        { "Emulated System: " },
        { "Center Screen" },
        { "Configure Save Path: " },
        { "" },
        { "Configure ELF Path:  " },
        { "" },
        { "Save FCEUltra.cnf"},
        { "Power Off" },
        { "Exit to ELF" },
        { "Exit Options Menu" }
    };

    //fill lines with values
    for(i=0;i<12;i++) {
        switch(i) {
            case 0:
                if(!Settings.display) {
                    sprintf(options[i],"%s%s",options[i],"NTSC");
                }
                else {
                    sprintf(options[i],"%s%s",options[i],"PAL");
                }
                break;
            case 1:
                if(Settings.interlace) {
                    sprintf(options[i],"%s%s",options[i],"On");
                }
                else {
                    sprintf(options[i],"%s%s",options[i],"Off");
                }
                break;
            case 2:
                if(!Settings.emulation) {
                    sprintf(options[i],"%s%s",options[i],"NTSC");
                }
                else {
                    sprintf(options[i],"%s%s",options[i],"PAL");
                }
                break;
            case 5:
                strzncpy(options[5],Settings.savepath,38);
                break;
            case 7:
                strzncpy(options[7],Settings.elfpath,38);
                break;
        }
    }



    while(1) {
        selected = 0; //clear selected flag
        selection += menu_input(0,0);

        if(selection > 11) { selection = 0; }
        if(selection < 0) { selection = 11; }
        if(selection == 5 && oldselect == 4) { selection++; } //5 is savepath
        if(selection == 5 && oldselect == 6) { selection--; }
        if(selection == 7 && oldselect == 6) { selection++; } //7 is elfpath
        if(selection == 7 && oldselect == 8) { selection--; }


        if((oldselect != selection) || option_changed) {

            gsKit_clear(gsGlobal,GS_SETREG_RGBAQ(0x00,0x00,0x00,0x80,0x00));

            menu_primitive("Options", &MENU_TEX, menu_x1, menu_y1, menu_x2, menu_y2);

            for(i=0;i<12;i++) {
                if(selection == i) {
                    //font_print(gsGlobal, menu_x1+10.0f, text_line + i*FONT_HEIGHT, 2, DarkYellowFont, options[i]);
                    printXY(options[i],menu_x1+10,text_line+i*FONT_HEIGHT, 4, FCEUSkin.highlight, 1, 0);
                }
                else {
                    //font_print(gsGlobal, menu_x1+10.0f, text_line + i*FONT_HEIGHT, 2, WhiteFont, options[i]);
                    printXY(options[i],menu_x1+10,text_line + i*FONT_HEIGHT, 4, FCEUSkin.textcolor, 1, 0);
                }
            }

            DrawScreen(gsGlobal);

            if(power_off)
                option_changed = 1;
                power_off--;
                if(!power_off) {
                    strcpy(cnfpath,"xyz:/imaginary/hypothetical/doesn't.exist");
                    FILE *File;
                    File = fopen(cnfpath,"r");
                    if(File != NULL)
                        fclose(File);
                }
        }

        oldselect = selection;
        option_changed = 0;

        if(selected) {
            if(selected == 2) {
                selection = 11;
            }
            i = selection;
            switch(i) {
                case 0: //Display PAL/NTSC
                    Settings.display ^= 1;
                    if(Settings.display) {
                        gsGlobal->Mode = GS_MODE_PAL;
                        gsGlobal->Height = 512;
                        defaulty = 72;
                        temp = strstr(options[i],"NTSC");
                        *temp = 0;
                        strcat(options[i],"PAL");
                    }
                    else {
                        gsGlobal->Mode = GS_MODE_NTSC;
                        gsGlobal->Height = 448;
                        defaulty = 50;
                        temp = strstr(options[i],"PAL");
                        *temp = 0;
                        strcat(options[i],"NTSC");
                    }
					gsGlobal->Width = 640;
					gsGlobal->Field = GS_FIELD;
					if (gsGlobal->Interlace == GS_NONINTERLACED) {
						gsGlobal->Height = gsGlobal->Height/2;
						gsGlobal->StartY = gsGlobal->StartY/2 -1 ;
					}

                    gsGlobal->StartY = gsGlobal->StartY + Settings.offset_y;
                    //if(Settings.interlace && (gsGlobal->Mode == GS_MODE_NTSC))
                        //gsGlobal->StartY = gsGlobal->StartY + 22;
                    //else
                        //gsGlobal->StartY = gsGlobal->StartY + 11;
                    //normalize_screen();
					gsKit_init_screen(gsGlobal);	/* Apply settings. */
					gsKit_mode_switch(gsGlobal, GS_ONESHOT);

                    menu_x1 = gsGlobal->Width*0.25;
                    menu_y1 = gsGlobal->Height*0.15;
                    menu_x2 = gsGlobal->Width*0.75;
                    menu_y2 = gsGlobal->Height*0.85+FONT_HEIGHT;
					text_line = menu_y1 + 4;
					    
                    option_changed = 1;
                    //SetGsCrt(gsGlobal->Interlace,gsGlobal->Mode,gsGlobal->Field);
                    break;
                case 1: //Interlacing Off/On
                    Settings.interlace ^= 1;
                    if (gsGlobal->Mode == GS_MODE_PAL)
						gsGlobal->Height = 512;
					else
						gsGlobal->Height = 448;
                    if(Settings.interlace) {
                        gsGlobal->Interlace = GS_INTERLACED;
                        //gsGlobal->StartY = (gsGlobal->StartY-1)*2;
                        temp = strstr(options[i],"Off");
                        *temp = 0;
                        strcat(options[i],"On");
                    }
                    else {
                        gsGlobal->Interlace = GS_NONINTERLACED;
                        gsGlobal->StartY = gsGlobal->StartY/2 + 1;
						gsGlobal->Height = gsGlobal->Height/2;
                        temp = strstr(options[i],"On");
                        *temp = 0;
                        strcat(options[i],"Off");
                    }
					gsGlobal->Width = 640;
					gsGlobal->Field = GS_FIELD;
                    //normalize_screen();
					gsKit_init_screen(gsGlobal);	/* Apply settings. */
					gsKit_mode_switch(gsGlobal, GS_ONESHOT);
					
                    menu_x1 = gsGlobal->Width*0.25;
                    menu_y1 = gsGlobal->Height*0.15;
                    menu_x2 = gsGlobal->Width*0.75;
                    menu_y2 = gsGlobal->Height*0.85+FONT_HEIGHT;
					text_line = menu_y1 + 4;
                    option_changed = 1;
                    //SetGsCrt(gsGlobal->Interlace,gsGlobal->Mode,gsGlobal->Field);
                    break;
                case 2: //Emulated System
                    Settings.emulation ^= 1;
                    if(Settings.emulation) {
                        temp = strstr(options[i],"NTSC");
                        *temp = 0;
                        strcat(options[i],"PAL");
                    }
                    else {
                        temp = strstr(options[i],"PAL");
                        *temp = 0;
                        strcat(options[i],"NTSC");
                    }
                    FCEUI_SetVidSystem(Settings.emulation);
                    option_changed = 1;
                    break;
                case 3: //Center Screen
                    while(menu_input(0,2) != 2) {}
                    i = 0x10000;
                    while(i--) asm("nop\nnop\nnop\nnop");
                    option_changed = 1;
                    break;
                case 4: //Configure Save Path
                    h = 0; //reset browser
                    selection = 0;
                    oldselect = -1;
                    selected = 0;
                    strcpy(path,"path"); //end reset browser
                    strcpy(Settings.savepath,Browser(0,1));
                    printf("%s",Settings.savepath);
                    strzncpy(options[5],Settings.savepath,38);
                    selected_dir = 0;
                    h = 0;
                    selection = 0;
                    oldselect = -1;
                    strcpy(path,"path");
                    option_changed = 1;
                    selected = 0;
                    break;
                case 6: //Configure ELF Path
                    h = 0;
                    selection = 0;
                    oldselect = -1;
                    selected = 0;
                    strcpy(path,"path");
                    strcpy(Settings.elfpath,Browser(1,2));
                    strzncpy(options[7],Settings.elfpath,38);
                    h = 0;
                    selection = 0;
                    oldselect = -1;
                    strcpy(path,"path");
                    option_changed = 1;
                    selected = 0;
                    break;
                case 8: //Save CNF
                    fioMkdir("mc0:FCEUMM");
                    Save_Global_CNF("mc0:/FCEUMM/FCEUltra.cnf");
                    break;
                case 9: //Power Off
                    poweroffShutdown();
                    if(Settings.display)
                        power_off = 50/4;
                    else
                        power_off = 60/4;
                    option_changed = 1;
                    break;
                case 10: //Exit to ELF
                    return 2;
                case 11: //Exit Options Menu
                    selected = 0;
                    return 1;

            }
        }
    }
}
Пример #3
0
time_t read_cache()
{
    FILE * fp;
    char buff[BUFSIZ];
    int state = CACHE_NEED_FILE;
    CvsFile * f = NULL;
    PatchSet * ps = NULL;
    char datebuff[20] = "";
    char authbuff[AUTH_STR_MAX] = "";
    char tagbuff[LOG_STR_MAX] = "";
    int tag_flags = 0;
    char branchbuff[LOG_STR_MAX] = "";
    int branch_add = 0;
    int logbufflen = LOG_STR_MAX + 1;
    char * logbuff = malloc(logbufflen);
    time_t cache_date = -1;
    int read_version;

    if (logbuff == NULL)
    {
	debug(DEBUG_SYSERROR, "could not malloc %d bytes for logbuff in read_cache", logbufflen);
	exit(1);
    }

    logbuff[0] = 0;

    if (!(fp = cache_open("r")))
	goto out;

    /* first line is cache version  format "cache version: %d\n" */
    if (!fgets(buff, BUFSIZ, fp) || strncmp(buff, "cache version:", 14))
    {
	debug(DEBUG_APPERROR, "bad cvsps.cache file");
	goto out_close;
    }

    if ((read_version = atoi(buff + 15)) != cache_version)
    {
	debug(DEBUG_APPERROR, "bad cvsps.cache version %d, expecting %d.  ignoring cache",
	      read_version, cache_version);
	goto out_close;
    }

    /* second line is date cache was created, format "cache date: %d\n" */
    if (!fgets(buff, BUFSIZ, fp) || strncmp(buff, "cache date:", 11))
    {
	debug(DEBUG_APPERROR, "bad cvsps.cache file");
	goto out_close;
    }

    cache_date = atoi(buff + 12);
    debug(DEBUG_STATUS, "read cache_date %d", (int)cache_date);

    while (fgets(buff, BUFSIZ, fp))
    {
	int len = strlen(buff);

	switch(state)
	{
	case CACHE_NEED_FILE:
	    if (strncmp(buff, "file:", 5) == 0)
	    {
		len -= 6;
		f = create_cvsfile();
		f->filename = xstrdup(buff + 6);
		f->filename[len-1] = 0; /* Remove the \n at the end of line */
		debug(DEBUG_STATUS, "read cache filename '%s'", f->filename);
		put_hash_object_ex(file_hash, f->filename, f, HT_NO_KEYCOPY, NULL, NULL);
		state = CACHE_NEED_BRANCHES;
	    }
	    else
	    {
		state = CACHE_NEED_PS;
	    }
	    break;
	case CACHE_NEED_BRANCHES:
	    if (buff[0] != '\n')
	    {
		char * tag;

		tag = strchr(buff, ':');
		if (tag)
		{
		    *tag = 0;
		    tag += 2;
		    buff[len - 1] = 0;
		    cvs_file_add_branch(f, buff, tag);
		}
	    }
	    else
	    {
		f->have_branches = 1;
		state = CACHE_NEED_SYMBOLS;
	    }
	    break;
	case CACHE_NEED_SYMBOLS:
	    if (buff[0] != '\n')
	    {
		char * rev;

		rev = strchr(buff, ':');
		if (rev)
		{
		    *rev = 0;
		    rev += 2;
		    buff[len - 1] = 0;
		    cvs_file_add_symbol(f, rev, buff);
		}
	    }
	    else
	    {
		state = CACHE_NEED_REV;
	    }
	    break;
	case CACHE_NEED_REV:
	    if (isdigit(buff[0]))
	    {
		char * p = strchr(buff, ' ');
		if (p)
		{
		    CvsFileRevision * rev;
		    *p++ = 0;
		    buff[len-1] = 0;
		    rev = cvs_file_add_revision(f, buff);
		    if (strcmp(rev->branch, p) != 0)
		    {
			debug(DEBUG_APPERROR, "branch mismatch for %s:%s %s != %s", 
			      rev->file->filename, rev->rev, rev->branch, p);
		    }
		}
	    }
	    else
	    {
		state = CACHE_NEED_FILE;
	    }
	    break;
	case CACHE_NEED_PS:
	    if (strncmp(buff, "patchset:", 9) == 0)
		state = CACHE_NEED_PS_DATE;
	    break;
	case CACHE_NEED_PS_DATE:
	    if (strncmp(buff, "date:", 5) == 0)
	    {
		/* remove prefix "date: " and LF from len */
		len -= 6;
		strzncpy(datebuff, buff + 6, MIN(len, sizeof(datebuff)));
		state = CACHE_NEED_PS_AUTHOR;
	    }
	    break;
	case CACHE_NEED_PS_AUTHOR:
	    if (strncmp(buff, "author:", 7) == 0)
	    {
		/* remove prefix "author: " and LF from len */
		len -= 8;
		strzncpy(authbuff, buff + 8, MIN(len, AUTH_STR_MAX));
		state = CACHE_NEED_PS_TAG;
	    }
	    break;
	case CACHE_NEED_PS_TAG:
	    if (strncmp(buff, "tag:", 4) == 0)
	    {
		/* remove prefix "tag: " and LF from len */
		len -= 5;
		strzncpy(tagbuff, buff + 5, MIN(len, LOG_STR_MAX));
		state = CACHE_NEED_PS_TAG_FLAGS;
	    }
	    break;
	case CACHE_NEED_PS_TAG_FLAGS:
	    if (strncmp(buff, "tag_flags:", 10) == 0)
	    {
		/* remove prefix "tag_flags: " and LF from len */
		len -= 11;
		tag_flags = atoi(buff + 11);
		state = CACHE_NEED_PS_BRANCH;
	    }
	    break;
	case CACHE_NEED_PS_BRANCH:
	    if (strncmp(buff, "branch:", 7) == 0)
	    {
		/* remove prefix "branch: " and LF from len */
		len -= 8;
		strzncpy(branchbuff, buff + 8, MIN(len, LOG_STR_MAX));
		state = CACHE_NEED_PS_BRANCH_ADD;
	    }
	    break;
	case CACHE_NEED_PS_BRANCH_ADD:
	    if (strncmp(buff, "branch_add:", 11) == 0)
	    {
		/* remove prefix "branch_add: " and LF from len */
		len -= 12;
		branch_add = atoi(buff + 12);
		state = CACHE_NEED_PS_DESCR;
	    }
	    break;
	case CACHE_NEED_PS_DESCR:
	    if (strncmp(buff, "descr:", 6) == 0)
		state = CACHE_NEED_PS_EOD;
	    break;
	case CACHE_NEED_PS_EOD:
	    if (strcmp(buff, CACHE_DESCR_BOUNDARY) == 0)
	    {
		debug(DEBUG_STATUS, "patch set %s %s %s %s", datebuff, authbuff, logbuff, branchbuff);
		ps = get_patch_set(datebuff, logbuff, authbuff, branchbuff, NULL);
		/* the tag and tag_flags will be assigned by the resolve_global_symbols code 
		 * ps->tag = (strlen(tagbuff)) ? get_string(tagbuff) : NULL;
		 * ps->tag_flags = tag_flags;
		 */
		ps->branch_add = branch_add;
		state = CACHE_NEED_PS_MEMBERS;
	    }
	    else
	    {
		/* Make sure we have enough in the buffer */
		int len = strlen(buff);
		if (strlen(logbuff) + len >= LOG_STR_MAX)
		{
		    logbufflen += (len >= LOG_STR_MAX ? (len+1) : LOG_STR_MAX);
		    char * newlogbuff = realloc(logbuff, logbufflen);
		    if (newlogbuff == NULL)
		    {
			debug(DEBUG_SYSERROR, "could not realloc %d bytes for logbuff in read_cache", logbufflen);
			exit(1);
		    }
		    logbuff = newlogbuff;
		}
		strcat(logbuff, buff);
	    }
	    break;
	case CACHE_NEED_PS_MEMBERS:
	    if (strncmp(buff, "members:", 8) == 0)
		state = CACHE_NEED_PS_EOM;
	    break;
	case CACHE_NEED_PS_EOM:
	    if (buff[0] == '\n')
	    {
		datebuff[0] = 0;
		authbuff[0] = 0;
		tagbuff[0] = 0;
		tag_flags = 0;
		branchbuff[0] = 0;
		branch_add = 0;
		logbuff[0] = 0;
		state = CACHE_NEED_PS;
	    }
	    else
	    {
		PatchSetMember * psm = create_patch_set_member();
		parse_cache_revision(psm, buff);
		patch_set_add_member(ps, psm);
	    }
	    break;
	}
    }

 out_close:
    fclose(fp);
 out:
    free(logbuff);

    return cache_date;
}