Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
60c1afe7
...
60c1afe7697f18c7b0ed6d3adc65334673e4531c
authored
2007-02-23 11:45:58 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
(mutil_parse_field_map): New function
1 parent
edbc0d19
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
2 deletions
include/mailutils/mutil.h
mailbox/mutil.c
include/mailutils/mutil.h
View file @
60c1afe
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2004, 2005,
2006
Free Software Foundation, Inc.
2006
, 2007
Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
...
...
@@ -149,6 +149,9 @@ extern size_t mu_strftime (char *s, size_t max, const char *format,
const
struct
tm
*
tm
);
extern
int
mutil_parse_field_map
(
const
char
*
map
,
mu_assoc_t
*
passoc_tab
,
int
*
perr
);
#ifdef __cplusplus
}
#endif
...
...
mailbox/mutil.c
View file @
60c1afe
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2003,
2005, 2006 Free Software Foundation, Inc.
2005, 2006
, 2007
Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
...
...
@@ -43,6 +43,8 @@
#endif
#include <mailutils/address.h>
#include <mailutils/assoc.h>
#include <mailutils/argcv.h>
#include <mailutils/error.h>
#include <mailutils/errno.h>
#include <mailutils/iterator.h>
...
...
@@ -1403,3 +1405,56 @@ mu_strftime (char *s, size_t max, const char *format, const struct tm *tm)
}
static
void
assoc_str_free
(
void
*
data
)
{
free
(
data
);
}
int
mutil_parse_field_map
(
const
char
*
map
,
mu_assoc_t
*
passoc_tab
,
int
*
perr
)
{
int
rc
;
int
i
;
char
*
copy
=
strdup
(
map
);
char
*
sp
,
*
tok
;
mu_assoc_t
assoc_tab
=
NULL
;
for
(
tok
=
strtok_r
(
copy
,
","
,
&
sp
);
tok
;
tok
=
strtok_r
(
NULL
,
","
,
&
sp
))
{
char
*
p
=
strchr
(
tok
,
'='
);
char
*
pptr
;
if
(
!
p
)
{
rc
=
EINVAL
;
break
;
}
if
(
!
assoc_tab
)
{
rc
=
mu_assoc_create
(
&
assoc_tab
,
sizeof
(
char
*
));
if
(
rc
)
break
;
mu_assoc_set_free
(
assoc_tab
,
assoc_str_free
);
*
passoc_tab
=
assoc_tab
;
}
*
p
++
=
0
;
pptr
=
strdup
(
p
);
if
(
!
pptr
)
{
rc
=
errno
;
break
;
}
rc
=
mu_assoc_install
(
assoc_tab
,
tok
,
&
pptr
);
if
(
rc
)
{
free
(
p
);
break
;
}
}
free
(
copy
);
if
(
rc
&&
perr
)
*
perr
=
i
;
return
rc
;
}
...
...
Please
register
or
sign in
to post a comment