Rename "libratbag" to just "ratbag"

Naming scheme is now:
* ratbag - the context
* ratbag_device - the device
* ratbag_profile
* ratbag_button
...

Only leftovers of "libratbag" are the header file name, #defines that are
exported through that header file and anything that has to do with the actual
library iself (e.g. the symbol export file).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer
2015-08-19 12:08:39 +10:00
parent b8be026032
commit 44a675534e
9 changed files with 188 additions and 188 deletions

View File

@@ -190,7 +190,7 @@ etekcity_read_profile(struct ratbag_profile *profile, unsigned int index)
if (rc < 50)
return;
log_debug(device->libratbag, "profile: %d %s:%d\n",
log_debug(device->ratbag, "profile: %d %s:%d\n",
buf[2],
__FILE__, __LINE__);
}
@@ -217,7 +217,7 @@ etekcity_read_button(struct ratbag_device *device, struct ratbag_profile *profil
data = drv_data->profiles[profile->index][3 + index * 3];
if (data)
log_debug(device->libratbag,
log_debug(device->ratbag,
" - button%d: %s (%02x) %s:%d\n",
button->index, print_key(data), data, __FILE__, __LINE__);
}
@@ -236,11 +236,11 @@ etekcity_probe(struct ratbag_device *device, const struct ratbag_id id)
struct ratbag_profile *profile;
struct etekcity_data *drv_data;
log_debug(device->libratbag, "data: %d\n", id.data);
log_debug(device->ratbag, "data: %d\n", id.data);
rc = ratbag_open_hidraw(device);
if (rc) {
log_error(device->libratbag,
log_error(device->ratbag,
"Can't open corresponding hidraw node: '%s' (%d)\n",
strerror(-rc),
rc);
@@ -259,7 +259,7 @@ etekcity_probe(struct ratbag_device *device, const struct ratbag_id id)
profile = ratbag_device_get_active_profile(device);
if (!profile) {
log_error(device->libratbag,
log_error(device->ratbag,
"Can't talk to the mouse: '%s' (%d)\n",
strerror(-rc),
rc);
@@ -267,7 +267,7 @@ etekcity_probe(struct ratbag_device *device, const struct ratbag_id id)
goto err;
}
log_info(device->libratbag,
log_info(device->ratbag,
"'%s' is in profile %d\n",
ratbag_device_get_name(device),
profile->index);

View File

@@ -53,7 +53,7 @@ ratbag_open_hidraw(struct ratbag_device *ratbag)
/* Get Raw Info */
res = ioctl(fd, HIDIOCGRAWINFO, &info);
if (res < 0) {
log_error(ratbag->libratbag,
log_error(ratbag->ratbag,
"error while getting info from device");
goto err;
}

View File

@@ -39,16 +39,16 @@
struct ratbag_driver;
struct libratbag {
const struct libratbag_interface *interface;
struct ratbag {
const struct ratbag_interface *interface;
void *userdata;
struct udev *udev;
struct list drivers;
int refcount;
libratbag_log_handler log_handler;
enum libratbag_log_priority log_priority;
ratbag_log_handler log_handler;
enum ratbag_log_priority log_priority;
};
struct ratbag_device {
@@ -59,7 +59,7 @@ struct ratbag_device {
int refcount;
struct input_id ids;
struct ratbag_driver *driver;
struct libratbag *libratbag;
struct ratbag *ratbag;
unsigned num_profiles;
struct list profiles;
@@ -117,17 +117,17 @@ struct ratbag_button {
static inline int
ratbag_open_path(struct ratbag_device *device, const char *path, int flags)
{
struct libratbag *libratbag = device->libratbag;
struct ratbag *ratbag = device->ratbag;
return libratbag->interface->open_restricted(path, flags, libratbag->userdata);
return ratbag->interface->open_restricted(path, flags, ratbag->userdata);
}
static inline void
ratbag_close_fd(struct ratbag_device *device, int fd)
{
struct libratbag *libratbag = device->libratbag;
struct ratbag *ratbag = device->ratbag;
return libratbag->interface->close_restricted(fd, libratbag->userdata);
return ratbag->interface->close_restricted(fd, ratbag->userdata);
}
static inline void
@@ -156,19 +156,19 @@ ratbag_profile_get_drv_data(struct ratbag_profile *profile)
void
log_msg_va(struct libratbag *libratbag,
enum libratbag_log_priority priority,
log_msg_va(struct ratbag *ratbag,
enum ratbag_log_priority priority,
const char *format,
va_list args);
void log_msg(struct libratbag *libratbag,
enum libratbag_log_priority priority,
void log_msg(struct ratbag *ratbag,
enum ratbag_log_priority priority,
const char *format, ...);
#define log_debug(li_, ...) log_msg((li_), LIBRATBAG_LOG_PRIORITY_DEBUG, __VA_ARGS__)
#define log_info(li_, ...) log_msg((li_), LIBRATBAG_LOG_PRIORITY_INFO, __VA_ARGS__)
#define log_error(li_, ...) log_msg((li_), LIBRATBAG_LOG_PRIORITY_ERROR, __VA_ARGS__)
#define log_bug_kernel(li_, ...) log_msg((li_), LIBRATBAG_LOG_PRIORITY_ERROR, "kernel bug: " __VA_ARGS__)
#define log_bug_libratbag(li_, ...) log_msg((li_), LIBRATBAG_LOG_PRIORITY_ERROR, "libratbag bug: " __VA_ARGS__)
#define log_debug(li_, ...) log_msg((li_), RATBAG_LOG_PRIORITY_DEBUG, __VA_ARGS__)
#define log_info(li_, ...) log_msg((li_), RATBAG_LOG_PRIORITY_INFO, __VA_ARGS__)
#define log_error(li_, ...) log_msg((li_), RATBAG_LOG_PRIORITY_ERROR, __VA_ARGS__)
#define log_bug_kernel(li_, ...) log_msg((li_), RATBAG_LOG_PRIORITY_ERROR, "kernel bug: " __VA_ARGS__)
#define log_bug_libratbag(li_, ...) log_msg((li_), RATBAG_LOG_PRIORITY_ERROR, "libratbag bug: " __VA_ARGS__)
#define log_bug_client(li_, ...) log_msg((li_), LIBRATBAG_LOG_PRIORITY_ERROR, "client bug: " __VA_ARGS__)
/* list of all supported drivers */

View File

@@ -35,81 +35,81 @@
#include "libratbag-util.h"
static void
libratbag_default_log_func(struct libratbag *libratbag,
enum libratbag_log_priority priority,
const char *format, va_list args)
ratbag_default_log_func(struct ratbag *ratbag,
enum ratbag_log_priority priority,
const char *format, va_list args)
{
const char *prefix;
switch(priority) {
case LIBRATBAG_LOG_PRIORITY_DEBUG: prefix = "debug"; break;
case LIBRATBAG_LOG_PRIORITY_INFO: prefix = "info"; break;
case LIBRATBAG_LOG_PRIORITY_ERROR: prefix = "error"; break;
case RATBAG_LOG_PRIORITY_DEBUG: prefix = "debug"; break;
case RATBAG_LOG_PRIORITY_INFO: prefix = "info"; break;
case RATBAG_LOG_PRIORITY_ERROR: prefix = "error"; break;
default: prefix="<invalid priority>"; break;
}
fprintf(stderr, "libratbag %s: ", prefix);
fprintf(stderr, "ratbag %s: ", prefix);
vfprintf(stderr, format, args);
}
void
log_msg_va(struct libratbag *libratbag,
enum libratbag_log_priority priority,
log_msg_va(struct ratbag *ratbag,
enum ratbag_log_priority priority,
const char *format,
va_list args)
{
if (libratbag->log_handler &&
libratbag->log_priority <= priority)
libratbag->log_handler(libratbag, priority, format, args);
if (ratbag->log_handler &&
ratbag->log_priority <= priority)
ratbag->log_handler(ratbag, priority, format, args);
}
void
log_msg(struct libratbag *libratbag,
enum libratbag_log_priority priority,
log_msg(struct ratbag *ratbag,
enum ratbag_log_priority priority,
const char *format, ...)
{
va_list args;
va_start(args, format);
log_msg_va(libratbag, priority, format, args);
log_msg_va(ratbag, priority, format, args);
va_end(args);
}
LIBRATBAG_EXPORT void
libratbag_log_set_priority(struct libratbag *libratbag,
enum libratbag_log_priority priority)
ratbag_log_set_priority(struct ratbag *ratbag,
enum ratbag_log_priority priority)
{
libratbag->log_priority = priority;
ratbag->log_priority = priority;
}
LIBRATBAG_EXPORT enum libratbag_log_priority
libratbag_log_get_priority(const struct libratbag *libratbag)
LIBRATBAG_EXPORT enum ratbag_log_priority
ratbag_log_get_priority(const struct ratbag *ratbag)
{
return libratbag->log_priority;
return ratbag->log_priority;
}
LIBRATBAG_EXPORT void
libratbag_log_set_handler(struct libratbag *libratbag,
libratbag_log_handler log_handler)
ratbag_log_set_handler(struct ratbag *ratbag,
ratbag_log_handler log_handler)
{
libratbag->log_handler = log_handler;
ratbag->log_handler = log_handler;
}
static inline struct udev_device *
udev_device_from_devnode(struct libratbag *libratbag,
udev_device_from_devnode(struct ratbag *ratbag,
struct ratbag_device *device,
int fd)
{
struct udev_device *dev;
struct stat st;
size_t count = 0;
struct udev *udev = libratbag->udev;
struct udev *udev = ratbag->udev;
if (fstat(fd, &st) < 0)
return NULL;
dev = udev_device_new_from_devnum(libratbag->udev, 'c', st.st_rdev);
dev = udev_device_new_from_devnum(ratbag->udev, 'c', st.st_rdev);
while (dev && !udev_device_get_is_initialized(dev)) {
udev_device_unref(dev);
@@ -118,7 +118,7 @@ udev_device_from_devnode(struct libratbag *libratbag,
count++;
if (count > 50) {
log_bug_libratbag(libratbag,
log_bug_libratbag(ratbag,
"udev device never initialized\n");
break;
}
@@ -128,7 +128,7 @@ udev_device_from_devnode(struct libratbag *libratbag,
}
static struct udev_device *
udev_find_hidraw(struct libratbag *libratbag, struct ratbag_device *device)
udev_find_hidraw(struct ratbag *ratbag, struct ratbag_device *device)
{
struct udev_enumerate *e;
struct udev_list_entry *entry;
@@ -136,7 +136,7 @@ udev_find_hidraw(struct libratbag *libratbag, struct ratbag_device *device)
const char *path, *sysname;
struct udev_device *hid_udev;
struct udev_device *hidraw_udev = NULL;
struct udev *udev = libratbag->udev;
struct udev *udev = ratbag->udev;
hid_udev = udev_device_get_parent_with_subsystem_devtype(device->udev_device, "hid", NULL);
@@ -169,7 +169,7 @@ out:
}
static int
ratbag_device_init_udev(struct libratbag *libratbag, struct ratbag_device *device,
ratbag_device_init_udev(struct ratbag *ratbag, struct ratbag_device *device,
struct udev_device *udev_device)
{
struct udev_device *hidraw_udev;
@@ -177,13 +177,13 @@ ratbag_device_init_udev(struct libratbag *libratbag, struct ratbag_device *devic
device->udev_device = udev_device_ref(udev_device);
hidraw_udev = udev_find_hidraw(libratbag, device);
hidraw_udev = udev_find_hidraw(ratbag, device);
if (!hidraw_udev)
goto out;
device->udev_hidraw = udev_device_ref(hidraw_udev);
log_debug(libratbag,
log_debug(ratbag,
"%s is associated to '%s'.\n",
udev_device_get_devnode(device->udev_hidraw),
device->name);
@@ -212,7 +212,7 @@ ratbag_match_id(const struct input_id *dev_id, const struct input_id *match_id)
}
static struct ratbag_driver *
ratbag_find_driver(struct libratbag *libratbag, struct ratbag_device *device,
ratbag_find_driver(struct ratbag *ratbag, struct ratbag_device *device,
const struct input_id *dev_id)
{
struct ratbag_driver *driver;
@@ -220,8 +220,8 @@ ratbag_find_driver(struct libratbag *libratbag, struct ratbag_device *device,
struct ratbag_id matched_id;
int rc;
list_for_each(driver, &libratbag->drivers, link) {
log_debug(libratbag, "testing against %s\n", driver->name);
list_for_each(driver, &ratbag->drivers, link) {
log_debug(ratbag, "testing against %s\n", driver->name);
matching_id = driver->table_ids;
do {
if (ratbag_match_id(dev_id, &matching_id->id)) {
@@ -282,15 +282,15 @@ get_product_id(struct udev_device *device, struct input_id *id)
}
LIBRATBAG_EXPORT struct ratbag_device*
ratbag_device_new_from_udev_device(struct libratbag *libratbag,
ratbag_device_new_from_udev_device(struct ratbag *ratbag,
struct udev_device *udev_device)
{
int rc;
struct ratbag_device *device = NULL;
struct ratbag_driver *driver;
if (!libratbag) {
fprintf(stderr, "libratbag is NULL\n");
if (!ratbag) {
fprintf(stderr, "ratbag is NULL\n");
return NULL;
}
@@ -298,7 +298,7 @@ ratbag_device_new_from_udev_device(struct libratbag *libratbag,
if (!device)
return NULL;
device->libratbag = libratbag_ref(libratbag);
device->ratbag = ratbag_ref(ratbag);
if (get_product_id(udev_device, &device->ids) != 0)
goto out_err;
free(device->name);
@@ -309,11 +309,11 @@ ratbag_device_new_from_udev_device(struct libratbag *libratbag,
}
ratbag_device_init(device);
rc = ratbag_device_init_udev(libratbag, device, udev_device);
rc = ratbag_device_init_udev(ratbag, device, udev_device);
if (rc)
goto out_err;
driver = ratbag_find_driver(libratbag, device, &device->ids);
driver = ratbag_find_driver(ratbag, device, &device->ids);
if (!driver) {
errno = ENOTSUP;
goto err_udev;
@@ -327,7 +327,7 @@ err_udev:
out_err:
if (device) {
free(device->name);
device->libratbag = libratbag_unref(device->libratbag);
device->ratbag = ratbag_unref(device->ratbag);
}
free(device);
return NULL;
@@ -353,7 +353,7 @@ ratbag_device_unref(struct ratbag_device *device)
if (device->hidraw_fd >= 0)
close(device->hidraw_fd);
device->libratbag = libratbag_unref(device->libratbag);
device->ratbag = ratbag_unref(device->ratbag);
free(device->name);
free(device);
return NULL;
@@ -366,65 +366,65 @@ ratbag_device_get_name(const struct ratbag_device* device)
}
static void
ratbag_register_driver(struct libratbag *libratbag, struct ratbag_driver *driver)
ratbag_register_driver(struct ratbag *ratbag, struct ratbag_driver *driver)
{
list_insert(&libratbag->drivers, &driver->link);
list_insert(&ratbag->drivers, &driver->link);
}
LIBRATBAG_EXPORT struct libratbag *
libratbag_create_context(const struct libratbag_interface *interface,
LIBRATBAG_EXPORT struct ratbag *
ratbag_create_context(const struct ratbag_interface *interface,
void *userdata)
{
struct libratbag *libratbag;
struct ratbag *ratbag;
if (interface == NULL ||
interface->open_restricted == NULL ||
interface->close_restricted == NULL)
return NULL;
libratbag = zalloc(sizeof(*libratbag));
if (!libratbag)
ratbag = zalloc(sizeof(*ratbag));
if (!ratbag)
return NULL;
libratbag->refcount = 1;
libratbag->interface = interface;
libratbag->userdata = userdata;
ratbag->refcount = 1;
ratbag->interface = interface;
ratbag->userdata = userdata;
list_init(&libratbag->drivers);
libratbag->udev = udev_new();
if (!libratbag->udev) {
free(libratbag);
list_init(&ratbag->drivers);
ratbag->udev = udev_new();
if (!ratbag->udev) {
free(ratbag);
return NULL;
}
libratbag->log_handler = libratbag_default_log_func;
libratbag->log_priority = LIBRATBAG_LOG_PRIORITY_DEBUG;
ratbag->log_handler = ratbag_default_log_func;
ratbag->log_priority = RATBAG_LOG_PRIORITY_DEBUG;
ratbag_register_driver(libratbag, &etekcity_driver);
ratbag_register_driver(ratbag, &etekcity_driver);
return libratbag;
return ratbag;
}
LIBRATBAG_EXPORT struct libratbag *
libratbag_ref(struct libratbag *libratbag)
LIBRATBAG_EXPORT struct ratbag *
ratbag_ref(struct ratbag *ratbag)
{
libratbag->refcount++;
return libratbag;
ratbag->refcount++;
return ratbag;
}
LIBRATBAG_EXPORT struct libratbag *
libratbag_unref(struct libratbag *libratbag)
LIBRATBAG_EXPORT struct ratbag *
ratbag_unref(struct ratbag *ratbag)
{
if (libratbag == NULL)
if (ratbag == NULL)
return NULL;
assert(libratbag->refcount > 0);
libratbag->refcount--;
if (libratbag->refcount > 0)
return libratbag;
assert(ratbag->refcount > 0);
ratbag->refcount--;
if (ratbag->refcount > 0)
return ratbag;
libratbag->udev = udev_unref(libratbag->udev);
free(libratbag);
ratbag->udev = udev_unref(ratbag->udev);
free(ratbag);
return NULL;
}

View File

@@ -41,43 +41,43 @@ extern "C" {
*
* Log priority for internal logging messages.
*/
enum libratbag_log_priority {
LIBRATBAG_LOG_PRIORITY_DEBUG = 10,
LIBRATBAG_LOG_PRIORITY_INFO = 20,
LIBRATBAG_LOG_PRIORITY_ERROR = 30,
enum ratbag_log_priority {
RATBAG_LOG_PRIORITY_DEBUG = 10,
RATBAG_LOG_PRIORITY_INFO = 20,
RATBAG_LOG_PRIORITY_ERROR = 30,
};
/**
* @ingroup base
* @struct libratbag
* @struct ratbag
*
* A handle for accessing libratbag. This struct is refcounted, use
* libratbag_ref() and libratbag_unref().
* A handle for accessing ratbag contexts. This struct is refcounted, use
* ratbag_ref() and ratbag_unref().
*/
struct libratbag;
struct ratbag;
/**
* @ingroup base
*
* Log handler type for custom logging.
*
* @param libratbag The libratbag context
* @param ratbag The ratbag context
* @param priority The priority of the current message
* @param format Message format in printf-style
* @param args Message arguments
*
* @see libratbag_log_set_priority
* @see libratbag_log_get_priority
* @see libratbag_log_set_handler
* @see ratbag_log_set_priority
* @see ratbag_log_get_priority
* @see ratbag_log_set_handler
*/
typedef void (*libratbag_log_handler)(struct libratbag *libratbag,
enum libratbag_log_priority priority,
typedef void (*ratbag_log_handler)(struct ratbag *ratbag,
enum ratbag_log_priority priority,
const char *format, va_list args)
LIBRATBAG_ATTRIBUTE_PRINTF(3, 0);
/**
* @defgroup base Initialization and manipulation of libratbag contexts
* @defgroup base Initialization and manipulation of ratbag contexts
* @defgroup device Querying and manipulating devices
*
* Device configuration is managed by "profiles" (see @ref ratbag_profile).
@@ -136,15 +136,15 @@ struct ratbag_button;
/**
* @ingroup base
* @struct libratbag_interface
* @struct ratbag_interface
*
* libratbag does not open file descriptors to devices directly, instead
* open_restricted() and close_restricted() are called for each path that
* must be opened.
*
* @see libratbag_create_context
* @see ratbag_create_context
*/
struct libratbag_interface {
struct ratbag_interface {
/**
* Open the device at the given path with the flags provided and
* return the fd.
@@ -152,7 +152,7 @@ struct libratbag_interface {
* @param path The device path to open
* @param flags Flags as defined by open(2)
* @param user_data The user_data provided in
* libratbag_create_context()
* ratbag_create_context()
*
* @return The file descriptor, or a negative errno on failure.
*/
@@ -162,7 +162,7 @@ struct libratbag_interface {
*
* @param fd The file descriptor to close
* @param user_data The user_data provided in
* libratbag_create_context()
* ratbag_create_context()
*/
void (*close_restricted)(int fd, void *user_data);
};
@@ -170,38 +170,38 @@ struct libratbag_interface {
/**
* @ingroup base
*
* Create a new libratbag context.
* Create a new ratbag context.
*
* @return An initialized libratbag context or NULL on error
* @return An initialized ratbag context or NULL on error
*/
struct libratbag *
libratbag_create_context(const struct libratbag_interface *interface,
struct ratbag *
ratbag_create_context(const struct ratbag_interface *interface,
void *userdata);
/**
* @ingroup base
*
* Add a reference to the context. A context is destroyed whenever the
* reference count reaches 0. See @ref libratbag_unref.
* reference count reaches 0. See @ref ratbag_unref.
*
* @param libratbag A previously initialized valid libratbag context
* @return The passed libratbag context
* @param ratbag A previously initialized valid ratbag context
* @return The passed ratbag context
*/
struct libratbag *
libratbag_ref(struct libratbag *libratbag);
struct ratbag *
ratbag_ref(struct ratbag *ratbag);
/**
* @ingroup base
*
* Dereference the libratbag context. After this, the context may have been
* Dereference the ratbag context. After this, the context may have been
* destroyed, if the last reference was dereferenced. If so, the context is
* invalid and may not be interacted with.
*
* @param libratbag A previously initialized libratbag context
* @param ratbag A previously initialized ratbag context
* @return NULL if context was destroyed otherwise the passed context
*/
struct libratbag *
libratbag_unref(struct libratbag *libratbag);
struct ratbag *
ratbag_unref(struct ratbag *ratbag);
/**
* @ingroup base
@@ -209,7 +209,7 @@ libratbag_unref(struct libratbag *libratbag);
* Create a new ratbag context from the given udev device.
*/
struct ratbag_device*
ratbag_device_new_from_udev_device(struct libratbag *libratbag,
ratbag_device_new_from_udev_device(struct ratbag *ratbag,
struct udev_device *device);
/**
@@ -702,17 +702,17 @@ ratbag_device_unref(struct ratbag_device *ratbag);
* equal to or higher than the argument will be printed to the context's
* log handler.
*
* The default log priority is @ref LIBRATBAG_LOG_PRIORITY_ERROR.
* The default log priority is @ref RATBAG_LOG_PRIORITY_ERROR.
*
* @param libratbag A previously initialized ratbag context
* @param ratbag A previously initialized ratbag context
* @param priority The minimum priority of log messages to print.
*
* @see libratbag_log_set_handler
* @see libratbag_log_get_priority
* @see ratbag_log_set_handler
* @see ratbag_log_get_priority
*/
void
libratbag_log_set_priority(struct libratbag *libratbag,
enum libratbag_log_priority priority);
ratbag_log_set_priority(struct ratbag *ratbag,
enum ratbag_log_priority priority);
/**
* @ingroup base
@@ -720,16 +720,16 @@ libratbag_log_set_priority(struct libratbag *libratbag,
* Get the context's log priority. Messages with priorities equal to or
* higher than the argument will be printed to the current log handler.
*
* The default log priority is @ref LIBRATBAG_LOG_PRIORITY_ERROR.
* The default log priority is @ref RATBAG_LOG_PRIORITY_ERROR.
*
* @param libratbag A previously initialized libratbag context
* @param ratbag A previously initialized ratbag context
* @return The minimum priority of log messages to print.
*
* @see libratbag_log_set_handler
* @see libratbag_log_set_priority
* @see ratbag_log_set_handler
* @see ratbag_log_set_priority
*/
enum libratbag_log_priority
libratbag_log_get_priority(const struct libratbag *libratbag);
enum ratbag_log_priority
ratbag_log_get_priority(const struct ratbag *ratbag);
/**
* @ingroup base
@@ -740,15 +740,15 @@ libratbag_log_get_priority(const struct libratbag *libratbag);
*
* The default log handler prints to stderr.
*
* @param libratbag A previously initialized libratbag context
* @param ratbag A previously initialized ratbag context
* @param log_handler The log handler for library messages.
*
* @see libratbag_log_set_priority
* @see libratbag_log_get_priority
* @see ratbag_log_set_priority
* @see ratbag_log_get_priority
*/
void
libratbag_log_set_handler(struct libratbag *libratbag,
libratbag_log_handler log_handler);
ratbag_log_set_handler(struct ratbag *ratbag,
ratbag_log_handler log_handler);
#ifdef __cplusplus
}

View File

@@ -2,15 +2,10 @@
LIBRATBAG_0.1.0 {
global:
libratbag_create_context;
libratbag_ref;
libratbag_unref;
libratbag_log_get_priority;
libratbag_log_set_handler;
libratbag_log_set_priority;
ratbag_create_context;
ratbag_button_ref;
ratbag_button_unref;
ratbag_profile_get_button_by_index;
ratbag_device_unref;
ratbag_device_get_active_profile;
ratbag_device_get_name;
ratbag_device_get_num_profiles;
@@ -19,9 +14,14 @@ global:
ratbag_device_has_capability;
ratbag_device_new_from_udev_device;
ratbag_device_set_active_profile;
ratbag_log_get_priority;
ratbag_log_set_handler;
ratbag_log_set_priority;
ratbag_profile_get_button_by_index;
ratbag_profile_ref;
ratbag_profile_unref;
ratbag_device_unref;
ratbag_ref;
ratbag_unref;
local:
*;
};

View File

@@ -10,8 +10,8 @@ cd `dirname $0`
diff -a -u \
<(cat @top_srcdir@/src/libratbag.sym | \
grep '^\s\+libratbag_.*' | \
grep '^\s\+ratbag_.*' | \
sed -e 's/^\s\+\(.*\);/\1/' | sort) \
<(cat @top_srcdir@/src/*.c | \
grep LIBRATBAG_EXPORT -A 1 | grep '^libratbag_.*' | \
grep LIBRATBAG_EXPORT -A 1 | grep '^ratbag_.*' | \
sed -e 's/(.*//' | sort)

View File

@@ -50,66 +50,66 @@ close_restricted(int fd, void *user_data)
close(fd);
}
struct libratbag_interface simple_iface = {
struct ratbag_interface simple_iface = {
.open_restricted = open_restricted,
.close_restricted = close_restricted,
};
START_TEST(context_init_NULL)
{
struct libratbag *lr;
lr = libratbag_create_context(NULL, NULL);
struct ratbag *lr;
lr = ratbag_create_context(NULL, NULL);
ck_assert(lr == NULL);
}
END_TEST
START_TEST(context_init_bad_iface)
{
struct libratbag *lr;
struct libratbag_interface iface = {
struct ratbag *lr;
struct ratbag_interface iface = {
.open_restricted = NULL,
.close_restricted = NULL,
};
lr = libratbag_create_context(&iface, NULL);
lr = ratbag_create_context(&iface, NULL);
ck_assert(lr == NULL);
iface.open_restricted = open_restricted;
lr = libratbag_create_context(&iface, NULL);
lr = ratbag_create_context(&iface, NULL);
ck_assert(lr == NULL);
iface.open_restricted = NULL;
iface.close_restricted = close_restricted;
lr = libratbag_create_context(&iface, NULL);
lr = ratbag_create_context(&iface, NULL);
ck_assert(lr == NULL);
}
END_TEST
START_TEST(context_init)
{
struct libratbag *lr;
struct ratbag *lr;
lr = libratbag_create_context(&simple_iface, NULL);
lr = ratbag_create_context(&simple_iface, NULL);
ck_assert(lr != NULL);
libratbag_unref(lr);
ratbag_unref(lr);
}
END_TEST
START_TEST(context_ref)
{
struct libratbag *lr;
struct libratbag *lr2;
struct ratbag *lr;
struct ratbag *lr2;
lr = libratbag_create_context(&simple_iface, NULL);
lr = ratbag_create_context(&simple_iface, NULL);
ck_assert(lr != NULL);
lr2 = libratbag_ref(lr);
lr2 = ratbag_ref(lr);
ck_assert_ptr_eq(lr, lr2);
lr2 = libratbag_unref(lr2);
lr2 = ratbag_unref(lr2);
ck_assert_ptr_eq(lr2, lr);
lr2 = libratbag_unref(lr2);
lr2 = ratbag_unref(lr2);
ck_assert_ptr_eq(lr2, NULL);
}
END_TEST

View File

@@ -84,7 +84,7 @@ udev_device_from_path(struct udev *udev, const char *path)
}
static int
ratbag_cmd_info(struct libratbag *libratbag, uint32_t flags, int argc, char **argv)
ratbag_cmd_info(struct ratbag *ratbag, uint32_t flags, int argc, char **argv)
{
const char *path;
struct ratbag_device *rb;
@@ -107,7 +107,7 @@ ratbag_cmd_info(struct libratbag *libratbag, uint32_t flags, int argc, char **ar
if (!udev_device)
return 1;
rb = ratbag_device_new_from_udev_device(libratbag, udev_device);
rb = ratbag_device_new_from_udev_device(ratbag, udev_device);
if (!rb) {
fprintf(stderr, "Looks like '%s' is not supported\n", path);
goto out;
@@ -136,7 +136,7 @@ out:
struct ratbag_cmd {
const char *name;
int (*cmd)(struct libratbag *libratbag, uint32_t flags, int argc, char **argv);
int (*cmd)(struct ratbag *ratbag, uint32_t flags, int argc, char **argv);
};
const struct ratbag_cmd cmd_info = {
@@ -166,7 +166,7 @@ close_restricted(int fd, void *user_data)
close(fd);
}
const struct libratbag_interface interface = {
const struct ratbag_interface interface = {
.open_restricted = open_restricted,
.close_restricted = close_restricted,
};
@@ -174,15 +174,15 @@ const struct libratbag_interface interface = {
int
main(int argc, char **argv)
{
struct libratbag *libratbag;
struct ratbag *ratbag;
const char *command;
int rc = 0;
const struct ratbag_cmd **cmd;
uint32_t flags = 0;
libratbag = libratbag_create_context(&interface, NULL);
if (!libratbag) {
fprintf(stderr, "Can't initialize libratbag\n");
ratbag = ratbag_create_context(&interface, NULL);
if (!ratbag) {
fprintf(stderr, "Can't initialize ratbag\n");
goto out;
}
@@ -227,12 +227,12 @@ main(int argc, char **argv)
/* reset optind to reset the internal state, see NOTES in
* getopt(3) */
optind = 0;
rc = (*cmd)->cmd(libratbag, flags, argc, argv);
rc = (*cmd)->cmd(ratbag, flags, argc, argv);
break;
}
out:
libratbag_unref(libratbag);
ratbag_unref(ratbag);
return rc;
}