|
@@ -61,6 +61,8 @@
|
|
#include "config.h"
|
|
#include "config.h"
|
|
#include "dprint.h"
|
|
#include "dprint.h"
|
|
#include "str.h"
|
|
#include "str.h"
|
|
|
|
+#include "mem/mem.h"
|
|
|
|
+#include "mem/shm_mem.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -592,6 +594,45 @@ static inline int str2sint(str* _s, int* _r)
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * \brief Make a copy of a str structure using shm_malloc
|
|
|
|
+ * \param dst destination
|
|
|
|
+ * \param src source
|
|
|
|
+ * \return 0 on success, -1 on failure
|
|
|
|
+ */
|
|
|
|
+static inline int shm_str_dup(str* dst, const str* src)
|
|
|
|
+{
|
|
|
|
+ dst->s = shm_malloc(src->len);
|
|
|
|
+ if (!dst->s) {
|
|
|
|
+ SHM_MEM_ERROR;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ memcpy(dst->s, src->s, src->len);
|
|
|
|
+ dst->len = src->len;
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * \brief Make a copy of a str structure using pkg_malloc
|
|
|
|
+ * \param dst destination
|
|
|
|
+ * \param src source
|
|
|
|
+ * \return 0 on success, -1 on failure
|
|
|
|
+ */
|
|
|
|
+static inline int pkg_str_dup(str* dst, const str* src)
|
|
|
|
+{
|
|
|
|
+ dst->s = pkg_malloc(src->len);
|
|
|
|
+ if (dst->s==NULL)
|
|
|
|
+ {
|
|
|
|
+ PKG_MEM_ERROR;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ memcpy(dst->s, src->s, src->len);
|
|
|
|
+ dst->len = src->len;
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
/* converts a username into uid:gid,
|
|
/* converts a username into uid:gid,
|
|
* returns -1 on error & 0 on success */
|
|
* returns -1 on error & 0 on success */
|
|
int user2uid(int* uid, int* gid, char* user);
|
|
int user2uid(int* uid, int* gid, char* user);
|