Esempio n. 1
0
static void
wpiattach(Ether *edev)
{
	FWImage *fw;
	Ctlr *ctlr;
	char *err;

	ctlr = edev->ctlr;
	eqlock(ctlr);
	if(waserror()){
		print("#l%d: %s\n", edev->ctlrno, up->errstr);
		if(ctlr->power)
			poweroff(ctlr);
		qunlock(ctlr);
		nexterror();
	}
	if(ctlr->attached == 0){
		if((csr32r(ctlr, Gpc) & RfKill) == 0)
			error("wifi disabled by switch");

		if(ctlr->wifi == nil){
			ctlr->wifi = wifiattach(edev, transmit);
			ctlr->wifi->rates = wpirates;
		}

		if(ctlr->fw == nil){
			fw = readfirmware();
			print("#l%d: firmware: %ux, size: %ux+%ux+%ux+%ux+%ux\n",
				edev->ctlrno, fw->version,
				fw->main.text.size, fw->main.data.size,
				fw->init.text.size, fw->init.data.size,
				fw->boot.text.size);
			ctlr->fw = fw;
		}

		if((err = reset(ctlr)) != nil)
			error(err);
		if((err = boot(ctlr)) != nil)
			error(err);

		ctlr->bcastnodeid = -1;
		ctlr->bssnodeid = -1;
		ctlr->channel = 1;
		ctlr->aid = 0;

		setoptions(edev);

		ctlr->attached = 1;

		kproc("wpirecover", wpirecover, edev);
	}
	qunlock(ctlr);
	poperror();
}
Esempio n. 2
0
void save_omegarc(void)
{
    int i=VERSION;
    FILE *fd;
    change_to_user_perms();

    getOmegaRCPath();

    fd = fopen(Str1,"w");
    if (fd == NULL)
        print1("Sorry, couldn't save .omegarc for some reason.");
    else {
        fwrite((char *)&i,sizeof(int),1,fd);
        print1("First, set options.");
        setoptions();
        fwrite((char *)&Player,sizeof(Player),1,fd);
        fwrite((char *)&Searchnum,sizeof(int),1,fd);
        fwrite((char *)&Verbosity,sizeof(char),1,fd);
        fclose(fd);
    }
    change_to_game_perms();
}
Esempio n. 3
0
/* deal with a new player command in countryside mode */
void p_country_process(void)
{
    int no_op;

    drawvision(Player.x,Player.y);
    do {
        no_op = FALSE;
        Cmd = mgetc();
        clear_if_necessary();
        switch (Cmd) {
        case ' ':
        case 13:
            no_op = TRUE;
            break;
        case 7:
            wizard();
            break; /* ^g */
        case 12:
            xredraw();
            no_op = TRUE;
            break; /* ^l */
#if !defined(WIN32)
        case 16:
            bufferprint();
            no_op = TRUE;
            break; /* ^p */
#else
        case 15:
            bufferprint();
            no_op = TRUE;
            break; /* ^o */
#endif
        case 18:
            redraw();
            no_op = TRUE;
            break; /* ^r */
        case 23:
            if (gamestatusp(CHEATED)) drawscreen();
            break; /* ^w */
        case 24:
            if (gamestatusp(CHEATED) ||
                    Player.rank[ADEPT]) wish(1);
            break; /* ^x */
        case 'd':
            drop();
            break;
        case 'e':
            eat();
            break;
        case 'i':
            do_inventory_control();
            break;
        case 's':
            countrysearch();
            break;
        case 'x':
            examine();
            break;
        case 'E':
            dismount_steed();
            break;
        case 'H':
            hunt(Country[Player.x][Player.y].current_terrain_type);
            break;
        case 'I':
            if (! optionp(TOPINV)) top_inventory_control();
            else {
                menuclear();
                display_possessions();
                inventory_control();
            }
            break;
        case 'O':
            setoptions();
            break;
        case 'P':
            show_license();
            break; /* actually show_license is in file.c */
        case 'Q':
            quit();
            break;
        case 'R':
            rename_player();
            break;
        case 'S':
            save(FALSE);
            break;
        case 'V':
            version();
            break;
        case '>':
            enter_site(Country[Player.x][Player.y].base_terrain_type);
            break;
        case '#':
            if (gamestatusp(CHEATED)) editstats();
            break; /* RAC - char editor */
        case '/':
            charid();
            no_op = TRUE;
            break;
        case '?':
            help();
            no_op = TRUE;
            break;
        case '4':
        case 'h':
            movepincountry(-1,0);
            break;
        case '2':
        case 'j':
            movepincountry(0,1);
            break;
        case '8':
        case 'k':
            movepincountry(0,-1);
            break;
        case '6':
        case 'l':
            movepincountry(1,0);
            break;
        case '1':
        case 'b':
            movepincountry(-1,1);
            break;
        case '3':
        case 'n':
            movepincountry(1,1);
            break;
        case '7':
        case 'y':
            movepincountry(-1,-1);
            break;
        case '9':
        case 'u':
            movepincountry(1,-1);
            break;
        default:
            commanderror();
            no_op = TRUE;
            break;
        }
    } while (no_op);
    screencheck(Player.x,Player.y);
}
Esempio n. 4
0
long proctrace(enum __ptrace_request __request, pid_t pid, void *addr, void *data) {
	long retval = 0;
#ifdef USE_PTRACE
	retval = ptrace(__request, pid, addr, data);
	return retval;
#endif

	if (attached_pid != 0 && attached_pid != pid) {
		fprintf(stderr, "i can only trace one guy\n");
		exit(1);
	}

	switch (__request) {
	case PTRACE_TRACEME:
		retval = traceme();
		break;
	case PTRACE_PEEKTEXT:
	case PTRACE_PEEKDATA:
		retval = readfile("mem", (unsigned long long)addr);
		break;
	case PTRACE_PEEKUSER:
		retval = readfile("uregs", (long)addr);
		break;
	case PTRACE_POKETEXT:
	case PTRACE_POKEDATA:
		retval = writefile("mem", (long) addr, (long) data);
		break;
	case PTRACE_POKEUSER:
		retval = writefile("uregs", (long)addr, (long) data);
		break;
	case PTRACE_CONT:
		if (data) 
			retval = kill(attached_pid, (int) data);
		// next time someboy calls proctrace_wait, start the child
		if (!retval)
			proctrace_wait_mask |= 1;
		break;
	case PTRACE_KILL:
		retval = kill(attached_pid, (int) data);
		break;
	case PTRACE_SINGLESTEP:
		singlestep = 1;
		retval = 0;
		break;
	case PTRACE_GETREGS:
		retval = copyfromfile("regs", (char *) data,
				sizeof(struct user_regs_struct));
		if (retval == sizeof(struct user_regs_struct)) {
			retval = 0;
		}
		break;
	case PTRACE_SETREGS:
		retval = copytofile("regs", (char *) data,
				sizeof(struct user_regs_struct));
		if (retval == sizeof(struct user_regs_struct)) {
			retval = 0;
		}
		break;
	case PTRACE_GETFPREGS:
		retval = copyfromfile("fpregs", (char *) data,
				sizeof(struct user_fpregs_struct));
		if (retval == sizeof(struct user_fpregs_struct)) {
			retval = 0;
		}
		break;
	case PTRACE_SETFPREGS:
		retval = copytofile("fpregs", (char *) data,
				sizeof(struct user_fpregs_struct));
		if (retval == sizeof(struct user_fpregs_struct)) {
			retval = 0;
		}
		break;
	case PTRACE_ATTACH:
		attached_pid = pid;
		kill(pid, SIGSTOP);
		proctrace_wait_mask = ((1ULL << 31) - 1) << 1;
		break;
	case PTRACE_DETACH:
		attached_pid = proctrace_wait_mask = singlestep = 0;
		break;
	case PTRACE_SYSCALL:
		proctrace_wait_mask |= (1ULL << 33);
		break;
	case PTRACE_SETOPTIONS:
		setoptions((int) data);
		break;
	case PTRACE_GETEVENTMSG:
		retval = copyfromfile("eventmessage", (char *) data, sizeof(unsigned long int));
		break;
	case PTRACE_GETSIGINFO:
		retval = copyfromfile("last_siginfo", (char *) data, sizeof(siginfo_t));
		break;
	case PTRACE_SETSIGINFO:
		fprintf(stderr, "not supported yet\n");
		exit(1);
		break;
	}

	return retval;
}
Esempio n. 5
0
int main(int argc, char** argv) {
    pcap_dumper_t *dumper;
    pcap_t *p;
    struct pcap_pkthdr header;
    u_char *packet;
    int i;
    struct sockaddr *sin_src;
    struct sockaddr *sin_net;
    struct sockaddr *sin_dst;
    struct sockaddr *sin_mask;
    int sendsize;
    struct options_args opts;
    FILE* fp_domain;
    char * domain;

    int q_class;
    int q_type;



    /**
     * 
     * headers
     */
    struct ether_header *eth;
    struct iphdr *ip;
    struct ip6_hdr *ip6;
    struct udphdr *udp;
    u_char *dns;

    setoptions(argc, argv, &opts);

    header.ts.tv_sec = 0;
    header.ts.tv_usec = 0;

    packet = calloc(sizeof (u_char) * 4096, 1);
    sin_src = calloc(sizeof (struct sockaddr_storage), 1);
    sin_net = calloc(sizeof (struct sockaddr_storage), 1);
    sin_dst = calloc(sizeof (struct sockaddr_storage), 1);
    sin_mask = calloc(sizeof (struct sockaddr_storage), 1);
    domain = calloc(sizeof (char) * 1024, 1);

    if(packet == NULL || 
            sin_src == NULL ||
            sin_net == NULL || 
            sin_dst == NULL || 
            sin_mask == NULL || 
            domain == NULL) {
        return -1;
    }
    
    /**
     * 
     * ETHERNET static
     */

    eth = (struct ether_header *) packet;

    if (ether_setaddr(opts.smac, &(eth->ether_shost)) < 0) {
        fprintf(stderr, "smac error\n");
        return 1;
    }
    if (ether_setaddr(opts.dmac, &(eth->ether_dhost)) < 0) {
        fprintf(stderr, "dmac error\n");
        return 1;
    }

    /**
     * 
     * IP static
     */
    if (getipaddr(opts.dip, sin_dst, opts.family) < 0) {
        fprintf(stderr, "dip error\n");
        return 2;
    }
    if (getipaddr(opts.snet, sin_net, opts.family) < 0) {
        fprintf(stderr, "sip error\n");
        return 2;
    }

    if (sin_net->sa_family != sin_dst->sa_family) {
        fprintf(stderr, "IP family doesn't match\n");
        return 2;
    }

    set_mask(sin_mask, sin_net->sa_family, opts.smask);

    if (sin_net->sa_family == AF_INET) {
        eth->ether_type = htons(ETHERTYPE_IP);

        ip = (struct iphdr *) (packet + ETHER_HDR_LEN);
        ip->daddr = ((struct sockaddr_in *) sin_dst)->sin_addr.s_addr;


        ip->version = 4;
        ip->ihl = 5; // no opts
        ip->frag_off = 0;
        ip->id = 0;
        ip->protocol = IPPROTO_UDP;
        ip->tos = 0;
        ip->ttl = IPDEFTTL;
        

        udp = (struct udphdr *) (((void *) ip) + IP_HDR_LEN);
    } else if (sin_net->sa_family == AF_INET6) {
        eth->ether_type = htons(ETHERTYPE_IPV6);

        ip6 = (struct ip6_hdr *) (packet + ETHER_HDR_LEN);
        ip6->ip6_vfc = 6 << 4;
        ip6->ip6_hlim = IPDEFTTL;
        ip6->ip6_nxt = IPPROTO_UDP;

        memcpy(&(ip6->ip6_dst), &(((struct sockaddr_in6 *) sin_dst)->sin6_addr), 16);

        udp = (struct udphdr *) (((void *) ip6) + IP6_HDR_LEN);
    } else {
        fprintf(stderr, "Family unknown\n");
        return 2;
    }
    
    /**
     * 
     * UDP static
     */
    udp->check = 0;
    udp->dest = htons(53);

    /**
     * 
     * DNS static
     */
    dns = (u_char *) (((void *) udp) + UDP_HDR_LEN);

    
    p = pcap_open_dead(DLT_EN10MB, PCAP_SNAPLEN);
    dumper = pcap_dump_open(p, opts.out_file_name);
    if(dumper == NULL) {
        fprintf(stderr, "Can't open output file\n");
        
        pcap_close(p);
        return 3;
    }
    init_domain_file(&fp_domain, opts.in_file_name);
    if (fp_domain == NULL) {
        fprintf(stderr, "Can't open queries file\n");
        
        pcap_dump_close(dumper);
        pcap_close(p);
        return 4;
    }
    for (i = 0; i < opts.count; i++) {
        
        /**
         * 
         * DNS dynamic
         */
        nextdomain(fp_domain, &domain, &q_type, &q_class);

        sendsize = res_mkquery(QUERY, domain, q_class, q_type, NULL,
                0, NULL, dns, PACKETSZ);

        /**
         * 
         * UDP dynamic
         */
        udp->source = htons(rand());
        udp->len = htons(sendsize + UDP_HDR_LEN);

        /**
         * 
         * IP dynamic
         */
        get_rand_addr(sin_net, sin_mask, sin_src);

        if (sin_net->sa_family == AF_INET) {
            ip->saddr = ((struct sockaddr_in *) sin_src)->sin_addr.s_addr;
            ip->tot_len = htons(sendsize + UDP_HDR_LEN + (ip->ihl * 4));
            header.len = sendsize + UDP_HDR_LEN + (ip->ihl * 4) + ETHER_HDR_LEN;

            ip->check = 0;
            ip->check = inet_cksum(ip, (ip->ihl * 4));
        } else if (sin_net->sa_family == AF_INET6) {
            memcpy(&(ip6->ip6_src), &(((struct sockaddr_in6 *) sin_src)->sin6_addr), 16);
            ip6->ip6_plen = htons(sendsize + UDP_HDR_LEN);
            header.len = sendsize + UDP_HDR_LEN + sizeof (struct ip6_hdr) +ETHER_HDR_LEN;
        }

        header.caplen = header.len;
        if (header.len > opts.mtu) {
            fprintf(stderr, "too long: %s needs %d MTU is %d\n", domain,header.len, opts.mtu);
        } else {
            pcap_dump(dumper, &header, packet);
        }
    }


    pcap_dump_close(dumper);
    pcap_close(p);
    fclose(fp_domain);

    return (EXIT_SUCCESS);
}
Esempio n. 6
0
/* deal with a new player command in dungeon or city mode*/
void p_process(void)
{
    static int searchval=0;

    if (Player.status[BERSERK])
        if (goberserk()) {
            setgamestatus(SKIP_PLAYER);
            drawvision(Player.x,Player.y);
        }
    if (! gamestatusp(SKIP_PLAYER)) {
        if (searchval > 0) {
            searchval--;
            if (searchval == 0) resetgamestatus(FAST_MOVE);
        }
        drawvision(Player.x,Player.y);
        if (! gamestatusp(FAST_MOVE)) {
            searchval = 0;
            Cmd = mgetc();
            clear_if_necessary();
        }
        Command_Duration = 0;
        switch (Cmd) {
        case ' ':
        case 13:
            setgamestatus(SKIP_MONSTERS);
            break; /*no op on space or return*/
        case 6:
            abortshadowform();
            break; /* ^f */
        case 7:
            wizard();
            break; /* ^g */
        case 4:
            player_dump();
            break; /* ^d */
        case 9:
            display_pack();
            morewait();
            xredraw();
            break; /* ^i */
        case 11:
            if (gamestatusp(CHEATED)) frobgamestatus();
            break;
        case 12:
            xredraw();
            setgamestatus(SKIP_MONSTERS);
            break; /* ^l */
#if !defined(WIN32)
        case 16:
            bufferprint();
            setgamestatus(SKIP_MONSTERS);
            break; /* ^p */
#else
        case 15:
            bufferprint();
            setgamestatus(SKIP_MONSTERS);
            break; /* ^o */
#endif
        case 18:
            redraw();
            setgamestatus(SKIP_MONSTERS);
            break; /* ^r */
        case 23:
            if (gamestatusp(CHEATED)) drawscreen();
            break; /* ^w */
        case 24: /* ^x */
            if (gamestatusp(CHEATED) ||
                    Player.rank[ADEPT])
                wish(1);
            Command_Duration = 5;
            break;
        case 'a':
            zapwand();
            Command_Duration = Player.speed*8/5;
            break;
        case 'c':
            closedoor();
            Command_Duration = Player.speed*2/5;
            break;
        case 'd':
            drop();
            Command_Duration = Player.speed*5/5;
            break;
        case 'e':
            eat();
            Command_Duration = 30;
            break;
        case 'f':
            fire();
            Command_Duration = Player.speed*5/5;
            break;
        case 'g':
            pickup();
            Command_Duration = Player.speed*10/5;
            break;
        case 'i':
            do_inventory_control();
            break;
        case 'm':
            magic();
            Command_Duration = 12;
            break;
        case 'o':
            opendoor();
            Command_Duration = Player.speed*5/5;
            break;
        case 'p':
            pickpocket();
            Command_Duration = Player.speed*20/5;
            break;
        case 'q':
            quaff();
            Command_Duration = 10;
            break;
        case 'r':
            peruse();
            Command_Duration = 20;
            break;
        case 's':
            search(&searchval);
            Command_Duration = 20;
            break;
        case 't':
            talk();
            Command_Duration = 10;
            break;
        case 'v':
            vault();
            Command_Duration = Player.speed*10/5;
            break;
        case 'x':
            examine();
            Command_Duration = 1;
            break;
        case 'z':
            bash_location();
            Command_Duration = Player.speed*10/5;
            break;
        case 'A':
            activate();
            Command_Duration = 10;
            break;
        case 'C':
            callitem();
            break;
        case 'D':
            disarm();
            Command_Duration = 30;
            break;
        case 'E':
            dismount_steed();
            Command_Duration = Player.speed*10/5;
            break;
        case 'F':
            tacoptions();
            break;
        case 'G':
            give();
            Command_Duration = 10;
            break;
        case 'I':
            if (! optionp(TOPINV)) top_inventory_control();
            else {
                display_possessions();
                inventory_control();
            }
            break;
        case 'M':
            city_move();
            Command_Duration = 10;
            break;
        case 'O':
            setoptions();
#if defined(WIN32)
            show_screen();
            xredraw();
#endif
            break;
        case 'P':
            show_license();
            break; /* actually show_license is in file.c */
        case 'Q':
            quit();
            break;
        case 'R':
            rename_player();
            break;
        case 'S':
            save(FALSE);
            break;
        case 'T':
            tunnel();
            Command_Duration =  Player.speed*30/5;
            break;
        case 'V':
            version();
            break;
        case 'Z':
            bash_item();
            Command_Duration = Player.speed*10/5;
            break;
        case '.':
            rest();
            Command_Duration = 10;
            break;
        case ',':
            Command_Duration = 10;
            nap();
            break;
        case '>':
            downstairs();
            break;
        case '<':
            upstairs();
            break;
        case '@':
            p_movefunction(Level->site[Player.x][Player.y].p_locf);
            Command_Duration = 5;
            break;
        case '#':
            if (gamestatusp(CHEATED)) editstats();
            break; /* RAC - char editor */
        case '/':
            charid();
            setgamestatus(SKIP_MONSTERS);
            break;
        case '?':
            help();
            setgamestatus(SKIP_MONSTERS);
            break;
        case '4':
        case 'h':
            moveplayer(-1,0);
            Command_Duration = Player.speed*5/5;
            break;
        case '2':
        case 'j':
            moveplayer(0,1);
            Command_Duration = Player.speed*5/5;
            break;
        case '8':
        case 'k':
            moveplayer(0,-1);
            Command_Duration = Player.speed*5/5;
            break;
        case '6':
        case 'l':
            moveplayer(1,0);
            Command_Duration = Player.speed*5/5;
            break;
        case '1':
        case 'b':
            moveplayer(-1,1);
            Command_Duration = Player.speed*5/5;
            break;
        case '3':
        case 'n':
            moveplayer(1,1);
            Command_Duration = Player.speed*5/5;
            break;
        case '7':
        case 'y':
            moveplayer(-1,-1);
            Command_Duration = Player.speed*5/5;
            break;
        case '9':
        case 'u':
            moveplayer(1,-1);
            Command_Duration = Player.speed*5/5;
            break;
        case '5':
            setgamestatus(SKIP_MONSTERS); /* don't do anything; a dummy turn */
            Cmd = mgetc();
            while ((Cmd != ESCAPE) &&
                    ((Cmd < '1') || (Cmd > '9') || (Cmd=='5'))) {
                print3("Run in keypad direction [ESCAPE to abort]: ");
                Cmd = mgetc();
            }
            if (Cmd != ESCAPE) 
                setgamestatus(FAST_MOVE);
            else
                clearmsg3();
            break;
        case 'H':
            setgamestatus(FAST_MOVE);
            Cmd = 'h';
            moveplayer(-1,0);
            Command_Duration = Player.speed*4/5;
            break;
        case 'J':
            setgamestatus(FAST_MOVE);
            Cmd = 'j';
            moveplayer(0,1);
            Command_Duration = Player.speed*4/5;
            break;
        case 'K':
            setgamestatus(FAST_MOVE);
            Cmd = 'k';
            moveplayer(0,-1);
            Command_Duration = Player.speed*4/5;
            break;
        case 'L':
            setgamestatus(FAST_MOVE);
            Cmd = 'l';
            moveplayer(1,0);
            Command_Duration = Player.speed*4/5;
            break;
        case 'B':
            setgamestatus(FAST_MOVE);
            Cmd = 'b';
            moveplayer(-1,1);
            Command_Duration = Player.speed*4/5;
            break;
        case 'N':
            setgamestatus(FAST_MOVE);
            Cmd = 'n';
            moveplayer(1,1);
            Command_Duration = Player.speed*4/5;
            break;
        case 'Y':
            setgamestatus(FAST_MOVE);
            Cmd = 'y';
            moveplayer(-1,-1);
            Command_Duration = Player.speed*4/5;
            break;
        case 'U':
            setgamestatus(FAST_MOVE);
            Cmd = 'u';
            moveplayer(1,-1);
            Command_Duration = Player.speed*4/5;
            break;
        default:
            commanderror();
            setgamestatus(SKIP_MONSTERS);
            break;
        }
    }
    if (Current_Environment != E_COUNTRYSIDE) roomcheck();
    screencheck(Player.x,Player.y);
}
Esempio n. 7
0
/* this is the plugin entry point */
enum plugin_status plugin_start(const void* parameter)
{
    rb->lcd_setfont(FONT_SYSFIXED);

