namespace io

namespace io {

// namespaces

namespace io.lnx;
namespace io.psx;
namespace io.win;

// typedefs

typedef io.ReadOnlyStreamOptions MailslotOptions;
typedef io.ReadOnlyStreamEvents MailslotEvents;
typedef io.StreamOptions ChildProcessOptions;
typedef io.StreamOptions UsbEndpointOptions;
typedef io.ReadOnlyStreamEvents UsbMonEvents;
typedef io.StreamEvents HidDeviceEvents;
typedef io.ReadOnlyStreamEvents DeviceMonitorEvents;

// enums

enum {
    DeviceMonitorNotifyHdrSignature = 'nomt',
};

enum AddressFamily;
bitflag enum ChildProcessEvents;
bitflag enum ChildProcessStartFlags;
enum DeviceMonitorMiMsgCode;
bitflag enum DeviceMonitorMiStartFlags;
bitflag enum DeviceMonitorNotifyFlags;
enum FileKind;
bitflag enum FileOpenFlags;
bitflag enum FileStreamEvents;
bitflag enum FileStreamOptions;
enum HidBusType;
bitflag enum HidDeviceOptions;
enum HidRdCollectionKind;
bitflag enum HidRdFlags;
enum HidRdItemId;
bitflag enum HidRdItemMask;
enum HidRdUnit;
enum HidRdUnitNibbleRole;
enum HidRdUnitSystem;
bitflag enum HidRdValueFlags;
enum HidReportType;
bitflag enum HostNameResolverEvents;
bitflag enum NamedPipeEvents;
bitflag enum NetworkAdapterFlags;
enum NetworkAdapterType;
bitflag enum PcapEvents;
enum PcapLinkType;
enum Protocol;
bitflag enum ReadOnlyStreamEvents;
bitflag enum ReadOnlyStreamOptions;
bitflag enum SerialEvents;
enum SerialFlowControl;
bitflag enum SerialLineErrors;
bitflag enum SerialOptions;
enum SerialParity;
bitflag enum SerialPortDescFlags;
bitflag enum SerialStatusLines;
enum SerialStopBits;
bitflag enum SocketEvents;
bitflag enum SocketOptions;
bitflag enum SshEvents;
enum SslCertFormat;
enum SslNid;
bitflag enum SslSocketEvents;
bitflag enum SslStateFlags;
enum SslStdDh;
bitflag enum SslVerifyMode;
bitflag enum StreamEvents;
bitflag enum StreamOptions;
enum UsbClass;
enum UsbControlDirection;
enum UsbControlRecipient;
enum UsbControlStdRequest;
enum UsbControlType;
bitflag enum UsbDeviceStringId;
bitflag enum UsbEndpointEvents;
bitflag enum UsbEnumFlags;
enum UsbIsoSyncType;
enum UsbIsoUsage;
bitflag enum UsbMonEnumFlags;
bitflag enum UsbMonOptions;
bitflag enum UsbMonTransferFlags;
enum UsbSpeed;
enum UsbTransferType;
bitflag enum WebSocketEvents;
enum WebSocketFrameOpcode;
bitflag enum WebSocketOptions;

// structs

struct DeviceMonitorMiMsgHdr;
struct DeviceMonitorMiStartParams;
struct DeviceMonitorNotifyHdr;
struct HidDeviceDesc;
struct HidMonDeviceDesc;
struct NetworkAdapterAddress;
struct NetworkAdapterDesc;
struct PcapAddress;
struct PcapDeviceDesc;
struct PtySize;
struct SerialPortDesc;
struct SocketAddress_ip4;
struct SocketAddress_ip6;
struct SshConnectParams;
struct SslCertNameEntry;
struct UsbConfigurationDescriptor;
struct UsbControlRequestType;
struct UsbControlSetup;
struct UsbDeviceDescriptor;
struct UsbDeviceEntry;
struct UsbDeviceStrings;
struct UsbEndpointDescriptor;
struct UsbInterfaceDescriptor;
struct UsbIsoHdr;
struct UsbIsoPacket;
struct UsbMonDeviceDesc;
struct UsbMonDeviceDescBase;
struct UsbMonTransferHdr;

// unions

union Address_ip4;
union Address_ip6;
union SocketAddress;

// classes

class ChildProcess;
class DeviceMonitor;
class File;
class FileStream;
class HidDb;
class HidDevice;
class HidRd;
class HidRdCollection;
class HidReport;
class HidReportField;
class HidStandaloneReport;
class HidUsagePage;
class HostNameResolver;
class Mailslot;
class MappedFile;
class NamedPipe;
class Pcap;
class PcapFilter;
class Serial;
class Socket;
class SshChannel;
class SslCertName;
class SslCertificate;
class SslCipher;
class SslSocket;
class SslState;
class UsbDevice;
class UsbEndpoint;
class UsbInterface;
class UsbMonitor;
class WebSocket;
class WebSocketHandshake;
class WebSocketHandshakeHeaders;

// global functions

string_t getFileStreamKindString(io.FileKind kind);
string_t getSymbolicLinkTarget(string_t name);
string_t getHomeDir();
string_t getTempDir();

string_t createTempFile(
    string_t dir = null,
    string_t prefix = null
);

bool errorcode renameFile(
    string_t srcFileName,
    string_t dstFileName
);

bool errorcode deleteFile(string_t fileName);

io.SerialPortDesc const* enumerateSerialPorts(
    io.SerialPortDescFlags flags,
    size_t* count = null
);

io.SerialPortDesc const* enumerateSerialPorts(size_t* count = null);

io.NetworkAdapterDesc const* enumerateNetworkAdapters(
    size_t* adapterCount = null,
    size_t* addressCount = null
);

string_t getSslNidShortName(io.SslNid nid);
string_t getSslNidLongName(io.SslNid nid);
io.PcapDeviceDesc const* createPcapDeviceDescList(size_t* count = null);

io.UsbDeviceEntry const* enumerateUsbDevices(
    io.UsbEnumFlags flags,
    size_t* count = null
);

io.UsbDeviceEntry const* enumerateUsbDevices(size_t* count = null);
io.UsbDevice* const* errorcode enumerateUsbDevicesNoDesc(size_t* count = null);

io.UsbDevice* errorcode openUsbDevice(
    uint_t vendorId,
    uint_t productId
);

bool detectUsbMon();

io.UsbMonDeviceDesc const* enumerateUsbMonDevices(
    io.UsbMonEnumFlags flags,
    size_t* count = null
);

io.UsbMonDeviceDesc const* enumerateUsbMonDevices(size_t* count = null);
bool isHidRdItemSigned(io.HidRdItemId id);

io.HidRdUnit getHidRdUnit(
    io.HidRdUnitNibbleRole role,
    io.HidRdUnitSystem system
);

int getHidRdUnitExponent(uint_t nibble);
string_t getHidRdComplexUnitString(uint32_t unit);
io.HidMonDeviceDesc const* enumerateHidMonDevices(size_t* count = null);
io.HidDeviceDesc const* enumerateHidDevices(size_t* count = null);
bool detectDeviceMonitor();

} // namespace io