static void test_BuildS3Request( const char *param ) { struct curl_slist *headers = NULL; struct curl_slist *currentHeader; int i = 0; char *method = "HEAD"; char *path = "/with.html?some=parameter"; char *keyId = "aboguskeyid"; char *secretKey = "somebogussecret"; SetupHandle( ); handle.keyId = keyId; handle.secretKey = secretKey; headers = curl_slist_append( headers, "Content-MD5: kahaKUW/a80945+a553" ); headers = curl_slist_append( headers, "Content-Type: image/jpeg" ); headers = curl_slist_append( headers, "x-amz-metavariable: something" ); headers = curl_slist_append( headers, "x-amz-also-metavariable: something else" ); headers = BuildS3Request( &handle, method, "bucket-name.s3-ap-southeast-1.amazonaws.com", headers, path ); currentHeader= headers; while( currentHeader != NULL ) { printf( "%d: %s\n", ++i, currentHeader->data ); currentHeader = currentHeader->next; } }
static void test_S3ReadDir( const char *param ) { char **directory; int dirEntries; int status; int i; ReadLiveConfig( param ); SetupHandle( ); InitializeS3If( ); s3comm = &handle; status = S3ReadDir( "/directory", &directory, &dirEntries, -1 ); if( status != 0) exit( 1 ); for( i = 0; i < dirEntries; i++ ) { printf( "%d: %s\n", i, directory[ i ] ); free( directory[ i ] ); } free( directory ); }
static void test_S3GetFileStat( const char *param ) { struct S3FileInfo *fi; int status; ReadLiveConfig( param ); SetupHandle( ); InitializeS3If( ); s3comm = &handle; status = S3GetFileStat( "/README", &fi ); if( status != 0) exit( 1 ); if( fi == NULL ) exit( 1 ); printf( "t=%c s=%d p=%3o uid=%d gid=%d\na=%s", fi->fileType, (int)fi->size, fi->permissions, fi->uid, fi->gid, ctime(&fi->atime) ); printf( "m=%s", ctime(&fi->mtime) ); printf( "c=%ssp=%d\n", ctime(&fi->ctime), ( fi->exeUid ? S_ISUID : 0 ) | ( fi->exeGid ? S_ISGID : 0 ) | ( fi->exeUid ? S_ISVTX : 0 ) ); free( fi ); }
static void test_S3FileStat_File( const char *param ) { struct S3FileInfo *fi; struct S3FileInfo *cachedFi; int status; ReadLiveConfig( param ); SetupHandle( ); InitializeS3If( ); s3comm = &handle; status = S3FileStat( "/README", &fi ); if( status != 0) { fprintf( stderr, "Error: %d\n", status ); exit( 1 ); } if( fi == NULL ) exit( 1 ); /* Verify that the file was found in the cache. */ cachedFi = SearchStatEntry( "/README" ); if( cachedFi == NULL ) { printf( "File not found in stat cache.\n" ); exit( 1 ); } else { printf( "t=%c s=%d p=%3o uid=%d gid=%d\na=%s", fi->fileType, (int)fi->size, fi->permissions, fi->uid, fi->gid, ctime(&fi->atime) ); printf( "m=%s", ctime(&fi->mtime) ); printf( "c=%ssp=%d\n", ctime(&fi->ctime), ( fi->exeUid ? S_ISUID : 0 ) | ( fi->exeGid ? S_ISGID : 0 ) | ( fi->exeUid ? S_ISVTX : 0 ) ); } }
bool AsyncUsbReceiver::Init() { m_usb_handle = SetupHandle(); m_inited_with_handle = false; return m_usb_handle != NULL; }