    rb->lcd_clear_display();

    if (!parameter)
    {
        rb->splash(HZ*3, "Play gameboy ROM file! (.gb/.gbc)");
        return PLUGIN_OK;
    }
    if(rb->audio_status())
    {
        audio_bufferbase = audio_bufferpointer
            = rb->plugin_get_buffer(&audio_buffer_free);
        plugbuf=true;
    }
    else
    {
        audio_bufferbase = audio_bufferpointer
            = rb->plugin_get_audio_buffer(&audio_buffer_free);
        plugbuf=false;
    }
#if MEMORYSIZE <= 8 && (CONFIG_PLATFORM & PLATFORM_NATIVE)
    /* loaded as an overlay plugin, protect from overwriting ourselves */
    if ((unsigned)(plugin_start_addr - (unsigned char *)audio_bufferbase)
        < audio_buffer_free)
        audio_buffer_free = plugin_start_addr - (unsigned char *)audio_bufferbase;
#endif
    setoptions();

    shut=0;
    cleanshut=0;

#ifdef HAVE_WHEEL_POSITION
    rb->wheel_send_events(false);
#endif

#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
    rb->lcd_set_mode(LCD_MODE_PAL256);
#endif

    /* ignore backlight time out */
    backlight_ignore_timeout();

    gnuboy_main(parameter);

#ifdef HAVE_WHEEL_POSITION
    rb->wheel_send_events(true);
#endif

#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
    rb->lcd_set_mode(LCD_MODE_RGB565);
#endif

