Ejemplo n.º 1
0
int main(int argc, char **argv)
{
  int ret;

  while((ret=getopt_clone(argc,argv,piip)) != GETOPT_RETURN_LAST)
  {
    if(ret == GETOPT_RETURN_FAILURE)
      return 1;

    else if(ret == GETOPT_RETURN_NORMAL)
    {
      print_out("Normal parameter at pos %d: \"%s\"\n",nextpos,
        optarg_clone);
    }
    else
    {
      print_out("Flag argument at pos %d: %d\"--%s\"",nextpos,ret,
        piip[ret].longflag);
      if(optarg_clone)
        print_out(" with argument \"%s\"",optarg_clone);
      print_out("\n");
    }
  }
  return 0;
}
Ejemplo n.º 2
0
int main(int argc,char *argv[])
{
  Seg_list seg_list;
  Point_list_list output_list;

  Number_Type prec;

  if (!read_data(argc,argv,prec,seg_list))
    return -1;

  CGAL::snap_rounding_2<Sr_traits, Seg_list::const_iterator,
                        Point_list_list>(seg_list.begin(),
                                         seg_list.end(),
                                         output_list,
                                         prec, true, false, 3);

  std::cout << "input segments" << std::endl;
  std::list<Segment_2>::iterator i1;
  for (i1 = seg_list.begin(); i1 != seg_list.end(); ++i1)
    std::cout << *i1 << std::endl;

  std::cout << std::endl << "the output" << std::endl;
  print_out(output_list.begin(),output_list.end());

  std::cout << std::endl << "testing sr" << std::endl;
  output_list.clear();
  CGAL::snap_rounding_2<Sr_traits, Seg_list::const_iterator,
                        Point_list_list>(seg_list.begin(),
                                         seg_list.end(),
                                         output_list,
                                         prec, false, false, 3);
   print_out(output_list.begin(),output_list.end());

   return(0);
}
Ejemplo n.º 3
0
Archivo: yab.c Proyecto: aragaer/bact
/* 0 if everything is solved, -1 on error, 1 on partial success */
static inline int unmake(struct level *level) {
    cell_t *map = level->map;
    int pos = 0, local_depth = level->solution_depth;

#ifndef ONLINE_JUDGE
        print_out(map, level->knowledge);
        printf(" ||%d\n \\/\n", local_depth);
#endif
    while (map[pos] != 1)
        pos++;
    while (pos < area) {
        if (untake_bacteria(map, pos))
            return -1;
        solution[local_depth++] = pos;
        if (local_depth == area)
            return 0;
#ifndef ONLINE_JUDGE
        print_out(map, level->knowledge);
        printf(" ||%d (%d)\n \\/\n", local_depth, pos);
#endif
        if (map[up[pos]] == 1)
            pos = up[pos];
        else if (map[left[pos]] == 1)
            pos = left[pos];
        else /* fast-forward to next 1 */
            while (map[pos] != 1)
                pos++;
    }
    level->solution_depth = local_depth;
    return local_depth != area;
}
Ejemplo n.º 4
0
void print_version()
{
    print_out(" ");
    print_out("%s %s - %s", __name, __version, __author);
    print_out(" ");
    print_out("%s",__license);
    exit(1);
}
Ejemplo n.º 5
0
/**
	Service event to wait on an I/O operation.

	This function services requests to check an I/O operation for completion.
	If the operation is complete, the process resumes execution immediately;
	otherwise, the process is blocked.

	<b> Important Notes:</b>
	\li Events of type WIO_EVT will result in this call via
	Interrupt_Handler() in simulator.c after interrupt() in obj1.c sets the
	global Event variable.
	\li WIO, unlike SIO, is a blocking I/O operation. As such, the program
	causing the event will be blocked (removed from the ready queue or from the
	CPU) after this event is serviced. However, if I/O had already been
	started from an earlier SIO event, then the process may be able to
	continue, but only if the I/O request has already been completed.
	\li Retrieving the request instruction (REQ) from memory is done similarly
	to finding the device ID in Alloc_rb(). The saved CPU information is used
	to find the necessary segment in the PCB's segment table. Once the segment
	has been found, the segment base is added to the current PC offset (minus
	1) to get the position in memory that the request instruction is located
	at.
	\li The request instruction's operand, which is an address, should be
	passed to Find_rb() to find the needed request block as the request address
	holds information pointing to the device being waited on.

	<b> Algorithm: </b>
	\verbatim
	Retrieve pcb from the terminal table that is waiting for I/O

	Retrieve request instruction using saved CPU information

	Locate request block that process wants to wait for--call Find_rb()

	Determine status of request block
		If rb is still active or pending
			Block process since I/O not finished:
				Mark PCB as blocked; mark it

				Turn CPU and scheduling switches on to schedule a new process

				Calculate active time for process and busy time for CPU

				Record time process was blocked

				Print output message giving blocked procese and burst count

		If rb has finished
			Delete it and keep running current process:
				Delete rb from pcb's list

				Turn CPU switch on to execute a process
				Turn scheduling flag off to use current process (i.e., not schedule a new process)

	\endverbatim
 */
