summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2013-07-15 15:57:36 +0200
committerGravatar Christian Hesse <mail@eworm.de>2013-07-15 15:57:36 +0200
commit15be852a2278111c0541cc84f692eb15d56b23a8 (patch)
tree9f3484f58800a8b708100e166b056e97761a5261
parent00f45fe87bf22167121994e75d30542987cd3f44 (diff)
downloadudev-block-notify-15be852a2278111c0541cc84f692eb15d56b23a8.tar.gz
udev-block-notify-15be852a2278111c0541cc84f692eb15d56b23a8.tar.zst
data types and comments
-rw-r--r--udev-block-notify.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/udev-block-notify.c b/udev-block-notify.c
index 995a885..faa142e 100644
--- a/udev-block-notify.c
+++ b/udev-block-notify.c
@@ -42,6 +42,8 @@ struct notifications {
/*** get_notification ***/
NotifyNotification * get_notification(struct notifications *notifications, dev_t devnum) {
+ /* work with notifications->next here, we need it later to not miss
+ * the pointer in main struct */
while (notifications->next != NULL) {
if (notifications->next->devnum == devnum)
return notifications->next->notification;
@@ -67,7 +69,7 @@ NotifyNotification * get_notification(struct notifications *notifications, dev_t
}
/*** newstr ***/
-char * newstr(char *text, char *device, unsigned short int major, unsigned short int minor) {
+char * newstr(const char *text, char *device, unsigned short int major, unsigned short int minor) {
char *notifystr;
notifystr = malloc(strlen(text) + strlen(device) + 10 /* max string length 2* unsigned short int */);
@@ -77,14 +79,14 @@ char * newstr(char *text, char *device, unsigned short int major, unsigned short
}
/*** appendstr ***/
-char * appendstr(char *text, char *notifystr, char *property, const char *value) {
+char * appendstr(const char *text, char *notifystr, char *property, const char *value) {
notifystr = realloc(notifystr, strlen(text) + strlen(notifystr) + strlen(property) + strlen(value));
sprintf(notifystr + strlen(notifystr), text, property, value);
return notifystr;
}
-/* main */
+/*** main ***/
int main (int argc, char ** argv) {
char action;
char *device = NULL, *icon = NULL, *notifystr = NULL;
@@ -121,6 +123,7 @@ int main (int argc, char ** argv) {
udev_monitor_filter_add_match_subsystem_devtype(mon, "block", NULL);
udev_monitor_enable_receiving(mon);
+ /* allocate first struct element as dummy */
notifications = malloc(sizeof(struct notifications));
notifications->devnum = 0;
notifications->notification = NULL;