当前位置: 首页>>代码示例>>C++>>正文


C++ SUCCESS函数代码示例

本文整理汇总了C++中SUCCESS函数的典型用法代码示例。如果您正苦于以下问题:C++ SUCCESS函数的具体用法?C++ SUCCESS怎么用?C++ SUCCESS使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SUCCESS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: load_balanced_redirect_for_create_operation


//.........这里部分代码省略.........
        // capture the name, time and load lists from the DB
        std::vector< std::string > names;
        std::vector< int >         loads;
        std::vector< int >         times;
        irods::error ret = get_load_lists(
                               _ctx,
                               names,
                               loads,
                               times );
        if ( !ret.ok() ) {
            return PASS( ret );
        }

        // =-=-=-=-=-=-=-
        // retrieve local time in order to check if the load information is up
        // to date, ie less than MAX_ELAPSE_TIME seconds old
        int    min_load = 100;
        time_t time_now = 0;
        time( &time_now );

        // =-=-=-=-=-=-=-
        // iterate over children and find them in the lists
        bool resc_found = false;
        irods::resource_ptr selected_resource;
        irods::resource_child_map::iterator itr = _ctx.child_map().begin();
        for ( ; itr != _ctx.child_map().end(); ++itr ) {
            // =-=-=-=-=-=-=-
            // cache resc ptr for ease of use
            irods::resource_ptr resc = itr->second.second;

            // =-=-=-=-=-=-=-
            // get the resource name for comparison
            std::string resc_name;
            ret = resc->get_property< std::string >( irods::RESOURCE_NAME, resc_name );
            if ( !ret.ok() ) {
                return PASS( ret );
            }

            // =-=-=-=-=-=-=-
            // scan the list for a match
            for ( size_t i = 0; i < names.size(); ++i ) {
                if ( resc_name == names[ i ] ) {
                    if ( loads[ i ] >= 0 &&
                            min_load > loads[ i ] &&
                            ( time_now - times[ i ] ) < MAX_ELAPSE_TIME ) {
                        resc_found = true;
                        min_load = loads[i];
                        selected_resource = resc;
                    }

                } // if match

            } // for i

        } // for itr

        // =-=-=-=-=-=-=-
        // if we did not find a resource, this is definitely an error
        if ( !resc_found ) {
            return ERROR(
                       CHILD_NOT_FOUND,
                       "failed to find child resc in load list" );
        }

        // =-=-=-=-=-=-=-
        // forward the redirect call to the child for assertion of the whole operation,
        // there may be more than a leaf beneath us
        float                   vote   = 0.0;
        irods::hierarchy_parser parser = ( *_out_parser );
        irods::error err = selected_resource->call <
                           const std::string*,
                           const std::string*,
                           irods::hierarchy_parser*,
                           float* > (
                               _ctx.comm(),
                               irods::RESOURCE_OP_RESOLVE_RESC_HIER,
                               _ctx.fco(),
                               _opr,
                               _curr_host,
                               &parser,
                               &vote );
        std::string hier;
        parser.str( hier );
        rodsLog(
            LOG_DEBUG1,
            "load_balanced node - hier : [%s], vote %f",
            hier.c_str(),
            vote );
        if ( !err.ok() ) {
            irods::log( PASS( err ) );
        }

        // =-=-=-=-=-=-=-
        // set the out variables
        ( *_out_parser ) = parser;
        ( *_out_vote )   = vote;

        return SUCCESS();

    } // load_balanced_redirect_for_create_operation
开发者ID:dthain,项目名称:irods,代码行数:101,代码来源:libload_balanced.cpp

示例2: main

