Documentation ¶
Overview ¶
Package noarch contains low-level functions that apply to multiple platforms.
Index ¶
- Constants
- Variables
- func Abs(n int32) int32
- func Asctime(tm *Tm) *byte
- func Atof(str *byte) float64
- func Atoi(str *byte) int32
- func Atol(str *byte) int32
- func Atoll(str *byte) int64
- func BoolToInt(x bool) int32
- func CPointerToGoPointer(a interface{}) interface{}
- func CStringIsNull(s *byte) bool
- func CStringToString(s *byte) string
- func CastInterfaceToPointer(in interface{}) unsafe.Pointer
- func Clearerr(stream *File)
- func Closelog()
- func Ctime(tloc *TimeT) *byte
- func Errno() *int32
- func Exit(exitCode int32)
- func Fclose(f *File) int32
- func Feof(stream *File) int32
- func Ferror(stream *File) int32
- func Fflush(stream *File) int32
- func Fgetc(stream *File) (ret int32)
- func Fgetpos(f *File, pos *int32) int32
- func Fgets(str *byte, num int32, stream *File) *byte
- func Fprintf(f *File, format *byte, args ...interface{}) int32
- func Fputc(c int32, f *File) int32
- func Fputs(str *byte, stream *File) int32
- func Fread(ptr unsafe.Pointer, size1, size2 int32, f *File) int32
- func Free(anything unsafe.Pointer)
- func Fscanf(f *File, format *byte, args ...interface{}) int32
- func Fseek(f *File, offset int32, origin int32) int32
- func Fsetpos(stream *File, pos *int32) int32
- func Ftell(f *File) int32
- func Fwrite(str *byte, size1, size2 int32, stream *File) int32
- func Getchar() int32
- func Getenv(name *byte) *byte
- func GoPointerToCPointer(destination interface{}, value interface{})
- func IsNaN(x float64) int32
- func Labs(n int32) int32
- func Ldexp(frac float64, exp int32) float64
- func Llabs(n int64) int64
- func Malloc(numBytes int32) unsafe.Pointer
- func Memcmp(src1, src2 unsafe.Pointer, n int32) int32
- func Memcpy(dst unsafe.Pointer, src unsafe.Pointer, size int32) unsafe.Pointer
- func Memset(dst unsafe.Pointer, val int32, size int32) unsafe.Pointer
- func NotInt(x int) int
- func NotInt32(x int32) int32
- func NotInt8(x int8) int8
- func NotUint16(x uint16) uint16
- func Openlog(ident *byte, logopt int32, facility int32)
- func Perror(str *byte)
- func Printf(format *byte, args ...interface{}) int32
- func Putchar(character int32)
- func Puts(str *byte) int32
- func Rand() int32
- func Remove(filePath *byte) int32
- func Rename(oldName, newName *byte) int32
- func Rewind(stream *File)
- func Scanf(format *byte, args ...interface{}) int32
- func Setlogmask(mask int32) int32
- func Signbitd(x float64) int32
- func Signbitf(x float32) int32
- func Signbitl(x float64) int32
- func Snprintf(buffer *byte, n int32, format *byte, args ...interface{}) int32
- func Sprintf(buffer, format *byte, args ...interface{}) int32
- func Strcasestr(str1, str2 *byte) *byte
- func Strcat(dest, src *byte) *byte
- func Strchr(str *byte, ch int32) *byte
- func Strcmp(str1, str2 *byte) int32
- func Strcpy(dest, src *byte) *byte
- func Strerror(errno int32) *byte
- func StringToCString(s string) *byte
- func Strlen(a *byte) int32
- func Strncmp(str1, str2 *byte, n int32) int32
- func Strncpy(dest, src *byte, len int32) *byte
- func Strstr(str1, str2 *byte) *byte
- func Strtod(str *byte, endptr **byte) float64
- func Strtof(str *byte, endptr **byte) float32
- func Strtol(str *byte, endptr **byte, radix int32) int32
- func Strtold(str *byte, endptr **byte) float64
- func Strtoll(str *byte, endptr **byte, radix int32) int64
- func Strtoul(str *byte, endptr **byte, radix int32) uint32
- func Strtoull(str *byte, endptr **byte, radix int32) uint64
- func Syslog(priority int32, format *byte, args ...interface{})
- func Ternary(a bool, b, c func() interface{}) interface{}
- func TimeTToFloat64(t TimeT) float64
- func Tmpnam(str *byte) *byte
- func UnsafeSliceToSlice(a interface{}, fromSize int32, toSize int32) *reflect.SliceHeader
- func UnsafeSliceToSliceUnlimited(a interface{}) *reflect.SliceHeader
- func Vsnprintf(buffer *byte, n int32, format *byte, args VaList) int32
- func Vsprintf(buffer, format *byte, args VaList) int32
- func Vsyslog(priority int32, format *byte, args VaList)
- type DivT
- type File
- type InterfaceWrapper
- type LdivT
- type LldivT
- type Safe
- type TimeT
- type Tm
- type VaList
Constants ¶
const ( EPERM = 1 // Operation not permitted ENOENT = 2 // No such file or directory ESRCH = 3 // No such process EINTR = 4 // Interrupted system call EIO = 5 // I/O error ENXIO = 6 // No such device or address E2BIG = 7 // Argument list too long ENOEXEC = 8 // Exec format error EBADF = 9 // Bad file number ECHILD = 10 // No child processes EAGAIN = 11 // Try again ENOMEM = 12 // Out of memory EACCES = 13 // Permission denied EFAULT = 14 // Bad address ENOTBLK = 15 // Block device required EBUSY = 16 // Device or resource busy EEXIST = 17 // File exists EXDEV = 18 // Cross-device link ENODEV = 19 // No such device ENOTDIR = 20 // Not a directory EISDIR = 21 // Is a directory EINVAL = 22 // Invalid argument ENFILE = 23 // File table overflow EMFILE = 24 // Too many open files ENOTTY = 25 // Not a typewriter ETXTBSY = 26 // Text file busy EFBIG = 27 // File too large ENOSPC = 28 // No space left on device ESPIPE = 29 // Illegal seek EROFS = 30 // Read-only file system EMLINK = 31 // Too many links EPIPE = 32 // Broken pipe EDOM = 33 // Math argument out of domain of func ERANGE = 34 // Math result not representable EDEADLK = 35 // Resource deadlock would occur ENAMETOOLONG = 36 // File name too long ENOLCK = 37 // No record locks available ENOSYS = 38 // Function not implemented ENOTEMPTY = 39 // Directory not empty ELOOP = 40 // Too many symbolic links encountered EWOULDBLOCK = EAGAIN // Operation would block ENOMSG = 42 // No message of desired type EIDRM = 43 // Identifier removed ECHRNG = 44 // Channel number out of range EL2NSYNC = 45 // Level 2 not synchronized EL3HLT = 46 // Level 3 halted EL3RST = 47 // Level 3 reset ELNRNG = 48 // Link number out of range EUNATCH = 49 // Protocol driver not attached ENOCSI = 50 // No CSI structure available EL2HLT = 51 // Level 2 halted EBADE = 52 // Invalid exchange EBADR = 53 // Invalid request descriptor EXFULL = 54 // Exchange full ENOANO = 55 // No anode EBADRQC = 56 // Invalid request code EBADSLT = 57 // Invalid slot EDEADLOCK = EDEADLK EBFONT = 59 // Bad font file format ENOSTR = 60 // Device not a stream ENODATA = 61 // No data available ETIME = 62 // Timer expired ENOSR = 63 // Out of streams resources ENONET = 64 // Machine is not on the network ENOPKG = 65 // Package not installed EREMOTE = 66 // Object is remote ENOLINK = 67 // Link has been severed EADV = 68 // Advertise error ESRMNT = 69 // Srmount error ECOMM = 70 // Communication error on send EPROTO = 71 // Protocol error EMULTIHOP = 72 // Multihop attempted EDOTDOT = 73 // RFS specific error EBADMSG = 74 // Not a data message EOVERFLOW = 75 // Value too large for defined data type ENOTUNIQ = 76 // Name not unique on network EBADFD = 77 // File descriptor in bad state EREMCHG = 78 // Remote address changed ELIBACC = 79 // Can not access a needed shared library ELIBBAD = 80 // Accessing a corrupted shared library ELIBSCN = 81 // .lib section in a.out corrupted ELIBMAX = 82 // Attempting to link in too many shared libraries ELIBEXEC = 83 // Cannot exec a shared library directly EILSEQ = 84 // Illegal byte sequence ERESTART = 85 // Interrupted system call should be restarted ESTRPIPE = 86 // Streams pipe error EUSERS = 87 // Too many users ENOTSOCK = 88 // Socket operation on non-socket EDESTADDRREQ = 89 // Destination address required EMSGSIZE = 90 // Message too long EPROTOTYPE = 91 // Protocol wrong type for socket ENOPROTOOPT = 92 // Protocol not available EPROTONOSUPPORT = 93 // Protocol not supported ESOCKTNOSUPPORT = 94 // Socket type not supported EOPNOTSUPP = 95 // Operation not supported on transport endpoint EPFNOSUPPORT = 96 // Protocol family not supported EAFNOSUPPORT = 97 // Address family not supported by protocol EADDRINUSE = 98 // Address already in use EADDRNOTAVAIL = 99 // Cannot assign requested address ENETDOWN = 100 // Network is down ENETUNREACH = 101 // Network is unreachable ENETRESET = 102 // Network dropped connection because of reset ECONNABORTED = 103 // Software caused connection abort ECONNRESET = 104 // Connection reset by peer ENOBUFS = 105 // No buffer space available EISCONN = 106 // Transport endpoint is already connected ENOTCONN = 107 // Transport endpoint is not connected ESHUTDOWN = 108 // Cannot send after transport endpoint shutdown ETOOMANYREFS = 109 // Too many references: cannot splice ETIMEDOUT = 110 // Connection timed out ECONNREFUSED = 111 // Connection refused EHOSTDOWN = 112 // Host is down EHOSTUNREACH = 113 // No route to host EALREADY = 114 // Operation already in progress EINPROGRESS = 115 // Operation now in progress ESTALE = 116 // Stale NFS file handle EUCLEAN = 117 // Structure needs cleaning ENOTNAM = 118 // Not a XENIX named type file ENAVAIL = 119 // No XENIX semaphores available EISNAM = 120 // Is a named type file EREMOTEIO = 121 // Remote I/O error EDQUOT = 122 // Quota exceeded ENOMEDIUM = 123 // No medium found EMEDIUMTYPE = 124 // Wrong medium type ECANCELED = 125 // Operation Canceled ENOKEY = 126 // Required key not available EKEYEXPIRED = 127 // Key has expired EKEYREVOKED = 128 // Key has been revoked EKEYREJECTED = 129 // Key was rejected by service // for robust mutexes EOWNERDEAD = 130 // Owner died ENOTRECOVERABLE = 131 // State not recoverable )
const EOF = -int32(1)
Variables ¶
var ( Stdin = NewFile(os.Stdin) Stdout = NewFile(os.Stdout) Stderr = NewFile(os.Stderr) )
Programs generated by c2go will reference noarch.Stdin instead of os.Stdin directly so that under test these can be replaced. This is required because "go test" does not redirect the stdin to the executable it is testing.
Functions ¶
func Abs ¶ added in v0.16.0
Abs returns the absolute value of parameter n.
In C++, this function is also overloaded in header <cmath> for floating-point types (see cmath abs), in header <complex> for complex numbers (see complex abs), and in header <valarray> for valarrays (see valarray abs).
func Atof ¶ added in v0.16.0
Atof parses the C string str, interpreting its content as a floating point number and returns its value as a double.
The function first discards as many whitespace characters (as in isspace) as necessary until the first non-whitespace character is found. Then, starting from this character, takes as many characters as possible that are valid following a syntax resembling that of floating point literals (see below), and interprets them as a numerical value. The rest of the string after the last valid character is ignored and has no effect on the behavior of this function.
C90 (C++98): A valid floating point number for atof using the "C" locale is formed by an optional sign character (+ or -), followed by a sequence of digits, optionally containing a decimal-point character (.), optionally followed by an exponent part (an e or E character followed by an optional sign and a sequence of digits).
C99/C11 (C++11): A valid floating point number for atof using the "C" locale is formed by an optional sign character (+ or -), followed by one of:
- A sequence of digits, optionally containing a decimal-point character (.), optionally followed by an exponent part (an e or E character followed by an optional sign and a sequence of digits).
- A 0x or 0X prefix, then a sequence of hexadecimal digits (as in isxdigit) optionally containing a period which separates the whole and fractional number parts. Optionally followed by a power of 2 exponent (a p or P character followed by an optional sign and a sequence of hexadecimal digits).
- INF or INFINITY (ignoring case).
- NAN or NANsequence (ignoring case), where sequence is a sequence of characters, where each character is either an alphanumeric character (as in isalnum) or the underscore character (_).
If the first sequence of non-whitespace characters in str does not form a valid floating-point number as just defined, or if no such sequence exists because either str is empty or contains only whitespace characters, no conversion is performed and the function returns 0.0.
func Atoi ¶ added in v0.9.0
Atoi parses the C-string str interpreting its content as an integral number, which is returned as a value of type int.
The function first discards as many whitespace characters (as in isspace) as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many base-10 digits as possible, and interprets them as a numerical value.
The string can contain additional characters after those that form the integral number, which are ignored and have no effect on the behavior of this function.
If the first sequence of non-whitespace characters in str is not a valid integral number, or if no such sequence exists because either str is empty or it contains only whitespace characters, no conversion is performed and zero is returned.
func Atol ¶ added in v0.16.0
Atol parses the C-string str interpreting its content as an integral number, which is returned as a value of C type "long int".
The function first discards as many whitespace characters (as in isspace) as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many base-10 digits as possible, and interprets them as a numerical value.
The string can contain additional characters after those that form the integral number, which are ignored and have no effect on the behavior of this function.
If the first sequence of non-whitespace characters in str is not a valid integral number, or if no such sequence exists because either str is empty or it contains only whitespace characters, no conversion is performed and zero is returned.
func Atoll ¶ added in v0.16.0
Atoll parses the C-string str interpreting its content as an integral number, which is returned as a value of C type long long int.
This function operates like atol to interpret the string, but produces numbers of type long long int (see atol for details on the interpretation process).
func BoolToInt ¶
BoolToInt converts boolean value to an int, which is a common operation in C. 0 and 1 represent false and true respectively.
func CPointerToGoPointer ¶ added in v0.14.0
func CPointerToGoPointer(a interface{}) interface{}
CPointerToGoPointer converts a C-style pointer into a Go-style pointer.
C pointers are represented as slices that have one element pointing to where the original C pointer would be referencing. This isn't useful if the pointed value needs to be passed to another Go function in these libraries.
See also GoPointerToCPointer.
func CStringIsNull ¶ added in v0.13.0
CStringIsNull will test if a C string is NULL. This is equivalent to:
s == NULL
func CStringToString ¶ added in v0.14.0
CStringToString returns a string that contains all the bytes in the provided C string up until the first NULL character.
func CastInterfaceToPointer ¶ added in v0.25.0
CastInterfaceToPointer will take an interface and store it in a map by its reflect.Value the unsafe.Pointer to its containing InterfaceWrapper is returned. Since no element is ever removed from the map this should only be used for a limited amount of elements, like function pointers.
func Clearerr ¶ added in v0.24.2
func Clearerr(stream *File)
Clearerr handles clearerr().
Resets both the error and the eof indicators of the stream.
When a i/o function fails either because of an error or because the end of the file has been reached, one of these internal indicators may be set for the stream. The state of these indicators is cleared by a call to this function, or by a call to any of: rewind, fseek, fsetpos and freopen.
func Fclose ¶ added in v0.9.0
Fclose handles fclose().
Closes the file associated with the stream and disassociates it.
All internal buffers associated with the stream are disassociated from it and flushed: the content of any unwritten output buffer is written and the content of any unread input buffer is discarded.
Even if the call fails, the stream passed as parameter will no longer be associated with the file nor its buffers.
func Feof ¶ added in v0.11.0
Feof handles feof().
Checks whether the end-of-File indicator associated with stream is set, returning a value different from zero if it is.
This indicator is generally set by a previous operation on the stream that attempted to read at or past the end-of-file.
Notice that stream's internal position indicator may point to the end-of-file for the next operation, but still, the end-of-file indicator may not be set until an operation attempts to read at that point.
This indicator is cleared by a call to clearerr, rewind, fseek, fsetpos or freopen. Although if the position indicator is not repositioned by such a call, the next i/o operation is likely to set the indicator again.
func Ferror ¶ added in v0.24.2
Ferror handles ferror().
Checks if the error indicator associated with stream is set, returning a value different from zero if it is.
This indicator is generally set by a previous operation on the stream that failed, and is cleared by a call to clearerr, rewind or freopen.
func Fflush ¶ added in v0.11.0
Fflush handles fflush().
If the given stream was open for writing (or if it was open for updating and the last i/o operation was an output operation) any unwritten data in its output buffer is written to the file.
If stream is a null pointer, all such streams should be flushed, but this is currently not supported.
The stream remains open after this call.
When a file is closed, either because of a call to fclose or because the program terminates, all the buffers associated with it are automatically flushed.
func Fgetc ¶ added in v0.11.0
Fgetc handles fgetc().
Returns the character currently pointed by the internal file position indicator of the specified stream. The internal file position indicator is then advanced to the next character.
If the stream is at the end-of-file when called, the function returns EOF and sets the end-of-file indicator for the stream (feof).
If a read error occurs, the function returns EOF and sets the error indicator for the stream (ferror).
fgetc and getc are equivalent, except that getc may be implemented as a macro in some libraries.
func Fgetpos ¶ added in v0.11.0
Fgetpos handles fgetpos().
Retrieves the current position in the stream.
The function fills the fpos_t object pointed by pos with the information needed from the stream's position indicator to restore the stream to its current position (and multibyte state, if wide-oriented) with a call to fsetpos.
The ftell function can be used to retrieve the current position in the stream as an integer value.
func Fgets ¶ added in v0.11.0
Fgets handles fgets().
Reads characters from stream and stores them as a C string into str until (num-1) characters have been read or either a newline or the end-of-file is reached, whichever happens first.
A newline character makes fgets stop reading, but it is considered a valid character by the function and included in the string copied to str.
A terminating null character is automatically appended after the characters copied to str.
Notice that fgets is quite different from gets: not only fgets accepts a stream argument, but also allows to specify the maximum size of str and includes in the string any ending newline character.
func Fprintf ¶ added in v0.11.0
Fprintf handles fprintf().
Writes the C string pointed by format to the stream. If format includes format specifiers (subsequences beginning with %), the additional arguments following format are formatted and inserted in the resulting string replacing their respective specifiers.
After the format parameter, the function expects at least as many additional arguments as specified by format.
func Fputc ¶ added in v0.11.0
Fputc handles fputc().
Writes a character to the stream and advances the position indicator.
The character is written at the position indicated by the internal position indicator of the stream, which is then automatically advanced by one.
func Fputs ¶ added in v0.11.0
Fputs handles fputs().
Writes the C string pointed by str to the stream.
The function begins copying from the address specified (str) until it reaches the terminating null character ('\0'). This terminating null-character is not copied to the stream.
Notice that fputs not only differs from puts in that the destination stream can be specified, but also fputs does not write additional characters, while puts appends a newline character at the end automatically.
func Fread ¶ added in v0.11.0
Fread handles fread().
Reads an array of count elements, each one with a size of size bytes, from the stream and stores them in the block of memory specified by ptr.
The position indicator of the stream is advanced by the total amount of bytes read.
The total amount of bytes read if successful is (size*count).
func Free ¶ added in v0.12.0
Free removes the reference to this memory address, so that the Go GC can free it.
func Fscanf ¶ added in v0.11.0
Fscanf handles fscanf().
Reads data from the stream and stores them according to the parameter format into the locations pointed by the additional arguments.
The additional arguments should point to already allocated objects of the type specified by their corresponding format specifier within the format string.
func Fseek ¶ added in v0.11.0
Fseek handles fseek().
Sets the position indicator associated with the stream to a new position.
For streams open in binary mode, the new position is defined by adding offset to a reference position specified by origin.
For streams open in text mode, offset shall either be zero or a value returned by a previous call to ftell, and origin shall necessarily be SEEK_SET.
If the function is called with other values for these arguments, support depends on the particular system and library implementation (non-portable).
The end-of-file internal indicator of the stream is cleared after a successful call to this function, and all effects from previous calls to ungetc on this stream are dropped.
On streams open for update (read+write), a call to fseek allows to switch between reading and writing.
func Fsetpos ¶ added in v0.11.0
Fsetpos handles fsetpos().
Restores the current position in the stream to pos.
The internal file position indicator associated with stream is set to the position represented by pos, which is a pointer to an fpos_t object whose value shall have been previously obtained by a call to fgetpos.
The end-of-file internal indicator of the stream is cleared after a successful call to this function, and all effects from previous calls to ungetc on this stream are dropped.
On streams open for update (read+write), a call to fsetpos allows to switch between reading and writing.
A similar function, fseek, can be used to set arbitrary positions on streams open in binary mode.
func Ftell ¶ added in v0.11.0
Ftell handles ftell().
Returns the current value of the position indicator of the stream.
For binary streams, this is the number of bytes from the beginning of the file.
For text streams, the numerical value may not be meaningful but can still be used to restore the position to the same position later using fseek (if there are characters put back using ungetc still pending of being read, the behavior is undefined).
func Fwrite ¶ added in v0.11.0
Fwrite handles fwrite().
Writes an array of count elements, each one with a size of size bytes, from the block of memory pointed by ptr to the current position in the stream.
The position indicator of the stream is advanced by the total number of bytes written.
Internally, the function interprets the block pointed by ptr as if it was an array of (size*count) elements of type unsigned char, and writes them sequentially to stream as if fputc was called for each byte.
func Getchar ¶ added in v0.11.0
func Getchar() int32
Getchar handles getchar().
Returns the next character from the standard input (stdin).
It is equivalent to calling getc with stdin as argument.
func Getenv ¶ added in v0.16.0
Getenv retrieves a C-string containing the value of the environment variable whose name is specified as argument. If the requested variable is not part of the environment list, the function returns a null pointer.
The pointer returned points to an internal memory block, whose content or validity may be altered by further calls to getenv (but not by other library functions).
The string pointed by the pointer returned by this function shall not be modified by the program. Some systems and library implementations may allow to change environmental variables with specific functions (putenv, setenv...), but such functionality is non-portable.
func GoPointerToCPointer ¶ added in v0.14.0
func GoPointerToCPointer(destination interface{}, value interface{})
GoPointerToCPointer does the opposite of CPointerToGoPointer.
A Go pointer (simply a pointer) is converted back into the original slice structure (of the original slice reference) so that the calling functions will be able to see the new data of that pointer.
func Labs ¶ added in v0.16.0
Labs returns the absolute value of parameter n ( /n/ ).
This is the long int version of abs.
func Ldexp ¶ added in v0.23.0
Ldexp is the inverse of Frexp. Ldexp uses math.Ldexp to calculate the value.
func Llabs ¶ added in v0.16.0
Llabs returns the absolute value of parameter n ( /n/ ).
This is the long long int version of abs.
func Malloc ¶ added in v0.25.0
Malloc returns a pointer to a memory block of the given length.
To prevent the Go garbage collector from collecting this memory, we store the whole block in a map.
func Memcmp ¶ added in v0.23.3
Memcmp compares two binary arrays upto n bytes. Different from strncmp, memcmp does not stop at the first NULL byte.
func Memcpy ¶ added in v0.23.1
Memcpy treats dst and src as binary arrays and copies size bytes from src to dst. Returns dst. While in C it it is undefined behavior to call memcpy with overlapping regions, in Go we rely on the built-in copy function, which has no such limitation. To copy overlapping regions in C memmove should be used, so we map that function to Memcpy as well.
func Memset ¶ added in v0.23.1
Memset treats dst as a binary array and sets size bytes to the value val. Returns dst.
func Perror ¶ added in v0.24.2
func Perror(str *byte)
Perror handles perror().
Interprets the value of errno as an error message, and prints it to stderr (the standard error output stream, usually the console), optionally preceding it with the custom message specified in str.
errno is an integral variable whose value describes the error condition or diagnostic information produced by a call to a library function (any function of the C standard library may set a value for errno, even if not explicitly specified in this reference, and even if no error happened), see errno for more info.
If the parameter str is not a null pointer, str is printed followed by a colon (:) and a space. Then, whether str was a null pointer or not, the generated error description is printed followed by a newline character ('\n').
perror should be called right after the error was produced, otherwise it can be overwritten by calls to other functions.
func Printf ¶ added in v0.12.0
Printf handles printf().
Writes the C string pointed by format to the standard output (stdout). If format includes format specifiers (subsequences beginning with %), the additional arguments following format are formatted and inserted in the resulting string replacing their respective specifiers.
func Putchar ¶ added in v0.13.7
func Putchar(character int32)
Putchar handles putchar().
Writes a character to the standard output (stdout).
It is equivalent to calling putc with stdout as second argument.
func Puts ¶ added in v0.12.0
Puts handles puts().
Writes the C string pointed by str to the standard output (stdout) and appends a newline character ('\n').
The function begins copying from the address specified (str) until it reaches the terminating null character ('\0'). This terminating null-character is not copied to the stream.
Notice that puts not only differs from fputs in that it uses stdout as destination, but it also appends a newline character at the end automatically (which fputs does not).
func Remove ¶ added in v0.11.0
Remove handles remove().
Deletes the file whose name is specified in filePath.
This is an operation performed directly on a file identified by its filePath; No streams are involved in the operation.
Proper file access shall be available.
func Rename ¶ added in v0.11.0
Rename handles rename().
Changes the name of the file or directory specified by oldName to newName.
This is an operation performed directly on a file; No streams are involved in the operation.
If oldName and newName specify different paths and this is supported by the system, the file is moved to the new location.
If newName names an existing file, the function may either fail or override the existing file, depending on the specific system and library implementation.
Proper file access shall be available.
func Rewind ¶ added in v0.11.0
func Rewind(stream *File)
Rewind handles rewind().
Sets the position indicator associated with stream to the beginning of the file.
The end-of-file and error internal indicators associated to the stream are cleared after a successful call to this function, and all effects from previous calls to ungetc on this stream are dropped.
On streams open for update (read+write), a call to rewind allows to switch between reading and writing.
func Scanf ¶ added in v0.12.0
Scanf handles scanf().
Reads data from stdin and stores them according to the parameter format into the locations pointed by the additional arguments.
The additional arguments should point to already allocated objects of the type specified by their corresponding format specifier within the format string.
func Snprintf ¶ added in v0.20.0
Snprintf handles snprintf().
Writes the C string pointed by format to the standard output (stdout). If format includes format specifiers (subsequences beginning with %), the additional arguments following format are formatted and inserted in the resulting string replacing their respective specifiers.
func Sprintf ¶ added in v0.20.0
Sprintf handles sprintf().
Writes the C string pointed by format to the standard output (stdout). If format includes format specifiers (subsequences beginning with %), the additional arguments following format are formatted and inserted in the resulting string replacing their respective specifiers.
func Strcasestr ¶ added in v0.23.5
Strcasestr - function is similar to Strstr(), but ignores the case of both strings.
func Strcat ¶ added in v0.19.5
Strcat - concatenate strings Appends a copy of the source string to the destination string. The terminating null character in destination is overwritten by the first character of source, and a null-character is included at the end of the new string formed by the concatenation of both in destination.
func Strchr ¶ added in v0.21.6
Strchr - Locate first occurrence of character in string See: http://www.cplusplus.com/reference/cstring/strchr/
func Strcmp ¶ added in v0.20.3
Strcmp - compare two strings Compares the C string str1 to the C string str2.
func Strcpy ¶ added in v0.19.3
Strcpy copies the C string pointed by source into the array pointed by destination, including the terminating null character (and stopping at that point).
To avoid overflows, the size of the array pointed by destination shall be long enough to contain the same C string as source (including the terminating null character), and should not overlap in memory with source.
func StringToCString ¶ added in v0.16.0
StringToCString returns the C string (also known as a null terminated string) to be as used as a string in C.
func Strlen ¶ added in v0.11.0
Strlen returns the length of a string.
The length of a C string is determined by the terminating null-character: A C string is as long as the number of characters between the beginning of the string and the terminating null character (without including the terminating null character itself).
func Strncmp ¶ added in v0.23.3
Strncmp - compare two strings Compares the C string str1 to the C string str2 upto the first NULL character or n-th character whichever comes first.
func Strncpy ¶ added in v0.19.3
Strncpy copies the first num characters of source to destination. If the end of the source C string (which is signaled by a null-character) is found before num characters have been copied, destination is padded with zeros until a total of num characters have been written to it.
No null-character is implicitly appended at the end of destination if source is longer than num. Thus, in this case, destination shall not be considered a null terminated C string (reading it as such would overflow).
destination and source shall not overlap (see memmove for a safer alternative when overlapping).
func Strstr ¶ added in v0.23.5
Strstr - locate a substring in a string function locates the first occurrence of the null-terminated string needle in the null-terminated string haystack.
func Strtod ¶ added in v0.16.0
Strtod parses the C-string str interpreting its content as a floating point number (according to the current locale) and returns its value as a double. If endptr is not a null pointer, the function also sets the value of endptr to point to the first character after the number.
The function first discards as many whitespace characters (as in isspace) as necessary until the first non-whitespace character is found. Then, starting from this character, takes as many characters as possible that are valid following a syntax resembling that of floating point literals (see below), and interprets them as a numerical value. A pointer to the rest of the string after the last valid character is stored in the object pointed by endptr.
func Strtol ¶ added in v0.9.0
Strtol parses the C-string str interpreting its content as an integral number of the specified base, which is returned as a long int value. If endptr is not a null pointer, the function also sets the value of endptr to point to the first character after the number.
The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes as many characters as possible that are valid following a syntax that depends on the base parameter, and interprets them as a numerical value. Finally, a pointer to the first character following the integer representation in str is stored in the object pointed by endptr.
If the value of base is zero, the syntax expected is similar to that of integer constants, which is formed by a succession of:
- An optional sign character (+ or -)
- An optional prefix indicating octal or hexadecimal base ("0" or "0x"/"0X" respectively)
A sequence of decimal digits (if no base prefix was specified) or either octal or hexadecimal digits if a specific prefix is present
If the base value is between 2 and 36, the format expected for the integral number is a succession of any of the valid digits and/or letters needed to represent integers of the specified radix (starting from '0' and up to 'z'/'Z' for radix 36). The sequence may optionally be preceded by a sign (either + or -) and, if base is 16, an optional "0x" or "0X" prefix.
If the first sequence of non-whitespace characters in str is not a valid integral number as defined above, or if no such sequence exists because either str is empty or it contains only whitespace characters, no conversion is performed.
For locales other than the "C" locale, additional subject sequence forms may be accepted.
func Strtoul ¶ added in v0.16.0
Strtoul works the same way as Strtol but returns a long unsigned int.
func Strtoull ¶ added in v0.16.0
Strtoull works the same way as Strtol but returns a long long unsigned int.
func Ternary ¶
func Ternary(a bool, b, c func() interface{}) interface{}
Ternary simulates the ternary (also known as the conditional operator). Go does not have the equivalent of using if statements as expressions or inline if statements. This function takes the true and false parts as closures to be sure that only the true or false condition is evaulated - to prevent side effects.
func TimeTToFloat64 ¶ added in v0.16.7
TimeTToFloat64 converts TimeT to a float64. It is used by the tests.
func Tmpnam ¶ added in v0.11.0
Tmpnam handles tmpnam().
Returns a string containing a file name different from the name of any existing file, and thus suitable to safely create a temporary file without risking to overwrite an existing file.
If str is a null pointer, the resulting string is stored in an internal static array that can be accessed by the return value. The content of this string is preserved at least until a subsequent call to this same function, which may overwrite it.
If str is not a null pointer, it shall point to an array of at least L_tmpnam characters that will be filled with the proposed temporary file name.
The file name returned by this function can be used to create a regular file using fopen to be used as a temporary file. The file created this way, unlike those created with tmpfile is not automatically deleted when closed; A program shall call remove to delete this file once closed.
func UnsafeSliceToSlice ¶ added in v0.22.4
func UnsafeSliceToSlice(a interface{}, fromSize int32, toSize int32) *reflect.SliceHeader
UnsafeSliceToSlice takes a slice and transforms it into a slice of a different type. For this we need to adjust the length and capacity in accordance with the sizes of the underlying types.
func UnsafeSliceToSliceUnlimited ¶ added in v0.24.3
func UnsafeSliceToSliceUnlimited(a interface{}) *reflect.SliceHeader
UnsafeSliceToSliceUnlimited takes a slice and transforms it into a slice of a different type. The length and capacity will be set to unlimited.
func Vsnprintf ¶ added in v0.20.0
Vsnprintf handles vsnprintf().
Writes the C string pointed by format to the standard output (stdout). If format includes format specifiers (subsequences beginning with %), the additional arguments following format are formatted and inserted in the resulting string replacing their respective specifiers.
func Vsprintf ¶ added in v0.20.0
Vsprintf handles vsprintf().
Writes the C string pointed by format to the standard output (stdout). If format includes format specifiers (subsequences beginning with %), the additional arguments following format are formatted and inserted in the resulting string replacing their respective specifiers.
Types ¶
type File ¶ added in v0.11.0
type File struct { // This is not part of the original struct but it is needed for internal // calls in Go. OsFile *os.File // contains filtered or unexported fields }
File represents the definition has been translated from the original definition for __sFILE, which is an alias for FILE. Not all of the attributes have been translated. They should be turned on as needed.
func Fopen ¶ added in v0.9.0
Fopen handles fopen().
Opens the file whose name is specified in the parameter filePath and associates it with a stream that can be identified in future operations by the File pointer returned.
The operations that are allowed on the stream and how these are performed are defined by the mode parameter.
The returned pointer can be disassociated from the file by calling fclose() or freopen(). All opened files are automatically closed on normal program termination.
func Tmpfile ¶ added in v0.11.0
func Tmpfile() *File
Tmpfile handles tmpfile().
Creates a temporary binary file, open for update ("wb+" mode, see fopen for details) with a filename guaranteed to be different from any other existing file.
The temporary file created is automatically deleted when the stream is closed (fclose) or when the program terminates normally. If the program terminates abnormally, whether the file is deleted depends on the specific system and library implementation.
type InterfaceWrapper ¶ added in v0.25.0
type InterfaceWrapper struct {
X interface{}
}
InterfaceWrapper is used for those case where we cannot use unsafe.Pointer the default catch all data type for c2go. For the moment this is the case for function pointers.
type Safe ¶ added in v0.24.0
type Safe struct {
// contains filtered or unexported fields
}
Safe contains a thread-safe value
type TimeT ¶ added in v0.16.7
type TimeT int32
TimeT is the representation of "time_t". For historical reasons, it is generally implemented as an integral value representing the number of seconds elapsed since 00:00 hours, Jan 1, 1970 UTC (i.e., a unix timestamp). Although libraries may implement this type using alternative time representations.
func IntToTimeT ¶ added in v0.16.7
IntToTimeT converts an int32 to a TimeT.
func Mktime ¶ added in v0.21.8
Mktime - Convert tm structure to time_t Returns the value of type time_t that represents the local time described by the tm structure pointed by timeptr (which may be modified).
func NullToTimeT ¶ added in v0.16.7
NullToTimeT converts a NULL to an array of TimeT.
type Tm ¶ added in v0.21.8
type Tm struct { Tm_sec int32 Tm_min int32 Tm_hour int32 Tm_mday int32 Tm_mon int32 Tm_year int32 Tm_wday int32 Tm_yday int32 Tm_isdst int32 }
Tm - base struct in "time.h" Structure containing a calendar date and time broken down into its components