---
name: "rapi_connection_from_name"
section: "3"
platform: "linux"
package: "librapi2-dev"
version: "0.15-2.1"
release: "Debian 7 (Wheezy)"
platforms: ["linux"]
url: "https://new.carta.tech/rapi_connection_from_name"
---

# rapi\_connection\_from\_name(3)

obtain connection for RAPI function calls

## NAME

rapi\_connection\_from\_name - obtain connection for RAPI function calls

## SYNOPSIS

```
#include <rapi.h>

RapiConnection *rapi_connection_from_name(const char *device_name);

RapiConnection *rapi_connection_from_info(SynceInfo *info);

void rapi_connection_select(RapiConnection *connection);

void rapi_connection_destroy(RapiConnection *connection);

HRESULT CeRapiInit();

STDAPI CeRapiUninit();
```

## DESCRIPTION

The **rapi\_connection\_from\_info**() function returns a pointer to a newly allocated RapiConnection struct, used for remote function calls to a mobile device. The RapiConnection keeps a pointer to the SynceInfo struct but does not copy it, therefore freeing the SynceInfo before the RapiConnection is not recommended.

**rapi\_connection\_from\_name**() accomplishes the same for the connected device named **device\_name.** Refer to **[synce\_info\_new(3)](/synce_info_new/3.md)** for insight on how this name and the connection daemon in use can affect the device contacted.

**rapi\_connection\_select**() allows for selection between multiple active connections. NULL can be passed to result in no active connection.

**rapi\_connection\_destroy**() frees a RapiConnection. This should not be called before CeRapiUninit().

**CeRapiInit**() connects the current RapiConnection to it's mobile device. If already initialised, CERAPI\_E\_ALREADYINITIALIZED is returned.

**CeRapiUninit**() destroys the connection for the current RapiConnection. The RapiConnection cannot be re-initialised, it must be destroyed.

An example of using multiple devices follows.

```
/*
 * SynCE support for switching between multiple devices
 *
 * Example code for two devices follows!
 *
 * It shows two different ways to get a RapiConnection object.
 *
 */
RapiConnection* a = rapi_connection_from_name("device_a");
rapi_connection_select(a);
CeRapiInit()
SynceInfo* info_b = synce_info_new("device_b");
RapiConnection* b = rapi_connection_from_info(info_b);
rapi_connection_select(b);
CeRapiInit()
rapi_connection_select(a);
 ...some RAPI calls to device A...
rapi_connection_select(b);
 ...some RAPI calls to device B...
rapi_connection_select(a);
CeRapiUninit();
rapi_connection_destroy(a);
rapi_connection_select(b);
CeRapiUninit();
rapi_connection_destroy(b);
synce_info_destroy(info_b);
```

## RETURN VALUE

**rapi\_connection\_from\_name**() and **rapi\_connection\_from\_info**() return a pointer to a new RapiConnection.

**CeRapiInit()** and **CeRapiUninit()** return S\_OK on success or an error code on failure.

## AUTHOR

This manual page was written by Mark Ellis \<mark\_ellis@users.sourceforge.net\>.

## SEE ALSO

[**synce**(7)](/synce/7.md), [**synce\_info\_new**(3)](/synce_info_new/3.md), [**odccm**(1)](/odccm/1.md), [**vdccm**(1)](/vdccm/1.md)