int
main (int argc,
    char **argv)
{
  int result;
  guint i;
  test_t tests[] = {
    SUCCESS("/xmpp-sasl/normal-auth", NULL, TRUE),
    SUCCESS("/xmpp-sasl/no-plain", NULL, FALSE),
    SUCCESS("/xmpp-sasl/only-plain", "PLAIN", TRUE),
    SUCCESS("/xmpp-sasl/only-digest-md5", "DIGEST-MD5", TRUE),
    { "/xmpp-sasl/digest-md5-final-data-in-success", "DIGEST-MD5", TRUE,
       0, 0, SERVER_PROBLEM_FINAL_DATA_IN_SUCCESS, FALSE, FALSE,
       "test", "test123", NULL },

    FAIL("/xmpp-sasl/no-supported-mechs", "NONSENSE", TRUE,
       WOCKY_AUTH_ERROR, WOCKY_AUTH_ERROR_NO_SUPPORTED_MECHANISMS,
       SERVER_PROBLEM_NO_PROBLEM),
    FAIL("/xmpp-sasl/refuse-plain-only", "PLAIN", FALSE,
       WOCKY_AUTH_ERROR, WOCKY_AUTH_ERROR_NO_SUPPORTED_MECHANISMS,
       SERVER_PROBLEM_NO_PROBLEM),
    FAIL("/xmpp-sasl/no-sasl-support", NULL, TRUE,
       WOCKY_AUTH_ERROR, WOCKY_AUTH_ERROR_NOT_SUPPORTED,
       SERVER_PROBLEM_NO_SASL),

    { "/xmpp-sasl/wrong-username-plain", "PLAIN", TRUE,
       WOCKY_AUTH_ERROR, WOCKY_AUTH_ERROR_FAILURE,
       SERVER_PROBLEM_INVALID_USERNAME, TRUE, FALSE, "test", "test123" },
    { "/xmpp-sasl/wrong-username-md5", "DIGEST-MD5", TRUE,
       WOCKY_AUTH_ERROR, WOCKY_AUTH_ERROR_FAILURE,
       SERVER_PROBLEM_INVALID_USERNAME, TRUE, FALSE, "test", "test123" },

    { "/xmpp-sasl/wrong-password-plain", "PLAIN", TRUE,
       WOCKY_AUTH_ERROR, WOCKY_AUTH_ERROR_FAILURE,
       SERVER_PROBLEM_INVALID_PASSWORD, FALSE, TRUE, "test", "test123" },
    { "/xmpp-sasl/wrong-password-md5", "DIGEST-MD5", TRUE,
       WOCKY_AUTH_ERROR, WOCKY_AUTH_ERROR_FAILURE,
       SERVER_PROBLEM_INVALID_PASSWORD, FALSE, TRUE, "test", "test123" },

    /* Redo the MD5-DIGEST test with a username, password and realm that
     * happens to generate a \0 byte in the md5 hash of
     * 'username:realm:password'. This used to trigger a bug in the sasl helper
     * when calculating the A! part of the response MD5-DIGEST hash */
    { "/xmpp-sasl/digest-md5-A1-null-byte", "DIGEST-MD5", TRUE,
       0, 0, SERVER_PROBLEM_NO_PROBLEM, FALSE, FALSE,
       "moose", "something", "cass-x200s" },

    /* Redo the MD5-DIGEST test with extra whitespace in the challenge */
    { "/xmpp-sasl/digest-md5-spaced-challenge", "DIGEST-MD5", FALSE,
      0, 0, SERVER_PROBLEM_SPACE_CHALLENGE, FALSE, FALSE,
      "moose", "something", "cass-x200s" },

    /* Redo the MD5-DIGEST test with extra \ escapes in the challenge */
    { "/xmpp-sasl/digest-md5-slash-challenge", "DIGEST-MD5", FALSE,
      0, 0, SERVER_PROBLEM_SLASH_CHALLENGE, FALSE, FALSE,
      "moose", "something", "cass-x200s" },

    { "/xmpp-sasl/external-handler-fail", "X-TEST", FALSE,
      WOCKY_AUTH_ERROR, WOCKY_AUTH_ERROR_FAILURE,
      SERVER_PROBLEM_INVALID_PASSWORD, FALSE, FALSE,
      "dave", "daisy daisy", "hal" },

    { "/xmpp-sasl/external-handler-succeed", "X-TEST", FALSE,
      0, 0, SERVER_PROBLEM_NO_PROBLEM, FALSE, FALSE,
      "ripley", "open sesame", "mother" },
  };

  test_init (argc, argv);

  mainloop = g_main_loop_new (NULL, FALSE);

  for (i = 0; i < G_N_ELEMENTS (tests); i++)
    g_test_add_data_func (tests[i].description,
        &tests[i], run_test);

  result = g_test_run ();
  test_deinit ();
  return result;
}
开发者ID:freedesktop-unofficial-mirror,项目名称:wocky,代码行数:79,代码来源:wocky-test-sasl-auth.c

示例3: operator

 irods::error operator()( rcComm_t* ) {
     rodsLog( LOG_NOTICE, "mockarchive_resource::post_disconnect_maintenance_operation - [%s]",
              name_.c_str() );
     return SUCCESS();
 }
开发者ID:jrandall,项目名称:irods,代码行数:5,代码来源:libmockarchive.cpp

示例4: SUCCESS

// =-=-=-=-=-=-=-
// private - walk the resource map and wire children up to parents
    error resource_manager::init_child_map( void ) {
        error result = SUCCESS();

        // Iterate over all the resources
        lookup_table< boost::shared_ptr< resource > >::iterator it;
        for ( it = resources_.begin(); it != resources_.end(); ++it ) {
            resource_ptr resc = it->second;

            // Get the children string and resource name
            std::string children_string;
            error ret = resc->get_property<std::string>( RESOURCE_CHILDREN, children_string );
            if ( !ret.ok() ) {
                result = PASSMSG( "init_child_map failed.", ret );
            }
            else {
                std::string resc_name;
                error ret = resc->get_property<std::string>( RESOURCE_NAME, resc_name );
                if ( !ret.ok() ) {
                    result = PASSMSG( "init_child_map failed.", ret );
                }
                else {
                    // Get the list of children and their contexts from the resource
                    children_parser parser;
                    parser.set_string( children_string );
                    children_parser::children_map_t children_list;
                    error ret = parser.list( children_list );
                    if ( !ret.ok() ) {
                        result = PASSMSG( "init_child_map failed.", ret );
                    }
                    else {

                        // Iterate over all of the children
                        children_parser::children_map_t::const_iterator itr;
                        for ( itr = children_list.begin(); itr != children_list.end(); ++itr ) {
                            std::string child = itr->first;
                            std::string context = itr->second;

                            // Lookup the child resource pointer
                            lookup_table< boost::shared_ptr< resource > >::iterator child_itr = resources_.find( child );
                            if ( child_itr == resources_.end() ) {
                                std::stringstream msg;
                                msg << "Failed to find child \"" << child << "\" in resources.";
                                result = ERROR( SYS_INVALID_INPUT_PARAM, msg.str() );
                            }
                            else {

                                // Add a reference to the child resource pointer and its context to the resource
                                resource_ptr child_resc = child_itr->second;
                                error ret = resc->add_child( child, context, child_resc );
                                if ( !ret.ok() ) {
                                    result = PASSMSG( "init_child_map failed.", ret );
                                }

                                // set the parent for the child resource
                                child_resc->set_parent( resc );
                            }
                        } // for itr
                    } // else parse list
                } // else get name
            } // else get child string
        } // for it
        return result;
    } // init_child_map
