Пример #1
0
static int macro(char *name) {
	int	y;

	y = findmac(name);
	if (!y || Types[y] != TMACRO)
		return 0;
	playmac(Mtext[y]);
	return 1;
}
Пример #2
0
doundef ()
{
	int	mp;
	char	sname[NAMESIZE];

	if (!symname(sname)) {
		illname();
		kill();
		return;
	}

	if (mp = findmac(sname))
		delmac(mp);
	kill();
}
Пример #3
0
int main(int argc, char *argv[])
{
        pcap_if_t *alldevs, *dev;
        pcap_if_t dev2;
	char errbuf[PCAP_ERRBUF_SIZE];
        int i=0;
        int totaldev = 0;

	struct bpf_program fp;		/* The compiled filter expression */
	char filter_exp[] = "";	/* The filter expression */
	bpf_u_int32 mask;		/* The netmask of our sniffing device */
	bpf_u_int32 net;		/* The IP of our sniffing device */

        int pid;
        /*
        pid = fork();
        if (pid < 0)
        {
             printf("fork failed!\n");
             exit(1);
        }
        else if (pid == 0)
             execl("node", "server.js", (char *) 0);
        */
        pid = fork();
        if (pid < 0)
        {
             printf("fork failed!\n");
             exit(1);
        }
        else if (pid == 0)
        {
             execl("libpy/data_entry.py", (char *) 0);
             exit(1);
        }

        pid = fork();
        if (pid < 0)
        {
             printf("fork failed!\n");
             exit(1);
        }
        else if (pid == 0)
        {
             system("node server.js");
             exit(1);
        } 
        parse_ignorelist();

        if (pcap_findalldevs(&alldevs, errbuf) == -1)
        {
            fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf);
            exit(1);
        }
        /*
	dev = pcap_lookupdev(errbuf);
	if (dev == NULL) {
		fprintf(stderr, "Couldn't find default device: %s\n", errbuf);
		return(2);
	}
	printf("Device: %s\n", dev);
        */
        for(dev=alldevs; dev; dev=dev->next)
        { 
            totaldev++;
            printf("%d. %s", ++i, dev->name);
            if (dev->description)
                printf(" (%s)\n", dev->description);
            else
                printf(" (No description available)\n");
        }
        printf("Total Devices %d\n", totaldev);
        int no;
        printf("Enter choice\t");
        scanf("%d",&no);
        if(no < 1 || no > totaldev)
        {
            printf("\nInterface number out of range.\n");
            /* Free the device list */
            pcap_freealldevs(alldevs);
            return -1;
        }
            /* Jump to the selected adapter */
        for(dev=alldevs, i=0; i<no-1 ;dev=dev->next, i++);

        printf("%s",dev->name);
        printf("%s",dev->addresses->addr); 
        pcap_t *handle;
        handle = pcap_open_live(dev->name, BUFSIZ, 1, 1000, errbuf);
        if (handle == NULL) {
            fprintf(stderr, "Couldn't open device %s: %s\n", dev, errbuf);
            pcap_freealldevs(alldevs);
	    return(2);
	}
         // To get net and mask of the interface
        if (pcap_lookupnet(dev->name, &net, &mask, errbuf) == -1) {
	    fprintf(stderr, "Can't get netmask for device %s\n", dev->name);
	    net = 0;
	    mask = 0;
	}

	if (pcap_compile(handle, &fp, filter_exp, 0, net) == -1) {
	    fprintf(stderr, "Couldn't parse filter %s: %s\n", filter_exp, pcap_geterr(handle));
            pcap_freealldevs(alldevs);
	    return(2);
	}
	if (pcap_setfilter(handle, &fp) == -1) {
	    fprintf(stderr, "Couldn't install filter %s: %s\n", filter_exp, pcap_geterr(handle));
            pcap_freealldevs(alldevs);
	    return(2);
	}
       
        findmac(dev->name, &hwaddr);

        /* we don't need any more the device list. Free it */
        pcap_freealldevs(alldevs);

        //pcap_loop(handle, 10, parse_packet, NULL);
        while (1==1)
            pcap_loop(handle, 1, parse_packet, NULL);


        /*
        ####To travese a packet using pcap_next
        
	struct pcap_pkthdr header;	// The header that pcap gives us 
	const u_char *packet;		// The actual packet 
	// Grab a packet 
	packet = pcap_next(handle, &header);
	// Print its length
	printf("Jacked a packet with length of [%d]\n", header.len);
	// And close the session 
	pcap_close(handle);
        */

	return(0);
}
Пример #4
0
void 
#endif

