# _CP_logon

_CP_logon logs in to D3 from a C main
program. This function must be called prior to any other function.
This function returns -1 if an error occurs. The error code is contained
in _CP_errno.

## Syntax

```
int _CP_logon(CPSTR* machine, CPSTR* user, CPSTR* u_passwd, CPSTR* md,
CPSTR* md_passwd, int pib, int flags);
```

## Parameter(s)

| machine | D3 virtual machine. |
| --- | --- |
| user | D3 user. |
| u_passwd | D3 user password. |
| md | D3 master dictionary. |
| md_passwd | D3 master dictionary password. |
| pib | Requested PIB or -1 for first available. |
| flags | Reserved field - always pass a 0. |

## Example(s)

The example above logs in to
D3 as the dm user in the dm account. It assumes that no passwords
are present.

```
CPSTR * machine = _CP_mkstr("pick0");
CPSTR * user = _CP_mkstr("dm");
CPSTR * md = _CP_mkstr("dm");
int r;

r=_CP_logon(machine,user,_CP_str_null,md,_CP_str_null,-1,0);
```

## See also

- [C functions overview](https://d3codex.com/cfunctions/c-functions-overview/)

---
Source: https://d3codex.com/cfunctions/cp-logon/ - part of the D3Codex reference.