开发者ID:dthain,项目名称:irods,代码行数:65,代码来源:irods_resource_manager.cpp

示例5: ERROR

// =-=-=-=-=-=-=-
// public - retrieve a resource given a vault path
    error resource_manager::validate_vault_path(
        std::string       _physical_path,
        rodsServerHost_t* _svr_host,
        std::string&      _out_path ) {
        // =-=-=-=-=-=-=-
        // simple flag to state a resource matching the prop and value is found
        bool found = false;

        // =-=-=-=-=-=-=-
        // quick check on the resource table
        if ( resources_.empty() ) {
            return ERROR( SYS_INVALID_INPUT_PARAM, "empty resource table" );
        }

        // =-=-=-=-=-=-=-
        // quick check on the path that it has something in it
        if ( _physical_path.empty() ) {
            return ERROR( SYS_INVALID_INPUT_PARAM, "empty property" );
        }

        // =-=-=-=-=-=-=-
        // iterate through the map and search for our path
        lookup_table< resource_ptr >::iterator itr = resources_.begin();
        for ( ; !found && itr != resources_.end(); ++itr ) {
            // =-=-=-=-=-=-=-
            // get the host pointer from the resource
            rodsServerHost_t* svr_host = 0;
            error ret = itr->second->get_property< rodsServerHost_t* >( RESOURCE_HOST, svr_host );
            if ( !ret.ok() ) {
                PASS( ret );
            }

            // =-=-=-=-=-=-=-
            // if this host matches the incoming host pointer then were good
            // otherwise continue searching
            if ( svr_host != _svr_host ) {
                continue;
            }

            // =-=-=-=-=-=-=-
            // query resource for the property value
            std::string path;
            ret = itr->second->get_property<std::string>( RESOURCE_PATH, path );

            // =-=-=-=-=-=-=-
            // if we get a good parameter and do not match non-storage nodes with an empty physical path
            if ( ret.ok() ) {
                // =-=-=-=-=-=-=-
                // compare incoming value and stored value
                // one may be a subset of the other so compare both ways
                if ( !path.empty() && ( _physical_path.find( path ) != std::string::npos ) ) {
                    found     = true;
                    _out_path = path;
                }

            }
            else {
                std::stringstream msg;
                msg << "resource_manager::resolve_from_physical_path - ";
                msg << "failed to get vault parameter from resource";
                msg << ret.code();
                irods::log( PASSMSG( msg.str(), ret ) );

            }

        } // for itr

        // =-=-=-=-=-=-=-
        // did we find a resource and is the ptr valid?
        if ( true == found ) {
            return SUCCESS();
        }
        else {
            std::stringstream msg;
            msg << "failed to find resource for path [";
            msg << _physical_path;
            msg << "]";
            return ERROR( SYS_INVALID_INPUT_PARAM, msg.str() );
        }

    } // validate_vault_path
开发者ID:dthain,项目名称:irods,代码行数:83,代码来源:irods_resource_manager.cpp

示例6: SUCCESS

