elf-loader.dhover×146all
#!/usr/bin/env dub
/+ dub.sdl:
    name "android-research-elf-loader"
    platforms "linux"
    targetPath "build"
+/
/**
 * Read an actual ELF's PT_INTERP without executing it.
 * Evidence for ../index.md#canonical-store-and-elf-abi.
 * Defaults to this executable; pass a Linux or Android ELF as the argument.
 */
module 
(module) elf_loader

Read an actual ELF's PT_INTERP without executing it. Evidence for ../index.md#canonical-store-and-elf-abi. Defaults to this executable; pass a Linux or Android ELF as the argument.

elf_loader
;
import
(package) std
std
.
(module) std.file

Utilities for manipulating files and scanning directories. Functions in this module handle files as a unit, e.g., read or write one file at a time. For opening files and manipulating them via handles refer to module std.stdio.

Category Functions
General exists isDir isFile isSymlink rename thisExePath
Directories chdir dirEntries getcwd mkdir mkdirRecurse rmdir rmdirRecurse tempDir
Files append copy read readText remove slurp write
Symlinks symlink readLink
Attributes attrIsDir attrIsFile attrIsSymlink getAttributes getLinkAttributes getSize setAttributes
Timestamp getTimes getTimesWin setTimes timeLastModified timeLastAccessed timeStatusChanged
Other DirEntry FileException PreserveAttributes SpanMode getAvailableDiskSpace

Source

std/file.d

@copyrightCopyright The D Language Foundation 2007 - 2011.@seeThe official tutorial for an introduction to working with files in D, module std.stdio for opening files and manipulating them via handles, and module std.path for manipulating path strings.@licenseBoost License 1.0.@authorsWalter Bright, Andrei Alexandrescu, Jonathan M Davis
file
:
(alias template) elf_loader.read = std.file.read(R)(R name, size_t upTo = size_t.max) if (isSomeFiniteCharInputRange!R && !isConvertibleToString!R)

Read entire contents of file name and returns it as an untyped array. If the file size is larger than upTo, only upTo bytes are read.

@paramname string or range of characters representing the file name@paramupTo if present, the maximum number of bytes to read@returnsUntyped array of bytes read.@throwsFileException on error.@seereadText for reading and validating a text file.
read
;
import
(package) std
std
.
(module) std.stdio
Category Symbols
File handles _popen File isFileHandle openNetwork stderr stdin stdout
Reading chunks lines readf readfln readln
Writing toFile write writef writefln writeln
Misc KeepTerminator LockType StdioException

Standard I/O functions that extend core.stdc.stdio. core.stdc.stdio is publically imported when importing std.stdio.

There are three layers of I/O:

  1. The lowest layer is the operating system layer. The two main schemes are Windows and Posix.

  2. C's stdio.h which unifies the two operating system schemes.

  3. std.stdio, this module, unifies the various stdio.h implementations into a high level package for D programs.

Source

std/stdio.d

@copyrightCopyright The D Language Foundation 2007-.@licenseBoost License 1.0.@authorsWalter Bright, Andrei Alexandrescu, Alex Rønne Petersen
stdio
:
(alias template) elf_loader.writeln = std.stdio.writeln(T...)(T args)

Equivalent to write(args, '\n'). Calling writeln without arguments is valid and just prints a newline to the standard output.

Example

Reads stdin and writes it to stdout with an argument counter.

import std.stdio;

