Example #1
0
/*
 * 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)))
}
Example #2
0
File: glib.go Project: leif/go-gtk
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
}
Example #3
0
File: glib.go Project: leif/go-gtk
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
}
Example #4
0
// 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)
}
Example #5
0
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
}
Example #6
0
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
}
Example #7
0
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
}
Example #8
0
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
}
Example #9
0
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
}
Example #10
0
// 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
}
Example #11
0
File: glib.go Project: leif/go-gtk
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
}
Example #12
0
// 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
}
Example #13
0
File: glib.go Project: leif/go-gtk
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
}
Example #14
0
File: glib.go Project: leif/go-gtk
func (v *GValue) GetString() string {
	return C.GoString(C.to_charptr(C.g_value_get_string(&v.Value)))
}
Example #15
0
// xmlXPathCastToString
func (obj *XPathObject) String() string {
	cstr := C.xmlXPathCastToString(obj.Ptr)
	defer C.free(unsafe.Pointer(cstr))
	return C.GoString(C.to_charptr(cstr))
}
Example #16
0
func GetUserRuntimeDir() string {
	return C.GoString(C.to_charptr(C.g_get_user_runtime_dir()))
}
Example #17
0
func GetUserConfigDir() string {
	return C.GoString(C.to_charptr(C.g_get_user_config_dir()))
}
Example #18
0
func GetUserDataDir() string {
	return C.GoString(C.to_charptr(C.g_get_user_data_dir()))
}
Example #19
0
// Application Section
func GetApplicationName() string {
	return C.GoString(C.to_charptr(C.g_get_application_name()))
}
Example #20
0
func GetCurrentDir() string {
	return C.GoString(C.to_charptr(C.g_get_current_dir()))
}
Example #21
0
func GetTmpDir() string {
	return C.GoString(C.to_charptr(C.g_get_tmp_dir()))
}
Example #22
0
func GetHomeDir() string {
	return C.GoString(C.to_charptr(C.g_get_home_dir()))
}
Example #23
0
func GetPrgName() string {
	return C.GoString(C.to_charptr(C.g_get_prgname()))
}
Example #24
0
func (v *WebKitWebFrame) GetUri() string {
	return C.GoString(C.to_charptr(C.webkit_web_frame_get_uri(v.getWebFrame())))
}
Example #25
0
File: glib.go Project: leif/go-gtk
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))
}
Example #26
0
// User Information Section
func GetUserName() string {
	return C.GoString(C.to_charptr(C.g_get_user_name()))
}
Example #27
0
func (v *WebKitWebView) GetEncoding() string {
	return C.GoString(C.to_charptr(C.webkit_web_view_get_encoding(v.getWebView())))
}
Example #28
0
func GetRealName() string {
	return C.GoString(C.to_charptr(C.g_get_real_name()))
}
Example #29
0
func (v *WebKitWebView) GetUri() string {
	return C.GoString(C.to_charptr(C.webkit_web_view_get_uri(v.getWebView())))
}
Example #30
0
func GetUserCacheDir() string {
	return C.GoString(C.to_charptr(C.g_get_user_cache_dir()))
}