package opam-core

  1. Overview
  2. Docs

OS-specific functions requiring C code on at least one platform.

Most functions are Windows-specific and raise an exception on other platforms.

include module type of struct include OpamStubsTypes end
type console_screen_buffer_info = OpamStubsTypes.console_screen_buffer_info = {
  1. size : int * int;
    (*

    Width and height of the screen buffer

    *)
  2. cursorPosition : int * int;
    (*

    Current position of the console cursor (caret)

    *)
  3. attributes : int;
    (*

    Screen attributes; see https://docs.microsoft.com/en-us/windows/console/console-screen-buffers#_win32_character_attributes

    *)
  4. window : int * int * int * int;
    (*

    Coordinates of the upper-left and lower-right corners of the display window within the screen buffer

    *)
  5. maximumWindowSize : int * int;
    (*

    Maximum displayable size of the console for this screen buffer

    *)
}

CONSOLE_SCREEN_BUFFER_INFO struct (see https://docs.microsoft.com/en-us/windows/console/console-screen-buffer-info-str)

type console_font_infoex = OpamStubsTypes.console_font_infoex = {
  1. font : int;
    (*

    Index in the system's console font table

    *)
  2. fontSize : int * int;
    (*

    Size, in logical units, of the font

    *)
  3. fontFamily : int;
    (*

    Font pitch and family (low 8 bits only). See tmPitchAndFamily in https://msdn.microsoft.com/library/windows/desktop/dd145132

    *)
  4. fontWeight : int;
    (*

    Font weight. Normal = 400; Bold = 700

    *)
  5. faceName : string;
    (*

    Name of the typeface

    *)
}

CONSOLE_FONT_INFOEX struct (see https://docs.microsoft.com/en-us/windows/console/console-font-infoex)

type handle = OpamStubsTypes.handle

Win32 API handles

type stdhandle = OpamStubsTypes.stdhandle =
  1. | STD_INPUT_HANDLE
  2. | STD_OUTPUT_HANDLE
  3. | STD_ERROR_HANDLE

Standard handle constants (see https://docs.microsoft.com/en-us/windows/console/getstdhandle)

type registry_root = OpamStubsTypes.registry_root =
  1. | HKEY_CLASSES_ROOT
  2. | HKEY_CURRENT_CONFIG
  3. | HKEY_CURRENT_USER
  4. | HKEY_LOCAL_MACHINE
  5. | HKEY_USERS

Win32 Root Registry Hives (see https://msdn.microsoft.com/en-us/library/windows/desktop/ms724836.aspx)

type _ registry_value = _ OpamStubsTypes.registry_value =
  1. | REG_SZ : string registry_value

Win32 Registry Value Types (see https://msdn.microsoft.com/en-us/library/windows/desktop/ms724884.aspx

type ('a, 'b, 'c) winmessage = ('a, 'b, 'c) OpamStubsTypes.winmessage =
  1. | WM_SETTINGCHANGE : (int, string, int) winmessage
    (*

    See https://msdn.microsoft.com/en-us/library/windows/desktop/ms725497.aspx

    *)

Windows Messages (at least, one of them!)

type windows_cpu_architecture = OpamStubsTypes.windows_cpu_architecture =
  1. | AMD64
  2. | ARM
  3. | ARM64
  4. | IA64
  5. | Intel
  6. | Unknown

Windows CPU Architectures (SYSTEM_INFO.wProcessArchitecture / sysinfoapi.h)

type win32_non_fixed_version_info = OpamStubsTypes.win32_non_fixed_version_info = {
  1. comments : string option;
  2. companyName : string option;
  3. fileDescription : string option;
  4. fileVersionString : string option;
  5. internalName : string option;
  6. legalCopyright : string option;
  7. legalTrademarks : string option;
  8. originalFilename : string option;
  9. productName : string option;
  10. productVersionString : string option;
  11. privateBuild : string option;
  12. specialBuild : string option;
}

Predefined version information strings (see VerQueryValueW)

type win32_version_info = OpamStubsTypes.win32_version_info = {
  1. signature : int;
    (*

    0xFEEF04BD

    *)
  2. version : int * int;
    (*

    Structure version number

    *)
  3. fileVersion : int * int * int * int;
    (*

    File version

    *)
  4. productVersion : int * int * int * int;
    (*

    Product version

    *)
  5. fileFlagsMask : int;
    (*

    Valid bits in fileFlags

    *)
  6. fileFlags : int;
    (*

    File attributes (see VS_FIXEDFILEINFO)

    *)
  7. fileOS : int;
    (*

    File OS (see VS_FIXEDFILEINFO)

    *)
  8. fileType : int;
    (*

    File Type (see VS_FIXEDFILEINFO)

    *)
  9. fileSubtype : int;
    (*

    File Sub-type (see VS_FIXEDFILEINFO)

    *)
  10. fileDate : int64;
    (*

    File creation time stamp

    *)
  11. strings : ((int * int) * win32_non_fixed_version_info) list;
    (*

    Non-fixed string table. First field is a pair of Language and Codepage ID.

    *)
}

VS_FIXEDFILEINFO

val is_executable : string -> bool

faccessat on Unix; _waccess on Windows. Checks whether a path is executable for the current process. On Unix, unlike Unix.access, this is checked using the EUID/EGID rather than RUID/RGID.

val getpid : unit -> int

On Windows, this returns the actual process ID, rather than the non-unique faked process ID returned by the Microsoft C Runtime (see https://caml.inria.fr/mantis/view.php?id=4034).

On all other platforms, this is just an alias for Unix.getpid.

val getCurrentProcessID : unit -> int32

Windows only. As getpid, but without the possibility of truncating the ID on 32-bit platforms.

val getStdHandle : stdhandle -> handle

Windows only. Return a standard handle.

val getConsoleScreenBufferInfo : handle -> console_screen_buffer_info

Windows only. Return current Console screen buffer information.

val setConsoleTextAttribute : handle -> int -> unit

Windows only. Set the console's text attribute setting.

val fillConsoleOutputCharacter : handle -> char -> int -> (int * int) -> bool

Windows only. fillConsoleOutputCharacter buffer c n (x, y) writes c n times starting at the given coordinate (and wrapping if required).

val getConsoleMode : handle -> int

Windows only. Returns the input/output mode of the console screen buffer referred to by the handle.

  • raises Not_found

    If the handle does not refer to a console.

val setConsoleMode : handle -> int -> bool

Windows only. Sets the input/output mode of the console screen buffer referred to by the handle, returning true if the operation isr successful.

val getWindowsVersion : unit -> int * int * int * int

Windows only. Returns the Windows version as (major, minor, build, revision). This function only works if opam is compiled OCaml 4.06.0 or later, it returns (0, 0, 0, 0) otherwise.

val getArchitecture : unit -> windows_cpu_architecture

Windows only. Equivalent of uname -m.

val waitpids : int list -> int -> int * Unix.process_status

Windows only. Given a list pids with length elements, waitpids pids length behaves like Unix.wait, returning the pid and exit status of the first process to terminate.

val readRegistry : registry_root -> string -> string -> 'a registry_value -> 'a option

Windows only. readRegistry root key name value_type reads the value name from registry key key of root. As per Windows Registry convention, the default value can be read by passing "" for name.

  • raises Failure

    If the value in the registry does not have value_type

val enumRegistry : registry_root -> string -> 'a registry_value -> (string * 'a) list

Windows only. enumRegistry root key value_type reads all the values from registry key key of root which have type value_type.

Returns [] if the key is not found.

val writeRegistry : registry_root -> string -> string -> 'a registry_value -> 'a -> unit

Windows only. writeRegistry root key name value_type value sets the value name of type value_type in registry key key of root to value.

  • raises Failure

    If the value could not be set.

val getConsoleOutputCP : unit -> int

Windows only. Retrieves the current Console Output Code Page.

val getCurrentConsoleFontEx : handle -> bool -> console_font_infoex

Windows only. Gets information on the current console output font.

val create_glyph_checker : string -> handle * handle

Windows only. Given a font name, returns a pair consisting of a screen DC and a font object, which will have been selected into the DC.

  • raises Failure

    If anything goes wrong with the GDI calls.

val delete_glyph_checker : (handle * handle) -> unit

Windows only. Given (dc, font), deletes the font object and releases the DC.

val has_glyph : (handle * handle) -> Uchar.t -> bool

Windows only. has_glyph (dc, font) scalar returns true if font contains a glyph for scalar.

  • raises Failure

    If the call to GetGlyphIndicesW fails.

val getProcessArchitecture : int32 option -> windows_cpu_architecture

Windows only. Returns the CPU architecture of the given process ID (or the current process).

val process_putenv : int32 -> string -> string -> bool

Windows only. process_putenv pid name value sets the environment variable name to value in given process ID (Unix.putenv must also be called to update the value in the current process). This function must not be called if the target process is 32-bit and the current process is 64-bit or vice versa (outcomes vary from a no-op to a segfault).

val getPathToHome : unit -> string
val getPathToSystem : unit -> string
val getPathToLocalAppData : unit -> string

Windows only. retrieves the location of the wanted directory

val sendMessageTimeout : nativeint -> int -> int -> ('a, 'b, 'c) winmessage -> 'a -> 'b -> int * 'c

Windows only. sendMessageTimeout hwnd timeout flags message wParam lParam sends a message to the given handle, but is guaranteed to return within timeout milliseconds. The result consists of two parts, fst is the return value from SendMessageTimeout, snd depends on both the message and fst. See https://msdn.microsoft.com/en-us/library/windows/desktop/ms644952.aspx

val getProcessAncestry : unit -> (int32 * string) list

Windows only. Returns the pid and full path to the image for each entry in the ancestry list for this process, starting with the process itself. If an image name can't be determined, then "" is returned; on failure, returns [].

val getConsoleAlias : string -> string -> string

Windows only. getConsoleAlias alias exeName retrieves the value for a given executable or "" if the alias is not defined. See https://docs.microsoft.com/en-us/windows/console/getconsolealias

val win_create_process : string -> string -> string option -> Unix.file_descr -> Unix.file_descr -> Unix.file_descr -> int

Windows only. Provided by OCaml's win32unix library.

val getConsoleWindowClass : unit -> string option

Windows only. Returns the name of the class for the Console window or None if there is no console.

val setErrorMode : int -> int

Windows only. Directly wraps SetErrorMode.

val getErrorMode : unit -> int

Windows only. Directly wraps GetErrorMode.

val setConsoleToUTF8 : unit -> unit

Windows only. Directly wraps SetConsoleOutputCP(CP_UTF8).

val getVersionInfo : string -> win32_version_info option

Windows only. Returns the version info block for a file or None if the file either doesn't exist or doesn't have one.

val get_initial_environment : unit -> string list

Windows only. Returns the environment which new processes would receive.

val get_stdout_ws_col : unit -> int

Unix only. Returns the number of columns of the current terminal window linked with stdout. If stdout isn't linked to any terminal (e.g. redirection), then this function will return 0. A valid number of columns should be strictly above 0.

OCaml

Innovation. Community. Security.