void main()
{
    string line;

    for (size_t count = 0; (line = readln) !is null; count++)
    {
         writeln("Input ", count, ": ", line);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
writeln
;
import
(package) std
std
.
(module) std.exception

This module defines functions related to exceptions and general error handling. It also defines functions intended to aid in unit testing.

Category Functions
Assumptions assertNotThrown assertThrown assumeUnique assumeWontThrow mayPointTo
Enforce doesPointTo enforce errnoEnforce
Handlers collectException collectExceptionMsg ifThrown handle
Other basicExceptionCtors emptyExceptionMsg ErrnoException RangePrimitive

Source

std/exception.d

Examples

Synopis

import core.stdc.stdlib : malloc, free;
import std.algorithm.comparison : equal;
import std.algorithm.iteration : map, splitter;
import std.algorithm.searching : endsWith;
import std.conv : ConvException, to;
import std.range : front, retro;

// use enforce like assert
int a = 3;
enforce(a > 2, "a needs to be higher than 2.");

// enforce can throw a custom exception
enforce!ConvException(a > 2, "a needs to be higher than 2.");

// enforce will return it's input
enum size = 42;
auto memory = enforce(malloc(size), "malloc failed")[0 .. size];
scope(exit) free(memory.ptr);

// collectException can be used to test for exceptions
Exception e = collectException("abc".to!int);
assert(e.file.endsWith("conv.d"));

// and just for the exception message
string msg = collectExceptionMsg("abc".to!int);
assert(msg == "Unexpected 'a' when converting from type string to type int");

// assertThrown can be used to assert that an exception is thrown
assertThrown!ConvException("abc".to!int);

// ifThrown can be used to provide a default value if an exception is thrown
assert("x".to!int().ifThrown(0) == 0);

// handle is a more advanced version of ifThrown for ranges
auto r = "12,1337z32,54".splitter(',').map!(a => to!int(a));
auto h = r.handle!(ConvException, RangePrimitive.front, (e, r) => 0);
assert(h.equal([12, 0, 54]));
assertThrown!ConvException(h.retro.equal([54, 0, 12]));

// basicExceptionCtors avoids the boilerplate when creating custom exceptions
static class MeaCulpa : Exception
{
    mixin basicExceptionCtors;
}
e = collectException((){throw new MeaCulpa("diagnostic message");}());
assert(e.msg == "diagnostic message");
assert(e.file == __FILE__);
assert(e.line == __LINE__ - 3);

// assumeWontThrow can be used to cast throwing code into `nothrow`
void exceptionFreeCode() nothrow
{
    // auto-decoding only throws if an invalid UTF char is given
    assumeWontThrow("abc".front);
}

// assumeUnique can be used to cast mutable instance to an `immutable` one
// use with care
char[] str = "  mutable".dup;
str[0 .. 2] = "im";
immutable res = assumeUnique(str);
assert(res == "immutable");
@copyrightCopyright Andrei Alexandrescu 2008-, Jonathan M Davis 2011-.@licenseBoost License 1.0@authorsAndrei Alexandrescu and Jonathan M Davis
exception
:
(alias template) elf_loader.enforce = std.exception.enforce(E : Throwable = Exception) if (is(typeof(new E("", string.init, size_t.init)) : Throwable) || is(typeof(new E(string.init, size_t.init)) : Throwable))

Enforces that the given value is true. If the given value is false, an exception is thrown. The

  • msg - error message as a string

  • dg - custom delegate that return a string and is only called if an exception occurred

  • ex - custom exception to be thrown. It is lazy and is only created if an exception occurred

@paramvalue The value to test.@paramE Exception type to throw if the value evaluates to false.@parammsg The error message to put in the exception if it is thrown.@paramdg The delegate to be called if the value evaluates to false.@paramex The exception to throw if the value evaluates to false.@paramfile The source file of the caller.@paramline The line number of the caller.@returns

value, if cast(bool) value is true. Otherwise, depending on the chosen overload, new Exception(msg), dg() or ex is thrown.

enforce is used to throw exceptions and is therefore intended to aid in error handling. It is not intended for verifying the logic of your program - that is what assert is for.

Do not use enforce inside of contracts (i.e. inside of in and out blocks and invariants), because contracts are compiled out when compiling with -release.

If a delegate is passed, the safety and purity of this function are inferred from Dg's safety and purity.

enforce
;
ulong
ulong elf_loader.number(const(ubyte)[] bytes, ulong offset, ulong count, bool little)
number
(const(ubyte)[]
(parameter) const(ubyte)[] bytes
bytes
,
(alias) object.size_t = ulong
size_t
(parameter) ulong offset
offset
,
(alias) object.size_t = ulong
size_t
(parameter) ulong count
count
, bool
(parameter) bool little
little
)
{
bool std.exception.enforce!().enforce!bool(bool value, lazy const(char)[] msg = null, string file = __FILE__, ulong line = cast(ulong)__LINE__) pure @safe

Enforces that the given value is true. If the given value is false, an exception is thrown. The

  • msg - error message as a string

  • dg - custom delegate that return a string and is only called if an exception occurred

  • ex - custom exception to be thrown. It is lazy and is only created if an exception occurred

@paramvalue The value to test.@paramE Exception type to throw if the value evaluates to false.@parammsg The error message to put in the exception if it is thrown.@paramdg The delegate to be called if the value evaluates to false.@paramex The exception to throw if the value evaluates to false.@paramfile The source file of the caller.@paramline The line number of the caller.@returns

value, if cast(bool) value`` is true. Otherwise, depending on the chosen overload, new Exception(msg), dg() or ex is thrown.

enforce is used to throw exceptions and is therefore intended to aid in error handling. It is not intended for verifying the logic of your program - that is what assert is for.

Do not use enforce inside of contracts (i.e. inside of in and out blocks and invariants), because contracts are compiled out when compiling with -release.

If a delegate is passed, the safety and purity of this function are inferred from Dg's safety and purity.

enforce
(
(parameter) ulong offset
offset
<=
(parameter) const(ubyte)[] bytes
bytes
.
(field) ulong const(ubyte)[].length
length
&&
(parameter) ulong count
count
<=
(parameter) const(ubyte)[] bytes
bytes
.
(field) ulong const(ubyte)[].length
length
-
(parameter) ulong offset
offset
, "truncated ELF");
ulong
(local variable) ulong result
result
;
foreach (
(local variable) ulong i
i
; 0 ..
(parameter) ulong count
count
)
(local variable) ulong result
result
|= cast(ulong)
(parameter) const(ubyte)[] bytes
bytes
[
(parameter) ulong offset
offset
+
(local variable) ulong i
i
] << (8 * (
(parameter) bool little
little
?
(local variable) ulong i
i
:
(parameter) ulong count
count
-
(local variable) ulong i
i
- 1));
return
(local variable) ulong result
result
;
}
(alias) object.string = string
string
string elf_loader.interpreter(const(ubyte)[] bytes)
interpreter
(const(ubyte)[]
(parameter) const(ubyte)[] bytes
bytes
)
{
bool std.exception.enforce!().enforce!bool(bool value, lazy const(char)[] msg = null, string file = __FILE__, ulong line = cast(ulong)__LINE__) pure @safe

Enforces that the given value is true. If the given value is false, an exception is thrown. The

  • msg - error message as a string

  • dg - custom delegate that return a string and is only called if an exception occurred

  • ex - custom exception to be thrown. It is lazy and is only created if an exception occurred

@paramvalue The value to test.@paramE Exception type to throw if the value evaluates to false.@parammsg The error message to put in the exception if it is thrown.@paramdg The delegate to be called if the value evaluates to false.@paramex The exception to throw if the value evaluates to false.@paramfile The source file of the caller.@paramline The line number of the caller.@returns

value, if cast(bool) value`` is true. Otherwise, depending on the chosen overload, new Exception(msg), dg() or ex is thrown.

enforce is used to throw exceptions and is therefore intended to aid in error handling. It is not intended for verifying the logic of your program - that is what assert is for.

Do not use enforce inside of contracts (i.e. inside of in and out blocks and invariants), because contracts are compiled out when compiling with -release.

If a delegate is passed, the safety and purity of this function are inferred from Dg's safety and purity.

enforce
(
(parameter) const(ubyte)[] bytes
bytes
.
(field) ulong const(ubyte)[].length
length
>= 52 &&
(parameter) const(ubyte)[] bytes
bytes
[0 .. 4] == [0x7f, 'E', 'L', 'F'], "not an ELF");
bool std.exception.enforce!().enforce!bool(bool value, lazy const(char)[] msg = null, string file = __FILE__, ulong line = cast(ulong)__LINE__) pure @safe

Enforces that the given value is true. If the given value is false, an exception is thrown. The

  • msg - error message as a string

  • dg - custom delegate that return a string and is only called if an exception occurred

  • ex - custom exception to be thrown. It is lazy and is only created if an exception occurred

@paramvalue The value to test.@paramE Exception type to throw if the value evaluates to false.@parammsg The error message to put in the exception if it is thrown.@paramdg The delegate to be called if the value evaluates to false.@paramex The exception to throw if the value evaluates to false.@paramfile The source file of the caller.@paramline The line number of the caller.@returns

value, if cast(bool) value`` is true. Otherwise, depending on the chosen overload, new Exception(msg), dg() or ex is thrown.

enforce is used to throw exceptions and is therefore intended to aid in error handling. It is not intended for verifying the logic of your program - that is what assert is for.

Do not use enforce inside of contracts (i.e. inside of in and out blocks and invariants), because contracts are compiled out when compiling with -release.

If a delegate is passed, the safety and purity of this function are inferred from Dg's safety and purity.

enforce
(
(parameter) const(ubyte)[] bytes
bytes
[4] == 1 ||
(parameter) const(ubyte)[] bytes
bytes
[4] == 2, "unsupported ELF class");
bool std.exception.enforce!().enforce!bool(bool value, lazy const(char)[] msg = null, string file = __FILE__, ulong line = cast(ulong)__LINE__) pure @safe

Enforces that the given value is true. If the given value is false, an exception is thrown. The

  • msg - error message as a string

  • dg - custom delegate that return a string and is only called if an exception occurred

  • ex - custom exception to be thrown. It is lazy and is only created if an exception occurred

@paramvalue The value to test.@paramE Exception type to throw if the value evaluates to false.@parammsg The error message to put in the exception if it is thrown.@paramdg The delegate to be called if the value evaluates to false.@paramex The exception to throw if the value evaluates to false.@paramfile The source file of the caller.@paramline The line number of the caller.@returns

value, if cast(bool) value`` is true. Otherwise, depending on the chosen overload, new Exception(msg), dg() or ex is thrown.

enforce is used to throw exceptions and is therefore intended to aid in error handling. It is not intended for verifying the logic of your program - that is what assert is for.

Do not use enforce inside of contracts (i.e. inside of in and out blocks and invariants), because contracts are compiled out when compiling with -release.

If a delegate is passed, the safety and purity of this function are inferred from Dg's safety and purity.

enforce
(
(parameter) const(ubyte)[] bytes
bytes
[5] == 1 ||
(parameter) const(ubyte)[] bytes
bytes
[5] == 2, "unsupported ELF byte order");
const
(local variable) const(bool) wide
wide
=
(parameter) const(ubyte)[] bytes
bytes
[4] == 2;
const
(local variable) const(bool) little
little
=
(parameter) const(ubyte)[] bytes
bytes
[5] == 1;
const
(local variable) const(ulong) table
table
=
ulong elf_loader.number(const(ubyte)[] bytes, ulong offset, ulong count, bool little)
number
(
(parameter) const(ubyte)[] bytes
bytes
,
(local variable) const(bool) wide
wide
? 32 : 28,
(local variable) const(bool) wide
wide
? 8 : 4,
(local variable) const(bool) little
little
);
const
(local variable) const(ulong) stride
stride
=
ulong elf_loader.number(const(ubyte)[] bytes, ulong offset, ulong count, bool little)
number
(
(parameter) const(ubyte)[] bytes
bytes
,
(local variable) const(bool) wide
wide
? 54 : 42, 2,
(local variable) const(bool) little
little
);
const
(local variable) const(ulong) count
count
=
ulong elf_loader.number(const(ubyte)[] bytes, ulong offset, ulong count, bool little)
number
(
(parameter) const(ubyte)[] bytes
bytes
,
(local variable) const(bool) wide
wide
? 56 : 44, 2,
(local variable) const(bool) little
little
);
bool std.exception.enforce!().enforce!bool(bool value, lazy const(char)[] msg = null, string file = __FILE__, ulong line = cast(ulong)__LINE__) pure @safe

Enforces that the given value is true. If the given value is false, an exception is thrown. The

  • msg - error message as a string

  • dg - custom delegate that return a string and is only called if an exception occurred

  • ex - custom exception to be thrown. It is lazy and is only created if an exception occurred

@paramvalue The value to test.@paramE Exception type to throw if the value evaluates to false.@parammsg The error message to put in the exception if it is thrown.@paramdg The delegate to be called if the value evaluates to false.@paramex The exception to throw if the value evaluates to false.@paramfile The source file of the caller.@paramline The line number of the caller.@returns

value, if cast(bool) value`` is true. Otherwise, depending on the chosen overload, new Exception(msg), dg() or ex is thrown.

enforce is used to throw exceptions and is therefore intended to aid in error handling. It is not intended for verifying the logic of your program - that is what assert is for.

Do not use enforce inside of contracts (i.e. inside of in and out blocks and invariants), because contracts are compiled out when compiling with -release.

If a delegate is passed, the safety and purity of this function are inferred from Dg's safety and purity.

enforce
(
(local variable) const(ulong) stride
stride
>= (
(local variable) const(bool) wide
wide
? 56 : 32), "invalid ELF program header stride");
foreach (
(local variable) ulong i
i
; 0 ..
(local variable) const(ulong) count
count
)
{
bool std.exception.enforce!().enforce!bool(bool value, lazy const(char)[] msg = null, string file = __FILE__, ulong line = cast(ulong)__LINE__) pure @safe

Enforces that the given value is true. If the given value is false, an exception is thrown. The

  • msg - error message as a string

  • dg - custom delegate that return a string and is only called if an exception occurred

  • ex - custom exception to be thrown. It is lazy and is only created if an exception occurred

@paramvalue The value to test.@paramE Exception type to throw if the value evaluates to false.@parammsg The error message to put in the exception if it is thrown.@paramdg The delegate to be called if the value evaluates to false.@paramex The exception to throw if the value evaluates to false.@paramfile The source file of the caller.@paramline The line number of the caller.@returns

value, if cast(bool) value`` is true. Otherwise, depending on the chosen overload, new Exception(msg), dg() or ex is thrown.

enforce is used to throw exceptions and is therefore intended to aid in error handling. It is not intended for verifying the logic of your program - that is what assert is for.

Do not use enforce inside of contracts (i.e. inside of in and out blocks and invariants), because contracts are compiled out when compiling with -release.

If a delegate is passed, the safety and purity of this function are inferred from Dg's safety and purity.

enforce
(
(local variable) const(ulong) table
table
<=
(parameter) const(ubyte)[] bytes
bytes
.
(field) ulong const(ubyte)[].length
length
&&
(local variable) ulong i
i
<= (
(parameter) const(ubyte)[] bytes
bytes
.
(field) ulong const(ubyte)[].length
length
-
(local variable) const(ulong) table
table
) /
(local variable) const(ulong) stride
stride
, "truncated program headers");
const
(local variable) const(ulong) entry
entry
= cast(
(alias) object.size_t = ulong
size_t
) (
(local variable) const(ulong) table
table
+
(local variable) ulong i
i
*
(local variable) const(ulong) stride
stride
);
if (
ulong elf_loader.number(const(ubyte)[] bytes, ulong offset, ulong count, bool little)
number
(
(parameter) const(ubyte)[] bytes
bytes
,
(local variable) const(ulong) entry
entry
, 4,
(local variable) const(bool) little
little
) != 3) // PT_INTERP
continue; const
(local variable) const(ulong) offset
offset
=
ulong elf_loader.number(const(ubyte)[] bytes, ulong offset, ulong count, bool little)
number
(
(parameter) const(ubyte)[] bytes
bytes
,
(local variable) const(ulong) entry
entry
+ (
(local variable) const(bool) wide
wide
? 8 : 4),
(local variable) const(bool) wide
wide
? 8 : 4,
(local variable) const(bool) little
little
);
const
(local variable) const(ulong) length
length
=
ulong elf_loader.number(const(ubyte)[] bytes, ulong offset, ulong count, bool little)
number
(
(parameter) const(ubyte)[] bytes
bytes
,
(local variable) const(ulong) entry
entry
+ (
(local variable) const(bool) wide
wide
? 32 : 16),
(local variable) const(bool) wide
wide
? 8 : 4,
(local variable) const(bool) little
little
);
bool std.exception.enforce!().enforce!bool(bool value, lazy const(char)[] msg = null, string file = __FILE__, ulong line = cast(ulong)__LINE__) pure @safe

Enforces that the given value is true. If the given value is false, an exception is thrown. The

  • msg - error message as a string

  • dg - custom delegate that return a string and is only called if an exception occurred

  • ex - custom exception to be thrown. It is lazy and is only created if an exception occurred

@paramvalue The value to test.@paramE Exception type to throw if the value evaluates to false.@parammsg The error message to put in the exception if it is thrown.@paramdg The delegate to be called if the value evaluates to false.@paramex The exception to throw if the value evaluates to false.@paramfile The source file of the caller.@paramline The line number of the caller.@returns

value, if cast(bool) value`` is true. Otherwise, depending on the chosen overload, new Exception(msg), dg() or ex is thrown.

enforce is used to throw exceptions and is therefore intended to aid in error handling. It is not intended for verifying the logic of your program - that is what assert is for.

Do not use enforce inside of contracts (i.e. inside of in and out blocks and invariants), because contracts are compiled out when compiling with -release.

If a delegate is passed, the safety and purity of this function are inferred from Dg's safety and purity.

enforce
(
(local variable) const(ulong) offset
offset
<=
(parameter) const(ubyte)[] bytes
bytes
.
(field) ulong const(ubyte)[].length
length
&&
(local variable) const(ulong) length
length
<=
(parameter) const(ubyte)[] bytes
bytes
.
(field) ulong const(ubyte)[].length
length
-
(local variable) const(ulong) offset
offset
&&
(local variable) const(ulong) length
length
> 0,
"truncated ELF interpreter"); const
(local variable) const(ubyte[]) value
value
=
(parameter) const(ubyte)[] bytes
bytes
[cast(
(alias) object.size_t = ulong
size_t
)
(local variable) const(ulong) offset
offset
.. cast(
(alias) object.size_t = ulong
size_t
) (
(local variable) const(ulong) offset
offset
+
(local variable) const(ulong) length
length
)];
bool std.exception.enforce!().enforce!bool(bool value, lazy const(char)[] msg = null, string file = __FILE__, ulong line = cast(ulong)__LINE__) pure @safe

Enforces that the given value is true. If the given value is false, an exception is thrown. The

  • msg - error message as a string

  • dg - custom delegate that return a string and is only called if an exception occurred

  • ex - custom exception to be thrown. It is lazy and is only created if an exception occurred

@paramvalue The value to test.@paramE Exception type to throw if the value evaluates to false.@parammsg The error message to put in the exception if it is thrown.@paramdg The delegate to be called if the value evaluates to false.@paramex The exception to throw if the value evaluates to false.@paramfile The source file of the caller.@paramline The line number of the caller.@returns

value, if cast(bool) value`` is true. Otherwise, depending on the chosen overload, new Exception(msg), dg() or ex is thrown.

enforce is used to throw exceptions and is therefore intended to aid in error handling. It is not intended for verifying the logic of your program - that is what assert is for.

Do not use enforce inside of contracts (i.e. inside of in and out blocks and invariants), because contracts are compiled out when compiling with -release.

If a delegate is passed, the safety and purity of this function are inferred from Dg's safety and purity.

enforce
(
(local variable) const(ubyte[]) value
value
[$ - 1] == 0, "unterminated ELF interpreter");
return cast(
(alias) object.string = string
string
)
(local variable) const(ubyte[]) value
value
[0 .. $ - 1].
immutable(ubyte)[] object.idup!(const(ubyte))(const(ubyte)[] a) pure nothrow @property @safe

Provide the .idup array property, which creates an immutable duplicate.

idup
;
} return null; } void
void D main(string[] args)
main
(
(alias) object.string = string
string
[]
(parameter) string[] args
args
)
{ const
(local variable) const(string) path
path
=
(parameter) string[] args
args
.
(field) ulong string[].length
length
> 1 ?
(parameter) string[] args
args
[1] : "/proc/self/exe";
const
(local variable) const(string) loader
loader
=
string elf_loader.interpreter(const(ubyte)[] bytes)
interpreter
(cast(ubyte[])
void[] std.file.read!string(string name, ulong upTo = 18446744073709551615LU) @safe

Read entire contents of file name and returns it as an untyped array. If the file size is larger than upTo, only upTo bytes are read.

Examples

import std.utf : byChar;
scope(exit)
{
    assert(exists(deleteme));
    remove(deleteme);
}

std.file.write(deleteme, "1234"); // deleteme is the name of a temporary file
assert(read(deleteme, 2) == "12");
assert(read(deleteme.byChar) == "1234");
assert((cast(const(ubyte)[])read(deleteme)).length == 4);
@paramname string or range of characters representing the file name@paramupTo if present, the maximum number of bytes to read@returnsUntyped array of bytes read.@throwsFileException on error.@seereadText for reading and validating a text file.
read
(
(local variable) const(string) path
path
));
void std.stdio.writeln!(string, string)(string __param_0, string __param_1) @safe

Equivalent to write(args, '\n'). Calling writeln without arguments is valid and just prints a newline to the standard output.

Example

Reads stdin and writes it to stdout with an argument counter.

import std.stdio;

void main()
{
    string line;

    for (size_t count = 0; (line = readln) !is null; count++)
    {
         writeln("Input ", count, ": ", line);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
writeln
("ELF: ",
(local variable) const(string) path
path
);
void std.stdio.writeln!(string, string)(string __param_0, string __param_1) @safe

Equivalent to write(args, '\n'). Calling writeln without arguments is valid and just prints a newline to the standard output.

Example

Reads stdin and writes it to stdout with an argument counter.

import std.stdio;

void main()
{
    string line;

    for (size_t count = 0; (line = readln) !is null; count++)
    {
         writeln("Input ", count, ": ", line);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
writeln
("PT_INTERP: ",
(local variable) const(string) loader
loader
.
(field) ulong const(string).length
length
?
(local variable) const(string) loader
loader
: "none (no dynamic interpreter)");
void std.stdio.writeln!string(string __param_0) @safe

Equivalent to write(args, '\n'). Calling writeln without arguments is valid and just prints a newline to the standard output.

Example

Reads stdin and writes it to stdout with an argument counter.

import std.stdio;

void main()
{
    string line;

    for (size_t count = 0; (line = readln) !is null; count++)
    {
         writeln("Input ", count, ": ", line);
    }
}
@paramargs the items to write to stdout@throwsIn case of an I/O error, throws an StdioException.
writeln
("An ELF's directory does not change its embedded interpreter path.");
}