void
Wio_Service( )
{
    //Retrieve pcb from the terminal table that is waiting for I/O
    //~ pcb_type *pcb = Term_Table[Agent-1];
    pcb_type *pcb = Term_Table[Agent - 1]->rb_q->rb->pcb;

    //Retrieve request instruction using saved CPU information
    //~ instr_type instr = Mem[pcb->seg_table[pcb->cpu_save.pc.segment].base + pcb->cpu_save.pc.offset-1];
    instr_type instr = Mem[pcb->seg_table[pcb->cpu_save.pc.segment].base + CPU.state.pc.offset-1];

    //Locate request block that process wants to wait for--call Find_rb()
    rb_type *rb = Find_rb(pcb, &instr.operand.address);

    //Determine status of request block
    //If rb is still active or pending
    if(rb->status == ACTIVE_RB || rb->status == PENDING_RB)
    {
        //Block process since I/O not finished:
        //Mark PCB as blocked; mark it
        pcb->status = BLOCKED_PCB;

        //Turn CPU and scheduling switches on to schedule a new process
        CPU_SW = ON;
        SCHED_SW = ON;

        //Calculate active time for process and busy time for CPU
        time_type currTime = Clock;
        Diff_time(&pcb->run_time, &currTime);
        Add_time(&currTime, &(pcb->total_run_time));
        Add_time(&currTime, &(CPU.total_busy_time));

        //Record time process was blocked
        pcb->block_time = Clock;

        pcb->wait_rb = rb;

        //Print output message giving blocked procese and burst count
        print_out("\t\tUser %s is blocked for I/O.\n", pcb->username);
        print_out("\t\tCPU burst was %d instructions.\n\n",pcb->sjnburst);
    }

    //If rb has finished
    if(rb->status == DONE_RB)
    {
        //Delete it and keep running current process:
        //Delete rb from pcb's list
        Delete_rb(rb, pcb);

        //Turn CPU switch on to execute a process
        CPU_SW = ON;

        //Turn scheduling flag off to use current process (i.e., not schedule a new process)
        SCHED_SW = OFF;
    }
}
Ejemplo n.º 6
0
/* Prints the helptext for options in a generated form */
static tvalue print_flags(option_clone *opts,
  gen_cli_helpstr *opts_explain,
  unsigned int arglen,unsigned int cols)
{
  register unsigned int beta=0, gamma;
  unsigned int optcount = 0, curlen;
  unsigned int conslen = PRINTSPACELEN+2;

  if(opts)
    while(opts[optcount].longflag != NULL || opts[optcount].has_arg != 0
      || opts[optcount].shortflag != 0)
      optcount++;

  /* do the printing */
  for(beta = 0; beta < optcount; beta++)
  {
    curlen = conslen;

    print_out(PRINTSPACE);
    if(opts[beta].shortflag != 0)
      print_out("-%c", opts[beta].shortflag);

    if(opts[beta].longflag != NULL)
    {
      curlen += 4 + strlen(opts[beta].longflag);

      if(opts[beta].shortflag != 0)
        iolet_out_char(IL_IOStd,',');

      else
        print_out("   ");

      print_out(" --%s", opts[beta].longflag);

      if(opts_explain[beta].arg != NULL)
      {
        curlen += 1 + strlen(opts_explain[beta].arg);
        print_out(" %s", opts_explain[beta].arg);
      }
    }

    for(gamma = curlen; gamma < arglen; gamma++)
      iolet_out_char(IL_IOStd,' ');
  
    print_explain(arglen, opts_explain[beta].desc,cols);
  }

  iolet_out_char(IL_IOStd,'\n');

  return TRUE;
}
Ejemplo n.º 7
0
/* print help statement */
static void help_logcollector()
{
    print_header();
    print_out("  %s: -[Vhdtf] [-c config]", ARGV0);
    print_out("    -V          Version and license message");
    print_out("    -h          This help message");
    print_out("    -d          Execute in debug mode. This parameter");
    print_out("                can be specified multiple times");
    print_out("                to increase the debug level.");
    print_out("    -t          Test configuration");
    print_out("    -f          Run in foreground");
    print_out("    -c <config> Configuration file to use (default: %s)", DEFAULTCPATH);
    print_out(" ");
    exit(1);
}
Ejemplo n.º 8
0
void print_out(unsigned int n)
{
	if(n >= 10)
		print_out(n / 10);

	printf("%d\n", n % 10);
}
Ejemplo n.º 9
0
/* print help statement */
void helpmsg()
{
    print_header();
    print_out("  %s: -[Vhl] [-e id] [-r id] [-i id] [-f file]", ARGV0);
    print_out("    -V          Version and license message");
    print_out("    -h          This help message");
    print_out("    -l          List available agents.");
    print_out("    -e <id>     Extracts key for an agent (Manager only)");
    print_out("    -r <id>     Remove an agent (Manager only)");
    print_out("    -i <id>     Import authentication key (Agent only)");
    print_out("    -f <file>   Bulk generate client keys from file (Manager only)");
    print_out("                <file> contains lines in IP,NAME format");
    exit(1);
}
Ejemplo n.º 10
0
uint64_t parse_elf(char* path) {
	
	uint64_t parse_ptr = (uint64_t)&_binary_tarfs_start;
	struct posix_header_ustar* ptr;
	uint64_t size;	
	uint64_t remainder;
		//print_out("   name is %s ",parse_ptr->name);
		//print_out("  size id %s",parse_ptr->size);

	while(parse_ptr < (uint64_t)&_binary_tarfs_end) {

		ptr = (struct posix_header_ustar *) (parse_ptr);
		if(ptr->name[0] == '\0') {
			parse_ptr += 512;
			continue;
		}
		//print_out("   name is %s ",ptr->name);
		//print_out("  size is %s",ptr->size);
		size = atoi_t(ptr->size);
		
		//print_out("  size is %d",size);
		
		parse_ptr += (512);

		//if(xstrcmp(ptr->name,"bin/hello")) 
		if(xstrcmp(ptr->name,path)) 
			break;	
		
		if(size > 0) {
			remainder = size % 512UL;
			//print_out("  remainder is %d ",remainder);
			parse_ptr += (size + 512 - remainder);
		}
			
	}
	
	struct parse_info *loadptr;
	clear_screen();
	loadptr = elf_parser(parse_ptr);
	print_out("\n ---- \nentry point is %x",loadptr->entry_point);
	print_out("\n file start ptr is %x",loadptr->file_start_ptr);
	
	struct load_info* temp = loadptr->load_list;
	while(temp != NULL){
		print_out("\n File offset is %d",temp->file_offset);	
		print_out("\n virtual addr is %x",temp->v_addr);
		print_out("\n File seg size is %d",temp->file_seg_size);
		print_out("\n Mem seg size is %d",temp->mem_seg_size);	
		print_out("\n Flags are %d",temp->flags);	
		temp = temp->next;
	}

	
	return parse_ptr;


	
	
}
Ejemplo n.º 11
0
static tvalue print_command_path(char *prog_name,gen_cli_argument *arg)
{
  register gen_cli_argument *beta=arg;
  register unsigned int gamma=0;
  unsigned int count=0,constcount;
  char **cmds=NULL;
  
  if(!arg)
    return FALSE;

  /* count the number of supcommands */
  while(beta != NULL && beta->prev != NULL)
  {
    count++;
    beta=beta->prev;
  }

  cmds=use_malloc(count*sizeof(char *));
  if(!cmds)
  {
    print_err("Error: Ran out of memory in helpprinting.\n");
    return FALSE;
  }

  constcount=count;

  /* copy the pointers */
  beta=arg;
  while(count > 0)
  {
    count--;
    cmds[count] = beta->cmd;
    beta=beta->prev;
  }

  print_out("%s",prog_name);
  for(gamma=0;gamma<constcount;gamma++)
    print_out(" %s",cmds[gamma]);

  nullify(cmds);
  return TRUE;  
}
Ejemplo n.º 12
0
int main(void)
{
	unsigned int n;

	n = 120304;

	printf("n = %d\n", n);
	void print_out(unsigned int n);	
	print_out(n);	
	return 0;
}	
Ejemplo n.º 13
0
void *Action_FP(Eventinfo *lf, char *field)
{
#ifdef TESTRULE
    if (!alert_only) {
        print_out("       action: '%s'", field);
    }
#endif

    lf->action = field;
    return (NULL);
}
Ejemplo n.º 14
0
void *SystemName_FP(Eventinfo *lf, char *field)
{
#ifdef TESTRULE
    if (!alert_only) {
        print_out("       system_name: '%s'", field);
    }
#endif

    lf->systemname = field;
    return (NULL);
}
Ejemplo n.º 15
0
void *Data_FP(Eventinfo *lf, char *field)
{
#ifdef TESTRULE
    if (!alert_only) {
        print_out("       extra_data: '%s'", field);
    }
#endif

    lf->data = field;
    return (NULL);
}
Ejemplo n.º 16
0
void *SrcUser_FP(Eventinfo *lf, char *field)
{
#ifdef TESTRULE
    if (!alert_only) {
        print_out("       srcuser: '******'", field);
    }
#endif

    lf->srcuser = field;
    return (NULL);
}
Ejemplo n.º 17
0
void *Protocol_FP(Eventinfo *lf, char *field)
{
#ifdef TESTRULE
    if (!alert_only) {
        print_out("       proto: '%s'", field);
    }
#endif

    lf->protocol = field;
    return (NULL);
}
Ejemplo n.º 18
0
void *Url_FP(Eventinfo *lf, char *field)
{
#ifdef TESTRULE
    if (!alert_only) {
        print_out("       url: '%s'", field);
    }
#endif

    lf->url = field;
    return (NULL);
}
Ejemplo n.º 19
0
void *DstPort_FP(Eventinfo *lf, char *field)
{
#ifdef TESTRULE
    if (!alert_only) {
        print_out("       dstport: '%s'", field);
    }
#endif

    lf->dstport = field;
    return (NULL);
}
Ejemplo n.º 20
0
void *Status_FP(Eventinfo *lf, char *field)
{
#ifdef TESTRULE
    if (!alert_only) {
        print_out("       status: '%s'", field);
    }
#endif

    lf->status = field;
    return (NULL);
}
Ejemplo n.º 21
0
Archivo: duh.c Proyecto: aclark4life/CS
void main(int argc, char *argv[]) {
        if (argc!=1) {
                printf("Sorry, I don't take command line arguments.\n");
                exit(-1);
	}
        else {
		get_first();
		get_matrices();
		mul_matrices();
		print_out();
	}
}
Ejemplo n.º 22
0
static void print_help()
{
    print_out(
        "Usage:  " + NCore::applicationBasenameName() + " [[option] | [files]]\n"
        "\n"
        "Options:\n"
        "    --next         play next file\n"
        "    --prev         play previous file\n"
        "    --stop         stop playback\n"
        "    --pause        pause playback\n"
        "    --version      print version\n"
        "    -h, --help     print this message\n"
    );
}
Ejemplo n.º 23
0
void motor_eq (double t, struct input *in, struct param *parms, double h) {

	double i,w_last,t_last,phih,rest,P,*PP,mean,change,P_last;
	int j,k,Plen,interv,runs=0;
	
	struct output out;
	struct vector v_next;
	
	interv = 10;
	Plen = (int)(t*(1/h));
	out.sig = 1;
	change = 100;	

	v_next.ia = 0;
	v_next.ib = 0;
	v_next.ic = 0;
    	v_next.w = 2 / (parms->r/(2*PI));
	out.P = 0;

	for (i=0;i<t;i+=h) {
		
		w_last = v_next.w;
		t_last = v_next.t;
		P_last = out.P;
/*
		if (i > change) {
			out.sig = (out.sig+1)%2;
			change += 100;
		}
*/

        	step_diff(&v_next,in,&out,parms,h);

		out.phi += h*(v_next.w + w_last)/2.0;

		out.ia = v_next.ia;
        	out.ib = v_next.ib;
        	out.ic = v_next.ic;
		out.v = v_next.w * (parms->r/(2*PI));
		out.Te = out.a * parms->J;
		out.s = v_next.s;
		out.P = v_next.P;

		if ((runs % 1000) == 0) {
			print_out(&out,t);
		}
		runs++;
	}
}
Ejemplo n.º 24
0
void kern_sleep(uint16_t sec) {
	uint16_t * sleep_sec = (uint16_t *)0xfffffe0000000000;
	sleep_sec[0] = (uint16_t)sec;
	print_out("...The sleep count will be set to %d...",sleep_sec[0]);
        __asm__ volatile(
                "mov $0x83,%%eax;"
                " int $0x83;"
                :
                :
                :"memory"
                );
	uint64_t * sleep_wait = (uint64_t *)0xfffffe0000000000;
	sleep_wait[0] = 10000000;
	while(sleep_wait[0] > 0)
		sleep_wait[0]--;
}
Ejemplo n.º 25
0
int main(int argc, char *argv[]) {
	char line[LINE_LENGTH];
	char clockface[51][51];
	char cf_fin[51][51];
	argc = argc;
	argv = argv;
	int hour, min;
	init(clockface);
	
	
/*	while (true)*/
	{
		hour = (getchar()-'0')*10;
		hour += (getchar()-'0');
		getchar();
		min = (getchar()-'0')*10;
		min += (getchar()-'0');
		big = true;
		double mAng = min*6;
		
		double hAng = (hour*6+(min/3600));
		
		doMin(mAng, clockface, cf_fin);
		big = false;
		doMin(hAng, clockface, cf_fin);
		
		doit();
		
		//~ if ()
			//~ break;
	}


	//*************8
	//double mAng = 18;
	//doMin(mAng, clockface, cf_fin);
//	double hAng = 
	
	//*************8
	modify_pic(clockface, cf_fin);
	
	
	print_out(cf_fin);
	
	return 0;
}
Ejemplo n.º 26
0
void *DstIP_FP(Eventinfo *lf, char *field)
{
#ifdef TESTRULE
    if (!alert_only) {
        print_out("       dstip: '%s'", field);
    }
#endif

    lf->dstip = field;
#ifdef LIBGEOIP_ENABLED

    if(!lf->dstgeoip) { 
        lf->dstgeoip = GetGeoInfobyIP(lf->dstip);
    }
    return (NULL);
#endif

}
Ejemplo n.º 27
0
Archivo: ii.c Proyecto: hedbuz/ii
static void run() {
	Channel *c;
	int r, maxfd;
	fd_set rd;
	struct timeval tv;
	char ping_msg[512];

	snprintf(ping_msg, sizeof(ping_msg), "PING %s\r\n", host);
	for(;;) {
		FD_ZERO(&rd);
		maxfd = irc->irc;
		FD_SET(irc->irc, &rd);
		for(c = channels; c; c = c->next) {
			if(maxfd < c->fd)
				maxfd = c->fd;
			FD_SET(c->fd, &rd);
		}

		tv.tv_sec = 120;
		tv.tv_usec = 0;
		r = select(maxfd + 1, &rd, 0, 0, &tv);
		if(r < 0) {
			if(errno == EINTR)
				continue;
			perror("ii: error on select()");
			exit(EXIT_FAILURE);
		} else if(r == 0) {
			if(time(NULL) - last_response >= PING_TIMEOUT) {
				print_out(NULL, "-!- ii shutting down: ping timeout");
				exit(EXIT_FAILURE);
			}
			WRITE(irc, ping_msg, strlen(ping_msg));
			continue;
		}
		if(FD_ISSET(irc->irc, &rd)) {
			handle_server_output();
			last_response = time(NULL);
		}
		for(c = channels; c; c = c->next)
			if(FD_ISSET(c->fd, &rd))
				handle_channels_input(c);
	}
}
Ejemplo n.º 28
0
uint64_t kern_fork() {
	uint64_t * ret_addr = (uint64_t *)0xfffffe0000000000;
	__asm__ volatile(
		"movq 8(%%rsp),%0;"
		:"=r"(*ret_addr)
		:
		:"memory"
		);
	__asm__ volatile(
		"mov $0x81,%%eax;"
                "int $0x81;"
		:
		:
		:"memory"
		);
	uint64_t * ret_val = (uint64_t *)0xffffff7fbfdfefe8;
	print_out(" The ret value is %d   ",ret_val[0]);
	return ret_val[0];		
}
Ejemplo n.º 29
0
void GPF_isr_handler () {
	print_out("    General Protection fault Caught    ");
	while(1);
/*
	uint64_t * virtual_addr;
	asm volatile("movq %%cr2, %0"
                        : "=b" (virtual_addr)
                        : 
                );
	uint64_t free = (uint64_t)get_free_page();
	print_out("mapping %p to %x     phys_free is at %p",virtual_addr,free,virtual_physfree); 
	map_page_virtual((uint64_t *)virtual_physfree,(uint64_t)virtual_addr,free,1);	
	
	char * try = (char *)virtual_addr;
	try[0] = 'b';
	print_out("   Haha....%c", try[0]);
	//while(1);
*/
}
Ejemplo n.º 30
0
void settings(){
    delay(500);
    
    print_set(); //Print "Set" on the screen
    
    //Firstly set the time
    do{ set_hrs_mins(); }
    while (digitalRead(button_settings_in) == LOW);
    beep();
    
    
    print_set_alrarm_1(); //Print "Set" on the screen
    
    //Then set Alarm 1
    do{ set_alarm_1(); }
    while (digitalRead(button_settings_in) == LOW);
    beep();
    
    
    print_out();
    delay(500);
}