    backlight_use_settings();

    if(!rb->audio_status())
        rockboy_pcm_close();

    if(shut&&!cleanshut)
    {
        rb->splash(HZ/2, errormsg);
        return PLUGIN_ERROR;
    }

    rb->splash(HZ/2, "Closing Rockboy");

    savesettings();

    cleanup();

    return PLUGIN_OK;
}
Esempio n. 8
0
/* this is the plugin entry point */
enum plugin_status plugin_start(const void* parameter)
{
    PLUGIN_IRAM_INIT(rb)

    rb->lcd_setfont(0);

    rb->lcd_clear_display();

    if (!parameter)
    {
        rb->splash(HZ*3, "Play gameboy ROM file! (.gb/.gbc)");
        return PLUGIN_OK;
    }
    if(rb->audio_status())
    {
        audio_bufferbase = audio_bufferpointer
            = rb->plugin_get_buffer(&audio_buffer_free);
        plugbuf=true;
    }
    else
    {
        audio_bufferbase = audio_bufferpointer
            = rb->plugin_get_audio_buffer(&audio_buffer_free);
        plugbuf=false;
    }
#if MEM <= 8 && !defined(SIMULATOR)
    /* loaded as an overlay plugin, protect from overwriting ourselves */
    if ((unsigned)(plugin_start_addr - (unsigned char *)audio_bufferbase)
        < audio_buffer_free)
        audio_buffer_free = plugin_start_addr - (unsigned char *)audio_bufferbase;
#endif
    setoptions();