dumpfns()
{
    int ident,type,storage;
    SYMBOL *ptr;
    FILE    *fp;

#ifdef HEADERFILE
    outstr(";\tHeader file for file:\t");
    outstr(Filename);
    outstr("\n;\n;\tEven if empty do not delete!!!\n");
    outstr(";\n;\t***START OF HEADER DEFNS***\n\n");
#else
    outstr("\n\n; --- Start of Scope Defns ---\n\n");
#endif
    if (!glbcnt)
        return;

/* Start at the start! */
    glbptr=STARTGLB;

    ptr=STARTGLB;
    while (ptr < ENDGLB) {
        if (ptr->name[0] != 0 && ptr->name[0] != '0' ) {
            ident=ptr->ident;
         if (ident==FUNCTIONP) ident=FUNCTION;
            type =ptr->type;
            storage=ptr->storage;
            if ( ident == FUNCTION && ptr->size != 0 ) {
                outstr("\tdefc\t");
                outname(ptr->name,1);
                ot("=\t");
                outdec(ptr->size);
                nl();
            } else {
                if (ident == FUNCTION && storage!=LSTATIC ) {
                    if (storage==EXTERNAL) {
                        if (ptr->flags&LIBRARY) {
                            GlobalPrefix(LIB);
                            if ( (ptr->flags&SHARED) && useshare ){
                                outstr(ptr->name); outstr("_sl\n");
                                GlobalPrefix(LIB);
                            }
                        } else {
                            GlobalPrefix(XREF);
                        }
                    } else {
                        if (ptr->offset.i == FUNCTION || ptr->storage==DECLEXTN )
                            GlobalPrefix(XDEF);
                        else
                            GlobalPrefix(XREF);
                    }
                    outname(ptr->name,dopref(ptr));
                    nl();
                } else {
                    if (storage == EXTERNP) {
                        GlobalPrefix(XDEF);
                        outname(ptr->name,1);
                        nl();
                        outstr("\tdefc\t");
                        outname(ptr->name,1);
                        ot("=\t");
                        outdec(ptr->size);
                        nl();
                    } else  if (ident != ENUM && type !=ENUM && ident != MACRO && storage != LSTATIC && storage != LSTKEXT && storage!=TYPDEF ) {
                        if (storage == EXTERNAL)
                            GlobalPrefix(XREF);
                        else 
                            GlobalPrefix(XDEF);
                        outname(ptr->name,1);
                        nl();
                    }
                }
            }
        }
        ++ptr;
    }
/*
 *      If a module requires floating point then previously we wrote
 *      it out to the header file. However, if the module didn't
 *      contain main() then important routines wouldn't be included.
 *      So, if main didn't need float, but ours did we couldn't
 *      compile correctly.
 *
 *      The solution was to separate startup code, and then define
 *      a new file to which all the math type headers would be
 *      appended.
 *
 *      This file is zcc_opt.def in the source code directory.
 *
 */

    if ( (fp=fopen("zcc_opt.def","a")) == NULL ) {
        error(E_ZCCOPT);
    }
/* Now output the org */
    if (zorg) {
        fprintf(fp,"\nIF !DEFINED_myzorg\n");
        fprintf(fp,"\tDEFINE DEFINED_myzorg\n");
        fprintf(fp,"\tdefc myzorg = %u\n",zorg);
        fprintf(fp,"ENDIF");
    }
    if (appz88) {
        int k,value=0;
        fprintf(fp,"\nIF !NEED_appstartup\n");
        fprintf(fp,"\tDEFINE\tNEED_appstartup\n");
        if (safedata != -1 )
            fprintf(fp,"\tdefc safedata = %d\n",safedata);
        if (intuition)
            fprintf(fp,"\tdefc intuition = 1\n");
        if (farheapsz != -1) {
            fprintf(fp,"\tDEFINE DEFINED_farheapsz\n");
            fprintf(fp,"\tdefc farheapsz = %d\n",farheapsz);
        }
 
        if (reqpag != -1 ) {
            fprintf(fp,"\tdefc reqpag = %d\n",reqpag);
            value=reqpag;
        }
        else {
/*
 * Consider the malloc pool as well, if defined we need 32 (standard) +
 * size of malloc - this is a little kludgy, hence the tuning command
 * line option
 */
            if ( (k=findmac("HEAPSIZE"))) {
                sscanf(&macq[k],"%d",&value);
                if (value != 0 ) value/=256;
            }
            value+=32;
            fprintf(fp,"\tdefc reqpag = %d\n",value);
        }
        if (value > 32) expanded=YES;
        fprintf(fp,"\tdefc NEED_expanded = %d\n",expanded);
        fprintf(fp,"ENDIF\n\n");

    }
    if (incfloat) {
        fprintf(fp,"\nIF !NEED_floatpack\n");
        fprintf(fp,"\tDEFINE\tNEED_floatpack\n");
        fprintf(fp,"ENDIF\n\n");
    }
    if (mathz88) {
        fprintf(fp,"\nIF !NEED_mathz88\n");
        fprintf(fp,"\tDEFINE\tNEED_mathz88\n");
        fprintf(fp,"ENDIF\n\n");
    }
    if (lpointer) {
        fprintf(fp,"\nIF !NEED_farpointer\n");
        fprintf(fp,"\tDEFINE NEED_farpointer\n");
        fprintf(fp,"ENDIF\n\n");
    }
    if (startup) {
        fprintf(fp,"\nIF !DEFINED_startup\n");
        fprintf(fp,"\tDEFINE DEFINED_startup\n");
        fprintf(fp,"\tdefc startup=%d\n",startup);
        fprintf(fp,"ENDIF\n\n");
    }
/*
 * Now, we're gonna use #pragma define _FAR_PTR to indicate whether we need
 * far stuff - this has to go with a -D_FAR_PTR from the compile line
 * as well for everything to work just right, so if we find this then
 * we can indicate to the startup code via zcc_opt.def what the scam
 * is - this could be used for eg. to allocate space for file structures
 * etc
 */
    if ( (ptr=findglb("_FAR_PTR")) && ptr->ident==MACRO ) {
        fprintf(fp,"\nIF !NEED_farstartup\n");
        fprintf(fp,"\tDEFINE NEED_farstartup\n");
        fprintf(fp,"ENDIF\n\n");
    }

    fclose(fp);

   if ( defvars != 0 )
      WriteDefined("defvarsaddr",defvars);

   switch(printflevel) {
    case 1:  
        WriteDefined("ministdio",0);
        break;
    case 2:
        WriteDefined("complexstdio",0);
        break;
    case 3:
        WriteDefined("floatstdio",0);
        break;
   }
 

/*
 * DO_inline is obsolete, but it may have a use sometime..
 */
    if (doinline)
        outstr("\tDEFINE\tDO_inline\n");
    outstr("\n\n; --- End of Scope Defns ---\n\n");
}