예제 #1
0
파일: Module.C 프로젝트: orlammd/non-mixer
int
Module::handle ( int m )
{
    switch ( m )
    {
        case FL_KEYBOARD:
        {
            if ( Fl_Group::handle( m ) )
                return 1;

            if ( Fl::event_key() == FL_Menu )
            {
                menu_popup( &menu(), x(), y() );
                return 1;
            }
            else
                return menu().test_shortcut() != 0;
        }
        case FL_PUSH:
        {
            take_focus();

            if ( Fl_Group::handle( m ) )
                return 1;
            else if ( test_press( FL_BUTTON3 ) )
            {
                menu_popup( &menu() );
                return 1;
            }
            else if ( test_press( FL_BUTTON1 ) )
            {
                command_open_parameter_editor();
                return 1;
            }
            else if ( test_press( FL_BUTTON3 | FL_CTRL ) )
            {
                command_remove();
                return 1;
            }
            else if ( test_press( FL_BUTTON2 ) )
            {
                bypass( !bypass() );
                redraw();
                return 1;
            }

            return 0;
        }
        case FL_FOCUS:
        case FL_UNFOCUS:
            redraw();
            return 1;
    }

    return Fl_Group::handle( m );
}
예제 #2
0
파일: Module.C 프로젝트: 0mk/non
void
Module::menu_cb ( const Fl_Menu_ *m )
{
    char picked[256];

    if ( ! m->mvalue() || m->mvalue()->flags & FL_SUBMENU_POINTER || m->mvalue()->flags & FL_SUBMENU )
        return;

    strncpy( picked, m->mvalue()->label(), sizeof( picked ) );

//    m->item_pathname( picked, sizeof( picked ) );

    DMESSAGE( "%s", picked );

    Logger log( this );

    if ( ! strcmp( picked, "Edit Parameters" ) )
        command_open_parameter_editor();
    else if ( ! strcmp( picked, "Bypass" ) )
    {
        if ( ! bypassable() )
        {
            fl_alert( "Due to its channel configuration, this module cannot be bypassed." );
        }
        else
        {
            bypass( !bypass() );
            redraw();
        }
    }
    else if ( ! strcmp( picked, "Cut" ) )
    {
        if ( copy() )
        {
            chain()->remove( this );
            Fl::delete_widget( this );
        }
    }
    else if ( ! strcmp( picked, "Copy" ) )
    {
        copy();
    }
    else if ( ! strcmp( picked, "Paste" ) )
    {
        paste_before();
    }
    else if ( ! strcmp( picked, "Show Analysis" ) )
    {
        show_analysis_window();
    }
    else if ( ! strcmp( picked, "Remove" ) )
        command_remove();
}
예제 #3
0
void
Controller_Module::menu_cb ( const Fl_Menu_ *m )
{
    char picked[256];

    m->item_pathname( picked, sizeof( picked ) );

    Logger log( this );

    if ( ! strcmp( picked, "Mode/GUI + OSC" ) )
        mode( GUI );
    else if ( ! strcmp( picked, "Mode/Control Voltage (JACK)" ) )
        mode( CV );
    else if ( ! strcmp( picked, "/Remove" ) )
        command_remove();
}
예제 #4
0
int main(int argc, char **argv) {
//{{{
    int ret = 0;

    if (argc < 2) {
        usage();
        return 1;
    }
    
    char *command = argv[1];

    argc --;
    argv ++;
    
    curl_global_init(CURL_GLOBAL_ALL);

    if (strcmp(command, "info") == 0) {
        ret = command_info(argc, argv);
    } else if (strcmp(command, "ls") == 0) {
        ret = command_ls(argc, argv);
    } else if (strcmp(command, "upload") == 0 || strcmp(command, "up") == 0) {
        ret = command_upload(argc, argv);
    } else if (strcmp(command, "download") == 0 || strcmp(command, "down") == 0) {
        ret = command_download(argc, argv);
    } else if (strcmp(command, "mv") == 0) {
        ret = command_move_or_copy(argc, argv, "mv");
    } else if (strcmp(command, "cp") == 0) {
        ret = command_move_or_copy(argc, argv, "cp");
    } else if (strcmp(command, "rm") == 0) {
        ret = command_remove(argc, argv);
    } else {
        color_log(COLOR_LOG_ERROR, "未知命令!\n");
        usage();
        ret = 1;
    }

    if (api != NULL) {
        BaiduPCS_Free(api);
    }
    curl_global_cleanup();
    return ret;
}
예제 #5
0
파일: main.c 프로젝트: whs1787/ffs
static int process_args(args_t * args)
{
	assert(args != NULL);

	switch (args->cmd) {
	case c_INJECT:
		command_inject(args);
		break;
	case c_REMOVE:
		command_remove(args);
		break;
	case c_HEXDUMP:
		command_hexdump(args);
		break;
	default:
		UNEXPECTED("NOT IMPLEMENTED YET => '%c'", args->cmd);
		return -1;
	}

	return 0;
}
예제 #6
0
파일: Module.C 프로젝트: orlammd/non-mixer
void
Module::menu_cb ( const Fl_Menu_ *m )
{
    char picked[256];

    if ( ! m->mvalue() || m->mvalue()->flags & FL_SUBMENU_POINTER || m->mvalue()->flags & FL_SUBMENU )
        return;

    strncpy( picked, m->mvalue()->label(), sizeof( picked ) );

//    m->item_pathname( picked, sizeof( picked ) );

    DMESSAGE( "%s", picked );

    Logger log( this );

    if ( ! strcmp( picked, "Edit Parameters" ) )
        command_open_parameter_editor();
    else if ( ! strcmp( picked, "Bypass" ) )
        bypass( ! ( m->mvalue()->flags & FL_MENU_VALUE ) );
    else if ( ! strcmp( picked, "Cut" ) )
    {
        copy();

        chain()->remove( this );
        Fl::delete_widget( this );
    }
    else if ( ! strcmp( picked, "Copy" ) )
    {
        copy();
    }
    else if ( ! strcmp( picked, "Paste" ) )
    {
        paste_before();
    }
    else if ( ! strcmp( picked, "Remove" ) )
        command_remove();
}
예제 #7
0
파일: unix.c 프로젝트: tmartinx/vtmpegd
void unix_client (int fd)
{
	GList *q = NULL;
	char temp[2048];

	memset (temp, 0, sizeof (temp));
	if (read (fd, temp, sizeof (temp)) < 0) return;

	switch (atoi (temp)) {
	case COMMAND_LIST:
		command_list (fd, g_list_first (queue), playing_mpeg);
		break;

	case COMMAND_INSERT:
	{
		int pos;
		char filename[1024];

		memset (filename, 0, sizeof (filename));
		sscanf (temp + 2, "%[^];];%d\n", filename, &pos);

		q = command_insert (fd, queue, filename,
				    pos, &playing_mpeg, unix_list_count ());
		if (q != NULL) queue = g_list_first (q);
	}
		break;

	case COMMAND_REMOVE:
	{
		int pos = 0;

		sscanf (temp + 2, "%d\n", &pos);
		q = command_remove (fd, queue, pos, &playing_mpeg);
		if (q != NULL) {
			unix_command = COMMAND_REMOVE;
			queue = g_list_first (q);
		}
	}
		break;

	case COMMAND_PLAY:
		unix_command = COMMAND_PLAY;
		break;
	
	case COMMAND_PAUSE:
		unix_command = COMMAND_PAUSE;
		break;
	
	case COMMAND_STOP:
		unix_command = COMMAND_STOP;
		break;

	case COMMAND_NEXT:
		unix_command = COMMAND_NEXT;
		break;
	
	case COMMAND_PREV:
	{
		int temp;

		if ((temp = playing_mpeg - 2) < 0) temp = unix_list_count ();
		playing_mpeg = temp;

		unix_command = COMMAND_NEXT;
	}
		break;

	case COMMAND_MUTE:
		unix_command = COMMAND_MUTE;
		break;

	default:
		dprintf (fd, "%c: Unknown command.\n%c\n",
			 COMMAND_ERROR, COMMAND_DELIM);
	}

	return;
}
예제 #8
0
파일: Controller_Module.C 프로젝트: 0mk/non
void
Controller_Module::menu_cb ( const Fl_Menu_ *m )
{
    char picked[256];

    m->item_pathname( picked, sizeof( picked ) );

    Logger log( this );

    if ( ! strcmp( picked, "Mode/GUI + OSC" ) )
        mode( GUI );
    else if ( ! strcmp( picked, "Mode/Control Voltage (JACK)" ) )
        mode( CV );
    else if ( ! strcmp( picked, "/Remove" ) )
        command_remove();
    else if ( ! strncmp( picked, "Connect To/", strlen( "Connect To/" ) ) )
    { 
        char *peer_name = index( picked, '/' ) + 1;
    
        *index( peer_name, '/' ) = 0;

//        OSC::Signal s = (OSC::Signal*)m->mvalue()->user_data();
        const char *path = ((OSC::Signal*)m->mvalue()->user_data())->path();

        /* if ( ! _osc_output()->is_connected_to( ((OSC::Signal*)m->mvalue()->user_data()) ) ) */
        /* { */
            /* _persistent_osc_connections.push_back( strdup(path) ); */

            Port *p = control_output[0].connected_port();

            if ( learn_by_number )
                mixer->osc_endpoint->add_translation( path, p->osc_number_path());
            else
                mixer->osc_endpoint->add_translation( path, p->osc_path() );
    }
    else if ( ! strncmp( picked, "Disconnect From/", strlen( "Disconnect From/" ) ) )
    { 
        /* char *peer_name = index( picked, '/' ) + 1; */
    
        /* *index( peer_name, '/' ) = 0; */

//        OSC::Signal s = (OSC::Signal*)m->mvalue()->user_data();
        const char *path = (const char*)m->mvalue()->user_data();

        /* if ( ! _osc_output()->is_connected_to( ((OSC::Signal*)m->mvalue()->user_data()) ) ) */
        /* { */
            /* _persistent_osc_connections.push_back( strdup(path) ); */

        //        Port *p = control_output[0].connected_port();

            mixer->osc_endpoint->del_translation( path );

            /* if ( learn_by_number ) */
            /* { */
            /*     char *our_path = p->osc_number_path(); */
                
            /*     mixer->osc_endpoint->add_translation( path, our_path ); */

            /*     free(our_path); */
            /* } */
            /* else */
            /*     mixer->osc_endpoint->add_translation( path, p->osc_path() ); */
    }



        /* } */
        /* else */
        /* { */
        /*     /\* timeline->osc->disconnect_signal( _osc_output(), path ); *\/ */
            
        /*     /\* for ( std::list<char*>::iterator i = _persistent_osc_connections.begin(); *\/ */
        /*     /\*       i != _persistent_osc_connections.end(); *\/ */
        /*     /\*       ++i ) *\/ */
        /*     /\* { *\/ */
        /*     /\*     if ( !strcmp( *i, path ) ) *\/ */
        /*     /\*     { *\/ */
        /*     /\*         free( *i ); *\/ */
        /*     /\*         i = _persistent_osc_connections.erase( i ); *\/ */
        /*     /\*         break; *\/ */
        /*     /\*     } *\/ */
        /*     /\* } *\/ */
            
        /*     //free( path ); */
        /* } */
   

    
}
예제 #9
0
int main (int argc, const char** argv)
{
  int status = 0;

  // Create a vector of args.
  std::vector <std::string> args;
  for (int i = 1; i < argc; ++i)
    args.push_back (argv[i]);

  Config config;
  config.set ("verbose", "1");

  // Some options are hard-coded.
  if (args.size ())
  {
    if (args[0] == "-h" || closeEnough ("--help", args[0], 3))
      command_help (args);

    else if (args[0] == "-v" || closeEnough ("--version", args[0], 3))
    {
      Color bold ("bold");
      std::cout << "\n"
                << bold.colorize (PACKAGE_STRING)
#ifdef HAVE_COMMIT
                << " "
                << COMMIT
#endif
                << " built for "

#if defined (DARWIN)
                << "darwin"
#elif defined (SOLARIS)
                << "solaris"
#elif defined (CYGWIN)
                << "cygwin"
#elif defined (HAIKU)
                << "haiku"
#elif defined (OPENBSD)
                << "openbsd"
#elif defined (FREEBSD)
                << "freebsd"
#elif defined (NETBSD)
                << "netbsd"
#elif defined (LINUX)
                << "linux"
#elif defined (KFREEBSD)
                << "GNU/kFreeBSD"
#elif defined (GNUHURD)
                << "GNU/Hurd"
#else
                << "unknown"
#endif

          << "\n"
          << "Copyright (C) 2010 - 2015 Göteborg Bit Factory."
          << "\n"
          << "\n"
          << "Taskd may be copied only under the terms of the MIT license, "
          << "which may be found in the taskd source kit."
          << "\n"
          << "Documentation for taskd can be found using 'man taskd' or at "
          << "http://taskwarrior.org"
          << "\n"
          << "\n";
    }
    else
    {
      try
      {
        // Some defaults come from the environment.
        char* root_env = getenv ("TASKDDATA");
        if (root_env)
          config.set ("root", root_env);

        // Process all the options.
        std::vector <std::string> positionals;
        std::vector <std::string>::iterator arg;
        for (arg = args.begin (); arg != args.end (); ++arg)
        {
          if (closeEnough ("--data", *arg, 3))
          {
            ++arg;
            if (arg == args.end () || (*arg)[0] == '-')
              throw std::string (STRING_TASKD_DATA);

            config.set ("root", *arg);
          }
          else if (closeEnough ("--quiet",  *arg, 3))  config.set ("verbose",      0);
          else if (closeEnough ("--debug",  *arg, 3))  config.set ("debug",        1);
          else if (closeEnough ("--force",  *arg, 3))  config.set ("confirmation", 0);
          else if (closeEnough ("--daemon", *arg, 3))  config.set ("daemon",       1);
          else if (taskd_applyOverride (config, *arg)) ;
          else                                         positionals.push_back (*arg);
        }

        // A database object interfaces to the data.
        Database db (&config);

        // The highest-level commands are hard-coded:
             if (closeEnough ("init",        args[0], 3)) command_init     (db, positionals);
        else if (closeEnough ("config",      args[0], 3)) command_config   (db, positionals);
        else if (closeEnough ("status",      args[0], 3)) command_status   (db, positionals);
        else if (closeEnough ("help",        args[0], 3)) command_help     (    positionals);
        else if (closeEnough ("diagnostics", args[0], 3)) command_diag     (db, positionals);
        else if (closeEnough ("server",      args[0], 3)) command_server   (db, positionals);
        else if (closeEnough ("add",         args[0], 3)) command_add      (db, positionals);
        else if (closeEnough ("remove",      args[0], 3)) command_remove   (db, positionals);
        else if (closeEnough ("suspend",     args[0], 3)) command_suspend  (db, positionals);
        else if (closeEnough ("resume",      args[0], 3)) command_resume   (db, positionals);
        else if (closeEnough ("client",      args[0], 3)) command_client   (db, positionals);
        else if (closeEnough ("validate",    args[0], 3)) command_validate (db, positionals);
        else
          throw format (STRING_TASKD_BAD_COMMAND, args[0]);
      }

      catch (std::string& error)
      {
        if (error == "usage")
        {
          std::vector <std::string> no_args;
          command_help (no_args);
        }
        else
          std::cout << error << "\n";
        status = -1;
      }

      catch (std::bad_alloc& error)
      {
        std::cerr << "Error: Memory allocation failed: " << error.what () << "\n";
        status = -3;
      }

      catch (...)
      {
        std::cerr << STRING_ERROR_UNKNOWN
                  << "\n";
        status = -2;
      }
    }
  }
  else
    command_help (args);

  return status;
}
예제 #10
0
파일: Module.C 프로젝트: 0mk/non
int
Module::handle ( int m )
{
    static unsigned long _event_state = 0;

    unsigned long evstate = Fl::event_state();

    switch ( m )
    {
        case FL_ENTER:
//            Fl::focus(this);
        case FL_LEAVE:
            return 1;
    }

    if ( Fl_Group::handle( m ) )
        return 1;

    switch ( m )
    {
        case FL_KEYBOARD:
        {
            if ( Fl::event_key() == FL_Menu )
            {
                menu_popup( &menu(), x(), y() );
                return 1;
            }
            else
                return menu().test_shortcut() != 0;
        }
        case FL_PUSH:     
            take_focus();
            _event_state = evstate;
            return 1;
            // if ( Fl::visible_focus() && handle( FL_FOCUS )) Fl::focus(this);
        case FL_DRAG:
            _event_state = evstate;
            return 1;
        case FL_RELEASE:
        {
            unsigned long e = _event_state;
            _event_state = 0;

            if ( ! Fl::event_inside( this ) )
                return 1;

            if ( ( e & FL_BUTTON1 ) && ( e & FL_CTRL ) )
            {
                Fl::focus(this);
                return 1;
            }
            else if ( e & FL_BUTTON1 )
            {
                command_open_parameter_editor();
                return 1;
            }
            else if ( e & FL_BUTTON3 && e & FL_CTRL )
            {
                command_remove();
                return 1;
            }
            else if ( e & FL_BUTTON3 )
            {
                menu_popup( &menu() );
                return 1;
            }
            else if ( e & FL_BUTTON2 )
            {
                if ( !bypassable() )
                {
                    fl_alert( "Due to its channel configuration, this module cannot be bypassed." );
                }
                else
                {
                    bypass( !bypass() );
                    redraw();
                }
                return 1;
            }
            /* else */
            /* { */
            /*     take_focus(); */
            /* } */

            return 0;
        }
        case FL_FOCUS:
        case FL_UNFOCUS:
            redraw();
            return 1;
    }

    return 0;
}
예제 #11
0
파일: main.c 프로젝트: marintsev/rx-dict
int main(int argc, char ** argv) {
	check();

	// Передан файл базы как параметр
	if (argc == 2) {
		db_filename = argv[1];
	}
	// Файл не передан, используется имя по умолчанию
	else if (argc == 1) {
		db_filename = "default.db";
	}
	// Неправильное использование
	else {
		fprintf( stderr, "Usage: dictionary [words.db]\n");
		exit( EXIT_WRONG_USAGE);
	}

	assert(NULL != db_filename);

	FILE * f = NULL;
	int code = access(db_filename, R_OK | W_OK);
	// Нет прав, не существует файл или что-нибудь ещё
	if (-1 == code) {
		// Нет файла, можно создавать
		if ( errno == ENOENT) {
			f = fopen(db_filename, "w+");
			fprintf( stderr, "INFO: Файл не существовал и теперь создан.\n");
		} else if ( errno == EACCES) {
			fprintf( stderr, "FATAL: Нет прав доступа к базе.\n");
			exit( EXIT_WRONG_RIGHTS);
		} else {
			printf("errno = %d\n", errno);
			exit( EXIT_WTF);
		}
	}
	// Есть права и файл существует
	else {
		f = fopen(db_filename, "r+");
		fprintf( stderr, "INFO: Существующий файл открыт для работы.\n");
	}
	assert(NULL != f);

	fseek(f, 0, SEEK_END);
	int length = ftell(f);
	fprintf( stderr, "DEBUG: Длина файла: %d\n", length);

	if (length < HEADER_SIZE) {
		// Длина файла заведомо меньше размера header. Пишем новый.
		write_new_header(&header, f);
	} else {
		// Читаем
		read_header(&header, f);

		// Проверяем
		if (header.version != 1 || header.actual_words > header.total_words) {
			fprintf( stderr,
					"FATAL: База данных (%s), вероятно, испорчена. Возможно, стоит её удалить.\n",
					db_filename);
			WTF();
		}
	}

	// Всё есть. Можно работать.
	printf("Введите help для справки, quit для выхода.\n");
	int working = 1;
	while (working) {
		printf("> ");

		char str[6];
		fgets(str, 6, stdin);
		remove_newline(str);
		if (strcmp(str, "help") == 0) {
			command_help();
		} else if (strcmp(str, "quit") == 0 || strcmp(str, "exit") == 0
				|| strcmp(str, "bye") == 0) {
			save_database(f);
			exit( EXIT_SUCCESS);
		} else if (strcmp(str, "add") == 0) {
			command_add(f);
		} else if (strcmp(str, "find") == 0) {
			command_find(f);
		} else if (strcmp(str, "del") == 0 || strcmp(str, "rm") == 0) {
			command_remove(f);
		} else if (strcmp(str, "frag") == 0) {
			command_defragment(f);
		} else {
			fprintf( stderr, "ERROR: Неизвестная команда '%s'\n", str);
		}
	}

	/*
	 Операции:
	 1. Добавить слово. Имя (128 байт), содержание (не ограничено) ->
	 2. Найти слово. Имя -> содержание
	 3. Удалить. Имя ->
	 */
	if (f != NULL)
		fclose(f);

	return EXIT_SUCCESS;
}