Golang C.uint32_t类(方法)实例源码

下面列出了Golang C.uint32_t 类(方法)源码代码实例,从而了解它的用法。

作者:xushiwe    项目:go-mtpf   
func (d *Device) FilesAndFolders(storageId uint32, parentId uint32) (files []*File, err error) {
	file := C.LIBMTP_Get_Files_And_Folders(d.me(), C.uint32_t(storageId), C.uint32_t(parentId))
	for f := (*File)(file); f != nil; f = (*File)(f.next) {
		files = append(files, f)
	}
	return files, d.ErrorStack()
}

作者:auroralaboratorie    项目:corona-ap   
// Set the volume of all channels of this sink to a factor of the maximum
// volume (0.0 <= v <= 1.0).  Factors greater than 1.0 will be accepted, but
// clipping or distortion may occur beyond that value.
//
func (self *Sink) SetVolume(factor float64) error {
	if self.Channels > 0 {
		operation := NewOperation(self.Client)
		newVolume := &C.pa_cvolume{}

		//  new volume is the (maximum number of normal volume steps * factor)
		newVolume = C.pa_cvolume_init(newVolume)
		newVolumeT := C.pa_volume_t(C.uint32_t(uint(float64(self.NumVolumeSteps) * factor)))

		//  prepare newVolume for its journey into PulseAudio
		C.pa_cvolume_set(newVolume, C.uint(self.Channels), newVolumeT)

		//  make the call
		operation.paOper = C.pa_context_set_sink_volume_by_index(C.pulse_get_context(), C.uint32_t(self.Index), newVolume, (C.pa_context_success_cb_t)(unsafe.Pointer(C.pulse_generic_success_callback)), unsafe.Pointer(operation))

		//  wait for the result, refresh, return any errors
		return operation.WaitSuccess(func(op *Operation) error {
			return self.Refresh()
		})
	} else {
		return fmt.Errorf("Cannot set volume on sink %d, no channels defined", self.Index)
	}

	return nil
}

作者:jeffalle    项目:mini   
func Write(m message.Message) ([]byte, error) {
	var b C.buf_t
	m2 := C.messageNew()

	switch m1 := m.(type) {
	case *message.Setup:
		m2.mtype = C.Setup
		s := (*C.struct_Setup)(unsafe.Pointer(ptr(m2.u[:])))
		s.ver_min = C.uint32_t(m1.Versions.Min)
		s.ver_max = C.uint32_t(m1.Versions.Max)
		for i, x := range m1.PeerNaClPublicKey {
			s.PeerNaClPublicKey[i] = C.uchar(x)
		}
		s.mtu = C.uint64_t(m1.Mtu)
		s.sharedTokens = C.uint64_t(m1.SharedTokens)
	default:
		panic("not impl yet")
	}

	err := C.messageAppend(m2, &b)
	if err != C.ERR_OK {
		return nil, GoError(err)
	}

	out := C.GoBytes(unsafe.Pointer(b.buf), C.int(b.len))
	C.bufDealloc(&b)
	return out, nil
}

作者:shitfSig    项目:gowebim   
func Wi_crop(im *Image, x int, y int, cols int, rows int) (int, error) {
	ret := int(C.wi_crop(im.im, C.uint32_t(x), C.uint32_t(y), C.uint32_t(cols), C.uint32_t(rows)))
	if ret == WI_FAILED {
		return ret, errors.New("C.wi_crop() failed!")
	}
	return ret, nil
}

