Class: Net::SMB
- Inherits:
-
Object
show all
- Defined in:
- lib/net/smb/version.rb,
ext/net_smb/smb.c
Overview
Defined Under Namespace
Classes: Dir, DirEntry, Error, File, Stat
Constant Summary
collapse
- VERSION =
"0.0.5"
- SMBC_WORKGROUP =
INT2FIX(SMBC_WORKGROUP)
- SMBC_SERVER =
INT2FIX(SMBC_SERVER)
- SMBC_FILE_SHARE =
INT2FIX(SMBC_FILE_SHARE)
- SMBC_PRINTER_SHARE =
INT2FIX(SMBC_PRINTER_SHARE)
- SMBC_COMMS_SHARE =
INT2FIX(SMBC_COMMS_SHARE)
- SMBC_IPC_SHARE =
INT2FIX(SMBC_IPC_SHARE)
- SMBC_DIR =
INT2FIX(SMBC_DIR)
- SMBC_FILE =
INT2FIX(SMBC_FILE)
- SMBC_LINK =
INT2FIX(SMBC_LINK)
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Object
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
# File 'ext/net_smb/smb.c', line 151
static VALUE rb_smb_initialize(VALUE self)
{
RB_SMB_DATA_FROM_OBJ(self, data);
/* FIXME: Take encoding from argument */
/* FIXME: Read unix charset (?) from smb.conf for default encoding */
data->enc = rb_enc_find("UTF-8");
smbc_setDebug(data->smbcctx, 0);
smbc_setOptionUserData(data->smbcctx, (void *)self);
smbc_setOptionDebugToStderr(data->smbcctx, SMBC_TRUE);
smbc_setOptionNoAutoAnonymousLogin(data->smbcctx, SMBC_TRUE);
smbc_setFunctionAuthDataWithContext(data->smbcctx, smbcctx_auth_fn);
if (smbc_init_context(data->smbcctx) == NULL) {
rb_sys_fail("smbc_init_context() failed");
}
return self;
}
|
Instance Method Details
#auth_callback(*args) ⇒ Object
Also known as:
auth
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
# File 'ext/net_smb/smb.c', line 204
static VALUE rb_smb_auth_callback(int argc, VALUE* argv, VALUE self)
{
RB_SMB_DATA_FROM_OBJ(self, data);
VALUE proc;
VALUE block;
if (argc == 0 && !rb_block_given_p()) {
rb_raise(rb_eArgError, "No block or proc given");
}
else if (argc > 0 && rb_block_given_p()) {
rb_raise(rb_eArgError, "Cannot use both block and proc");
}
rb_scan_args(argc, argv, "01&", &proc, &block);
if (argc == 1) {
data->auth_callback = proc;
}
else {
data->auth_callback = block;
}
return Qnil;
}
|
#debug ⇒ Object
172
173
174
175
176
177
|
# File 'ext/net_smb/smb.c', line 172
static VALUE rb_smb_debug_get(VALUE self)
{
RB_SMB_DATA_FROM_OBJ(self, data);
return INT2NUM(smbc_getDebug(data->smbcctx));
}
|
#debug=(debug) ⇒ Object
179
180
181
182
183
184
185
186
|
# File 'ext/net_smb/smb.c', line 179
static VALUE rb_smb_debug_set(VALUE self, VALUE debug)
{
RB_SMB_DATA_FROM_OBJ(self, data);
smbc_setDebug(data->smbcctx, NUM2INT(debug));
return debug;
}
|
#open(*args) ⇒ Object
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
|
# File 'ext/net_smb/smb.c', line 257
static VALUE rb_smb_open(int argc, VALUE *argv, VALUE self)
{
RB_SMB_DATA_FROM_OBJ(self, data);
VALUE argv_new[argc+1];
VALUE smbfile;
argv_new[0] = self;
memcpy(argv_new + 1, argv, sizeof(*argv) * argc);
smbfile = rb_class_new_instance(argc+1, argv_new, rb_cSMBFile);
RB_SMBFILE_DATA_FROM_OBJ(smbfile, smbfile_data);
DLIST_ADD(data->smbfile_data_list, smbfile_data);
return smbfile;
}
|
#opendir(url_obj) ⇒ Object
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
# File 'ext/net_smb/smb.c', line 241
static VALUE rb_smb_opendir(VALUE self, VALUE url_obj)
{
RB_SMB_DATA_FROM_OBJ(self, data);
VALUE args[2];
VALUE smbdir;
args[0] = self;
args[1] = url_obj;
smbdir = rb_class_new_instance(2, args, rb_cSMBDir);
RB_SMBFILE_DATA_FROM_OBJ(smbdir, smbfile_data);
DLIST_ADD(data->smbfile_data_list, smbfile_data);
return smbdir;
}
|
#stat(url_obj) ⇒ Object
229
230
231
232
233
234
235
236
237
238
239
|
# File 'ext/net_smb/smb.c', line 229
static VALUE rb_smb_stat(VALUE self, VALUE url_obj)
{
VALUE args[2];
VALUE smbstat;
args[0] = self;
args[1] = url_obj;
smbstat = rb_class_new_instance(2, args, rb_cSMBStat);
return smbstat;
}
|
#use_kerberos ⇒ Object
188
189
190
191
192
193
|
# File 'ext/net_smb/smb.c', line 188
static VALUE rb_smb_use_kerberos_get(VALUE self)
{
RB_SMB_DATA_FROM_OBJ(self, data);
return SMBC2RB_BOOL(smbc_getOptionUseKerberos(data->smbcctx));
}
|
#use_kerberos=(flag) ⇒ Object
195
196
197
198
199
200
201
202
|
# File 'ext/net_smb/smb.c', line 195
static VALUE rb_smb_use_kerberos_set(VALUE self, VALUE flag)
{
RB_SMB_DATA_FROM_OBJ(self, data);
smbc_setOptionUseKerberos(data->smbcctx, RB2SMBC_BOOL(flag));
return flag;
}
|
#xattr(url_obj, name_obj) ⇒ Object
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
|
# File 'ext/net_smb/smb.c', line 273
VALUE rb_smb_xattr_get(VALUE self, VALUE url_obj, VALUE name_obj)
{
RB_SMB_DATA_FROM_OBJ(self, data);
const char *url = RSTRING_PTR(url_obj);
const char *name = RSTRING_PTR(name_obj);
char value[1024];
smbc_getxattr_fn fn = smbc_getFunctionGetxattr(data->smbcctx);
if ((*fn)(data->smbcctx, url, name, value, sizeof(value)) < 0) {
rb_sys_fail_str(url_obj);
}
return rb_str_new2(value);
}
|