diff options
author | ng0 <ng0@n0.is> | 2019-05-15 15:51:29 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-05-15 15:51:29 +0000 |
commit | 51cf7682ce12732f75365e2766f481132b3baaee (patch) | |
tree | a3f0a8e08c6e93a17216dc66236ad3e157878cd9 /src/namestore/plugin_gtk_namestore_mx.c | |
parent | f85786c61f2f03c6e3d2d7f00a6b1446bab3c41e (diff) | |
download | gnunet-gtk-51cf7682ce12732f75365e2766f481132b3baaee.tar.gz gnunet-gtk-51cf7682ce12732f75365e2766f481132b3baaee.zip |
clang-format all C code. Add symlink of clang-format to bootstrap.
Diffstat (limited to 'src/namestore/plugin_gtk_namestore_mx.c')
-rw-r--r-- | src/namestore/plugin_gtk_namestore_mx.c | 63 |
1 files changed, 24 insertions, 39 deletions
diff --git a/src/namestore/plugin_gtk_namestore_mx.c b/src/namestore/plugin_gtk_namestore_mx.c index e1376554..bc9b299b 100644 --- a/src/namestore/plugin_gtk_namestore_mx.c +++ b/src/namestore/plugin_gtk_namestore_mx.c | |||
@@ -35,8 +35,7 @@ | |||
35 | * @param user_data the plugin environment | 35 | * @param user_data the plugin environment |
36 | */ | 36 | */ |
37 | static void | 37 | static void |
38 | GNS_edit_dialog_mx_entry_changed_cb (GtkEditable *entry, | 38 | GNS_edit_dialog_mx_entry_changed_cb (GtkEditable *entry, gpointer user_data) |
39 | gpointer user_data) | ||
40 | { | 39 | { |
41 | struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc = user_data; | 40 | struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc = user_data; |
42 | 41 | ||
@@ -54,31 +53,27 @@ GNS_edit_dialog_mx_entry_changed_cb (GtkEditable *entry, | |||
54 | * @param builder the edit dialog's builder | 53 | * @param builder the edit dialog's builder |
55 | */ | 54 | */ |
56 | static void | 55 | static void |
57 | mx_load (void *cls, | 56 | mx_load (void *cls, gchar *n_value, GtkBuilder *builder) |
58 | gchar *n_value, | ||
59 | GtkBuilder *builder) | ||
60 | { | 57 | { |
61 | uint16_t mx_pref; | 58 | uint16_t mx_pref; |
62 | char result[253 + 1]; | 59 | char result[253 + 1]; |
63 | 60 | ||
64 | if (2 != SSCANF (n_value, | 61 | if (2 != SSCANF (n_value, "%hu,%253s", &mx_pref, result)) |
65 | "%hu,%253s", | ||
66 | &mx_pref, result)) | ||
67 | { | 62 | { |
68 | GNUNET_break (0); | 63 | GNUNET_break (0); |
69 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 64 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
70 | _("Unable to parse MX record `%s'\n"), | 65 | _ ("Unable to parse MX record `%s'\n"), |
71 | n_value); | 66 | n_value); |
72 | return; | 67 | return; |
73 | } | 68 | } |
74 | gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (builder, | 69 | gtk_entry_set_text (GTK_ENTRY ( |
75 | "edit_dialog_mx_entry")), | 70 | gtk_builder_get_object (builder, |
71 | "edit_dialog_mx_entry")), | ||
76 | result); | 72 | result); |
77 | gtk_spin_button_set_value | 73 | gtk_spin_button_set_value ( |
78 | (GTK_SPIN_BUTTON | 74 | GTK_SPIN_BUTTON ( |
79 | (gtk_builder_get_object (builder, | 75 | gtk_builder_get_object (builder, "edit_dialog_mx_distance_spinbutton")), |
80 | "edit_dialog_mx_distance_spinbutton")), | 76 | mx_pref); |
81 | mx_pref); | ||
82 | } | 77 | } |
83 | 78 | ||
84 | 79 | ||
@@ -91,8 +86,7 @@ mx_load (void *cls, | |||
91 | * @return record value as a string, as specified in the dialog | 86 | * @return record value as a string, as specified in the dialog |
92 | */ | 87 | */ |
93 | static gchar * | 88 | static gchar * |
94 | mx_store (void *cls, | 89 | mx_store (void *cls, GtkBuilder *builder) |
95 | GtkBuilder *builder) | ||
96 | { | 90 | { |
97 | GtkEntry *entry; | 91 | GtkEntry *entry; |
98 | const gchar *value; | 92 | const gchar *value; |
@@ -100,17 +94,11 @@ mx_store (void *cls, | |||
100 | unsigned int distance; | 94 | unsigned int distance; |
101 | gchar *ret; | 95 | gchar *ret; |
102 | 96 | ||
103 | entry = GTK_ENTRY (gtk_builder_get_object (builder, | 97 | entry = GTK_ENTRY (gtk_builder_get_object (builder, "edit_dialog_mx_entry")); |
104 | "edit_dialog_mx_entry")); | ||
105 | value = gtk_entry_get_text (entry); | 98 | value = gtk_entry_get_text (entry); |
106 | distance = gtk_spin_button_get_value | 99 | distance = gtk_spin_button_get_value (GTK_SPIN_BUTTON ( |
107 | (GTK_SPIN_BUTTON | 100 | gtk_builder_get_object (builder, "edit_dialog_mx_distance_spinbutton"))); |
108 | (gtk_builder_get_object (builder, | 101 | GNUNET_asprintf (&result, "%hu,%s", distance, value); |
109 | "edit_dialog_mx_distance_spinbutton"))); | ||
110 | GNUNET_asprintf (&result, | ||
111 | "%hu,%s", | ||
112 | distance, | ||
113 | value); | ||
114 | ret = g_strdup (result); | 102 | ret = g_strdup (result); |
115 | GNUNET_free (result); | 103 | GNUNET_free (result); |
116 | return ret; | 104 | return ret; |
@@ -129,17 +117,15 @@ mx_store (void *cls, | |||
129 | * @return #GNUNET_OK if there is a valid record value in the dialog | 117 | * @return #GNUNET_OK if there is a valid record value in the dialog |
130 | */ | 118 | */ |
131 | static int | 119 | static int |
132 | mx_validate (void *cls, | 120 | mx_validate (void *cls, GtkBuilder *builder) |
133 | GtkBuilder *builder) | ||
134 | { | 121 | { |
135 | GtkEditable *entry; | 122 | GtkEditable *entry; |
136 | const gchar *preedit; | 123 | const gchar *preedit; |
137 | 124 | ||
138 | entry = GTK_EDITABLE (gtk_builder_get_object (builder, | 125 | entry = |
139 | "edit_dialog_mx_entry")), | 126 | GTK_EDITABLE (gtk_builder_get_object (builder, "edit_dialog_mx_entry")), |
140 | preedit = gtk_editable_get_chars (entry, 0, -1); | 127 | preedit = gtk_editable_get_chars (entry, 0, -1); |
141 | if ( (NULL == preedit) || | 128 | if ((NULL == preedit) || (GNUNET_OK != GNUNET_DNSPARSER_check_name (preedit))) |
142 | (GNUNET_OK != GNUNET_DNSPARSER_check_name (preedit)) ) | ||
143 | return GNUNET_SYSERR; | 129 | return GNUNET_SYSERR; |
144 | return GNUNET_OK; | 130 | return GNUNET_OK; |
145 | } | 131 | } |
@@ -156,11 +142,10 @@ libgnunet_plugin_gtk_namestore_mx_init (void *cls) | |||
156 | { | 142 | { |
157 | struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = cls; | 143 | struct GNUNET_GTK_NAMESTORE_PluginEnvironment *env = cls; |
158 | struct GNUNET_GTK_NAMESTORE_PluginFunctions *plugin; | 144 | struct GNUNET_GTK_NAMESTORE_PluginFunctions *plugin; |
159 | static struct GNUNET_GTK_NAMESTORE_Symbol symbols[] = { | 145 | static struct GNUNET_GTK_NAMESTORE_Symbol symbols[] = |
160 | { "GNS_edit_dialog_mx_entry_changed_cb", | 146 | {{"GNS_edit_dialog_mx_entry_changed_cb", |
161 | G_CALLBACK (GNS_edit_dialog_mx_entry_changed_cb) }, | 147 | G_CALLBACK (GNS_edit_dialog_mx_entry_changed_cb)}, |
162 | { NULL, NULL } | 148 | {NULL, NULL}}; |
163 | }; | ||
164 | 149 | ||
165 | plugin = GNUNET_new (struct GNUNET_GTK_NAMESTORE_PluginFunctions); | 150 | plugin = GNUNET_new (struct GNUNET_GTK_NAMESTORE_PluginFunctions); |
166 | plugin->cls = env; | 151 | plugin->cls = env; |