作者:jezel    项目:git2g   
func diffOptionsToC(opts *DiffOptions) (copts *C.git_diff_options, notifyData *diffNotifyData) {
	cpathspec := C.git_strarray{}
	if opts != nil {
		notifyData = &diffNotifyData{
			Callback: opts.NotifyCallback,
		}
		if opts.Pathspec != nil {
			cpathspec.count = C.size_t(len(opts.Pathspec))
			cpathspec.strings = makeCStringsFromStrings(opts.Pathspec)
		}

		copts = &C.git_diff_options{
			version:           C.GIT_DIFF_OPTIONS_VERSION,
			flags:             C.uint32_t(opts.Flags),
			ignore_submodules: C.git_submodule_ignore_t(opts.IgnoreSubmodules),
			pathspec:          cpathspec,
			context_lines:     C.uint32_t(opts.ContextLines),
			interhunk_lines:   C.uint32_t(opts.InterhunkLines),
			id_abbrev:         C.uint16_t(opts.IdAbbrev),
			max_size:          C.git_off_t(opts.MaxSize),
			old_prefix:        C.CString(opts.OldPrefix),
			new_prefix:        C.CString(opts.NewPrefix),
		}

		if opts.NotifyCallback != nil {
			C._go_git_setup_diff_notify_callbacks(copts)
			copts.notify_payload = unsafe.Pointer(notifyData)
		}
	}
	return
}

作者:rectan    项目:goluc   
// This will need to be a bit more generic,
// but for testing this will work fine.
func (search *Search) GetSearcher() IndexReader {
	idxLocation := cb_newf(search.Location)
	search.lucySearcher = C.LucyIxSearcherNew(idxLocation)
	C.DECREF(idxLocation)
	return func(q string, field string, offset, limit uint) (uint, []string) {
		query := cb_new_from_utf8(q)
		getField := cb_newf(field)
		hits := C.LucyIxSearcherHits(search.lucySearcher, query, C.uint32_t(offset), C.uint32_t(limit), nil)
		totalNumHits := uint(C.LucyHitsTotal(hits))
		requestedNumHits := minUInt(limit, totalNumHits)
		results := make([]string, requestedNumHits)
		var hit *C.LucyHitDoc
		for i := uint(0); i < requestedNumHits; i++ {
			hit = C.LucyHitsNext(hits)
			if hit == nil {
				break
			}
			value_cb := C.LucyHitDocExtract(hit, getField, nil) // do i need to free this
			value := cb_ptr2char(value_cb)                      // do i need to free this
			results[i] = C.GoString(value)
			C.DECREF(hit)
		}
		C.DECREF(query)
		C.DECREF(getField)
		C.DECREF(hits)
		return totalNumHits, results
	}
}

作者:wi    项目:git2g   
func (v *Repository) BlameFile(path string, opts *BlameOptions) (*Blame, error) {
	var blamePtr *C.git_blame

	var copts *C.git_blame_options
	if opts != nil {
		copts = &C.git_blame_options{
			version:              C.GIT_BLAME_OPTIONS_VERSION,
			flags:                C.uint32_t(opts.Flags),
			min_match_characters: C.uint16_t(opts.MinMatchCharacters),
			min_line:             C.uint32_t(opts.MinLine),
			max_line:             C.uint32_t(opts.MaxLine),
		}
		if opts.NewestCommit != nil {
			copts.newest_commit = *opts.NewestCommit.toC()
		}
		if opts.OldestCommit != nil {
			copts.oldest_commit = *opts.OldestCommit.toC()
		}
	}

	cpath := C.CString(path)
	defer C.free(unsafe.Pointer(cpath))

	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	ecode := C.git_blame_file(&blamePtr, v.ptr, cpath, copts)
	if ecode < 0 {
		return nil, MakeGitError(ecode)
	}

	return newBlameFromC(blamePtr), nil
}

