The Samba-Bugzilla – Attachment 3023 Details for
Bug 5128
readdir returns wrong names in some cases
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
test program
smbtest.cpp (text/plain), 2.42 KB, created by
Jonas Hansson (mail bounces back)
on 2007-12-06 07:05:41 UTC
(
hide
)
Description:
test program
Filename:
MIME Type:
Creator:
Jonas Hansson (mail bounces back)
Created:
2007-12-06 07:05:41 UTC
Size:
2.42 KB
patch
obsolete
>/* > Compile: > g++ -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -I/usr/local/samba/include -L/usr/local/samba/lib -lsmbclient smbtest.cpp -o smbtest >*/ >#include <iostream> >#include <iomanip> >#include <libsmbclient.h> >#include <errno.h> > >using namespace std; > >#define MAX_BUFF_SIZE 255 > >char g_workgroup[MAX_BUFF_SIZE]; >char g_username[MAX_BUFF_SIZE]; >char g_password[MAX_BUFF_SIZE]; >char g_server[MAX_BUFF_SIZE]; >char g_share[MAX_BUFF_SIZE]; > >void auth_fn(const char* server, const char* share, char* workgroup, int wgmaxlen, > char* username, int unmaxlen, char* password, int pwmaxlen) >{ > strncpy(workgroup, "", 0); >// strncpy(workgroup, g_workgroup, wgmaxlen - 1); > strncpy(username, g_username, unmaxlen - 1); > strncpy(password, g_password, pwmaxlen - 1); > strcpy(g_server, server); > strcpy(g_share, share); >} > >void GetContext(SMBCCTX** _ppContext ) >{ > if( *_ppContext != NULL ) > { > smbc_free_context( *_ppContext, 1 ); > } > > *_ppContext = smbc_new_context(); > if( !(*_ppContext) ) > throw exception(); > > (*_ppContext)->debug = 0; > (*_ppContext)->callbacks.auth_fn = auth_fn; > (*_ppContext)->timeout = 5000; > (*_ppContext)->options.urlencode_readdir_entries = 1; > > // initialize the context using the previously specified options > if( !smbc_init_context(*_ppContext) ) > { > smbc_free_context( *_ppContext, 1 ); > throw exception(); > } > smbc_option_set( *_ppContext, "full_time_names", 1 ); >} > >int main( int _nArgC, char** _ppArgV ) >{ > // edit these > strcpy( g_workgroup, "" ); > strcpy( g_username, "jonas" ); > strcpy( g_password, "xxxxx" ); > strcpy( g_server, "192.168.1.xxx" ); > strcpy( g_share, "jonas" ); > // --- > > string strURL( "smb://192.168.1.203/jonas/testdir" ); > cout << strURL << endl; > > SMBCCTX *pCtx = NULL; > GetContext( &pCtx ); > > SMBCFILE *pDir = pCtx->opendir( pCtx, strURL.c_str() ); > struct smbc_dirent *pDirEnt; > while( pDirEnt = pCtx->readdir(pCtx, pDir) ) > { > switch( pDirEnt->smbc_type ) > { > case SMBC_FILE: > cout << setw(8) << "<FILE>"; > break; > case SMBC_DIR: > cout << setw(8) << left << "<DIR>"; > break; > default: > cout << setw(8) << left << "<OTHER>"; > break; > } > cout << "name: " << setw(30) << left << pDirEnt->name; > > size_t nBuffSize = strlen(pDirEnt->name) + 1; > char *pBuffer = new char[nBuffSize]; > int nReturnCode = smbc_urldecode( pBuffer, pDirEnt->name, nBuffSize ); > if( 0 == nReturnCode ) cout << "decoded: " << setw(30) << left << pBuffer; > delete[] pBuffer; > > cout << endl; > } > > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 5128
: 3023 |
5410
|
5411