-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Format C code using clang-format, add .clang-format file to the project
Changelog: none Signed-off-by: Fabio Tranchitella <fabio.tranchitella@northern.tech>
- Loading branch information
1 parent
a4f6d8a
commit 6a0b990
Showing
3 changed files
with
79 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
BasedOnStyle: Google | ||
Language: Cpp | ||
ColumnLimit: 78 | ||
IndentWidth: 4 | ||
TabWidth: 4 | ||
UseTab: Never | ||
MaxEmptyLinesToKeep: 3 | ||
AlignTrailingComments: true | ||
SpacesBeforeTrailingComments: 1 | ||
SortIncludes: false | ||
DerivePointerAlignment: false | ||
PointerAlignment: Right | ||
AlignConsecutiveAssignments: false | ||
AlignConsecutiveDeclarations: false | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeParens: ControlStatements | ||
BreakStringLiterals: false | ||
BinPackArguments: false | ||
BinPackParameters: false | ||
AlignAfterOpenBracket: AlwaysBreak | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
IndentCaseLabels: false | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortIfStatementsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: None | ||
BreakBeforeBraces: Allman |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,85 @@ | ||
// exported by golang, see dbus_libgio.go | ||
GVariant * | ||
handle_method_call_callback(gchar *objectPath, | ||
gchar *interfaceName, | ||
gchar *methodName); | ||
GVariant *handle_method_call_callback( | ||
gchar *objectPath, gchar *interfaceName, gchar *methodName); | ||
|
||
// convert an unsafe pointer to a GDBusConnection structure | ||
static GDBusConnection* | ||
to_gdbusconnection(void* ptr) | ||
static GDBusConnection *to_gdbusconnection(void *ptr) | ||
{ | ||
return (GDBusConnection*)ptr; | ||
return (GDBusConnection *)ptr; | ||
} | ||
|
||
// convert an unsafe pointer to a GMainLoop structure | ||
static GMainLoop* | ||
to_gmainloop(void* ptr) | ||
static GMainLoop *to_gmainloop(void *ptr) | ||
{ | ||
return (GMainLoop*)ptr; | ||
return (GMainLoop *)ptr; | ||
} | ||
|
||
// create a new GVariant from a string value | ||
static GVariant *g_variant_new_from_string(gchar *value) | ||
{ | ||
return g_variant_new("(s)", value); | ||
return g_variant_new("(s)", value); | ||
} | ||
|
||
// create a new GVariant from a boolean valule | ||
static GVariant *g_variant_new_from_boolean(gboolean value) | ||
{ | ||
return g_variant_new("(b)", value); | ||
return g_variant_new("(b)", value); | ||
} | ||
|
||
// handle method call events on registered objects | ||
static void | ||
handle_method_call (GDBusConnection *connection, | ||
const gchar *sender, | ||
const gchar *object_path, | ||
const gchar *interface_name, | ||
const gchar *method_name, | ||
GVariant *parameters, | ||
GDBusMethodInvocation *invocation, | ||
gpointer user_data) | ||
static void handle_method_call( | ||
GDBusConnection *connection, | ||
const gchar *sender, | ||
const gchar *object_path, | ||
const gchar *interface_name, | ||
const gchar *method_name, | ||
GVariant *parameters, | ||
GDBusMethodInvocation *invocation, | ||
gpointer user_data) | ||
{ | ||
GVariant *response = handle_method_call_callback((char *)object_path, | ||
(char *)interface_name, | ||
(char *)method_name); | ||
if (response != NULL) { | ||
g_dbus_method_invocation_return_value(invocation, response); | ||
} | ||
GVariant *response = handle_method_call_callback( | ||
(char *)object_path, (char *)interface_name, (char *)method_name); | ||
if (response != NULL) | ||
{ | ||
g_dbus_method_invocation_return_value(invocation, response); | ||
} | ||
} | ||
|
||
// handle get property events on registered objects | ||
static GVariant * | ||
handle_get_property (GDBusConnection *connection, | ||
const gchar *sender, | ||
const gchar *object_path, | ||
const gchar *interface_name, | ||
const gchar *property_name, | ||
GError **error, | ||
gpointer user_data) | ||
static GVariant *handle_get_property( | ||
GDBusConnection *connection, | ||
const gchar *sender, | ||
const gchar *object_path, | ||
const gchar *interface_name, | ||
const gchar *property_name, | ||
GError **error, | ||
gpointer user_data) | ||
{ | ||
return NULL; | ||
return NULL; | ||
} | ||
|
||
// handle set property events on registered objects | ||
static gboolean | ||
handle_set_property (GDBusConnection *connection, | ||
const gchar *sender, | ||
const gchar *object_path, | ||
const gchar *interface_name, | ||
const gchar *property_name, | ||
GVariant *value, | ||
GError **error, | ||
gpointer user_data) | ||
static gboolean handle_set_property( | ||
GDBusConnection *connection, | ||
const gchar *sender, | ||
const gchar *object_path, | ||
const gchar *interface_name, | ||
const gchar *property_name, | ||
GVariant *value, | ||
GError **error, | ||
gpointer user_data) | ||
{ | ||
return FALSE; | ||
return FALSE; | ||
} | ||
|
||
// global static interface vtable to hook the call method, get and set property callbacks | ||
static GDBusInterfaceVTable interface_vtable = | ||
{ | ||
handle_method_call, | ||
handle_get_property, | ||
handle_set_property | ||
}; | ||
// global static interface vtable to hook the call method, get and set | ||
// property callbacks | ||
static GDBusInterfaceVTable interface_vtable = { | ||
handle_method_call, handle_get_property, handle_set_property}; | ||
|
||
// return the static interface vtable above, as golang cannot access statics from C | ||
static GDBusInterfaceVTable * | ||
get_interface_vtable() | ||
// return the static interface vtable above, as golang cannot access statics | ||
// from C | ||
static GDBusInterfaceVTable *get_interface_vtable() | ||
{ | ||
return (GDBusInterfaceVTable*)&interface_vtable; | ||
return (GDBusInterfaceVTable *)&interface_vtable; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
static GError* to_error(void* err) { | ||
return (GError*)err; | ||
static GError *to_error(void *err) | ||
{ | ||
return (GError *)err; | ||
} |