作者:mkb21    项目:gosndfil   
// Return true if the file header contains instrument information for the file. false otherwise.
func (f *File) SetInstrument(i *Instrument) bool {
	c := new(C.SF_INSTRUMENT)
	c.gain = C.int(i.Gain)
	c.basenote = C.char(i.Basenote)
	c.detune = C.char(i.Detune)
	c.velocity_lo = C.char(i.Velocity[0])
	c.velocity_hi = C.char(i.Velocity[1])
	c.key_lo = C.char(i.Key[0])
	c.key_hi = C.char(i.Key[1])
	c.loop_count = C.int(i.LoopCount)
	var index int
	for ; index < i.LoopCount; index++ {
		c.loops[index].mode = C.int(i.Loops[index].Mode)
		c.loops[index].start = C.uint32_t(i.Loops[index].Start)
		c.loops[index].end = C.uint32_t(i.Loops[index].End)
		c.loops[index].count = C.uint32_t(i.Loops[index].Count)
	}
	for ; index < 16; index++ {
		c.loops[index].mode = C.int(None)
		// why is this necessary? libsndfile doesn't check loopcount for AIFF
	}

	r := C.sf_command(f.s, C.SFC_SET_INSTRUMENT, unsafe.Pointer(c), C.int(unsafe.Sizeof(*c)))
	return (r == C.SF_TRUE)
}

作者:auroralaboratorie    项目:puls   
// Set the volume of all channels of this source to a factor of the maximum
// volume (0.0 <= v <= 1.0).  Factors greater than 1.0 will be accepted, but
// clipping or distortion may occur beyond that value.
//
func (self *Source) SetVolume(factor float64) error {
	if self.Channels > 0 {
		operation := NewOperation(self.Client)
		defer operation.Destroy()
		newVolume := &C.pa_cvolume{}

		//  new volume is the (maximum number of normal volume steps * factor)
		newVolume = C.pa_cvolume_init(newVolume)
		newVolumeT := C.pa_volume_t(C.uint32_t(uint(float64(self.NumVolumeSteps) * factor)))

		//  prepare newVolume for its journey into PulseAudio
		C.pa_cvolume_set(newVolume, C.uint(self.Channels), newVolumeT)

		//  make the call
		operation.paOper = C.pa_context_set_source_volume_by_index(self.Client.context, C.uint32_t(self.Index), newVolume, (C.pa_context_success_cb_t)(C.pulse_generic_success_callback), operation.ToUserdata())

		//  wait for the result, refresh, return any errors
		if err := operation.Wait(); err == nil {
			return self.Refresh()
		} else {
			return err
		}
	} else {
		return fmt.Errorf("Cannot set volume on source %d, no channels defined", self.Index)
	}

	return nil
}

作者:umsat    项目:go-aqbankin   
func newUser(ptr *C.AB_USER) User {
	user := User{}
	user.ID = int(C.AB_User_GetUniqueId(ptr))

	user.UserID = C.GoString(C.AB_User_GetUserId(ptr))
	user.CustomerID = C.GoString(C.AB_User_GetCustomerId(ptr))
	user.Name = C.GoString(C.AB_User_GetUserName(ptr))
	user.BankCode = C.GoString(C.AB_User_GetBankCode(ptr))

	url := C.AH_User_GetServerUrl(ptr)
	if url != nil {
		tbuf := C.GWEN_Buffer_new(
			nil,
			C.uint32_t(256),
			C.uint32_t(0),
			C.int(1),
		)
		C.GWEN_Url_toString(url, tbuf)
		user.ServerURI = C.GoString(C.GWEN_Buffer_GetStart(tbuf))
		C.GWEN_Buffer_free(tbuf)
	}

	user.HbciVersion = int(C.AH_User_GetHbciVersion(ptr))

	user.ptr = ptr
	return user
}

作者:runner-me    项目:snmpclien   
func (usm *USM) Read(user *C.snmp_user_t) SnmpError {
	usm.auth_proto = AuthType(user.auth_proto)
	usm.priv_proto = PrivType(user.priv_proto)
	usm.name = readGoString(&user.sec_name[0], SNMP_ADM_STR32_LEN)
	usm.localization_auth_key = readGoBytes(&user.auth_key[0], C.uint32_t(user.auth_len))
	usm.localization_priv_key = readGoBytes(&user.priv_key[0], C.uint32_t(user.priv_len))
	return nil
}

