{"id":17053906,"url":"https://github.com/vertexclique/smbclient-sys","last_synced_at":"2025-04-12T16:50:42.097Z","repository":{"id":44381972,"uuid":"40683939","full_name":"vertexclique/smbclient-sys","owner":"vertexclique","description":"SMB client(SAMBA impl) FFI bindings [libsmbclient] for Rust","archived":false,"fork":false,"pushed_at":"2018-09-04T15:54:44.000Z","size":2386,"stargazers_count":11,"open_issues_count":2,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T07:04:45.933Z","etag":null,"topics":["libsmbclient","samba","smb","smbclient-sys"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vertexclique.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-13T22:07:55.000Z","updated_at":"2024-03-06T14:52:00.000Z","dependencies_parsed_at":"2022-07-14T12:50:00.339Z","dependency_job_id":null,"html_url":"https://github.com/vertexclique/smbclient-sys","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vertexclique%2Fsmbclient-sys","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vertexclique%2Fsmbclient-sys/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vertexclique%2Fsmbclient-sys/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vertexclique%2Fsmbclient-sys/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vertexclique","download_url":"https://codeload.github.com/vertexclique/smbclient-sys/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248601218,"owners_count":21131607,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["libsmbclient","samba","smb","smbclient-sys"],"created_at":"2024-10-14T10:13:36.031Z","updated_at":"2025-04-12T16:50:42.075Z","avatar_url":"https://github.com/vertexclique.png","language":"Rust","readme":"smbclient-sys\n=====================\n![Samba](http://wiki.univention.de/images/thumb/6/6d/Logo_Samba.png/300px-Logo_Samba.png)\n\nFFI wrapper around libsmbclient which is the part of SAMBA implementation.\n\n[![Travis](https://img.shields.io/travis/vertexclique/smbclient-sys.svg?style=flat-square)]()\n|\n[![Crates.io](https://img.shields.io/crates/v/smbclient-sys.svg?style=flat-square)]()\n| [![Documentation](https://img.shields.io/badge/documentation-0.1.0-blue.svg?style=flat-square)](http://vertexclique.github.io/smbclient-sys/smbclient_sys/index.html)\n\nUsage\n------------\n\nAdd this to your `Cargo.toml`\n\n```\nsmbclient_sys = \"0.1.0\"\n```\n\nTo access a SMB share and read a file:\n\n```\nextern crate smbclient_sys as smbc;\nextern crate libc;\n\nuse std::str;\nuse std::ffi::{CStr, CString};\nuse libc::{c_char, c_int, strncpy, O_RDONLY};\n\nextern \"C\" fn auth_data(srv: *const c_char,\n            shr: *const c_char,\n            wg: *mut c_char,\n            wglen: c_int,\n            un: *mut c_char,\n            unlen: c_int,\n            pw: *mut c_char,\n            pwlen: c_int) {\n                unsafe {\n        strncpy(un, CString::new(\"vertexclique\").unwrap().as_ptr(), 12);\n        strncpy(pw, CString::new(\"1234\").unwrap().as_ptr(), 3);\n    }\n}\n\npub static mut authCallback: smbc::smbc_get_auth_data_fn = Some(auth_data);\n\nfn main() {\n    println!(\"Launch...\");\n    unsafe {\n        let fname = CString::new(\"smb://air5650-nas/rechner/naber.txt\").unwrap();\n\n        // Buffer for contents\n        let dstlen = 300;\n        let mut file_contents = Vec::with_capacity(dstlen as usize);\n\n        smbc::smbc_init(authCallback, 0);\n        let retval: i32 = smbc::smbc_open(fname.as_ptr(), O_RDONLY, 0);\n        if retval \u003c 0 {\n            println!(\"Couldn't accessed to a SMB file\");\n        } else {\n            println!(\"Accessed to specified SMB file\");\n\n            // Read file to buffer\n            let read_val: i64 = smbc::smbc_read(retval, file_contents.as_mut_ptr(), dstlen);\n            if read_val \u003e 0 {\n                // File successfully read, print contents to stdout\n\n                let c_str: \u0026CStr = CStr::from_ptr(file_contents.as_mut_ptr() as *const i8);\n                let content_bytes: \u0026[u8] = c_str.to_bytes();\n                let str_slice: \u0026str = str::from_utf8(content_bytes).unwrap();\n                let str_buf: String = str_slice.to_owned();\n\n                println!(\"{0}\", str_buf);\n            } else {\n                // Panic \\o/ if you couldn't read\n                panic!(\"Couldn't read file over SMB share\");\n            }\n\n            // Close it\n            smbc::smbc_close(read_val as i32);\n        }\n    }\n}\n\n```\n\nFor more information please see the `examples` dir.\n\nRequirements\n------------\n\n* `libsmbclient` is needed with development environment\n* Some of the systems need `udev` with samba packages. (optional dependency)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvertexclique%2Fsmbclient-sys","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvertexclique%2Fsmbclient-sys","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvertexclique%2Fsmbclient-sys/lists"}