예제 #1
0
파일: ls.c 프로젝트: YogaPan/linux-basic
static int show_stat(const char *path)
{
	int ret;
	struct stat s;

	if (access(path, F_OK) < 0) {
		fprintf(stderr, "path not exists\n");
		return -1;
	}

	ret = stat(path, &s);
	if (ret < 0) {
		perror("stat");
		return -1;
	}

	show_inode(&s);
	show_mode(&s);
	show_user(&s);
	show_size(&s);
	show_time(&s);
	printf(" %s\n", path);

	return 0;
}
//Choose LED Cube effect mode subfunction
char choose_mode(void)
{
	char temp_mode = 0;
	while(temp_mode == 0) // while the button SW1 is still not pressed for the first time, no mode chosen 
	{
		while(SW2 == 1)		//As button SW2 is not pressed
		{
			if(temp_mode == 0)	//if temp_mode equals 0 (means button SW1 is still not pressed for the 1st time ,no mode chosen)
			{
				for(int i = 0; i<8; i ++)	//Light up the whole LED Cube (1 layer LEDs at XY plane each time for layer 0 to layer 7)
				{	
					set_a_plane(i,XY);
				}	
			}

			if(SW1 == 0) //As button SW1 is pressed
			{
				while(SW1 == 0) continue;	//Wait for button SW1 to be released

				if (temp_mode<7)		//Maximum mode of LED Cube is 7. If temp_mode < 7, a '1' is plus to it.Else,change back to value 1
				{	
					temp_mode++;
				}

				else
				{	
					temp_mode = 1;
				}
				show_mode(temp_mode);	//Show the selected mode on the top layer of XY plane of LED Cube
			}
		}
		while(SW2 == 0) continue;	//If button SW2 is pressed, waits for the button SW2 to be released
	}
	return temp_mode;	//return the decided mode
}
예제 #3
0
void MPI_final_result_show(FILE * fp, int * recv_data, int send_data_num)
{
    int i;
    int min_dis = recv_data[2];
    int min_proc = recv_data[0];

    fprintf(fp, "*******************************************************\n");
    #ifdef SAMEGROUP_COMUNICATION
        fprintf(fp, "*** SAMEGROUP_COMUNICATION-MODE ***\n");
    #endif
    fprintf(fp, "TSP Size:%5d\n",get_tsp_size());
    fprintf(fp, "All Proces Num:%2d\n",get_num_of_all_proc());
    fprintf(fp, "Running Time:%f\n",get_time());
    for(i = 0; i < get_num_of_all_proc(); i++) {
        if(min_dis > recv_data[i * send_data_num + 2]) {
            min_proc = recv_data[i * send_data_num];
            min_dis = recv_data[i * send_data_num + 2];
        }
    }
    show_chart_of_all_proc_result(fp, recv_data, send_data_num, min_proc);
    fprintf(fp, "\nActive Modes--->\n");
    show_mode(fp);
    fprintf(fp, "<---Active Modes\n");
    fprintf(fp, "*******************************************************\n");
}
예제 #4
0
void final_result_show(FILE * fp)
{
    fprintf(fp, "*******************************************************\n");
    fprintf(fp, "TSP Size:%5d\n",get_tsp_size());
    fprintf(fp, "All Proces Num:%2d\n",get_num_of_all_proc());
    fprintf(fp, "Process Number:%2d\n",get_process_number());
    fprintf(fp, "Process Name:%s\n",get_process_name());
    fprintf(fp, "MPI Group:%2d\n",get_MPI_group_data());
    fprintf(fp, "Running Time:%f\n",get_time());
    fprintf(fp, "%.2f\n",get_best_cost());
    /*if(modep->pole_mode == ON) {
        fprintf(fp, "Search Count:%d\n",turn_loop_times(READONLY));
    }*/
    fprintf(fp, "Search Count Num:%d\n",num_counter(SEARCH_COUNTER, CHECK));
    fprintf(fp, "Tunr Count Num:%2d\n",num_counter(TURN_COUNTER, CHECK));
#ifdef DEBUG
    fprintf(fp, "Local Tabulist Num:%d\n",tabulist_counter(DEFAULT, READONLY));
#ifdef MPIMODE
    if(modep->parallel_mode == ON) {
        fprintf(fp, "Share Tabulist Num:%d\n",tabulist_counter(SHARE, READONLY));
    }
#endif
#endif
    fprintf(fp, "\nActive Modes--->\n");
    show_mode(fp);
    fprintf(fp, "<---Active Modes\n");
    fprintf(fp, "*******************************************************\n");
}
예제 #5
0
static void print_usage(SCTX_ struct token *pos, struct symbol *sym, unsigned mode)
{
	static unsigned curr_stream = -1;

	if (curr_stream != pos->pos.stream) {
		curr_stream = pos->pos.stream;
		printf("\nFILE: %s\n\n", stream_name(sctx_ curr_stream));
	}

	printf("%s%4d:%-3d %c %-5.3s", sctxp reporter->indent ? "\t" : "",
		pos->pos.line, pos->pos.pos, storage(sym), show_mode(mode));
}
예제 #6
0
파일: 3.c 프로젝트: hemiao3000/code
void show_info(struct stat* st, struct dirent * dir)
{
	//printf("%c ", type);
	//printf("%d ", st->st_mode);
	show_mode(st);
	printf("%d ", st->st_nlink);
	// printf("%d ", st->st_uid);
	show_uname(st->st_uid);
	// printf("%d ", st->st_gid);
	show_gname(st->st_gid);
	printf("%d ", st->st_size);
	// printf("%d ", st->st_mtime);
	show_time(st->st_mtime);
	printf("%s", dir->d_name);

	printf("\n");
}
void loop()
{

  timechk();

    volume();
    beat();
    int tmp_mode = system_mode;
    system_mode = (int)(float)analogRead(pot_one)/ (1024/ num_modes);
 

    if (num_modes ==system_mode)
    {
      system_mode = do_automatic_mode();
    }
     changed = system_mode != x_mode;
    x_mode = system_mode;
 
    
    printit = true;
    show_mode(system_mode);

 Serial.print(current_volume);
 Serial.print(' ');
 Serial.print(amount);
 Serial.print(' ');
Serial.println((int)running_vol_avg );
    
   
  
 
  if (printit)
  {
    print();
  }


}
예제 #8
0
int main(int argc, char **argv) {
  int v_opt;
  int v_set1404 = 0;
  int v_set1003 = 0;
  int v_show = 0;
  extern int optind, optopt;
  extern char *optarg;

  while((v_opt = getopt(argc, argv, "edbvskn:")) != -1) { 
    switch(v_opt) {
      case 'e':
        v_set1404 = 1;
        break;
      case 'd':
        v_set1003 = 1;
        break;
      case 'b':
        g_daemon = 1;
        break;
      case 'v':
        g_verbose = 1;
        break;
      case 's':
        v_show = 1;
        break;
      case 'k':
        g_kill = 1;
        break;
      case 'n':
        g_svc = optarg;
        break;
      case ':':
      case '?':
        helpme();
    }
  }

  if((v_set1404 + v_set1003 + g_daemon + v_show > 1) ||
     (v_set1404 + v_set1003 + g_daemon + v_show == 0)) {
    helpme();
  }
  if(g_kill == 1 && g_svc != '\0') {
    helpme();
  }

  if(v_set1404 == 1) {
    set_1404();
    exit(0);
  }
  if(v_set1003 == 1) {
    set_1003();
    exit(0);
  }
  if(v_show == 1) {
    show_mode();
    exit(0);
  }
  if(g_daemon == 1) {
    daemonize();
  }
  helpme();
}