示例#1
0
//--------------------------------- SHELL core os.c---------
char listen_key(){
//	unsigned short int init_pos = get_pointer_pos();
	flag_len=17;
	char i = gets( key);
	screen_sc_T = 1;
	Print_flag_mark = 1;
	if( strcmp( key, "clear\0")){			// char *,const char *
		clear();
		return i;
	}

	if( strcmp( key, "python\0")){
		python();
		Print_flag_mark = 1;
		return i;
	}

	if( strcmp( key, "start\0")){
		clear();
		set_pointer_pos();
		Print_flag_mark = 0;
		Process();
		return i;
	}

	if( strcmp( key, "help\0")){
		//can't refer 2 two times, so...
		init_flag_position();	
		screen_init();
		print_welcome_msg();
		print_message();
		print_flag(); //root@wangqin4377@:   position

		return i;
	}
//---------------------------------mark: man xxx, run xxx,asc xx...
		
	if( synCheck( key, "run\0")){
		run( key);
		return i;
	}

	if( key[0] == '\0'){
		return i;
	}
	
	flag_scroll();
	set_pointer_pos();
	print_str("  No such file or Directory", 27);
	screen_sc_T = 2;
	return i;
}
示例#2
0
void SSProfile::setBackend(const QString &a, bool relativePath)
{
    backend = QDir::toNativeSeparators(a);
#ifdef Q_OS_WIN
    if (type.compare("Shadowsocks-Python", Qt::CaseInsensitive) == 0) {
        QDir python(a);
        python.cdUp();
        QString scriptPath(python.absolutePath() + QString("/Scripts/sslocal-script.py"));
        if (QFile::exists(scriptPath)) {
            backend = QDir::toNativeSeparators(scriptPath);
        }
        else {
            backend = QString();
        }
    }
#endif
    if (relativePath) {
        QDir workingDir;
        backend = workingDir.relativeFilePath(backend);
    }
}
示例#3
0
int main( int argc, char *argv[] )
 {
  std::cout << __FUNCTION__ << std::endl;

  MyMainClass o;
  MyClassReflection   r;  //!< Reflection of Original, with pointing to some instance

  ::reflection::operation::transfer::observe_class<std::ostream> observe;

  {
   typedef ::reflection::operation::transfer::python::print_struct<std::ostream> python_type;
   auto python_context = python_type::context();
   python_type python( observe, python_context );

    //python_type::register_class<MyFirstClassOriginal, MyFirstClassReflectionView>( observe, python_context );
    //python_type::register_class<MyBaseClass, MyBaseClasssReflectionView>( observe, python_context );
    //python_type::register_enum<MyMainClass::Enumerator>( observe, python_context );
    //python_type::register_container< std::vector<int> >( observe, python_context );
  }
  observe.view( std::cout, r ); // PYTHONize

  return EXIT_SUCCESS;
 }
示例#4
0
int process(char *argu){
	char *trail;
	trail = argu;
	int trailingOp = -1; //0 for bg, 1 for routing, -1 for neither
	while (trail != NULL){
		if (strcmp(trail, "&") == 0){ //anything after the & is summarily ignored
			//run in background
			trailingOp = 0;
			break;
		}
		if (strcmp(trail, ">") == 0){
			trailingOp = 1;
			//routing
			break;
		}
		args[argSize] = trail;
		//printf("Trail = %s. Arg = %s.\n", trail, args[argSize]);
		argSize++;
		trail = strtok(NULL, " \n\t\r");
	}
	args[argSize] = '\0'; //sets end of argument array to \0 because execvp likes that
	argSize++;

	if (trailingOp == 0){
		//implementation to run jobs in the backgrounds
		if (executeProgram(argu, 0) == 0){
			return 0;
		}
	}
	else if (trailingOp == 1){
		//implementation to redirect job output
		trail = strtok(NULL, " \n\t\r");
		char outPath[512];
		memset(outPath, '\0', 512);
		strcpy(outPath, trail); //outpath now holds the name/path of the output file that the user has specified
		int i;
		for (i = 0; i < 512; i++){
			if ((outPath[i] == ' ') || (outPath[i] == '>')){
				fprintf(stderr, "Error: Invalid file name.\n");
				return -1;
			}
		}
		if (redir(outPath, argu) == 0){
			return 0;
		}
		else return -1;
	}
        //checks the first word in the user input
	//exit
	if (strcmp(argu, "exit") == 0){
		exit(0);
	}
	//returns current pid, good for testing
	if (strcmp(argu, "pid") == 0){
		int pid = getpid();
		printf("PID: %d\n", pid);
		return 0;
	}
	//wait
	if (strcmp(argu, "wait") == 0){
		//wont return until all background jobs are completed
		wait();
		return(0);
	
	}
    if (strcmp(argu, "pwd") == 0){
		char buffer[255]; //all ex file systems have a maximum file name size of 255 bytes
		getcwd(buffer, 256);
        printf("%s\n", buffer);
		return(0);
    }
	if (strcmp(argu, "cd") == 0){
		char *argu;
		char path[512];
		if (args[1] == NULL){
			strcpy(path, getenv("HOME"));
		}
		else {
			strcpy(path, args[1]);
		}
		chdir(path);
		return 0;
	}
	if (python(argu) == 0){
		char *pyArg[512];
		char path[128];
		strcpy(path, "python");
		pyArg[0] = argu;
		int i;
		for(i = 1; i < argSize + 1; i++){
			pyArg[i] = args[i - 1];
		}
		int childID = fork();
		if (childID == 0){
			execvp(path, pyArg);
		}
		return 0;

	}
	if (executeProgram(argu, 1) == 0) return 0;
	else return -1;
}
示例#5
0
//--------------------------------- SHELL core os.c---------
char listen_key(){
//	unsigned short int init_pos = get_pointer_pos();
	flag_len=17;
	char i = gets( key);
	screen_sc_T = 1;
	Print_flag_mark = 1;
	if( strcmp( key, "clear\0")){			// char *,const char *
		clear();
		return i;
	}

	if( strcmp( key, "time\0")){
		time();
		return i;
	}

	if( strcmp( key, "date\0")){
		date();
		return i;
	}

	if( strcmp( key, "python\0")){
		python();
		return i;
	}
	if( strcmp( key, "start\0")){
		screen_init();
		Print_flag_mark = 0;
		Process();
		return i;
	}

	if( strcmp( key, "help\0")){
		//can't refer 2 two times, so...
		init_flag_position();	
		screen_init();
		print_welcome_msg();
		print_message();
		print_flag(); //root@wangqin4377@:   position

		return i;
	}
//---------------------------------mark: man xxx, run xxx,asc xx...

	if( synCheck( key, "asc\0")){
		asc( key);
		return i;
	}

	if( synCheck( key, "man\0")){
		man( key);
		return i;
	}	
	
	if( synCheck( key, "run\0")){
		run( key);
		return i;
	}

	if( synCheck( key, "syscall\0")){
		syscall_test();
		return i;
	}


	if( synCheck( key, "int\0")){
		if( strcmp( key, "int 33h")){
			__asm__(  "int $0x33");
			return i;
		}
		if( strcmp( key, "int 34h")){
			__asm__(  "int $0x34");
			return i;
		}
		if( strcmp( key, "int 35h")){
			__asm__(  "int $0x35");
			return i;
		}
		if( strcmp( key, "int 36h")){
			__asm__(  "int $0x36");
			return i;
		}
	}

	if( key[0] == '\0'){
		return i;
	}
	
	flag_scroll();
	set_pointer_pos();
	print_str("  No such file or Directory", 27);
	screen_sc_T = 2;
	return i;
}