本文整理汇总了C++中smbc_init函数的典型用法代码示例。如果您正苦于以下问题:C++ smbc_init函数的具体用法?C++ smbc_init怎么用?C++ smbc_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了smbc_init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: open_f
static int open_f (stream_t *stream, int mode, void *opts, int* file_format) {
struct stream_priv_s *p = (struct stream_priv_s*)opts;
char *filename;
mode_t m = 0;
off_t len;
int fd, err;
filename = stream->url;
if(mode == STREAM_READ)
m = O_RDONLY;
else if (mode == STREAM_WRITE) //who's gonna do that ?
m = O_RDWR|O_CREAT|O_TRUNC;
else {
mp_msg(MSGT_OPEN, MSGL_ERR, "[smb] Unknown open mode %d\n", mode);
m_struct_free (&stream_opts, opts);
return STREAM_UNSUPPORTED;
}
if(!filename) {
mp_msg(MSGT_OPEN,MSGL_ERR, "[smb] Bad url\n");
m_struct_free(&stream_opts, opts);
return STREAM_ERROR;
}
err = smbc_init(smb_auth_fn, 1);
if (err < 0) {
mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_SMBInitError,err);
m_struct_free(&stream_opts, opts);
return STREAM_ERROR;
}
fd = smbc_open(filename, m,0644);
if (fd < 0) {
mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_SMBFileNotFound, filename);
m_struct_free(&stream_opts, opts);
return STREAM_ERROR;
}
stream->flags = mode;
len = 0;
if(mode == STREAM_READ) {
len = smbc_lseek(fd,0,SEEK_END);
smbc_lseek (fd, 0, SEEK_SET);
}
if(len > 0 || mode == STREAM_WRITE) {
stream->flags |= MP_STREAM_SEEK;
stream->seek = seek;
if(mode == STREAM_READ) stream->end_pos = len;
}
stream->type = STREAMTYPE_SMB;
stream->fd = fd;
stream->fill_buffer = fill_buffer;
stream->write_buffer = write_buffer;
stream->close = close_f;
stream->control = control;
m_struct_free(&stream_opts, opts);
return STREAM_OK;
}
开发者ID:NeeMeese,项目名称:mplayer-ce,代码行数:60,代码来源:stream_smb.c
示例2: main
int main(int argc, char** argv)
{
int err = -1;
int fd = 0;
char url[MAX_BUFF_SIZE];
struct stat st;
memset(g_workgroup, '\0', MAX_BUFF_SIZE);
memset(url, '\0', MAX_BUFF_SIZE);
if ( argc == 5 )
{
strncpy(g_workgroup,argv[1],strlen(argv[1]));
strncpy(g_username,argv[2],strlen(argv[2]));
strncpy(g_password,argv[3],strlen(argv[3]));
strncpy(url,argv[4],strlen(argv[4]));
smbc_init(auth_fn, 0);
fd = smbc_open(url,O_RDWR | O_CREAT, 0666);
smbc_close(fd);
smbc_stat(url, &st);
err = errno;
}
return err;
}
开发者ID:sprymak,项目名称:samba,代码行数:32,代码来源:stat_4.c
示例3: get_smb_server_fd
int get_smb_server_fd(struct SMB_DS *ds, char* filename)
{
int ret, fd, i;
char buf[256+1];
ret = smbc_init(smb_auth_fn, 0);NE_ERR(ret, 0);
for(i=0;i<strlen(ds->path);i++)
{
if(ds->path[i]=='\\')
ds->path[i] = '/';
}
sprintf(buf, "smb://%s/%s/%s", ds->server, ds->path, filename);
buf[256]='\0';
//fprintf(stderr, "%s\n", buf);
if(ds->user[0]!='\0')
strcpy(smb_username, ds->user);
else
strcpy(smb_username, "dummy");
strcpy(smb_password, ds->passwd);
//fprintf(stderr, "%s %s\n", smb_username, smb_password);
fd = smbc_open(buf, O_RDWR | O_CREAT | O_TRUNC, 0666);EQ_ERR(fd, -1);
return fd;
errout:
if(fd != -1)
smbc_close(fd);
return -1;
}
开发者ID:niubl,项目名称:camera_project,代码行数:28,代码来源:smbc_put.c
示例4: main
int main(int argc, char** argv)
{
int err = -1;
char url[MAX_BUFF_SIZE];
bzero(g_workgroup,MAX_BUFF_SIZE);
bzero(url,MAX_BUFF_SIZE);
if ( argc == 5 )
{
strncpy( g_workgroup, argv[1], strlen(argv[1]) );
strncpy( g_username, argv[2], strlen(argv[2]) );
strncpy( g_password, argv[3], strlen(argv[3]) );
strncpy( url, argv[4], strlen(argv[4]) );
smbc_init( auth_fn, 0 );
smbc_rmdir( url );
smbc_mkdir( url, 0666 );
smbc_mkdir( url, 0666 );
err = errno;
}
return err;
}
开发者ID:0x24bin,项目名称:winexe-1,代码行数:29,代码来源:mkdir_3.c
示例5: main
int main(int argc, char** argv)
{
int err = -1;
int fd = 0;
char url[MAX_BUFF_SIZE];
bzero(g_workgroup,MAX_BUFF_SIZE);
bzero(url,MAX_BUFF_SIZE);
if ( argc == 5 )
{
strncpy(g_workgroup,argv[1],strlen(argv[1]));
strncpy(g_username,argv[2],strlen(argv[2]));
strncpy(g_password,argv[3],strlen(argv[3]));
strncpy(url,argv[4],strlen(argv[4]));
smbc_init(auth_fn, 0);
smbc_unlink(url);
fd = smbc_open(url,O_RDWR|O_CREAT,0666);
smbc_close(fd);
smbc_opendir(url);
err = errno;
}
return err;
}
开发者ID:0x24bin,项目名称:winexe-1,代码行数:32,代码来源:opendir_4.c
示例6: main
int main(int argc, char* argv[])
{
int fd;
struct stat st1;
struct stat st2;
char * pUrl = argv[1];
if(argc != 2)
{
printf("usage: %s <file_url>\n", argv[0]);
return 1;
}
smbc_init(get_auth_data_fn, 0);
if (smbc_stat(pUrl, &st1) < 0)
{
perror("smbc_stat");
return 1;
}
if ((fd = smbc_open(pUrl, O_RDONLY, 0)) < 0)
{
perror("smbc_open");
return 1;
}
if (smbc_fstat(fd, &st2) < 0)
{
perror("smbc_fstat");
return 1;
}
smbc_close(fd);
#define COMPARE(name, field) \
if (st1.field != st2.field) \
{ \
printf("Field " name " MISMATCH: st1=%lu, st2=%lu\n", \
(unsigned long) st1.field, \
(unsigned long) st2.field); \
}
COMPARE("st_dev", st_dev);
COMPARE("st_ino", st_ino);
COMPARE("st_mode", st_mode);
COMPARE("st_nlink", st_nlink);
COMPARE("st_uid", st_uid);
COMPARE("st_gid", st_gid);
COMPARE("st_rdev", st_rdev);
COMPARE("st_size", st_size);
COMPARE("st_blksize", st_blksize);
COMPARE("st_blocks", st_blocks);
COMPARE("st_atime", st_atime);
COMPARE("st_mtime", st_mtime);
COMPARE("st_ctime", st_ctime);
return 0;
}
开发者ID:AIdrifter,项目名称:samba,代码行数:60,代码来源:teststat3.c
示例7: main
int main(int argc, char** argv)
{
int err = -1;
char url[MAX_BUFF_SIZE];
memset(g_workgroup, '\0', MAX_BUFF_SIZE);
memset(url, '\0', MAX_BUFF_SIZE);
if ( argc == 5 )
{
strncpy(g_workgroup,argv[1],strlen(argv[1]));
strncpy(g_username,argv[2],strlen(argv[2]));
strncpy(g_password,argv[3],strlen(argv[3]));
strncpy(url,argv[4],strlen(argv[4]));
smbc_init(auth_fn, 0);
err = smbc_unlink(url);
if ( err < 0 )
err = 1;
}
return 1;
}
开发者ID:sprymak,项目名称:samba,代码行数:28,代码来源:unlink_9.c
示例8: main
int main(int argc, char** argv)
{
int err = -1;
char url[MAX_BUFF_SIZE];
memset(g_workgroup, '\0', MAX_BUFF_SIZE);
memset(url, '\0', MAX_BUFF_SIZE);
if ( argc == 6 )
{
strncpy(g_workgroup,argv[1],strlen(argv[1]));
strncpy(g_username,argv[2],strlen(argv[2]));
strncpy(g_password,argv[3],strlen(argv[3]));
strncpy(url,argv[4],strlen(argv[4]));
smbc_init(auth_fn, 0);
smbc_rename( url, argv[5] );
err = errno;
}
return err;
}
开发者ID:sprymak,项目名称:samba,代码行数:25,代码来源:rename_2.c
示例9: main
int main(int argc, char** argv)
{
int err = -1;
int fd = 0;
char* message = "Testing";
memset(g_workgroup, '\0', MAX_BUFF_SIZE);
if ( argc == 4 )
{
strncpy(g_workgroup,argv[1],strlen(argv[1]));
strncpy(g_username,argv[2],strlen(argv[2]));
strncpy(g_password,argv[3],strlen(argv[3]));
fd = 10345; /* Random value for File Descriptor */
smbc_init(auth_fn, 0);
err = smbc_read(fd, message, sizeof(message));
if ( err < 0 )
err = 1;
else
err = 0;
}
return err;
}
开发者ID:sprymak,项目名称:samba,代码行数:30,代码来源:read_7.c
示例10: main
int main(int argc, char** argv)
{
int err = -1;
int fd1 = 0;
char url[MAX_BUFF_SIZE];
memset(g_workgroup, '\0', MAX_BUFF_SIZE);
memset(url, '\0', MAX_BUFF_SIZE);
if ( argc == 5 )
{
strncpy( g_workgroup, argv[1], strlen(argv[1]) );
strncpy( g_username, argv[2], strlen(argv[2]) );
strncpy( g_password, argv[3], strlen(argv[3]) );
strncpy( url, argv[4], strlen(argv[4]) );
smbc_init( auth_fn, 0 );
fd1 = smbc_open( url, O_RDWR | O_CREAT, 0666 );
smbc_close( fd1 );
err = smbc_rmdir( url );
if ( err < 0 )
err = 1;
else
err = 0;
}
return err;
}
开发者ID:sprymak,项目名称:samba,代码行数:34,代码来源:rmdir_5.c
示例11: main
int main(int argc, char** argv)
{
int err = -1;
int fd = 0;
bzero(g_workgroup,MAX_BUFF_SIZE);
if ( argc == 4 )
{
strncpy(g_workgroup,argv[1],strlen(argv[1]));
strncpy(g_username,argv[2],strlen(argv[2]));
strncpy(g_password,argv[3],strlen(argv[3]));
smbc_init(auth_fn, 0);
fd = -1;
err = smbc_lseek(fd, 0, SEEK_SET);
if ( err < 0 )
err = 1;
else
err = 0;
}
return err;
}
开发者ID:0x24bin,项目名称:winexe-1,代码行数:31,代码来源:lseek_1.c
示例12: main
int main(int argc, char** argv)
{
int err = -1;
int fd = 0;
memset(g_workgroup, '\0', MAX_BUFF_SIZE);
if ( argc == 4 )
{
strncpy(g_workgroup,argv[1],strlen(argv[1]));
strncpy(g_username,argv[2],strlen(argv[2]));
strncpy(g_password,argv[3],strlen(argv[3]));
smbc_init(auth_fn, 0);
fd = -1;
smbc_lseek(fd, 0, SEEK_SET);
err = errno;
}
return err;
}
开发者ID:sprymak,项目名称:samba,代码行数:27,代码来源:lseek_2.c
示例13: main
int main(int argc, char** argv)
{
int err = -1;
int dh = 0;
char url[MAX_BUFF_SIZE];
bzero(g_workgroup,MAX_BUFF_SIZE);
bzero(url,MAX_BUFF_SIZE);
if ( argc == 5 )
{
strncpy(g_workgroup,argv[1],strlen(argv[1]));
strncpy(g_username,argv[2],strlen(argv[2]));
strncpy(g_password,argv[3],strlen(argv[3]));
strncpy(url,argv[4],strlen(argv[4]));
smbc_init(auth_fn, 0);
dh = smbc_opendir(url);
/* printf("directory handle: %i\n",dh); */
smbc_closedir(dh);
err = errno;
}
return err;
}
开发者ID:0x24bin,项目名称:winexe-1,代码行数:30,代码来源:closedir_4.c
示例14: main
int main(int argc, char** argv)
{
int err = -1;
int fd = 0;
char url[MAX_BUFF_SIZE];
memset(g_workgroup, '\0', MAX_BUFF_SIZE);
memset(url, '\0', MAX_BUFF_SIZE);
if ( argc == 5 )
{
strncpy(g_workgroup,argv[1],strlen(argv[1]));
strncpy(g_username,argv[2],strlen(argv[2]));
strncpy(g_password,argv[3],strlen(argv[3]));
strncpy(url,argv[4],strlen(argv[4]));
fd = smbc_init(auth_fn, 0);
if ( fd < 0 )
err = 1;
else
err = 0;
}
return err;
}
开发者ID:sprymak,项目名称:samba,代码行数:30,代码来源:chown_1.c
示例15: main
int main(int argc, char** argv)
{
int err = -1;
char url[MAX_BUFF_SIZE];
bzero(g_workgroup,MAX_BUFF_SIZE);
bzero(url,MAX_BUFF_SIZE);
if ( argc == 6 )
{
strncpy(g_workgroup,argv[1],strlen(argv[1]));
strncpy(g_username,argv[2],strlen(argv[2]));
strncpy(g_password,argv[3],strlen(argv[3]));
strncpy(url,argv[4],strlen(argv[4]));
smbc_init(auth_fn, 0);
err = smbc_print_file(url,argv[6]);
if ( err < 0 )
err = 1;
else
err = 0;
}
return err;
}
开发者ID:srimalik,项目名称:samba,代码行数:30,代码来源:print_file_3.c
示例16: xmms_samba_plugin_setup
static gboolean
xmms_samba_plugin_setup (xmms_xform_plugin_t *xform_plugin)
{
xmms_xform_methods_t methods;
gint err;
XMMS_XFORM_METHODS_INIT (methods);
methods.init = xmms_samba_init;
methods.destroy = xmms_samba_destroy;
methods.read = xmms_samba_read;
methods.seek = xmms_samba_seek;
methods.browse = xmms_samba_browse;
xmms_xform_plugin_methods_set (xform_plugin, &methods);
xmms_xform_plugin_indata_add (xform_plugin, XMMS_STREAM_TYPE_MIMETYPE,
"application/x-url", XMMS_STREAM_TYPE_URL,
"smb://*", XMMS_STREAM_TYPE_END);
g_static_mutex_lock (&mutex);
err = smbc_init (xmms_samba_auth_fn, 0);
g_static_mutex_unlock (&mutex);
if (err < 0) {
xmms_log_error ("%s", strerror (errno));
return FALSE;
}
return TRUE;
}
开发者ID:Reilithion,项目名称:xmms2-reilithion,代码行数:31,代码来源:samba.c
示例17: main
int main(int argc, char** argv)
{
int err = -1;
char url[MAX_BUFF_SIZE];
bzero(g_workgroup,MAX_BUFF_SIZE);
bzero(url,MAX_BUFF_SIZE);
if ( argc == 6 )
{
strncpy(g_workgroup,argv[1],strlen(argv[1]));
strncpy(g_username,argv[2],strlen(argv[2]));
strncpy(g_password,argv[3],strlen(argv[3]));
strncpy(url,argv[4],strlen(argv[4]));
smbc_init(auth_fn, 0);
smbc_open(url,O_RDWR | O_CREAT,0666);
err = smbc_rename( url, argv[5] );
if ( err < 0 )
err = 1;
}
return err;
}
开发者ID:0x24bin,项目名称:winexe-1,代码行数:27,代码来源:rename_3.c
示例18: SMB_init
int SMB_init(int index)
{
strcpy(g_workgroup, smb_config.multrule[index]->workgroup);
strcpy(g_username, smb_config.multrule[index]->acount);
strcpy(g_password, smb_config.multrule[index]->password);
smbc_init(auth_fn, 0);
return 0;
}
开发者ID:rjknight123,项目名称:asuswrt-merlin,代码行数:8,代码来源:smb_api.c
示例19: printf
/*
* FUNCTION : static BOOL access_dir(char* name, char* user, char *passwd)
* DESCRIPTION : check user can access directory or not
* INPUT : char* name - server name
* char* user - username
* char *passwd - password
* int id -
* OUTPUT : N/A
* RETURN : TRUE - can access
* FALSE - can't access
*/
void *access_dir(void *value)
{
int err, dh1;
char url[MAX_NAME_LEN] = {0};
struct smbserverinfo_t *psmbserverinfo = NULL;
if(value == NULL)
return NULL;
psmbserverinfo = (struct smbserverinfo_t *)value;
printf("%s[%d], name = [%s], ip = [%s], user = [%s], passwd = [%s], cmd_id = [%d]\n", __FILE__, __LINE__, psmbserverinfo->name, psmbserverinfo->ip, psmbserverinfo->user, psmbserverinfo->passwd, psmbserverinfo->cmd_id);
memset(smb_username, 0, sizeof(smb_username));
memset(smb_passwd, 0, sizeof(smb_passwd));
if(psmbserverinfo->user != NULL) {
strncpy(smb_username, psmbserverinfo->user, strlen(psmbserverinfo->user));
smb_username[strlen(psmbserverinfo->user)] = '\0';
}
if(psmbserverinfo->passwd != NULL) {
strncpy(smb_passwd, psmbserverinfo->passwd, strlen(psmbserverinfo->passwd));
smb_passwd[strlen(psmbserverinfo->passwd)] = '\0';
}
printf("%s[%d], smb_username = [%s], smb_passwd = [%s]\n", __FILE__, __LINE__, smb_username, smb_passwd);
snprintf(url, sizeof(url), "smb://%s:%[email protected]%s", smb_username, smb_passwd, psmbserverinfo->name);
err = smbc_init(get_static_auth_data_fn, 0); /* Initialize things */
if (err < 0) {
printf("%s[%d], Initializing the smbclient library ...: %s\n", __FILE__, __LINE__, strerror(errno));
if(errno == EACCES) {
printf("\033[1;33;41m%s[%d], errno = EACCES (%s)\033[0m\n", __FILE__, __LINE__, strerror(errno));
SMBTREE_send_event_to_OSD(SMB_CMD_ACCESS_RESPONSE, SMB_ACCESS_LOGIN_FAILED, psmbserverinfo->cmd_id, NULL);
} else {
printf("\033[1;33;41m%s[%d], SMB_ACCESS_FAILED\033[0m\n", __FILE__, __LINE__);
SMBTREE_send_event_to_OSD(SMB_CMD_ACCESS_RESPONSE, SMB_ACCESS_FAILED, psmbserverinfo->cmd_id, NULL);
}
SMBTREE_free_smbserverinfo(psmbserverinfo);
return NULL;
}
if ((dh1 = smbc_opendir(url))<1) {
printf("%s[%d], Could not open directory: %s: %s\n", __FILE__, __LINE__, url, strerror(errno));
if(errno == EACCES) {
printf("\033[1;33;41m%s[%d], errno = EACCES (%s)\033[0m\n", __FILE__, __LINE__, strerror(errno));
SMBTREE_send_event_to_OSD(SMB_CMD_ACCESS_RESPONSE, SMB_ACCESS_LOGIN_FAILED, psmbserverinfo->cmd_id, NULL);
} else {
printf("\033[1;33;41m%s[%d], SMB_ACCESS_FAILED\033[0m\n", __FILE__, __LINE__);
SMBTREE_send_event_to_OSD(SMB_CMD_ACCESS_RESPONSE, SMB_ACCESS_FAILED, psmbserverinfo->cmd_id, NULL);
}
SMBTREE_free_smbserverinfo(psmbserverinfo);
return NULL;
}
smbc_closedir(dh1);
SMBTREE_send_event_to_OSD(SMB_CMD_ACCESS_RESPONSE, SMB_ACCESS_OK, psmbserverinfo->cmd_id, NULL);
SMBTREE_free_smbserverinfo(psmbserverinfo);
return NULL;
}
开发者ID:NikhilNJ,项目名称:screenplay-dx,代码行数:69,代码来源:smbtree_3.0.28a.c
示例20: open_f
static int open_f (stream_t *stream, int mode)
{
char *filename;
mode_t m = 0;
int64_t len;
int fd, err;
struct priv *priv = talloc_zero(stream, struct priv);
stream->priv = priv;
filename = stream->url;
if(mode == STREAM_READ)
m = O_RDONLY;
else if (mode == STREAM_WRITE) //who's gonna do that ?
m = O_RDWR|O_CREAT|O_TRUNC;
else {
MP_ERR(stream, "[smb] Unknown open mode %d\n", mode);
return STREAM_UNSUPPORTED;
}
if(!filename) {
MP_ERR(stream, "[smb] Bad url\n");
return STREAM_ERROR;
}
err = smbc_init(smb_auth_fn, 1);
if (err < 0) {
MP_ERR(stream, "Cannot init the libsmbclient library: %d\n",err);
return STREAM_ERROR;
}
fd = smbc_open(filename, m,0644);
if (fd < 0) {
MP_ERR(stream, "Could not open from LAN: '%s'\n", filename);
return STREAM_ERROR;
}
stream->flags = mode;
len = 0;
if(mode == STREAM_READ) {
len = smbc_lseek(fd,0,SEEK_END);
smbc_lseek (fd, 0, SEEK_SET);
}
if(len > 0 || mode == STREAM_WRITE) {
stream->flags |= MP_STREAM_SEEK;
stream->seek = seek;
if(mode == STREAM_READ) stream->end_pos = len;
}
priv->fd = fd;
stream->fill_buffer = fill_buffer;
stream->write_buffer = write_buffer;
stream->close = close_f;
stream->control = control;
return STREAM_OK;
}
开发者ID:hroncok,项目名称:mpv,代码行数:57,代码来源:stream_smb.c
注:本文中的smbc_init函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论