+#define strnfieldcpy(to, from, maxsize) \
+do { \
+ to[maxsize-1] = '\0'; \
+ strncpy(to, from, maxsize-1); \
+} while (0)
+
+#define strnfieldcat(to, from, maxsize) \
+do { \
+ to[maxsize-1] = '\0'; \
+ strncat(to, from, maxsize - strlen(to)-1); \
+} while (0)
+
+static inline char *get_action(void)
+{
+ char *action;
+
+ action = getenv("ACTION");
+ if (strlen(action) > ACTION_SIZE)
+ action[ACTION_SIZE-1] = '\0';
+
+ return action;
+}
+
+static inline char *get_devpath(void)
+{
+ char *devpath;
+
+ devpath = getenv("DEVPATH");
+ if (strlen(devpath) > DEVPATH_SIZE)
+ devpath[DEVPATH_SIZE-1] = '\0';
+
+ return devpath;
+}
+
+static inline char *get_seqnum(void)
+{
+ char *seqnum;
+
+ seqnum = getenv("SEQNUM");
+
+ return seqnum;
+}
+
+static inline char *get_subsystem(char *subsystem)
+{
+ if (strlen(subsystem) > SUBSYSTEM_SIZE)
+ subsystem[SUBSYSTEM_SIZE-1] = '\0';
+
+ return subsystem;
+}
+