/* * Bind() is used for LDAP authentifications * * if who is empty this is an anonymous bind * else this is an authentificated bind * * return value : * - nil on succes, * - error with error description on error. * */ func (self *Ldap) Bind(who, cred string) error { var rv int authmethod := C.int(LDAP_AUTH_SIMPLE) // DEPRECATED // API: int ldap_bind_s (LDAP *ld, LDAP_CONST char *who, LDAP_CONST char *cred, int authmethod ); if who == "" { _who := C.to_charptr(unsafe.Pointer(nil)) _cred := C.to_charptr(unsafe.Pointer(nil)) rv = int(C.ldap_bind_s(self.conn, _who, _cred, authmethod)) } else { _who := C.CString(who) _cred := C.CString(cred) defer C.free(unsafe.Pointer(_who)) rv = int(C.ldap_bind_s(self.conn, _who, _cred, authmethod)) } if rv == LDAP_OPT_SUCCESS { return nil } self.conn = nil return errors.New(fmt.Sprintf("LDAP::Bind() error (%d) : %s", rv, ErrorToString(rv))) }
func FilenameFromUri(uri string) (filename string, hostname string, err error) { str := C.CString(uri) defer C.free_string(str) var gerror *C.GError var ptr *C.gchar filename = C.GoString(C.to_charptr(C.g_filename_from_uri(C.to_gcharptr(str), &ptr, &gerror))) if unsafe.Pointer(gerror) != nil { err = ErrorFromNative(unsafe.Pointer(gerror)) } else { err = nil } hostname = "" if ptr != nil { hostname = C.GoString(C.to_charptr(ptr)) } return }
func LocaleToUtf8(opsysstring []byte) (ret string, bytes_read int, bytes_written int, err *Error) { var gerror *C.GError var cbytes_read, cbytes_written C.int str := C._g_locale_to_utf8(unsafe.Pointer(&opsysstring[0]), C.int(len(opsysstring)), &cbytes_read, &cbytes_written, &gerror) if unsafe.Pointer(str) != nil { defer C.free_string(C.to_charptr(str)) ret = C.GoString(C.to_charptr(str)) } else { ret = "" } bytes_read = int(cbytes_read) bytes_written = int(cbytes_written) if unsafe.Pointer(gerror) != nil { err = ErrorFromNative(unsafe.Pointer(gerror)) } else { err = nil } return }
// xmlNodeListGetString func (node *Node) ListGetString(inLine bool) string { ptr := node.Ptr docptr := C.xmlDocPtr((*C.xmlDoc)(ptr.doc)) cInLine := C.int(0) if inLine { cInLine = C.int(1) } str := C.to_charptr(C.xmlNodeListGetString(docptr, ptr, cInLine)) defer C.free_string(str) return C.GoString(str) }
func (v *GtkSourceLanguageManager) GetLanguageIds() []string { var ids []string cids := C.gtk_source_language_manager_get_language_ids(v.LanguageManager) for { ids = append(ids, C.GoString(C.to_charptr(*cids))) cids = C.next_gcharptr(cids) if *cids == nil { break } } return ids }
func (v *GtkSourceLanguage) GetMimeTypes() []string { var types []string ctypes := C.gtk_source_language_get_mime_types(v.SourceLanguage) for { types = append(types, C.GoString(C.to_charptr(*ctypes))) ctypes = C.next_gcharptr(ctypes) if *ctypes == nil { break } } return types }
func (v *GtkSourceLanguage) GetStyleIds() []string { var ids []string cids := C.gtk_source_language_get_globs(v.SourceLanguage) for { ids = append(ids, C.GoString(C.to_charptr(*cids))) cids = C.next_gcharptr(cids) if *cids == nil { break } } return ids }
func (v *GtkSourceLanguageManager) GetSearchPath() []string { var dirs []string cdirs := C.gtk_source_language_manager_get_search_path(v.LanguageManager) for { dirs = append(dirs, C.GoString(C.to_charptr(*cdirs))) cdirs = C.next_gcharptr(cdirs) if *cdirs == nil { break } } return dirs }
func (v *GtkSourceLanguage) GetGlobs() []string { var globs []string cglobs := C.gtk_source_language_get_globs(v.SourceLanguage) for { globs = append(globs, C.GoString(C.to_charptr(*cglobs))) cglobs = C.next_gcharptr(cglobs) if *cglobs == nil { break } } return globs }
// xmlTextReaderGetAttribute func (r *TextReader) GetAttribute(name string) *string { cname := C.CString(name) defer C.free_string(cname) cvalue := C.xmlTextReaderGetAttribute(r.Ptr, C.to_xmlcharptr(cname)) if cvalue != nil { value := C.GoString(C.to_charptr(cvalue)) return &value } return nil }
func LocaleFromUtf8(utf8string string) (ret []byte, bytes_read int, bytes_written int, err *Error) { var gerror *C.GError var cbytes_read, cbytes_written C.int src := C.CString(utf8string) defer C.free_string(src) str := C._g_locale_from_utf8(src, C.int(C.strlen(src)), &cbytes_read, &cbytes_written, &gerror) if unsafe.Pointer(str) != nil { defer C.free_string(C.to_charptr(str)) ret = ([]byte)(C.GoString(C.to_charptr(str))) } else { ret = ([]byte)("") } bytes_read = int(cbytes_read) bytes_written = int(cbytes_written) if unsafe.Pointer(gerror) != nil { err = ErrorFromNative(unsafe.Pointer(gerror)) } else { err = nil } return }
// convert array to slice func toSlice(ar **C.gchar) []string { result := make([]string, 0) for i := 0; ; i++ { str := C.GoString(C.to_charptr(*ar)) if str == "" { break } result = append(result, str) *ar = C.next_string(*ar) } return result }
func FilenameToUri(filename string, hostname string) (uri string, err error) { pfilename := C.CString(filename) defer C.free_string(pfilename) phostname := C.CString(hostname) defer C.free_string(phostname) var gerror *C.GError uri = C.GoString(C.to_charptr(C.g_filename_to_uri(C.to_gcharptr(pfilename), C.to_gcharptr(phostname), &gerror))) if unsafe.Pointer(gerror) != nil { err = ErrorFromNative(unsafe.Pointer(gerror)) } else { err = nil } return }
func (v *GValue) GetString() string { return C.GoString(C.to_charptr(C.g_value_get_string(&v.Value))) }
// xmlXPathCastToString func (obj *XPathObject) String() string { cstr := C.xmlXPathCastToString(obj.Ptr) defer C.free(unsafe.Pointer(cstr)) return C.GoString(C.to_charptr(cstr)) }
func GetUserRuntimeDir() string { return C.GoString(C.to_charptr(C.g_get_user_runtime_dir())) }
func GetUserConfigDir() string { return C.GoString(C.to_charptr(C.g_get_user_config_dir())) }
func GetUserDataDir() string { return C.GoString(C.to_charptr(C.g_get_user_data_dir())) }
// Application Section func GetApplicationName() string { return C.GoString(C.to_charptr(C.g_get_application_name())) }
func GetCurrentDir() string { return C.GoString(C.to_charptr(C.g_get_current_dir())) }
func GetTmpDir() string { return C.GoString(C.to_charptr(C.g_get_tmp_dir())) }
func GetHomeDir() string { return C.GoString(C.to_charptr(C.g_get_home_dir())) }
func GetPrgName() string { return C.GoString(C.to_charptr(C.g_get_prgname())) }
func (v *WebKitWebFrame) GetUri() string { return C.GoString(C.to_charptr(C.webkit_web_frame_get_uri(v.getWebFrame()))) }
func (v *Error) Message() string { if unsafe.Pointer(v.GError) == nil || unsafe.Pointer(v.GError.message) == nil { return "" } return C.GoString(C.to_charptr(v.GError.message)) }
// User Information Section func GetUserName() string { return C.GoString(C.to_charptr(C.g_get_user_name())) }
func (v *WebKitWebView) GetEncoding() string { return C.GoString(C.to_charptr(C.webkit_web_view_get_encoding(v.getWebView()))) }
func GetRealName() string { return C.GoString(C.to_charptr(C.g_get_real_name())) }
func (v *WebKitWebView) GetUri() string { return C.GoString(C.to_charptr(C.webkit_web_view_get_uri(v.getWebView()))) }
func GetUserCacheDir() string { return C.GoString(C.to_charptr(C.g_get_user_cache_dir())) }