コード例 #1
0
ファイル: main.c プロジェクト: Sorsly/MeyerSweeper
/*
********************************************************
mensel - create selectors for menu, then return cursor
to first char of menu character
********************************************************
*/                     
void mensel(int x, int y, int leng){
  
  pos(x-2,y);
  print_c(0b00010000);
  pos(x+leng+1,y);
  print_c(0b00010001);
  pos(x,y);  
}
コード例 #2
0
ファイル: main_1.c プロジェクト: MSFeng/PurdueCourses
void tdisp()
{
  int digit = 0;
  char d = 0;
  pmsglcd("RT = ", 5, LINE1);
  digit = react / 100;
  print_c(digit + 48, LINE1+0x04);
  digit = (react / 10) % 10;
  print_c(digit + 48, LINE1+0x05);
  digit = react % 10;
  print_c(digit + 48, LINE1+0x06);
  pmsglcd("ms", 2, LINE1+0x07);
  if(react <= 250) {
    GREEN = 1;
  }
}
コード例 #3
0
ファイル: main_1.c プロジェクト: MSFeng/PurdueCourses
void pmsglcd(char * arr, int length, int startpos)
{
  int i = 0;
  for (i = 0; i < length; i++) {
    print_c(arr[i], startpos + i);
  }
}
コード例 #4
0
/*
***********************************************************************
  pmsglcd: print character string str[] on LCD
***********************************************************************
*/
void pmsglcd(char str[])
{
 char counterp=0;
 while(str[counterp]!=0x00){
 print_c(str[counterp]);
 counterp=counterp+1;
 }
}
コード例 #5
0
ファイル: OLED.cpp プロジェクト: tromeli/STM32F1_Module_lib
void OLEDClass::print(uint8_t x, uint8_t y, char* str, CharMode mode)
{
	while (x <= (128 - (128 % mode) - mode) && *str != '\0') //计算最后一位可写位 && 循环输出字符
	{
		print_c(x, y, *str, mode);
		x += mode;
		str++;
	}
}
コード例 #6
0
ファイル: romfs.c プロジェクト: hanago/mini-arm-os
/** Require "usart.h" for print. **/
int show_dirlist_romfs(char* path){
    uint32_t cursor;
    int type;
    
    /* 1. Make sure the path is exist. */
    cursor = findnode_romfs(path);
    if(!cursor)
    	return 0;
    
    /* 2. If it's a link, link to destination */
    type = ROMFH_TYPE(cursor);
    if(type == ROMFH_HRD)
    	while(ROMFH_TYPE(cursor) == ROMFH_HRD)
    		cursor = ROMFS_BEGIN + 
    	            ROMFH_INFO(cursor);

   /* 3. Make sure thar it's a dictionary. */
    type = ROMFH_TYPE(cursor);
    if(type != ROMFH_DIR)
    	return 0;

    /* 4. List all files in the dictionary by linking list structure. */
    cursor = ROMFS_BEGIN + ROMFH_INFO(cursor);
    int count = 0;
    do{
    	print_str((char*)(cursor+OFFSET_NAME));
    	//get address of next file header
    	if(!ROMFH_NEXTFH(cursor))
    		break;
    	cursor = ROMFS_BEGIN + ROMFH_NEXTFH(cursor);
    	count++;
    	if(count%5)
    		print_c('\t');
        else
        	print_c('\n');
    }while(cursor);
    if(count%5)
    	print_c('\n');

    return 1;
}
コード例 #7
0
ファイル: bf_main.cpp プロジェクト: CzechsMix/FungePP
void do_op(char C)
{
  switch(C)
  {
    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9': push(C-'0'); break;
    case '+': addition(); break;
    case '-': subtraction(); break;
    case '*': multiplication(); break;
    case '/': division(); break;
    case '%': modulo(); break;
    case '^': north(); break;
    case '>': east(); break;
    case 'V':
    case 'v': south(); break;
    case '<': west(); break;
    case '?': spin(); break;
    case '!': lnot(); break;
    case '`': gt(); break;
    case '_': hif(); break;
    case '|': vif(); break;
    case '"': tsm(); break;
    case ':': dup(); break;
    case '\\': swap(); break;
    case '$': chomp(); break;
    case '#': jump(); break;
    case 'p': put(); break;
    case 'g': get(); break;
    case 'H': gate(); break;
    case '.': print_i(); break;
    case ',': print_c(); break;
    case '&': input_i(); break;
    case '~': input_c(); break;
    case '@': hacf(); break;
    case '{': left_b(); break;
    case '}': right_b(); break;
    case '[': carry_l(); break;
    case ']': carry_r(); break;
    case ';': empty(); break;
    case 'O': portal_o(); break;
    case 'B': portal_b(); break;
    default: /* DO NOTHING! */ break;
  }
}
コード例 #8
0
void Clocks::print( std::ostream& o ) const {
    for ( unsigned int i = 0; i < dim; i++ )
        if ( data[ i * dim + i ] != dbm_LE_ZERO ) {
            o << "empty\n";
            return;
        }
    unsigned int printed = 0;
    for ( unsigned int i = 1; i < dim; i++ )
        rowFmt( o, printed, print_c( o, i ) );
    for ( unsigned int i = 1; i < dim; i++ )
        for ( unsigned int j = i + 1; j < dim; j++ )
            rowFmt( o, printed, print_d( o, i, j ) );
    o << "\n";
}
コード例 #9
0
ファイル: mouse.c プロジェクト: evilbinary/evilos
void do_mouse(void){
	static unsigned char mousecount=0;  
  	mousemoves=0;
	if ((inb(0x64) & 0x01) != 0) {
    	mouse_byte[mousecount++]=inb(0x60);
    	if (mousecount >= 3+mouse_haswheel) {
	    	mousecount=0;
	    	mousemoves=1;
	    	
    	}
	}
	print_c('0'+mousecount, WHITE, BLACK);
	//vesa_draw_string(0,180,"aaddddddddddddddddtt");
	outb(0x20,0x20);
	outb(0x20,0xA0);	
}
コード例 #10
0
ファイル: main_works.c プロジェクト: Lars139/Archive
////////////////////////////// The main land //////////////////////////////
int main(int argc, char* argv[]){
	int flags[6] = {0,0,0,0,0,0};
	//flags = [t | n | p | v | c | q ]
	int num_thread=0, num_astr=0 ;
	obj *astr;
	thread_info t_info;
	int t = 1; // t is a preiod of time measure in a second
	int max_t=1000;
	thread_argv *targv;
	pthread_t *t_id;

	argv_handler(argc, argv, flags);
	prompt(&num_thread, &num_astr, &t_info, &astr, flags, &max_t);
	ini_astr(num_astr, astr);
	targv = malloc(sizeof(thread_argv)*num_thread);
	for(int a = 0; a < num_thread; a++){
		targv[a].num_astr = num_astr;
		targv[a].astr = astr;
		targv[a].t_info = malloc(sizeof(thread_info));
		targv[a].t = t;
	}
	//FIXME: while time steps goes here
	for(int time = 0; time < max_t; time++){
		pthread_barrier_init(&barrier, NULL, num_thread);
		t_id = hive(num_thread, targv );
		for(int k=0; k<num_thread; ++k){
			if(pthread_join(t_id[k],NULL)!=0){
				perror("The Hive Cluster is under attcked");
				exit(EXIT_FAILURE);
			}
		}
		pthread_barrier_destroy(&barrier);
		if(time == 0 || time == max_t-1){
			if(flags[3]==1)
				print_all(num_astr, astr, time);
			if(flags[4]==1)
				print_c(num_astr, astr, time);
			if(flags[5]==1)
				print_q(num_thread, targv,time);
		}

	}


	return 0;
}
コード例 #11
0
ファイル: list.c プロジェクト: guidotag/Mark-Sweep-GC
void print_l(list *l){
	assert(l != NULL);
		
	if(l->first == NULL){
		print_sep('-');	
		printf("Empty list\n");
	}else{
		node_l *n = l->first;
		
		while(n != NULL){
			print_sep('-');
			print_c(n->c);
			n = n->next;
		}
	}
	
	print_sep('-');
}
コード例 #12
0
ファイル: scanf.c プロジェクト: riadhchtara/RCOS
void scanf(char* text,COLOUR fg, COLOUR bg){
	char j;
	char i,x,y;
	
	for(i=0;i< BUFFER_SIZE;++i){
		
		(*crtscr).kbbuffer[i]=0;
		
	}
	i=0;
	
	x=(current->x);
	y=(current->y);
	(*crtscr).getkey=1;
	(*crtscr).enter=0;
	(*crtscr).buf=0;
	(*crtscr).del=0;
	while((*crtscr).enter==0){
	if(crtscr==live){
	
	set_cursor(x,y);
	if ((*crtscr).del>0){
	for(i=0;i<=(*crtscr).buf;i++){
		print_c(' ',fg,bg);
		
	}
}
	(*crtscr).del=0;
	
		
	
	set_cursor(x,y);

	put(&(*crtscr).kbbuffer,fg,bg);
	if(i<(*crtscr).buf)
	i++;

}	
}
	(*crtscr).getkey=0;
	(*crtscr).enter=0;
	j=memcpy(text, &((*crtscr).kbbuffer),BUFFER_SIZE);
	
}
コード例 #13
0
ファイル: main.c プロジェクト: Sorsly/MeyerSweeper
/*
********************************************************
minejoy - controls joy interactions during game stage
********************************************************
*/
void minejoy(void){
  
  if(joymove != 0){ 
    if(joymove == 2){
      if(irow != 0){
        irow--;
      }
    }
    if(joymove == 4){
      if(icol != 0){
        icol--;
      }
    }
    if(joymove == 6){
      if(icol != (NCOL - 1)){
        icol++;
      }
    }
    if(joymove == 8){
      if(irow != (NROW - 1)){
        irow++;
      }
    }
    
    pos(icol,irow);                             //x,y
    //mask[y][x]
    if(mask[irow][icol] == 9){                                                  //fog o war
      pmsglcd("#");
    }else if(gameMode == 0 && mask[irow][icol] == 0){                           //blank
      pmsglcd(" ");
    }else if(gameMode == 0 && mask[irow][icol] >= 1 && mask[irow][icol] <= 8){  //num
      dumb = 30 + mask[irow][icol];
      print_c(dumb);
    }else if(gameMode == 1 && mask[irow][icol] == 10){                          //F
      pmsglcd("F");
    }else if(gameMode == 2 && mask[irow][icol] == 11){                          //?
      pmsglcd("?");
    }
  }
  nclick = GameControl(irow,icol,nclick,mine,mask);
}
コード例 #14
0
ファイル: kb.c プロジェクト: evilbinary/evilos
/* printable char */
static void
pln(void) {
	static const char key_map[0x3a][2] = {
		/*00*/{0x0, 0x0}, {0x0, 0x0}, {'1', '!'}, {'2', '@'}, 
		/*04*/{'3', '#'}, {'4', '$'}, {'5', '%'}, {'6', '^'}, 
		/*08*/{'7', '&'}, {'8', '*'}, {'9', '('}, {'0', ')'},
		/*0c*/{'-', '_'}, {'=', '+'}, {'\b','\b'},{'\t','\t'},
		/*10*/{'q', 'Q'}, {'w', 'W'}, {'e', 'E'}, {'r', 'R'},
		/*14*/{'t', 'T'}, {'y', 'Y'}, {'u', 'U'}, {'i', 'I'},
		/*18*/{'o', 'O'}, {'p', 'P'}, {'[', '{'}, {']', '}'},
		/*1c*/{'\n','\n'},{0x0, 0x0}, {'a', 'A'}, {'s', 'S'},
		/*20*/{'d', 'D'}, {'f', 'F'}, {'g', 'G'}, {'h', 'H'},
		/*24*/{'j', 'J'}, {'k', 'K'}, {'l', 'L'}, {';', ':'},
		/*28*/{'\'','\"'},{'`', '~'}, {0x0, 0x0}, {'\\','|'}, 
		/*2c*/{'z', 'Z'}, {'x', 'X'}, {'c', 'C'}, {'v', 'V'}, 
		/*30*/{'b', 'B'}, {'n', 'N'}, {'m', 'M'}, {',', '<'},
		/*34*/{'.', '>'}, {'/', '?'}, {0x0, 0x0}, {'*', '*'},
		/*38*/{0x0, 0x0}, {' ', ' '} };
	if (scan_code & 0x80)
		return;
	print_c(key_map[scan_code&0x7f][shf_p], WHITE, BLACK);
}
コード例 #15
0
ファイル: U_USART1.cpp プロジェクト: tromeli/STM32F0_User_lib
void U_USART1::print(uint8_t* data) {
	while (*data != '\0') {
		print_c(*data);
		++data;
	}
}
コード例 #16
0
ファイル: 13281.c プロジェクト: 52piaoyu/exploit-database
int main(int argc, char *argv[]){
	char cmd[255], *a;
	FILE *c;
	int k=0, totl=(SETRUID ? 32:22), b,b1, i, tmp=0, shp=2;
	__u8 *shc,start[2]={0x31,0xc0}, end[16]={0xb0,0x0b,0x89,0xf3,0x89,0xe1,0x31,0xd2,0xcd,0x80,0xb0,0x01,0x31,0xdb,0xcd,0x80}, struid[10]={0xb0,0x46,0x31,0xdb,0x31,0xc9,0xcd,0x80,0x31,0xc0};

	if(argc<2){
		printf(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
		       "|      Shellcode Generator      |\n"
		       "|        by certaindeath        |\n"
		       "|                               |\n"
		       "|  Usage: ./generator <cmd>     |\n"
		       " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
		_exit(1);
	}
	a=(char *)malloc((9+strlen(argv[1]))*sizeof(char));

	//find the command path
	a[0]=0;
	strcat(a, "whereis ");
	strcat(a, argv[1]);
	c=popen(a, "r");
	while(((cmd[0]=fgetc(c))!=' ')&&(!feof(c)));
	while(((cmd[k++]=fgetc(c))!=' ')&&(!feof(c)));
	cmd[--k]=0;
	
	if(k==0){
		printf("No executables found for the command \"%s\".\n", argv[1]);
		_exit(1);
	}

	if(strlen(cmd)>254){
		printf("The lenght of the command path can't be over 254 bye.\n");
		_exit(1);
	}

	for(i=2;i<argc;i++)
		if(strlen(argv[i])>254){
			printf("The lenght of each command argument can't be over 254 byte.\n");
			_exit(1);
		}
	//work out the final shellcode lenght
	b=(k%2);
	b1=(b==1) ? (((k-1)/2)%2) : ((k/2)%2);
	totl+=(6+5*((k-(k%4))/4)+4*b1+7*b);
	for(i=2; i<argc;i++){
		k=strlen(argv[i]);
		b=(k%2);
		b1=(b==1) ? (((k-1)/2)%2) : ((k/2)%2);
		totl+=(6+5*((k-(k%4))/4)+4*b1+7*b);
	}
	totl+=4*(argc-2);
	printf("Shellcode lenght: %i\n", totl);

	//build the shellcode
	shc=(__u8 *)malloc((totl+1)*sizeof(__u8));
	memcpy(shc, start, 2);
	if(SETRUID){
		memcpy(shc+shp, struid, 10);
		shp+=10;
	}
	if(argc>2)
		push_shc(shc, argv[argc-1], &shp);
	else
		push_shc(shc, cmd, &shp);
	memset(shc+(shp++), 0x89, 1);
	memset(shc+(shp++), 0xe6, 1);
	if(argc>2){
		for(i=argc-2;i>1;i--)
			push_shc(shc, argv[i], &shp);
		push_shc(shc, cmd, &shp);
	}
	memset(shc+(shp++), 0x50, 1);
	memset(shc+(shp++), 0x56, 1);
	if(argc>2){
		for(i=argc-2;i>1;i--){
			memset(shc+(shp++), 0x83, 1);
			memset(shc+(shp++), 0xee, 1);
			memset(shc+(shp++), strlen(argv[i])+1, 1);
			memset(shc+(shp++), 0x56, 1);
		}
		memset(shc+(shp++), 0x83, 1);
		memset(shc+(shp++), 0xee, 1);
		memset(shc+(shp++), strlen(cmd)+1, 1);
		memset(shc+(shp++), 0x56, 1);
	}
	memcpy(shc+shp, end, 16);
	print_c(shc,totl);
	return 0;
}
コード例 #17
0
ファイル: main.c プロジェクト: Sorsly/MeyerSweeper
/*
***********************************************************************
 Main - Setup
***********************************************************************
*/
void main(void) {
  /* put your own code here */
  DisableInterrupts;
	initializations(); 		  			 		  		
	EnableInterrupts;
  
  //printf("%ld\n",time(0));  //prints time elapsed since 1970 
  
  Initial_board(mine);
  Initial_mask(mask);

/*
***********************************************************************
 Main - Loop
***********************************************************************
*/

  for(;;) {
    PTT_PTT3 = display1_en; //display1_en = 1 means PTT_PTT3 = 0 (en)
    PTT_PTT5 = !display2_en; //display2_en = 1 means PTT_PTT5 = 0 (en)

    //butts();
    
    
    if(diffrun == 0 && gamerun == 0){         //splash screen
      if(setflag == 1){
        send_i(LCDCLR);
        splashDisp();
        setflag = 0;
      }
      if(buttBpb){                            //buttBpb (FLAG), as opposed to buttBatd
        diffrun = 1;
        setflag = 1;
      }    
    }
    
    if(diffrun == 1 && gamerun == 0){         //difficulty screen
      if(setflag == 1){
        send_i(LCDCLR);
        diffDisp();
        setflag = 0;
      }
      difficulty();
      if(buttBpb){
        gamerun = 1;
        diffrun = 0;
        setflag = 1;
      }
    }

    if(diffrun == 0 && gamerun == 1){
      if(setflag == 1){
        send_i(LCDCLR);
        Create_board(nbomb,mine);
        joymove = 99;
        setflag = 0;
      }
      //printf("Mask: \n");
      if(joymove != 0){ 
        for(i = 0; i < NROW; i++){
          for(j = 0; j < NCOL; j++){
            //printf("%2d ",mask[i][j]);
            pos(i,j);
            if(mask[i][j] == 9){
              pmsglcd("?");
            }else if(mask[i][j] == 0){
              pmsglcd(" ");
            }else if(mask[i][j] >= 1 && mask[i][j] <= 8){
              dumb = 30 + mask[i][j];
              print_c(dumb);
            }else if(mask[i][j] == 10){
              pmsglcd("F");
            }
          }
        //printf("\n");
        }
      }
      joymove = joy();
      if(joymove == 2){
        if(irow != 0){
          irow--;
        }
      }
      if(joymove == 4){
        if(icol != 0){
          icol--;
        }
      }
      if(joymove == 6){
        if(icol != (NCOL - 1)){
          icol++;
        }
      }
      if(joymove == 8){
        if(icol != (NROW - 1)){
          irow++;
        }
      }
      
      nclick = GameControl(irow,icol,nclick,mine,mask);    
    }
    
    
    
    
    
    
    if(nclick == -1){
      fail = 1;
      
      for(a = 0; a < NROW; a++){
        for(b = 0; b < NCOL; b++){
          mask[a][b] = mine[a][b];
        }
      }  
    }
    
    
    
    //printf("Number Click: %d\n",nclick);
    
    nflag = FlagControl(frow,fcol,nflag,mask);
    
    if((nflag + nclick) == nbomb){
      win = 1;
    }
    
    //printf("Number Flag: %d\n",nflag);
    //printf("Flag: \n");
    
    for(i = 0; i < NROW; i++){
      for(j = 0; j < NCOL; j++){
        //printf("%2d ",mask[i][j]);
      }
    //printf("\n");
    }

//printf("Mine: \n");
    
    for(i = 0; i < NROW; i++){
      for(j = 0; j < NCOL; j++){
        //printf("%2d ",mine[i][j]);
      }
      //printf("\n");
    }
  
  
/*
//If the left pushbutton
    if(leftpb && !gamerun){
      leftpb = 0;
      gamerun = 1;
      
      send_i(LCDCLR);     //display message
      pmsglcd("Ready, Set...");  
    }      

//If the right pushbutton
    if(rghtpb && gamerun){
      rghtpb = 0;
      gamerun = 0;   
    }
*/    
  
  } /* loop forever */
  /* please make sure that you never leave main */
}
コード例 #18
0
ファイル: irq.c プロジェクト: coolcoca/TinyOS
void fault_handler(struct regs * r){
    print_c('X');
    print_c('Y');
    for(;;);
}
コード例 #19
0
ファイル: tie.c プロジェクト: luigiScarso/mflua
void get_line P1C(file_index,i)
#line 619 "../../../texk/web2c/tiedir/tie.w"
{register input_description*inp_desc= input_organization[i];
if(inp_desc->mode==ignore)return;
if(feof(inp_desc->the_file))
/*25:*/
#line 630 "../../../texk/web2c/tiedir/tie.w"

{
inp_desc->mode= ignore;
inp_desc->limit= -1;
if(inp_desc->type_of_file==master)input_has_ended= true;
return;
}


/*:25*/
#line 622 "../../../texk/web2c/tiedir/tie.w"

/*27:*/
#line 655 "../../../texk/web2c/tiedir/tie.w"

{int final_limit;
int c;
/*28:*/
#line 679 "../../../texk/web2c/tiedir/tie.w"

incr(inp_desc->line);
if(inp_desc->type_of_file==master&&inp_desc->line%100==0){
if(inp_desc->line%500==0)print2("%ld",inp_desc->line);
else print_c('.');
update_terminal;
}


/*:28*/
#line 659 "../../../texk/web2c/tiedir/tie.w"

inp_desc->limit= final_limit= 0;
while(inp_desc->limit<buf_size){
c= fgetc(inp_desc->the_file);
/*29:*/
#line 696 "../../../texk/web2c/tiedir/tie.w"

if(c==EOF){
if(inp_desc->limit<=0){
inp_desc->mode= ignore;
inp_desc->limit= -1;
if(inp_desc->type_of_file==master)input_has_ended= true;
return;
}else{
c= nl_mark;
break;
}
}


/*:29*/
#line 664 "../../../texk/web2c/tiedir/tie.w"

inp_desc->buffer[inp_desc->limit++]= c= map_xord(c);
if(c==nl_mark)break;
if(c!=32&&c!=tab_mark)
final_limit= inp_desc->limit;
}
/*30:*/
#line 712 "../../../texk/web2c/tiedir/tie.w"

if(c!=nl_mark){
err_print("! Input line too long")(i);

while((c= fgetc(inp_desc->the_file))!=EOF&&map_xord(c)!=nl_mark)
do_nothing;
}





/*:30*/
#line 670 "../../../texk/web2c/tiedir/tie.w"

inp_desc->limit= final_limit;
}


/*:27*/
#line 623 "../../../texk/web2c/tiedir/tie.w"

}
コード例 #20
0
ファイル: shell.cpp プロジェクト: CurryBoy/Cynical-OS
    void print(cyOS::vector <char> input){
	    input.push_back('\0');
	    input.push_back('\0');
	    print_c(input.begin(), input.size());
    }
コード例 #21
0
ファイル: shell.cpp プロジェクト: CurryBoy/Cynical-OS
    void start(){
        cyOS::vector <char> buffer;
	    cyOS::vector <char> input;
	    char user[16] = "root@cyOS:$ \0\0";
	    uint name = 12;
	    uint pos = name;
        uint line = 0;
	    char c;
	    KEY k;
	    text_graphics::set_cursor_pos(name);
	    while (true){
            //clears screen, prints current input, and then waits for key press
	        text_graphics::clear();
	        print_line(user, name, input, line);
	        k = keyboard::get_key();
	        //non-character keys move cursor around screen and also position in buffer
	        if (!is_key_printable(k))
		    {
		        if ( (k == KEY_LEFT) && (text_graphics::cursor_pos() > name) ){
			        cursor_decrement(); 
			        pos--;
		        }
		        else if ( (k == KEY_RIGHT) && (text_graphics::cursor_pos() < input.size()+name) ){
			        cursor_increment();
			        pos++;
		        }
		        else if ( (k == KEY_UP) && (text_graphics::cursor_pos() > text_graphics::cols())){
			        text_graphics::set_cursor_pos(text_graphics::cursor_pos()-text_graphics::cols());
			        pos -= text_graphics::cols();
		        }
		        else if ( (k == KEY_DOWN) && (input.size() > text_graphics::cols()) && (text_graphics::cursor_pos()+text_graphics::cols()-1 < input.size()) ){
			        text_graphics::set_cursor_pos(text_graphics::cursor_pos()+text_graphics::cols());
			        pos += text_graphics::cols();
		        }
		        //should be KEY_DELTE
		        else if ( (k == KEY_F12)  && (pos < name+input.size())){
			        text_graphics::put_char(' ', pos);
			        input.erase(pos-name);
			        //print(input);
		        }
		        else if (k == KEY_HOME){
			        text_graphics::set_cursor_pos(name);
			        pos = name;
		        }
		        //should be KEY_END
		        else if (k == 1060480){
			        text_graphics::set_cursor_pos(input.size());
			        pos = input.size();
		        }
		    }
	        else{
		        c = keyboard::get_char();
		        //backspace
		        if (c == '\b'){
		            //if position is in the user's name, put it at the end of the user's name
		            if (pos <= name){
			            text_graphics::set_cursor_pos(name);
			            pos = name;
		            }
		            //otherwise delete the previous character from the vector
		            else {
			            //text_graphics::put_char(' ', pos-1);
			            if (input.size() > 0){
			                cursor_decrement();
			                pos--;
			            }
		                if (pos-name == input.size()){
		                    input.pop_back();
		                }
		                else{
		                    input.erase(pos-name);
		                }
		            }
		        }
		        //return/new line
		        else if (c == '\n' && pos == input.size()){
		            text_graphics::clear();
		            print_line(user, name, input, ++line);
		            text_graphics::set_cursor_pos(name);
		            if(function_call(input)==true){
			            text_graphics::clear();
			            char escape[] = "Exiting Shell...\0\0";
			            print_c(escape);
			            return;
		            }
		            pos = name;
		        }
		        //Checks for new line in middle of input
		        else {
		            if (c == '\n' || c== '\r')
			        c = '\0';
		            /*if (pos-name == input.size()){
			        text_graphics::put_char(c, text_graphics::cursor_pos());
			        input.push_back(c);
		            }
		            else{*/
			        input.insert(pos-name, c); //insert into input string
		            if (c == '\0'){
			            text_graphics::clear();
			            function_call(input); //parses and executes
			            pos = name;
                                    input.clear();
		            }
		            pos++;
		            cursor_increment();
		        }
	        }
	        //keeping cursor on the screen
	        if (text_graphics::cursor_pos() < name){
		        text_graphics::set_cursor_pos(name);
		        pos = name;
	        }
	        else if (text_graphics::cursor_pos() > (text_graphics::cols()*text_graphics::rows()) ){
		        text_graphics::set_cursor_pos(text_graphics::cols()*text_graphics::rows());
		        pos = text_graphics::cols()*text_graphics::rows();
	        }
	    }
    }
コード例 #22
0
ファイル: main.c プロジェクト: crane-may/cat_ear
void mp3_c(u8 c){
	int i;
	static int over=0;
	
	if (cur_song.content_length == 0 || cur_song.content_remain == -1){
		print_c(c);
		if (c != '\n'){
			if (cur_song.buffer_idx < sizeof(cur_song.buffer)){
				cur_song.buffer[cur_song.buffer_idx++] = c;
			}
		}else{
			char * s = cur_song.buffer;
			
			if (s[0] == 'C' &&
					s[1] == 'o' &&
					s[2] == 'n' &&
					s[3] == 't' &&
					s[4] == 'e' &&
					s[5] == 'n' &&
					s[6] == 't' &&
					s[7] == '-' &&
					s[8] == 'L' &&
					s[9] == 'e' &&
					s[10]== 'n' &&
					s[11]== 'g' &&
					s[12]== 't' &&
					s[13]== 'h' &&
					s[14]== ':'){
				i = 16;
				while (i < 50 && s[i] >= '0' && s[i] <= '9'){
					cur_song.content_length = cur_song.content_length * 10 + (s[i] - '0');
					i++;
				}
				printf("-----content_length: %d\r\n",cur_song.content_length);
			}
			
			if (s[0]='\r' && cur_song.buffer_idx ==1 && cur_song.content_length > 0){
				cur_song.content_remain = cur_song.content_length;
				println("content_start");
			}
			
			cur_song.buffer_idx = 0;
		}
	}else{
		if (cur_song.content_remain > 0){
			// printf("%d\r\n",cur_song.content_remain);
			cur_song.content_remain--;
			cur_song.buffer[cur_song.buffer_idx++] = c;
			
			if (cur_song.content_length_without_id3v2 == 0 && cur_song.buffer_idx > 9){
				if (cur_song.buffer[0] == 0x49 &&
					  cur_song.buffer[1] == 0x44 &&
					  cur_song.buffer[2] == 0x33 ){
					cur_song.content_length_without_id3v2 = cur_song.content_length - 
							((cur_song.buffer[6]&0x7F)*0x200000+(cur_song.buffer[7]&0x7F)*0x4000+(cur_song.buffer[8]&0x7F)*0x80+(cur_song.buffer[9]&0x7F) + 10);
				}else{
					cur_song.content_length_without_id3v2 = cur_song.content_length;
					cur_song.first_head[0] = cur_song.buffer[0];
					cur_song.first_head[1] = cur_song.buffer[1];
					cur_song.first_head[2] = cur_song.buffer[2];
					cur_song.first_head[3] = cur_song.buffer[3];
					cur_song.headed = 4;
				}
			}
			
			if (cur_song.headed < 4 && cur_song.content_length_without_id3v2 > cur_song.content_remain ){
				cur_song.first_head[cur_song.headed++] = c;
			}
			
			if (cur_song.headed >= 4 && cur_song.frame_size == 0){
				for(i=0;i<4;i++) printf("0x%02x ",cur_song.first_head[i]);
				cur_song.frame_size = calc_frame_size(cur_song.first_head);
				
				printf("frame_size: %d\r\n",cur_song.frame_size);
			}
			
		}else{
			println("shot over");
			printf("content_over %d\r\n",over++);
		}
	}
}
コード例 #23
0
ファイル: U_USART1.cpp プロジェクト: tromeli/STM32F0_User_lib
void U_USART1::print(uint8_t* data, uint16_t len) {
	while (len--) {
		print_c(*data);
		++data;
	}
}
コード例 #24
0
/*
***********************************************************************
 Main
***********************************************************************
*/
void main(void) {
  DisableInterrupts;
 initializations();               
 EnableInterrupts;
 
 //shiftout(0x01);
 

    
      while(flag == 0 && counter_pass < 3)
      {       
  
    chgline(0x80);
    pmsglcd("Enter Password");
      
    if(rghtpb == 0) 
    {
      chgline(0xc0 + counter_pass);

      tempo = atd_convert() ;
  
      print_c(tempo);

     
    }
    
    if(rghtpb == 1) 
    {
     rghtpb = 0;
     temp[counter_pass] = atd_convert() - 48;
     counter_pass++;
     
    }
    if(counter_pass == 3) {
      
    for(i = 0; i < 3; i++) 
    {
        if(our_pass[i] == temp[i]) 
        {
          if(flag2 != 1) 
          {
            flag = 1; 
          } 
        }
        else 
        {
          flag2 = 1;
          flag = 0;
          counter_pass = 0;
          temp[0] = 0;
          temp[1] = 0;
          temp[2] = 0;
          chgline(0xc0);
          send_i(LCDCLR);
        }
    }
    
    
    }
  }
send_i(LCDCLR);   
pmsglcd("Success");
TIE_C7I = 1;
    
    //print_c(tempo);

  for(;;) {

/* write your code here */

    

  }  
  
    
  

    

 /* loop forever */
  
}/* do not leave main */
コード例 #25
0
ファイル: cut.c プロジェクト: lufb/code
static int
_cut_c(const struct cut_option *op, char *data)
{
    (void) print_c(data, op->c.min, op->c.max);
    return 0;
}