作者:mikkelosca    项目:go-wl   
func (g *Geometry) c() *C.struct_wlc_geometry {
	return C.init_geometry(
		C.int32_t(g.Origin.X),
		C.int32_t(g.Origin.Y),
		C.uint32_t(g.Size.W),
		C.uint32_t(g.Size.H),
	)
}

作者:ololoshka287    项目:kalibratorg   
func (this ModbusRTUConnection) SetTimeout(timeout time.Duration) error {
	var sec C.uint32_t = C.uint32_t(timeout / time.Second)
	var usec C.uint32_t = C.uint32_t((timeout - time.Duration(sec)) / time.Microsecond)
	if C.modbus_set_response_timeout(this.ctx, sec, usec) == -1 {
		return errors.New("Invalid timeout value")
	}
	return nil
}

作者:huachen021    项目:libm   
/*
New to create a memcached client:

servers: is a list of memcached server addresses. Each address can be
in format of hostname[:port] [alias]. port and alias are optional.
If port is not given, default port 11211 will be used. alias will be
used to compute server hash if given, otherwise server hash will be
computed based on host and port (i.e.: If port is not given or it is
equal to 11211, host will be used to compute server hash.
If port is not equal to 11211, host:port will be used).

noreply: whether to enable memcached's noreply behaviour.
default: False

prefix: The key prefix. default: ''

hashFunc: hashing function for keys. possible values:
HashMD5, HashFNV1_32, HashFNV1a32, HashCRC32
NOTE: fnv1_32, fnv1a_32, crc_32 implementations
in libmc are per each spec, but they're not compatible
with corresponding implementions in libmemcached.
NOTE: The hashing algorithm for host mapping on continuum is always md5.

failover: Whether to failover to next server when current server is
not available. default: False

disableLock: Whether to disable a lock of type sync.Mutex which will be
use in every retrieval/storage command. default False.
*/
func New(servers []string, noreply bool, prefix string, hashFunc int, failover bool, disableLock bool) (client *Client) {
	client = new(Client)
	client._imp = C.client_create()
	runtime.SetFinalizer(client, finalizer)

	n := len(servers)
	cHosts := make([]*C.char, n)
	cPorts := make([]C.uint32_t, n)
	cAliases := make([]*C.char, n)

	for i, srv := range servers {
		addrAndAlias := strings.Split(srv, " ")

		addr := addrAndAlias[0]
		if len(addrAndAlias) == 2 {
			cAlias := C.CString(addrAndAlias[1])
			defer C.free(unsafe.Pointer(cAlias))
			cAliases[i] = cAlias
		}

		hostAndPort := strings.Split(addr, ":")
		host := hostAndPort[0]
		cHost := C.CString(host)
		defer C.free(unsafe.Pointer(cHost))
		cHosts[i] = cHost

		if len(hostAndPort) == 2 {
			port, err := strconv.Atoi(hostAndPort[1])
			if err != nil {
				return nil
			}
			cPorts[i] = C.uint32_t(port)
		} else {
			cPorts[i] = C.uint32_t(DefaultPort)
		}
	}

	failoverInt := 0
	if failover {
		failoverInt = 1
	}

	C.client_init(
		client._imp,
		(**C.char)(unsafe.Pointer(&cHosts[0])),
		(*C.uint32_t)(unsafe.Pointer(&cPorts[0])),
		C.size_t(n),
		(**C.char)(unsafe.Pointer(&cAliases[0])),
		C.int(failoverInt),
	)

	client.configHashFunction(int(hashFunctionMapping[hashFunc]))
	client.servers = servers
	client.prefix = prefix
	client.noreply = noreply
	client.disableLock = disableLock
	return
}

作者:gmac    项目:go-bgf   
func DebugTextPrintf(x, y int, attr uint8, format string, args ...interface{}) {
	text := []byte(fmt.Sprintf(format+"\x00", args...))
	C.bgfx_dbg_text_print(
		C.uint32_t(x),
		C.uint32_t(y),
		C.uint8_t(attr),
		(*C.char)(unsafe.Pointer(&text[0])),
	)
}