// Read LEGACY_SERVER_CONFIG_FILE and fill server_properties::properties
    void server_properties::capture_legacy() {
        error result = SUCCESS();
        std::string property; // property setting

        FILE *fptr;
        char buf[BUF_LEN];
        char *fchar;
        int len;
        char *key;

        char DBKey[MAX_PASSWORD_LEN], DBPassword[MAX_PASSWORD_LEN];
        memset( &DBKey, '\0', MAX_PASSWORD_LEN );
        memset( &DBPassword, '\0', MAX_PASSWORD_LEN );

        std::string cfg_file;
        error ret = irods::get_full_path_for_config_file(
                        LEGACY_SERVER_CONFIG_FILE,
                        cfg_file );
        if ( !ret.ok() ) {
            THROW( ret.code(), ret.result() );
        }

        if ( !fs::exists( cfg_file ) ) {
            return;
        }

        rodsLog(
            LOG_ERROR,
            "server_properties::capture_legacy - use of legacy configuration is deprecated" );

        fptr = fopen( cfg_file.c_str(), "r" );

        if ( fptr == NULL ) {
            rodsLog( LOG_DEBUG,
                     "Cannot open LEGACY_SERVER_CONFIG_FILE file %s. errno = %d\n",
                     cfg_file.c_str(), errno );
            std::stringstream msg;
            msg << LEGACY_SERVER_CONFIG_FILE << " file error";
            THROW( SYS_CONFIG_FILE_ERR, msg.str().c_str() );
        }

        // =-=-=-=-=-=-=-
        // PAM configuration - init PAM values
        result = config_props_.set<bool>( PAM_NO_EXTEND_KW, false );
        result = config_props_.set<size_t>( PAM_PW_LEN_KW, 20 );

        property.assign( "121" );
        result = config_props_.set<std::string>( PAM_PW_MIN_TIME_KW, property );

        property.assign( "1209600" );
        result = config_props_.set<std::string>( PAM_PW_MAX_TIME_KW, property );
        // init PAM values

        std::string initializer[] = {
            ICAT_HOST_KW,
            RE_RULESET_KW,
            RE_FUNCMAPSET_KW,
            RE_VARIABLEMAPSET_KW,
            DB_USERNAME_KW,
            PAM_PW_MIN_TIME_KW,
            PAM_PW_MAX_TIME_KW,
            CATALOG_DATABASE_TYPE_KW,
            KERBEROS_NAME_KW,
            LOCAL_ZONE_SID_KW };
        std::vector<std::string> keys( initializer, initializer + sizeof( initializer ) / sizeof( std::string ) );

        buf[BUF_LEN - 1] = '\0';
        fchar = fgets( buf, BUF_LEN - 1, fptr );
        while ( fchar ) {
            if ( buf[0] == '#' || buf[0] == '/' ) {
                buf[0] = '\0'; /* Comment line, ignore */
            }

            /**
             * Parsing of server configuration settings
             */
            key = strstr( buf, DB_PASSWORD_KW );
            if ( key != NULL ) {
                len = strlen( DB_PASSWORD_KW );

                // Store password in temporary string
                snprintf( DBPassword, sizeof( DBPassword ), "%s", findNextTokenAndTerm( key + len ) );

            } // DB_PASSWORD_KW

            key = strstr( buf, DB_KEY_KW );
            if ( key != NULL ) {
                len = strlen( DB_KEY_KW );

                // Store key in temporary string
                snprintf( DBKey, sizeof( DBKey ), "%s", findNextTokenAndTerm( key + len ) );

            } // DB_KEY_KW

            for ( std::vector<std::string>::iterator it = keys.begin(); it != keys.end(); it++ ) {
                char * pos = strstr( buf, it->c_str() );
                if ( pos != NULL ) {

                    // Set property
//.........这里部分代码省略.........
开发者ID:0x414A,项目名称:irods,代码行数:101,代码来源:irods_server_properties.cpp

示例7: SHA256_Update

 error
 SHA256Strategy::update( const std::string& data, boost::any& _context ) const {
     SHA256_Update( boost::any_cast<SHA256_CTX>( &_context ), data.c_str(), data.size() );
     return SUCCESS();
 }
开发者ID:0x414A,项目名称:irods,代码行数:5,代码来源:SHA256Strategy.cpp

示例8: main

int main( int argc, char **argv )
{
   unicap_handle_t handle;
   unicap_device_t device;
   unicap_format_t format_spec;
   unicap_format_t format;
   unicap_data_buffer_t buffer;
   unicap_data_buffer_t *returned_buffer;
	
   int i;

   SDL_Surface *screen;
   SDL_Overlay *overlay;

   int quit=0;

   /*
     Enumerate available video capture devices
    */
   printf( "select video device\n" );
   for( i = 0; SUCCESS( unicap_enumerate_devices( NULL, &device, i ) ); i++ )
   {
      printf( "%i: %s\n", i, device.identifier );
   }
   if( --i > 0 )
   {
      printf( "Select video capture device: " );
      scanf( "%d", &i );
   }

   if( !SUCCESS( unicap_enumerate_devices( NULL, &device, i ) ) )
   {
      fprintf( stderr, "Failed to get info for device '%s'\n", device.identifier );
      exit( 1 );
   }

   /*
     Acquire a handle to selected device
   */
   if( !SUCCESS( unicap_open( &handle, &device ) ) )
   {
      fprintf( stderr, "Failed to open device: %s\n", device.identifier );
      exit( 1 );
   }

   printf( "Opened video capture device: %s\n", device.identifier );

   unicap_void_format( &format_spec );
	
   /*
     Get the list of video formats
   */
   for( i = 0; SUCCESS( unicap_enumerate_formats( handle, 
						  NULL, 
						  &format, i ) ); 
	i++ )
   {
      printf( "%d: %s\n", 
	      i,
	      format.identifier );
   }
   if( --i > 0 )
   {
      printf( "Select video format: " );
      scanf( "%d", &i );
   }
   if( !SUCCESS( unicap_enumerate_formats( handle, &format_spec, &format, i ) ) )
   {
      fprintf( stderr, "Failed to get video format %d\n", i );
      exit( 1 );
   }
	
   /*
     If a video format has more than one size, ask for which size to use
   */
   if( format.size_count )
   {
      for( i = 0; i < format.size_count; i++ )
      {
	 printf( "%d: %dx%d\n", i, format.sizes[i].width, format.sizes[i].height );
      }
      do
      {
	 printf( "Select video format size: " );
	 scanf( "%d", &i );
      }while( ( i < 0 ) && ( i > format.size_count ) );
      format.size.width = format.sizes[i].width;
      format.size.height = format.sizes[i].height;
   }

   /*
     Set this video format
   */
   if( !SUCCESS( unicap_set_format( handle, &format ) ) )
   {
      fprintf( stderr, "Failed to set video format\n" );
      exit( 1 );
   }

   /*
//.........这里部分代码省略.........
开发者ID:fabienchateau,项目名称:CCV-Calibrage-rond,代码行数:101,代码来源:sdl_display.c

示例9: STRING_IO_SUMMARY

PERROR
CGame::outputWrite(
    int key
)
{
    PERROR error = errorSuccess;

    if (key == DOWN_KEY)
    {
        if (m_outputWriteRegion > 0)
        {
            m_outputWriteRegion--;
        }
    }

    if (key == UP_KEY)
    {
        if (m_outputRegion[m_outputWriteRegion+1].activeMask != 0)
        {
            m_outputWriteRegion++;
        }
    }

    {
        const OUTPUT_REGION *region = &m_outputRegion[m_outputWriteRegion];

        if (key == SELECT_KEY)
        {
            //
            // Check if we need to perform a bank switch for this region.
            // and do that now for all the testing to be done upon it.
            //
            if (region->bankSwitch != NO_BANK_SWITCH)
            {
                error = region->bankSwitch( (void *) this );
            }

            {
                UINT8 outData;

                //
                // If we're wanting to write active(on) then just use the mask.
                // else use the clear of the mask. This is a toggle.
                //
                if (m_outputWriteRegionOn)
                {
                    errorCustom->description = "OK: Active";

                    outData = region->invertMask ^ region->activeMask;
                    m_outputWriteRegionOn = false;

                }
                else
                {
                    errorCustom->description = "OK: Inactive";

                    outData = region->invertMask;
                    m_outputWriteRegionOn = true;
                }

                error = m_cpu->memoryWrite( region->address,
                                            outData );
            }
        }
        else
        {
            STRING_IO_SUMMARY(errorCustom, region->location, region->activeMask, region->description);
        }
    }

    if (SUCCESS(error))
    {
        error = errorCustom;
    }

    return error;
}
开发者ID:Phillrb,项目名称:arduino-mega-ict,代码行数:77,代码来源:CGame.cpp

示例10: SHA256_CTX

 error
 SHA256Strategy::init( boost::any& _context ) const {
     _context = SHA256_CTX();
     SHA256_Init( boost::any_cast<SHA256_CTX>( &_context ) );
     return SUCCESS();
 }
开发者ID:0x414A,项目名称:irods,代码行数:6,代码来源:SHA256Strategy.cpp

示例11: onRamKeyMove

PERROR
CGame::ramWriteRead(
    int key
)
{
    PERROR error = errorSuccess;

    if (key == SELECT_KEY)
    {
        const RAM_REGION *region = &m_ramRegion[m_RamWriteReadRegion];

        UINT8 expData4[4] = {0x11, 0x22, 0x44, 0x88};
        UINT8 expData1[4] = {0x55, 0xAA, 0x55, 0xAA};
        UINT8 *expData = (UINT8*) NULL;;
        UINT8 recData[4] = {0};

        //
        // This is more complicated than this simple test
        // as it needs the bit shift done to be correct.
        //
        if (region->mask < 4)
        {
            expData = expData1;
        }
        else
        {
            expData = expData4;
        }

        errorCustom->description = "OK:";

        //
        // Check if we need to perform a bank switch for this region.
        // and do that now for all the testing to be done upon it.
        //
        if (region->bankSwitch != NO_BANK_SWITCH)
        {
            error = region->bankSwitch( (void *) this );
        }

        //
        // Write the first 4 bytes, maximum.
        //
        if (SUCCESS(error))
        {
            for (UINT16 address = 0 ; address < ARRAYSIZE(recData) ; address++)
            {
                error = m_cpu->memoryWrite( (address + region->start),
                                            expData[address] );

                if (FAILED(error))
                {
                    break;
                }
            }
        }

        if (SUCCESS(error))
        {
            //
            // Read the first 4 bytes, maximum.
            //
            for (UINT16 address = 0 ; address < ARRAYSIZE(recData) ; address++)
            {
                error = m_cpu->memoryRead( (address + region->start),
                                           &recData[address] );

                if (FAILED(error))
                {
                    break;
                }

                STRING_UINT8_HEX(errorCustom->description, (recData[address] & region->mask) );
                error = errorCustom;
            }
        }
    }
    else
    {
        error = onRamKeyMove(key);
    }

    return error;
}
开发者ID:Phillrb,项目名称:arduino-mega-ict,代码行数:84,代码来源:CGame.cpp

示例12: test_main

int
test_main(void)
{
  /* http://www.ecrypt.eu.org/stream/svn/viewcvs.cgi/ecrypt/trunk/submissions/salsa20/full/verified.test-vectors?logsort=rev&rev=210&view=markup */

  test_salsa20(HL("80000000 00000000 00000000 00000000"),
	       H("00000000 00000000"),
	       HL("00000000 00000000"),
	       H("4DFA5E48 1DA23EA0"));

  test_salsa20(HL("00000000 00000000 00000000 00000000"),
	       H("80000000 00000000"),
	       HL("00000000 00000000"),
	       H("B66C1E44 46DD9557"));

  test_salsa20(HL("0053A6F94C9FF24598EB3E91E4378ADD"),
	       H("0D74DB42A91077DE"),
	       HL("00000000 00000000"),
	       H("05E1E7BE B697D999"));

  test_salsa20(HL("80000000 00000000 00000000 00000000"
		  "00000000 00000000 00000000 00000000"),
	       H("00000000 00000000"),
	       HL("00000000 00000000"),
	       H("E3BE8FDD 8BECA2E3"));

  test_salsa20(HL("00000000 00000000 00000000 00000000"
		  "00000000 00000000 00000000 00000000"),
	       H("80000000 00000000"),
	       HL("00000000 00000000"),
	       H("2ABA3DC45B494700"));

  test_salsa20(HL("0053A6F94C9FF24598EB3E91E4378ADD"
		  "3083D6297CCF2275C81B6EC11467BA0D"),
	       H("0D74DB42A91077DE"),
	       HL("00000000 00000000"),
	       H("F5FAD53F 79F9DF58"));

  test_salsa20_stream(HL("80000000000000000000000000000000"),
		      H("00000000 00000000"),
		      H("4DFA5E481DA23EA09A31022050859936"
			"DA52FCEE218005164F267CB65F5CFD7F"
			"2B4F97E0FF16924A52DF269515110A07"
			"F9E460BC65EF95DA58F740B7D1DBB0AA"
			"DA9C1581F429E0A00F7D67E23B730676"
			"783B262E8EB43A25F55FB90B3E753AEF"
			"8C6713EC66C51881111593CCB3E8CB8F"
			"8DE124080501EEEB389C4BCB6977CF95"
			"7D5789631EB4554400E1E025935DFA7B"
			"3E9039D61BDC58A8697D36815BF1985C"
			"EFDF7AE112E5BB81E37ECF0616CE7147"
			"FC08A93A367E08631F23C03B00A8DA2F"
			"B375703739DACED4DD4059FD71C3C47F"
			"C2F9939670FAD4A46066ADCC6A564578"
			"3308B90FFB72BE04A6B147CBE38CC0C3"
			"B9267C296A92A7C69873F9F263BE9703"),
		      H("F7A274D268316790A67EC058F45C0F2A"
			"067A99FCDE6236C0CEF8E056349FE54C"
			"5F13AC74D2539570FD34FEAB06C57205"
			"3949B59585742181A5A760223AFA22D4"));

  test_salsa20_stream(HL("48494A4B4C4D4E4F5051525354555657"
			 "58595A5B5C5D5E5F6061626364656667"),
		      H("0000000000000000"),
		      H("53AD3698A011F779AD71030F3EFBEBA0"
			"A7EE3C55789681B1591EF33A7BE521ED"
			"68FC36E58F53FFD6E1369B00E390E973"
			"F656ACB097E0D603BE59A0B8F7975B98"
			"A04698274C6AC6EC03F66ED3F94C08B7"
			"9FFDBF2A1610E6F5814905E73AD6D0D2"
			"8164EEB8450D8ED0BB4B644761B43512"
			"52DD5DDF00C31E3DABA0BC17691CCFDC"
			"B826C7F071E796D34E3BFFB3C96E76A1"
			"209388392806947C7F19B86D379FA3AE"
			"DFCD19EBF49803DACC6E577E5B97B0F6"
			"D2036B6624D8196C96FCF02C865D30C1"
			"B505D41E2C207FA1C0A0E93413DDCFFC"
			"9BECA8030AFFAC2466E56482DA0EF428"
			"E63880B5021D3051F18679505A2B9D4F"
			"9B2C5A2D271D276DE3F51DBEBA934436"),
		      H("7849651A820B1CDFE36D5D6632716534"
			"E0635EDEFD538122D80870B60FB055DB"
			"637C7CA2B78B116F83AFF46E40F8F71D"
			"4CD6D2E1B750D5E011D1DF2E80F7210A"));

  SUCCESS();
}
开发者ID:Zeranoe,项目名称:gstreamer-nettle,代码行数:87,代码来源:salsa20-test.c

示例13: load_balanced_redirect_for_open_operation

    /// =-=-=-=-=-=-=-
    /// @brief
    irods::error load_balanced_redirect_for_open_operation(
        irods::resource_plugin_context& _ctx,
        const std::string*              _opr,
        const std::string*              _curr_host,
        irods::hierarchy_parser*        _out_parser,
        float*                          _out_vote ) {
        // =-=-=-=-=-=-=-
        // data struct to hold parser and vote from the search
        std::map< float, irods::hierarchy_parser > result_map;

        // =-=-=-=-=-=-=-
        // iterate over all the children and pick the highest vote
        irods::resource_child_map::iterator itr = _ctx.child_map().begin();
        for ( ; itr != _ctx.child_map().end(); ++itr ) {
            // =-=-=-=-=-=-=-
            // cache resc ptr for ease of use
            irods::resource_ptr resc = itr->second.second;

            // =-=-=-=-=-=-=-
            // temp results from open redirect call - init parser with incoming
            // hier parser
            float                   vote   = 0.0;
            irods::hierarchy_parser parser = ( *_out_parser );

            // =-=-=-=-=-=-=-
            // forward the redirect call to the child for assertion of the whole operation,
            // there may be more than a leaf beneath us
            irods::error err = resc->call <
                               const std::string*,
                               const std::string*,
                               irods::hierarchy_parser*,
                               float* > (
                                   _ctx.comm(),
                                   irods::RESOURCE_OP_RESOLVE_RESC_HIER,
                                   _ctx.fco(),
                                   _opr,
                                   _curr_host,
                                   &parser,
                                   &vote );
            std::string hier;
            parser.str( hier );
            rodsLog( LOG_DEBUG1, "load_balanced node - hier : [%s], vote %f", hier.c_str(), vote );
            if ( !err.ok() ) {
                irods::log( PASS( err ) );
            }
            else {
                result_map[ vote ] = parser;
            }

        } // for

        // =-=-=-=-=-=-=-
        // now that we have collected all of the results the map
        // will have put the largest one at the end of the map
        // so grab that one and return the result if it is non zero
        float high_vote = result_map.rbegin()->first;
        if ( high_vote > 0.0 ) {
            ( *_out_parser ) = result_map.rbegin()->second;
            ( *_out_vote )   = high_vote;
            return SUCCESS();

        }
        else {
            return ERROR( -1, "no valid data object found to open" );
        }

    } // load_balanced_redirect_for_open_operation
开发者ID:dthain,项目名称:irods,代码行数:69,代码来源:libload_balanced.cpp

示例14: main

int main (int argc, char *argv [])
{
    unicap_handle_t handle;
    unicap_device_t device;
    unicap_format_t src_format;
    unicap_format_t dest_format;
    unicap_data_buffer_t src_buffer;
    unicap_data_buffer_t dest_buffer;
    unicap_data_buffer_t *returned_buffer;

    if (argc != 4) {
        fprintf (stderr, "Usage: sender <hostname> <camera name> "
            "<interface>\n");
        exit (1);
    }

    //  Initialise 0MQ infrastructure

    //  1. Set error handler function (to ignore disconnected receivers)
    zmq::set_error_handler (error_handler);

    //  2. Initialise basic infrastructure for 2 threads
    zmq::dispatcher_t dispatcher (2);

    //  3. Initialise local locator (to connect to global locator)
    zmq::locator_t locator (argv [1]);

    //  4. Start one working thread (to send data to receivers)
    zmq::poll_thread_t *pt = zmq::poll_thread_t::create (&dispatcher);

    //  5. Register one API thread (the application thread - the one that
    //     is being executed at the moment)
    zmq::api_thread_t *api = zmq::api_thread_t::create (&dispatcher, &locator);

    //  6.  Define an entry point for the messages. The name of the entry point
    //      is user-defined ("camera name"). Specify that working thread "pt"
    //      will be used to listen to new connections being created as well as
    //      to send frames to existing connections.
    int e_id = api->create_exchange (argv [2], zmq::scope_global, argv [3],
        pt, 1, &pt);
    
    //  Open first available video capture device
    if (!SUCCESS (unicap_enumerate_devices (NULL, &device, 0))) {
        fprintf (stderr, "Could not enumerate devices\n");
        exit (1);
    }
    if (!SUCCESS (unicap_open (&handle, &device))) {
        fprintf (stderr, "Failed to open device: %s\n", device.identifier);
        exit (1);
    }
    printf( "Opened video capture device: %s\n", device.identifier );

    //  Find a suitable video format that we can convert to RGB24
    bool conversion_found = false;
    int index = 0;
    while (SUCCESS (unicap_enumerate_formats (handle, NULL, &src_format,
          index))) {
        printf ("Trying video format: %s\n", src_format.identifier);
        if (ucil_conversion_supported (FOURCC ('R', 'G', 'B', '3'), 
            src_format.fourcc)) {
            conversion_found = true;
            break;
        }
        index++;
    }
    if (!conversion_found) {
        fprintf (stderr, "Could not find a suitable video format\n");
        exit (1);
    }
    src_format.buffer_type = UNICAP_BUFFER_TYPE_USER;
    if (!SUCCESS (unicap_set_format (handle, &src_format))) {
        fprintf (stderr, "Failed to set video format\n");
        exit (1);
    }
    printf ("Using video format: %s [%dx%d]\n", 
        src_format.identifier, 
        src_format.size.width, 
        src_format.size.height);

    //  Clone destination format with equal dimensions, but RGB24 colorspace
    unicap_copy_format (&dest_format, &src_format);
    strcpy (dest_format.identifier, "RGB 24bpp");
    dest_format.fourcc = FOURCC ('R', 'G', 'B', '3');
    dest_format.bpp = 24;
    dest_format.buffer_size = dest_format.size.width *
        dest_format.size.height * 3;
    
    //  Initialise image buffers
    memset (&src_buffer, 0, sizeof (unicap_data_buffer_t));
    src_buffer.data = (unsigned char *)malloc (src_format.buffer_size);
    src_buffer.buffer_size = src_format.buffer_size;
    memset (&dest_buffer, 0, sizeof (unicap_data_buffer_t));
    dest_buffer.data = (unsigned char *)malloc (dest_format.buffer_size);
    dest_buffer.buffer_size = dest_format.buffer_size;
    dest_buffer.format = dest_format;

    //  Start video capture
    if (!SUCCESS (unicap_start_capture (handle))) {
        fprintf (stderr, "Failed to start capture on device: %s\n",
            device.identifier);
//.........这里部分代码省略.........
开发者ID:tenderlove,项目名称:quail,代码行数:101,代码来源:sender.cpp

示例15: ofLog

//--------------------------------------------------------------------
// If a 24 bit video format is founded this is the preferred one, if not, the first
// returned by unicap is selected.
//
// Then it tries to set the desired width and height, if these fails, tries find the
// nearest size or to set the default width and height.
//
// On V4L devices 24 bit format is always BGR, so it needs conversion.
// On some V4L devices using non-default width/heigth it reports BGR but returns RGB.
// ffmpeg color conversion
void ofUCUtils::set_format(int w, int h) {
	if(!deviceReady)
		return;
	d_width=w;
	d_height=h;
	unicap_format_t formats[MAX_FORMATS];
	int format_count;
	unicap_status_t status = STATUS_SUCCESS;
	int rgb24 = -1;

	ofLog(OF_LOG_NOTICE,"ofUCUtils : Available formats for this device:");
	for (format_count = 0; SUCCESS (status) && (format_count < MAX_FORMATS); format_count++) {
		status = unicap_enumerate_formats (handle, NULL, &formats[format_count], format_count);
		if (SUCCESS (status)) {
			if (formats[format_count].bpp == 8) {
				rgb24 = format_count;
			}
			ofLog(OF_LOG_NOTICE,
					"ofUCUtils : %d: %s, min size: %dx%d, max size:%dx%d, default size: %dx%d",
					format_count, formats[format_count].identifier,
					formats[format_count].min_size.width,
					formats[format_count].min_size.height,
					formats[format_count].max_size.width,
					formats[format_count].max_size.height,
					formats[format_count].size.width,
					formats[format_count].size.height);
			ofLog(OF_LOG_VERBOSE,"ofUCUtils: available sizes for this format:");
			for(int i=0; i<formats[format_count].size_count;i++){
				ofLog(OF_LOG_VERBOSE,"          %dx%d",formats[format_count].sizes[i].width,formats[format_count].sizes[i].height);
			}
		}
	}

	if (format_count > 0) {
		int selected_format = 0;
		if (rgb24 != -1)
			selected_format = rgb24;
		else{
			for(selected_format=0;selected_format<format_count;selected_format++){
				format = formats[selected_format];
				if(fourcc_to_pix_fmt(format.fourcc)!=-1)
					break;
			}
		}
		format = formats[selected_format];

		src_pix_fmt=fourcc_to_pix_fmt(format.fourcc);
		if( (PixelFormat)src_pix_fmt==-1){
			ofLog(OF_LOG_ERROR,"ofUCUtils : Format not suported\n");
			return;
		}

		bool exactMatch  = false;
		int sizeDiff = 99999999;
		int mostAproxSize = -1;

		for(int i=0; i<format.size_count;i++){
			if(format.sizes[i].width == w && format.sizes[i].height==h){
				exactMatch=true;
				format.size.width  = format.sizes[i].width;
				format.size.height = format.sizes[i].height;
				break;
			}else{
				if(abs(format.sizes[i].width-w)+abs(format.sizes[i].height-h)<sizeDiff){
					sizeDiff=abs(format.sizes[i].width-w)+abs(format.sizes[i].height-h);
					mostAproxSize=i;
				}
			}
		}
		if(!exactMatch && mostAproxSize!=-1){
			format.size.width  = format.sizes[mostAproxSize].width;
			format.size.height = format.sizes[mostAproxSize].height;

			ofLog(OF_LOG_WARNING, "ofUCUtils : Can't set video format %s, with size %dx%d, will use %dx%d",
							format.identifier, w, h,
							format.size.width, format.size.height);
		}else if(format.size_count==0){
			int defaultFormatWidth = format.size.width;
			int defaultFormatHeight = format.size.height;

			format.size.width  = w;
			format.size.height = h;

			ofLog(OF_LOG_WARNING, "ofUCUtils : Can't recognize supported video sizes for %s, trying with requested size: %i,%i",
										format.identifier, format.size.width, format.size.height);

			if ( !SUCCESS ( unicap_set_format (handle, &format) ) ) {
				format.size.width  = defaultFormatWidth;
				format.size.height = defaultFormatHeight;

//.........这里部分代码省略.........
开发者ID:fabienchateau,项目名称:CCV-Calibrage-rond,代码行数:101,代码来源:ofUCUtils.cpp


注:本文中的SUCCESS函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。