Tor  0.4.7.0-alpha-dev
Macros | Functions
time_to_tm.c File Reference

Convert to struct tm, portably. More...

#include "orconfig.h"
#include "lib/cc/torint.h"
#include "lib/cc/compat_compiler.h"
#include "lib/wallclock/time_to_tm.h"
#include "lib/string/printf.h"
#include "lib/err/torerr.h"
#include <errno.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>

Go to the source code of this file.

Macros

#define TIME_FNS_NEED_LOCKS
 

Functions

static struct tm * correct_tm (int islocal, const time_t *timep, struct tm *resultbuf, struct tm *r, char **err_out)
 
struct tm * tor_localtime_r_msg (const time_t *timep, struct tm *result, char **err_out)
 
struct tm * tor_gmtime_r_msg (const time_t *timep, struct tm *result, char **err_out)
 

Detailed Description

Convert to struct tm, portably.

Definition in file time_to_tm.c.

Macro Definition Documentation

◆ TIME_FNS_NEED_LOCKS

#define TIME_FNS_NEED_LOCKS

Defined iff we need to add locks when defining fake versions of reentrant versions of time-related functions.

Definition at line 26 of file time_to_tm.c.

Function Documentation

◆ correct_tm()

static struct tm* correct_tm ( int  islocal,
const time_t *  timep,
struct tm *  resultbuf,
struct tm *  r,
char **  err_out 
)
static

Helper: Deal with confused or out-of-bounds values from localtime_r and friends. (On some platforms, they can give out-of-bounds values or can return NULL.) If islocal, this is a localtime result; otherwise it's from gmtime. The function returns r, when given timep as its input. If we need to store new results, store them in resultbuf.

Definition at line 36 of file time_to_tm.c.

◆ tor_gmtime_r_msg()

struct tm* tor_gmtime_r_msg ( const time_t *  timep,
struct tm *  result,
char **  err_out 
)

As gmtime_r, but defined for platforms that don't have it:

Convert *timep to a struct tm in UTC, and store the value in *result. Return the result on success, or NULL on failure.

Definition at line 176 of file time_to_tm.c.

Referenced by tor_gmtime_r().

◆ tor_localtime_r_msg()

struct tm* tor_localtime_r_msg ( const time_t *  timep,
struct tm *  result,
char **  err_out 
)

As localtime_r, but defined for platforms that don't have it:

Convert *timep to a struct tm in local time, and store the value in *result. Return the result on success, or NULL on failure.

Definition at line 133 of file time_to_tm.c.

Referenced by log_prefix_(), and tor_localtime_r().