Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use LINE_MAX from <limits.h> in linux

Long notifications would not appear with the default limits.
  • Loading branch information...
commit daf912dcfe246bd8408ce1bee79ad08e1aff8579 1 parent 89c9550
@Cloudef authored
Showing with 26 additions and 9 deletions.
  1. +5 −5 notify.c
  2. +21 −4 notify.h
View
10 notify.c
@@ -210,7 +210,7 @@ static char *str_replace(const char *s, const char *old, const char *new)
if( !p )
return 0;
while( *s )
- if( !strncmp(s, old, strlen(old)) )
+ if((*s & 0xc0) != 0x80 && !strncmp(s, old, strlen(old)))
{
p -= (intptr_t)cout;
cout= realloc(cout, slen += strlen(new)-strlen(old) );
@@ -340,11 +340,11 @@ bool notify_Notify(DBusConnection *dbus, DBusMessage *msg) {
note->expires_after = (time_t)(expires<0?EXPIRE_DEFAULT:expires*EXPIRE_MULT);
note->closed=0;
- strncpy( note->appname, appname, 20);
- strncpy( note->summary, summary, 64);
- strncpy( note->body, body, 256);
+ strncpy( note->appname, appname, APP_LEN);
+ strncpy( note->summary, summary, SUMMARY_LEN);
+ strncpy( note->body, body, BODY_LEN);
//_strip_body(note->body);
- DEBUG(" body stripped to: '%s'\n", note->body);
+ //DEBUG(" body stripped to: '%s'\n", note->body);
if( nid==0 ) {
if( ptr==NULL ) messages=note;
View
25 notify.h
@@ -1,7 +1,10 @@
#include <stdbool.h>
-
#include <dbus/dbus.h>
+#ifdef __linux__
+ #include <limits.h>
+#endif
+
// default message delay in milliseconds
#define EXPIRE_DEFAULT 5000
@@ -18,15 +21,29 @@
// config file
#define CFG_FIL "config"
+// notification maximum text lengths
+// might want to increase these, if causes problems.
+//
+// thought won't have problems with LINE_MAX
+#ifdef __linux__
+ #define APP_LEN 256
+ #define SUMMARY_LEN LINE_MAX
+ #define BODY_LEN LINE_MAX
+#else
+ #define APP_LEN 256
+ #define SUMMARY_LEN 256
+ #define BODY_LEN 256
+#endif
+
typedef struct _notification {
dbus_uint32_t nid;
time_t started_at;
time_t expires_after;
char closed;
- char appname[20];
- char summary[64];
- char body[256];
+ char appname[APP_LEN];
+ char summary[SUMMARY_LEN];
+ char body[BODY_LEN];
struct _notification *next;
} notification;
Please sign in to comment.
Something went wrong with that request. Please try again.