    shut=0;
    cleanshut=0;

#ifdef HAVE_WHEEL_POSITION
    rb->wheel_send_events(false);
#endif

#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
    rb->lcd_set_mode(LCD_MODE_PAL256);
#endif

    gnuboy_main(parameter);

#ifdef HAVE_WHEEL_POSITION
    rb->wheel_send_events(true);
#endif

#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
    rb->lcd_set_mode(LCD_MODE_RGB565);
#endif

    if(shut&&!cleanshut)
    {
        rb->splash(HZ/2, errormsg);
        return PLUGIN_ERROR;
    }
    if(!rb->audio_status())
        pcm_close();
        
    rb->splash(HZ/2, "Closing Rockboy");

    savesettings();

    cleanup();

    return PLUGIN_OK;
}
Esempio n. 9
0
/* true return value indicates that connection must be closed */
int process_msg(int fd, char* msg)
{
    int client_proto_major;
    int client_proto_minor;
    char * args;
    char * ptr, * ptr2;
    char * msg_orig;

    /* check for leading protocol tag */
    if (!str_begins_static_str(msg, "FB/")
            || strlen(msg) < 8) {  // 8 stands for "FB/M.m f"(oo)
        send_line_log(fd, fl_line_unrecognized, msg);
        return 1;
    }

    /* check if client protocol is compatible; for simplicity, we don't support client protocol more recent
     * than server protocol, we suppose that our servers are upgraded when a new release appears (but of
     * course client protocol older is supported within the major protocol) */
    client_proto_major = charstar_to_int(msg + 3);
    client_proto_minor = charstar_to_int(msg + 5);
    if (client_proto_major != proto_major
            || client_proto_minor > proto_minor) {
        send_line_log(fd, fl_proto_mismatch, msg);
        return 1;
    }

    if (remote_proto_minor[fd] == -1)
        remote_proto_minor[fd] = client_proto_minor;

    msg_orig = strdup(msg);

    /* after protocol, first word is command, then possible args */
    current_command = msg + 7; // 7 stands for "FB/M.m "
    if ((ptr = strchr(current_command, ' '))) {
        *ptr = '\0';
        args = current_command + strlen(current_command) + 1;
    } else
        args = NULL;

    if (streq(current_command, "PING")) {
        send_line_log(fd, ok_pong, msg_orig);
    } else if (streq(current_command, "NICK")) {
        if (!args) {
            send_line_log(fd, wn_missing_arguments, msg_orig);
        } else {
            if ((ptr = strchr(args, ' ')))
                *ptr = '\0';
            if (strlen(args) > 10)
                args[10] = '\0';
            if (!is_nick_ok(args)) {
                send_line_log(fd, wn_nick_invalid, msg_orig);
            } else {
                if (nick[fd] != NULL) {
                    free(nick[fd]);
                }
                nick[fd] = strdup(args);
                calculate_list_games();
                send_ok(fd, msg_orig);
            }
        }
    } else if (streq(current_command, "GEOLOC")) {
        if (!args) {
            send_line_log(fd, wn_missing_arguments, msg_orig);
        } else {
            if ((ptr = strchr(args, ' ')))
                *ptr = '\0';
            if (strlen(args) > 13)  // sign, 4 digits, dot, colon, sign, 4 digits, dot
                args[13] = '\0';
            if (geoloc[fd] != NULL) {
                free(geoloc[fd]);
            }
            geoloc[fd] = strdup(args);
            calculate_list_games();
            send_ok(fd, msg_orig);
        }
    } else if (streq(current_command, "CREATE")) {
        if (!args) {
            send_line_log(fd, wn_missing_arguments, msg_orig);
        } else {
            if ((ptr = strchr(args, ' ')))
                *ptr = '\0';
            if (strlen(args) > 10)
                args[10] = '\0';
            if (!is_nick_ok(args)) {
                send_line_log(fd, wn_nick_invalid, msg_orig);
            } else if (!nick_available(args)) {
                send_line_log(fd, wn_nick_in_use, msg_orig);
            } else if (already_in_game(fd)) {
                send_line_log(fd, wn_already_in_game, msg_orig);
            } else if (games_open == 16) {  // FB client can display 16 max
                send_line_log(fd, wn_max_open_games, msg_orig);
            } else {
                create_game(fd, strdup(args));
                send_ok(fd, msg_orig);
            }
        }
    } else if (streq(current_command, "JOIN")) {
        if (!args || !(ptr = strchr(args, ' '))) {
            send_line_log(fd, wn_missing_arguments, msg_orig);
        } else {
            struct game * g;
            char* nick = ptr + 1;
            *ptr = '\0';
            if ((ptr2 = strchr(ptr, ' ')))
                *ptr2 = '\0';
            if (strlen(nick) > 10)
                nick[10] = '\0';
            if (!is_nick_ok(nick)) {
                send_line_log(fd, wn_nick_invalid, msg_orig);
            } else if (!nick_available(nick)) {
                send_line_log(fd, wn_nick_in_use, msg_orig);
            } else if (already_in_game(fd)) {
                send_line_log(fd, wn_already_in_game, msg_orig);
            } else if (!(g = find_game_by_nick(args))) {
                send_line_log(fd, wn_no_such_game, msg_orig);
            } else {
                if (add_player(g, fd, strdup(nick)))
                    send_ok(fd, msg_orig);
                else
                    send_line_log(fd, wn_game_full, msg_orig);
            }
        }
    } else if (streq(current_command, "KICK")) {
        if (!args) {
            send_line_log(fd, wn_missing_arguments, msg_orig);
        } else {
            if ((ptr = strchr(args, ' ')))
                *ptr = '\0';
            if (strlen(args) > 10)
                args[10] = '\0';
            if (!already_in_game(fd)) {
                send_line_log(fd, wn_not_in_game, msg_orig);
            } else {
                struct game * g = find_game_by_fd(fd);
                if (g->players_conn[0] != fd) {
                    send_line_log(fd, wn_not_creator, msg_orig);
                } else {
                    kick_player(fd, g, args);
                }
            }
        }
    } else if (streq(current_command, "PART")) {
        if (!already_in_game(fd)) {
            send_line_log(fd, wn_not_in_game, msg_orig);
        } else {
            player_part_game(fd);
            send_ok(fd, msg_orig);
        }
    } else if (streq(current_command, "LIST")) {
        send_line_log(fd, list_games_str, msg_orig);
    } else if (streq(current_command, "STATUS")) {  // 1.0 command
        if (!already_in_game(fd)) {
            send_line_log(fd, wn_not_in_game, msg_orig);
        } else {
            status(fd, msg_orig);
        }
    } else if (streq(current_command, "STATUSGEO")) {
        if (!already_in_game(fd)) {
            send_line_log(fd, wn_not_in_game, msg_orig);
        } else {
            status_geo(fd, msg_orig);
        }
    } else if (streq(current_command, "PROTOCOL_LEVEL")) {
        if (!already_in_game(fd)) {
            send_line_log(fd, wn_not_in_game, msg_orig);
        } else {
            protocol_level(fd, msg_orig);
        }
    } else if (streq(current_command, "TALK")) {
        if (!args) {
            send_line_log(fd, wn_missing_arguments, msg_orig);
        } else {
            talk(fd, args);
        }
    } else if (streq(current_command, "START")) {
        if (!already_in_game(fd)) {
            send_line_log(fd, wn_not_in_game, msg_orig);
        } else {
            start_game(fd);
        }
    } else if (streq(current_command, "CLOSE")) {
        if (!already_in_game(fd)) {
            send_line_log(fd, wn_not_in_game, msg_orig);
        } else {
            close_game(fd);
        }
    } else if (streq(current_command, "SETOPTIONS")) {
        if (!args) {
            send_line_log(fd, wn_missing_arguments, msg_orig);
        } else if (!already_in_game(fd)) {
            send_line_log(fd, wn_not_in_game, msg_orig);
        } else {
            setoptions(fd, args);
        }
    } else if (streq(current_command, "LEADER_CHECK_GAME_START")) {
        if (!already_in_game(fd)) {
            send_line_log(fd, wn_not_in_game, msg_orig);
        } else {
            leader_check_game_start(fd);
        }
    } else if (streq(current_command, "OK_GAME_START")) {
        if (!already_in_game(fd)) {
            send_line_log(fd, wn_not_in_game, msg_orig);
        } else {
            ok_start_game(fd);
        }
    } else if (streq(current_command, "ADMIN_REREAD")) {
        if (!admin_authorized[fd]) {
            send_line_log(fd, wn_denied, msg_orig);
        } else {
            reread();
            send_ok(fd, "ADMIN_REREAD");
        }
    } else {
        send_line_log(fd, wn_unknown_command, msg);
    }

    free(msg_orig);
    current_command = NULL;

    return 0;
}
Esempio n. 10
0
int main( int argc, char *argv[] )
{
    int res=0;
    if (argc < 3)
    {
        printf("frunagent <nodelist> start \"command\" [options] \n"
               "                     stop <commandid> [options]\n"
               "                     account <user> <password> <dir> [option]\n"
               "                     dir <dir> [option]\n"
               "                     alive <integer> [option]\n\n"
               "where <nodelist> is of the form h009100:h009119,h007010:h007020\n"
               "or 192.168.6.100:192.168.6.119,192.168.7.10:192.168.7.20\n"
               "or @filename where filename contains a file in the above format\n"
               "options: /n<number_of_thread> /t<call_time_out> /encrypt /o<replication_offset>\n"
              );
        return 255;
    }

    InitModuleObjects();

    StringBuffer tracepath;
    tracepath.append(".").append(PATHSEPCHAR).append("frunagent.txt");
    settrace(tracepath.str(),false);
    ECHO_TO_CONSOLE=true;

    try
    {
        setoptions(argc,argv);
        split_node x(argc,argv);
        if (argv[1][0]=='@')
        {
            StringBuffer b;
            b.loadFile(argv[1]+1);
            char *finger = (char *) b.str();
            while (*finger)
            {
                if (*finger == '\n')
                    *finger++ = ';';
                else if (*finger == '#')
                {
                    while (*finger && *finger != '\n')
                        *finger++ = ' ';
                }
                else
                    finger++;
            }
            x.split_nodes_ex(b.str(),replicationoffset);
        }
        else
            x.split_nodes_ex(argv[1],replicationoffset);
        disp->all_done_ex(false);
    }
    catch(IException *e)
    {
        pexception("",e);
        e->Release();
        res=255;
    }
    catch (...)
    {
        traceft("Caught unknown exception");
    }
#ifdef _TRACING
    traceflush();
#endif
    if (disp) delete disp;

    return res;
}
Esempio n. 11
0
int main(int argc, char** argv) {
    u_char *packet;
    int i;
    uint32_t ck;
    
    struct sockaddr *sin_src;
    struct sockaddr *sin_net;
    struct sockaddr *sin_dst;
    struct sockaddr *sin_mask;
    struct ip6_pseudo_hdr ps_hdr;
    int sendsize;
    struct options opts;
    FILE* fp_domain;
    char * domain;
    struct writer_info wi;
    int pkt_len;
    
    double speed_limit;
    double pkt_sent;

    

    int q_class;
    int q_type;


    pthread_t thread;


    pthread_create(&thread,NULL,readliner,&speed_limit);

    sleeper = 50;
    pkt_sent = 0;
    speed_limit = 50000;
    /**
     * 
     * headers
     */
    struct ether_header *eth;
    struct iphdr *ip;
    struct ip6_hdr *ip6;
    struct udphdr *udp;
    u_char *dns;
    u_char dns_opt[] = {00, 00, 0x29, 0x08, 00, 00, 00, 00, 00, 00, 00};
    setoptions(argc, argv, &opts);
    
    


    

    

    

    packet = calloc(sizeof (u_char) * 4096, 1);
    sin_src = calloc(sizeof (struct sockaddr_storage), 1);
    sin_net = calloc(sizeof (struct sockaddr_storage), 1);
    sin_dst = calloc(sizeof (struct sockaddr_storage), 1);
    sin_mask = calloc(sizeof (struct sockaddr_storage), 1);
    domain = calloc(sizeof (char) * 1024, 1);
    //domain = NULL;
    
    if (packet == NULL ||
            sin_src == NULL ||
            sin_net == NULL ||
            sin_dst == NULL ||
            sin_mask == NULL ||
            domain == NULL) {
        return -1;
    }

    /**
     * 
     * ETHERNET static
     */

    eth = (struct ether_header *) packet;

    if (ether_setaddr(opts.smac, &(eth->ether_shost)) < 0) {
        fprintf(stderr, "smac error:%s\n");
        return 1;
    }
    if (ether_setaddr(opts.dmac, &(eth->ether_dhost)) < 0) {
        fprintf(stderr, "dmac error\n");
        return 1;
    }

    /**
     * 
     * IP static
     */
    if (getipaddr(opts.dip, sin_dst, opts.family) < 0) {
        fprintf(stderr, "dip error\n");
        return 2;
    }
    if (getipaddr(opts.snet, sin_net, opts.family) < 0) {
        fprintf(stderr, "sip error\n");
        return 2;
    }

    if (sin_net->sa_family != sin_dst->sa_family) {
        fprintf(stderr, "IP family doesn't match\n");
        return 2;
    }

    set_mask(sin_mask, sin_net->sa_family, opts.smask);

    if (sin_net->sa_family == AF_INET) {
        eth->ether_type = htons(ETHERTYPE_IP);

        ip = (struct iphdr *) (packet + ETHER_HDR_LEN);
        ip->daddr = ((struct sockaddr_in *) sin_dst)->sin_addr.s_addr;


        ip->version = 4;
        ip->ihl = 5; // no opts
        ip->frag_off = 0;
        ip->id = 0;
        ip->protocol = IPPROTO_UDP;
        ip->tos = 0;
        ip->ttl = IPDEFTTL;


        udp = (struct udphdr *) (((void *) ip) + IP_HDR_LEN);
    } else if (sin_net->sa_family == AF_INET6) {
        eth->ether_type = htons(ETHERTYPE_IPV6);

        ip6 = (struct ip6_hdr *) (packet + ETHER_HDR_LEN);
        ip6->ip6_vfc = 6 << 4;
        ip6->ip6_hlim = IPDEFTTL;
        ip6->ip6_nxt = IPPROTO_UDP;

        memcpy(&(ip6->ip6_dst), &(((struct sockaddr_in6 *) sin_dst)->sin6_addr), 16);

        udp = (struct udphdr *) (((void *) ip6) + IP6_HDR_LEN);
    } else {
        fprintf(stderr, "Family unknown\n");
        return 2;
    }

    /**
     * 
     * UDP static
     */
    //udp->check = 0;
    udp->dest = htons(53);

    /**
     * 
     * DNS static
     */
    dns = (u_char *) (((void *) udp) + UDP_HDR_LEN);


    wopen(&wi,&opts);
    
    init_domain_file(&fp_domain, opts.in_file_name);
    if (fp_domain == NULL) {
        fprintf(stderr, "Can't open queries file\n");
        wclose(&wi);
        
        return 4;
    }
    for (i = 0; i < opts.count; i++) {
	if(pkt_sent >= sleeper) {
		speed_calc(pkt_sent,speed_limit, &sleeper);
                pkt_sent = 0;
		usleep(1);
	}
        /**
         * 
         * DNS dynamic
         */
        if(nextdomain(fp_domain, &domain, &q_type, &q_class)) {
            printf("Can't read next domain\n");
            exit(1);
        }

        sendsize = res_mkquery(QUERY, domain, q_class, q_type, NULL,
                0, NULL, dns, PACKETSZ);
        dns[11] = 1;
        memcpy(dns + sendsize, dns_opt, 11);
        sendsize += 11;
        /**
         * 
         * UDP dynamic
         */
        udp->source = htons(rand());
        udp->len = htons(sendsize + UDP_HDR_LEN);
        udp->check = 0;
        /**
         * 
         * IP dynamic
         */
        get_rand_addr(sin_net, sin_mask, sin_src);

        if (sin_net->sa_family == AF_INET) {
            ip->saddr = ((struct sockaddr_in *) sin_src)->sin_addr.s_addr;
            ip->tot_len = htons(sendsize + UDP_HDR_LEN + (ip->ihl * 4));
            pkt_len = sendsize + UDP_HDR_LEN + (ip->ihl * 4) + ETHER_HDR_LEN;

            ip->check = 0;
            ip->check = inet_cksum(ip, (ip->ihl * 4), 0);
        } else if (sin_net->sa_family == AF_INET6) {
            memcpy(&(ip6->ip6_src), &(((struct sockaddr_in6 *) sin_src)->sin6_addr), 16);
            ip6->ip6_plen = htons(sendsize + UDP_HDR_LEN);
            pkt_len = sendsize + UDP_HDR_LEN + sizeof (struct ip6_hdr) +ETHER_HDR_LEN;

            ps_hdr.src = ip6->ip6_src;
            ps_hdr.dst = ip6->ip6_dst;
            ps_hdr.len = udp->len;
            ps_hdr.nh = ntohs(17);

            ck = inet_cksum(&ps_hdr, sizeof (ps_hdr), 0);
            udp->check = inet_cksum(udp, sendsize + UDP_HDR_LEN, (~ck)&0xffff);
        }


        
        
        if (pkt_len > opts.mtu) {
            fprintf(stderr, "too long: %s needs %d MTU is %d\n", domain, pkt_len, opts.mtu);
        } else {
            wwrite(&wi,packet,pkt_len);
        }
	pkt_sent++;
    }

    wclose(&wi);
    fclose(fp_domain);

    return (EXIT_SUCCESS);
}
void cfe_main(int a,int b)
{

    /*
     * By the time this routine is called, the following things have
     * already been done:
     *
     * 1. The processor(s) is(are) initialized.
     * 2. The caches are initialized.
     * 3. The memory controller is initialized.
     * 4. BSS has been zeroed.
     * 5. The data has been moved to R/W space.
     * 6. The "C" Stack has been initialized.
     */

    cfe_bg_init();		       		/* init background processing */
    cfe_attach_init();
    cfe_timer_init();				/* Timer process */
    cfe_bg_add(cfe_device_poll,NULL);

    /*
     * Initialize the memory allocator
     */
        
    SETLEDS("KMEM");
    KMEMINIT((unsigned char *) (uintptr_t) mem_heapstart,
	     ((CFG_HEAP_SIZE)*1024));

    /*
     * Initialize the console.  It is done before the other devices
     * get turned on.  The console init also sets the variable that
     * contains the CPU speed.
     */

    SETLEDS("CONS");
    board_console_init();

    /*
     * Set up the exception vectors
     */

    cfe_setup_exceptions();

    /* 
     * Say hello.
     */

    SETLEDS("CIOK");
    cfe_say_hello();

    /*
     * Initialize the other devices.
     */

    SETLEDS("AREN");
#if CFG_XIP
	xprintf("CFE XIP\n");
#endif
    xprintf("Init Arena\n");
    cfe_arena_init();

#if CFG_PCI
    if (cfe_startflags & CFE_INIT_PCI) {
	pci_flags_t flags = PCI_FLG_NORMAL | PCI_FLG_LDT_PREFETCH;
#ifndef EB332
	char *str;
	extern cons_t pci_optnames[];

	flags = PCI_FLG_NORMAL | PCI_FLG_LDT_PREFETCH;
#if CFG_LDT_REV_017
	flags |= PCI_FLG_LDT_REV_017;
#endif
	str = env_getenv("PCI_OPTIONS");
	setoptions(pci_optnames,str,&flags);

	xprintf("Initializing PCI. [%s]\n",str ? str : "normal");
#endif
	pci_configure(flags);
	}
#endif

    SETLEDS("DEVI");
    xprintf("Init Devs.\n");
    board_device_init();

    cfe_startup_info();
    SETLEDS("ENVI");
    cfe_setup_default_env();

    xprintf("\n");

    cfe_init_ui();

    board_final_init();

    cfe_autostart();

    cfe_command_loop();
}
Esempio n. 13
0
int main( int argc, char **argv )
{
    int     i;
    FILE    *skeleton, *temp, *tokout, *actout;
    int     ch;
    char    tempfname[10];
    char    *fileprefix = "y";
    size_t  size;

    param_requested = 0;
    for( i = 1; i < argc; ++i ) {
        ch = argv[i][0];
        switch( param_requested ) {
        case 'b':
            if( ch != '-' ) {
                if( ch != '\0' )
                    fileprefix = argv[i];
                ++i;
            }
            break;
        case 'p':
            if( ch != '-' ) {
                if( ch != '\0' )
                    symprefix = argv[i];
                ++i;
            }
            break;
        default:
            break;
        }
        param_requested = 0;
        if( argv[i][0] != '-' )
            break;
        setoptions( &argv[i][1] );
    }
    if( i != argc - 1 && i != argc - 2 ) {
        puts( "usage: yacc [-dlv] [-d[bcdfhpstuw]] [-b <file_prefix>] [-p <sym_prefix>]" );
        puts( "                  <grammar> [<driver>]" );
        puts( "options:" );
        puts( "    -b <file_prefix> file prefix used in place of default 'y' prefix" );
        puts( "    -d    output header file" );
        puts( "    -db   output bigger (less optimal) tables" );
        puts( "    -dc   output compact tables (slower to execute)" );
        puts( "    -dd   use dense tokens (no '+' style tokens allowed)" );
        puts( "    -de   dump all symbols to header file as enum items, no macros" );
        puts( "    -df   output fast tables (larger size)" );
        puts( "    -dh   use 'default shift' optimization" );
        puts( "    -dp   dump all productions" );
        puts( "    -ds   dump full state tables" );
        puts( "    -dt   translate 'keyword' to Y_KEYWORD, '++' to Y_PLUS_PLUS, etc." );
        puts( "    -du   eliminate useless unit production reduction" );
        puts( "    -dw   disable default action type checking" );
        puts( "    -l    output #line directives" );
        puts( "    -p <sym_prefix> symbol prefix used in place of default 'yy' prefix" );
        puts( "    -v    write description and report into file" );
        exit( 1 );
    }
    skeleton = NULL;
    if( i == argc - 2 ) {
        skeleton = openr( argv[argc - 1] );
        if( skeleton == NULL ) {
            msg( "could not open driver source code '%s'\n", argv[argc - 1] );
        }
    }
    loadpath = argv[0];
    *getname( loadpath ) = '\0';
    srcname = argv[i];
    if( !strrchr( srcname, '.' ) ) {
        srcname = alloca( strlen( argv[i] )+3 );
        srcname = strcat( strcpy( srcname, argv[i] ), ".y" );
    }
    yaccin = openr( srcname );

    size = strlen( fileprefix);
    codefilename   = MALLOC( size + 6, char );
    strcat( strcpy( codefilename, fileprefix), "tab.c" );
    headerfilename = MALLOC( size + 6, char );
    strcat( strcpy( headerfilename, fileprefix), "tab.h" );
    descfilename   = MALLOC( size + 5, char );
    strcat( strcpy( descfilename, fileprefix), ".out" );
    actout = openw( codefilename );
    defs( actout );
    tokout = openw( headerfilename );
    dump_header( tokout );
    temp = NULL;
    for( i = 0; i < 1000 && temp == NULL; ++i ) {
        sprintf( tempfname, "ytab.%3d", i );
        temp = fopen( tempfname, "w+" );
    }
    if( temp == NULL ) {
        msg( "Cannot create temporary file\n" );
    }
    rules( temp );
    buildpro();
    CalcMinSentence();
    if( proflag || showflag ) {
        showpro();
    }
    lr0();
    lalr1();
    SetupStateTable();
    /* apply state filters */
    FindUnused();
    if( eliminateunitflag ) {
        EliminateUnitReductions();
    }
    if( default_shiftflag ) {
        if( keyword_id_low == 0 ) {
            msg( "No %%keyword_id <low> <high> specified." );
        } else {
            MarkDefaultShifts();
        }
    }
    MarkNoUnitRuleOptimizationStates();
    RemoveDeadStates();
    MarkDefaultReductions();
    if( showflag ) {
        showstates();
    }
    if( warnings ) {
        if( warnings == 1 ) {
            printf( "%s: 1 warning\n", srcname );
        } else {
            printf( "%s: %d warnings\n", srcname, warnings );
        }
        exit( 1 );
    }
    parsestats();
    dumpstatistic( "parser states", nstate );
    dumpstatistic( "# states (1 reduce only)", nstate_1_reduce );
    dumpstatistic( "reduce/reduce conflicts", RR_conflicts );
    dumpstatistic( "shift/reduce conflicts", SR_conflicts );
    show_unused();
    if( skeleton == NULL ) {
        skeleton = fpopen( loadpath, "yydriver.c" );
        if( skeleton == NULL ) {
            warn( "Can't find yacc skeleton yydriver.c\n" );
        }
    }
    /* copy first part of skeleton */
    if( skeleton != NULL )
        copy_part( skeleton, actout );
    rewind( tokout );
    /* copy tokens */
    copy_rest( tokout, actout );
    close_header( tokout );
    genobj( actout );
    /* copy middle part of skeleton */
    if( skeleton != NULL )
        copy_part( skeleton, actout );
    rewind( temp );
    copy_rest( temp, actout );
    fclose( temp );
    remove( tempfname );
    /* copy last part of skeleton */
    if( skeleton != NULL ) {
        copy_rest( skeleton, actout );
        fclose( skeleton );
    }
    tail( actout );
    fclose( actout );
    FREE( codefilename );
    FREE( headerfilename );
    FREE( descfilename );
    return( 0 );
}