NeoMutt  2025-09-05-2-g4bf191
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
node_conddate.h File Reference

Expando Node for a Conditional Date. More...

+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  NodeCondDatePrivate
 Private data for a Conditional Date -. More...
 

Functions

struct ExpandoNodenode_conddate_parse (const char *str, int did, int uid, const char **parsed_until, struct ExpandoParseError *err)
 Parse a CondDate format string.
 

Detailed Description

Expando Node for a Conditional Date.

Authors
  • Tóth János
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file node_conddate.h.

Function Documentation

◆ node_conddate_parse()

struct ExpandoNode * node_conddate_parse ( const char *  str,
int  did,
int  uid,
const char **  parsed_until,
struct ExpandoParseError err 
)

Parse a CondDate format string.

Parameters
[in]strString to parse
[in]didDomain ID
[in]uidUnique ID
[out]parsed_untilFirst character after parsed string
[out]errBuffer for errors

Definition at line 220 of file node_conddate.c.

223{
224 if (!str || (str[0] == '\0') || !parsed_until || !err)
225 return NULL;
226
227 int count = 0;
228 char period = '\0';
229
230 str++;
231
232 if (mutt_isdigit(*str))
233 {
234 unsigned short number = 0;
235 const char *end_ptr = mutt_str_atous(str, &number);
236
237 // NOTE(g0mb4): str is NOT NUL-terminated
238 if (!end_ptr || (number == USHRT_MAX))
239 {
240 err->position = str;
241 snprintf(err->message, sizeof(err->message), _("Invalid number: %s"), str);
242 return NULL;
243 }
244
245 count = number;
246 str = end_ptr;
247 };
248
249 // Allowed periods: year, month, week, day, hour, minute
250 if (!strchr("ymwdHM", *str))
251 {
252 err->position = str;
253 snprintf(err->message, sizeof(err->message),
254 // L10N: The 'ymwdHM' should not be translated
255 _("Invalid time period: '%c', must be one of 'ymwdHM'"), *str);
256 return NULL;
257 }
258
259 period = *str;
260 *parsed_until = str + 1;
261
262 return node_conddate_new(count, period, did, uid);
263}
const char * mutt_str_atous(const char *str, unsigned short *dst)
Convert ASCII string to an unsigned short.
Definition: atoi.c:270
bool mutt_isdigit(int arg)
Wrapper for isdigit(3)
Definition: ctype.c:65
#define _(a)
Definition: message.h:28
struct ExpandoNode * node_conddate_new(int count, char period, int did, int uid)
Create a new CondDate ExpandoNode.
char message[1024]
Error message.
Definition: parse.h:38
const char * position
Position of error in original string.
Definition: parse.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function: