예제 #1
0
// AddFile compiles rules from a file. Rules are added to the
// specified namespace.
func (c *Compiler) AddFile(file *os.File, namespace string) (err error) {
	fd := C.dup(C.int(file.Fd()))
	fh, err := C.fdopen(fd, C.CString("r"))
	if err != nil {
		return err
	}
	defer C.fclose(fh)
	var ns *C.char
	if namespace != "" {
		ns = C.CString(namespace)
		defer C.free(unsafe.Pointer(ns))
	}
	filename := C.CString(file.Name())
	defer C.free(unsafe.Pointer(filename))
	id := callbackData.Put(c)
	defer callbackData.Delete(id)
	C.yr_compiler_set_callback(c.cptr, C.YR_COMPILER_CALLBACK_FUNC(C.compilerCallback), unsafe.Pointer(id))
	numErrors := int(C.yr_compiler_add_file(c.cptr, fh, ns, filename))
	if numErrors > 0 {
		var buf [1024]C.char
		msg := C.GoString(C.yr_compiler_get_error_message(
			c.cptr, (*C.char)(unsafe.Pointer(&buf[0])), 1024))
		err = errors.New(msg)
	}
	return
}
예제 #2
0
파일: block.go 프로젝트: postfix/gsl-1
func BlockComplexFloatFprintf(stream *os.File, b *GslBlockComplexFloat, format string) int32 {
	_file_0 := C.fdopen(C.dup(C.int(stream.Fd())), (*C.char)(unsafe.Pointer(gogsl.APPEND_ONLY.Ptr())))
	_string_2 := C.CString(format)
	_result := int32(C.gsl_block_complex_float_fprintf(_file_0, (*C.gsl_block_complex_float)(unsafe.Pointer(b.Ptr())), _string_2))
	C.fclose(_file_0)
	C.free(unsafe.Pointer(_string_2))
	return _result
}
예제 #3
0
func VegasParamsSet(s *GslMonteVegasState, params *GslMonteVegasParams) {
	C.set_vegas_params((*C.gsl_monte_vegas_state)(unsafe.Pointer(s.Ptr())),
		C.double(params.Alpha), C.int(params.Iterations),
		C.int(params.Stage), C.int(params.Mode),
		C.int(params.Verbose),
		C.fdopen(C.dup(C.int(params.Ostream.Fd())),
			(*C.char)(unsafe.Pointer(gogsl.APPEND_ONLY.Ptr()))))
}
예제 #4
0
func Fprintf(stream *os.File, c *GslCombination, format string) int32 {
	_file_0 := C.fdopen(C.dup(C.int(stream.Fd())), (*C.char)(unsafe.Pointer(gogsl.APPEND_ONLY.Ptr())))
	_string_2 := C.CString(format)
	_result := int32(C.gsl_combination_fprintf(_file_0, (*C.gsl_combination)(unsafe.Pointer(c.Ptr())), _string_2))
	C.fclose(_file_0)
	C.free(unsafe.Pointer(_string_2))
	return _result
}
예제 #5
0
파일: histogram.go 프로젝트: postfix/gsl-1
func Histogram2dFprintf(stream *os.File, h *GslHistogram2d, rangeFormat string, binFormat string) int32 {
	_file_0 := C.fdopen(C.dup(C.int(stream.Fd())), (*C.char)(unsafe.Pointer(gogsl.APPEND_ONLY.Ptr())))
	_string_2 := C.CString(rangeFormat)
	_string_3 := C.CString(binFormat)
	_result := int32(C.gsl_histogram2d_fprintf(_file_0, (*C.gsl_histogram2d)(unsafe.Pointer(h.Ptr())), _string_2, _string_3))
	C.fclose(_file_0)
	C.free(unsafe.Pointer(_string_2))
	C.free(unsafe.Pointer(_string_3))
	return _result
}
예제 #6
0
파일: block.go 프로젝트: postfix/gsl-1
func BlockFloatFread(stream *os.File, b *GslBlockFloat) int32 {
	_file_0 := C.fdopen(C.dup(C.int(stream.Fd())), (*C.char)(unsafe.Pointer(gogsl.APPEND_ONLY.Ptr())))
	_result := int32(C.gsl_block_float_fread(_file_0, (*C.gsl_block_float)(unsafe.Pointer(b.Ptr()))))
	C.fclose(_file_0)
	return _result
}
예제 #7
0
파일: block.go 프로젝트: postfix/gsl-1
func BlockComplexFscanf(stream *os.File, b *GslBlockComplex) int32 {
	_file_0 := C.fdopen(C.dup(C.int(stream.Fd())), (*C.char)(unsafe.Pointer(gogsl.APPEND_ONLY.Ptr())))
	_result := int32(C.gsl_block_complex_fscanf(_file_0, (*C.gsl_block_complex)(unsafe.Pointer(b.Ptr()))))
	C.fclose(_file_0)
	return _result
}
예제 #8
0
파일: block.go 프로젝트: postfix/gsl-1
func BlockUcharFwrite(stream *os.File, b *GslBlockUchar) int32 {
	_file_0 := C.fdopen(C.dup(C.int(stream.Fd())), (*C.char)(unsafe.Pointer(gogsl.APPEND_ONLY.Ptr())))
	_result := int32(C.gsl_block_uchar_fwrite(_file_0, (*C.gsl_block_uchar)(unsafe.Pointer(b.Ptr()))))
	C.fclose(_file_0)
	return _result
}
예제 #9
0
파일: rng.go 프로젝트: postfix/gsl-1
func Fread(stream *os.File, r *GslRng) int32 {
	_file_0 := C.fdopen(C.dup(C.int(stream.Fd())), (*C.char)(unsafe.Pointer(gogsl.APPEND_ONLY.Ptr())))
	_result := int32(C.gsl_rng_fread(_file_0, (*C.gsl_rng)(unsafe.Pointer(r.Ptr()))))
	C.fclose(_file_0)
	return _result
}
예제 #10
0
func Fscanf(stream *os.File, c *GslCombination) int32 {
	_file_0 := C.fdopen(C.dup(C.int(stream.Fd())), (*C.char)(unsafe.Pointer(gogsl.APPEND_ONLY.Ptr())))
	_result := int32(C.gsl_combination_fscanf(_file_0, (*C.gsl_combination)(unsafe.Pointer(c.Ptr()))))
	C.fclose(_file_0)
	return _result
}
예제 #11
0
파일: histogram.go 프로젝트: postfix/gsl-1
func Histogram2dFscanf(stream *os.File, h *GslHistogram2d) int32 {
	_file_0 := C.fdopen(C.dup(C.int(stream.Fd())), (*C.char)(unsafe.Pointer(gogsl.APPEND_ONLY.Ptr())))
	_result := int32(C.gsl_histogram2d_fscanf(_file_0, (*C.gsl_histogram2d)(unsafe.Pointer(h.Ptr()))))
	C.fclose(_file_0)
	return _result
}
예제 #12
0
func Fread(stream *os.File, p *GslPermutation) int32 {
	_file_0 := C.fdopen(C.dup(C.int(stream.Fd())), (*C.char)(unsafe.Pointer(gogsl.APPEND_ONLY.Ptr())))
	_result := int32(C.gsl_permutation_fread(_file_0, (*C.gsl_permutation)(unsafe.Pointer(p.Ptr()))))
	C.fclose(_file_0)
	return _result
}
예제 #13
0
파일: multiset.go 프로젝트: postfix/gsl-1
func Fwrite(stream *os.File, c *GslMultiset) int32 {
	_file_0 := C.fdopen(C.dup(C.int(stream.Fd())), (*C.char)(unsafe.Pointer(gogsl.APPEND_ONLY.Ptr())))
	_result := int32(C.gsl_multiset_fwrite(_file_0, (*C.gsl_multiset)(unsafe.Pointer(c.Ptr()))))
	C.fclose(_file_0)
	return _result
}