作者:mikkelosca    项目:go-wl   
// KeyboardGetUtf32ForKey is an utility function to convert raw keycode to
// Unicdoe/UTF-32 codepoint. Passed modifiers may transform the key.
func KeyboardGetUtf32ForKey(key uint32, mods *Modifiers) uint32 {
	if mods != nil {
		cmods := mods.c()
		defer C.free(unsafe.Pointer(cmods))
		return uint32(C.wlc_keyboard_get_utf32_for_key(C.uint32_t(key), cmods))
	}

	return uint32(C.wlc_keyboard_get_utf32_for_key(C.uint32_t(key), nil))
}

作者:rectan    项目:luc   
func (s *SimpleIMP) Search(query string, offset, numWanted int) (totalHits int, err error) {
	err = clownfish.TrapErr(func() {
		self := (*C.lucy_Simple)(clownfish.Unwrap(s, "s"))
		qStringC := (*C.cfish_String)(clownfish.GoToClownfish(query, unsafe.Pointer(C.CFISH_STRING), false))
		defer C.cfish_decref(unsafe.Pointer(qStringC))
		totalHits = int(C.LUCY_Simple_Search(self, qStringC, C.uint32_t(offset), C.uint32_t(numWanted)))
	})
	return totalHits, err
}

作者:cyoun    项目:gortlsd   
// ReadAsync reads samples asynchronously. Note, this function
// will block until canceled using CancelAsync. ReadAsyncCbT is
// a package global variable and therefore unsafe for use with
// multiple dongles.
//
// Note, please use ReadAsync2 as this method will be deprecated
// in the future.
//
// Optional bufNum buffer count, bufNum * bufLen = overall buffer size,
// set to 0 for default buffer count (32).
// Optional bufLen buffer length, must be multiple of 512, set to 0 for
// default buffer length (16 * 32 * 512).
func (dev *Context) ReadAsync(f ReadAsyncCbT, _ *UserCtx, bufNum, bufLen int) error {
	clientCb = f
	i := int(C.rtlsdr_read_async((*C.rtlsdr_dev_t)(dev),
		(C.rtlsdr_read_async_cb_t)(C.get_go_cb()),
		nil, // userctx *UserCtx
		C.uint32_t(bufNum),
		C.uint32_t(bufLen)))
	return libError(i)
}

作者:457    项目:unicor   
func (u *uc) RegWriteMmr(reg int, value *X86Mmr) error {
	var val C.uc_x86_mmr
	val.selector = C.uint16_t(value.Selector)
	val.base = C.uint64_t(value.Base)
	val.limit = C.uint32_t(value.Limit)
	val.flags = C.uint32_t(value.Flags)
	ucerr := C.uc_reg_write(u.handle, C.int(reg), unsafe.Pointer(&val))
	return errReturn(ucerr)
}

作者:nlefle    项目:gortlsd   
// Read samples from the device asynchronously. This function will block until
// it is being canceled using rtlsdr_cancel_async()
//
// Optional buf_num buffer count, buf_num * buf_len = overall buffer size,
// set to 0 for default buffer count (32).
// Optional buf_len buffer length, must be multiple of 512, set to 0 for
// default buffer length (16 * 32 * 512).
//
// int rtlsdr_read_async(rtlsdr_dev_t *dev, rtlsdr_read_async_cb_t cb, void *ctx, uint32_t buf_num, uint32_t buf_len);
// rtlsdr_read_async returns 0 on success
func (c *Context) ReadAsync(f ReadAsyncCb_T, userctx *UserCtx, buf_num,
	buf_len int) (err int) {
	clientCb = f
	err = int(C.rtlsdr_read_async((*C.rtlsdr_dev_t)(c.dev),
		(C.rtlsdr_read_async_cb_t)(C.get_go_cb()),
		unsafe.Pointer(userctx),
		C.uint32_t(buf_num),
		C.uint32_t(buf_len)))
	return
}


问题


面经


文章

微信
公众号

扫码关注公众号