loudmouth/lm-utils.c
author psykose <alice@ayaya.dev>
Thu, 21 Apr 2022 20:23:32 +0200
changeset 744 4ebe32453682
parent 690 7ccf2113ec5f
permissions -rw-r--r--
fix macro define for freeaddrinfo with asyncns previously, this define was only made in lm-asyncns-resolver.c, which does not propagate it to lm-resolver.c, where freeaddrinfo() is used. this means that when asyncns support is used, the standard libc freeaddrinfo() is called on an addrinfo acquired from asyncns_getaddrinfo, which is undefined behaviour, and leads to a segfault on musl libc.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
516
4dd3aa6b83e5 Change the tab width to 4 steps in the emacs headers
Mikael Hallendal <micke@imendio.com>
parents: 515
diff changeset
     1
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
1
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
     2
/*
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 533
diff changeset
     3
 * Copyright (C) 2003 Imendio AB
1
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
     4
 *
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
     6
 * modify it under the terms of the GNU Lesser General Public License as
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
     7
 * published by the Free Software Foundation; either version 2 of the
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
     8
 * License, or (at your option) any later version.
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
     9
 *
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    13
 * Lesser General Public License for more details.
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    14
 *
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    15
 * You should have received a copy of the GNU Lesser General Public
690
7ccf2113ec5f Update the postal address of the FSF
Frank Zschockelt <lm@freakysoft.de>
parents: 607
diff changeset
    16
 * License along with this program; if not, see <https://www.gnu.org/licenses>
1
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    17
 */
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    18
417
364c17252e5f Added inlined documentation from generated through the Gtk-doc migration script.
Mikael Hallendal <micke@imendio.com>
parents: 407
diff changeset
    19
/**
420
f40434cca022 Fixed the SECTION parts of the inlined docs so that gtk-doc finds them.
Mikael Hallendal <micke@imendio.com>
parents: 417
diff changeset
    20
 * SECTION:lm-utils
421
2a91651d22de Added Title to the inlined documentation
Mikael Hallendal <micke@imendio.com>
parents: 420
diff changeset
    21
 * @Title: Miscellaneous Utility Functions
420
f40434cca022 Fixed the SECTION parts of the inlined docs so that gtk-doc finds them.
Mikael Hallendal <micke@imendio.com>
parents: 417
diff changeset
    22
 * @Short_description: Miscellaneous Utility Functions
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 533
diff changeset
    23
 *
417
364c17252e5f Added inlined documentation from generated through the Gtk-doc migration script.
Mikael Hallendal <micke@imendio.com>
parents: 407
diff changeset
    24
 * Functions to help application developers when writing XMPP applications using Loudmouth.
364c17252e5f Added inlined documentation from generated through the Gtk-doc migration script.
Mikael Hallendal <micke@imendio.com>
parents: 407
diff changeset
    25
 */
364c17252e5f Added inlined documentation from generated through the Gtk-doc migration script.
Mikael Hallendal <micke@imendio.com>
parents: 407
diff changeset
    26
1
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    27
#include <config.h>
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    28
#include <string.h>
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    29
#include <stdio.h>
155
d24c4392d4e3 2006-06-16 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 140
diff changeset
    30
#include <stdlib.h>
1
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    31
#include <time.h>
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    32
140
103227122f45 2006-04-19 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
    33
#include <glib.h>
103227122f45 2006-04-19 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
    34
103227122f45 2006-04-19 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
    35
#ifndef G_OS_WIN32
103227122f45 2006-04-19 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
    36
#include <unistd.h>
103227122f45 2006-04-19 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
    37
#endif
103227122f45 2006-04-19 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 99
diff changeset
    38
155
d24c4392d4e3 2006-06-16 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 140
diff changeset
    39
#ifdef HAVE_IDN
d24c4392d4e3 2006-06-16 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 140
diff changeset
    40
#include <stringprep.h>
d24c4392d4e3 2006-06-16 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 140
diff changeset
    41
#include <punycode.h>
d24c4392d4e3 2006-06-16 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 140
diff changeset
    42
#include <idna.h>
d24c4392d4e3 2006-06-16 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 140
diff changeset
    43
#endif
d24c4392d4e3 2006-06-16 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 140
diff changeset
    44
1
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    45
#include "lm-internals.h"
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    46
#include "lm-utils.h"
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    47
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    48
LmCallback *
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 533
diff changeset
    49
_lm_utils_new_callback (gpointer       func,
533
c45243823756 Added some TODO items and minor style fixes
Mikael Hallendal <micke@imendio.com>
parents: 518
diff changeset
    50
                        gpointer       user_data,
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    51
                        GDestroyNotify notify)
1
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    52
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    53
    LmCallback *cb;
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 533
diff changeset
    54
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    55
    cb = g_new0 (LmCallback, 1);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    56
    cb->func = func;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    57
    cb->user_data = user_data;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    58
    cb->notify = notify;
1
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    59
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    60
    return cb;
1
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    61
}
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    62
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    63
void
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    64
_lm_utils_free_callback (LmCallback *cb)
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    65
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    66
    if (!cb) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    67
        return;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    68
    }
64
dd835d5cee71 2004-01-06 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 57
diff changeset
    69
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    70
    if (cb->notify) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    71
        (* cb->notify) (cb->user_data);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    72
    }
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    73
    g_free (cb);
1
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    74
}
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    75
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    76
gchar *
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    77
_lm_utils_generate_id (void)
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    78
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    79
    static guint  last_id = 0;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    80
    GTimeVal      tv;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    81
    glong         val;
1
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    82
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    83
    g_get_current_time (&tv);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    84
    val = (tv.tv_sec & tv.tv_usec) + last_id++;
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 533
diff changeset
    85
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    86
    return g_strdup_printf ("%ld%ld", val, tv.tv_usec);
1
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    87
}
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
    88
155
d24c4392d4e3 2006-06-16 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 140
diff changeset
    89
gchar*
d24c4392d4e3 2006-06-16 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 140
diff changeset
    90
_lm_utils_hostname_to_punycode (const gchar *hostname)
d24c4392d4e3 2006-06-16 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 140
diff changeset
    91
{
d24c4392d4e3 2006-06-16 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 140
diff changeset
    92
#ifdef HAVE_IDN
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    93
    char *s;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    94
    uint32_t *q;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    95
    int rc;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    96
    gchar *result;
155
d24c4392d4e3 2006-06-16 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 140
diff changeset
    97
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    98
    q = stringprep_utf8_to_ucs4 (hostname, -1, NULL);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
    99
    if (q == NULL) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   100
        return g_strdup (hostname);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   101
    }
155
d24c4392d4e3 2006-06-16 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 140
diff changeset
   102
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   103
    rc = idna_to_ascii_4z (q, &s, IDNA_ALLOW_UNASSIGNED);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   104
    free(q);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   105
    if (rc != IDNA_SUCCESS) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   106
        return g_strdup (hostname);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   107
    }
155
d24c4392d4e3 2006-06-16 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 140
diff changeset
   108
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   109
    /* insures result is allocated through glib */
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   110
    result = g_strdup(s);
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   111
    free(s);
155
d24c4392d4e3 2006-06-16 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 140
diff changeset
   112
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   113
    return result;
155
d24c4392d4e3 2006-06-16 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 140
diff changeset
   114
#else
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   115
    return g_strdup(hostname);
155
d24c4392d4e3 2006-06-16 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 140
diff changeset
   116
#endif
168
ac1affcd5d22 2006-09-01 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 155
diff changeset
   117
}
ac1affcd5d22 2006-09-01 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 155
diff changeset
   118
179
6cc952969ff1 doc work
hallski <hallski>
parents: 177
diff changeset
   119
/**
236
b4e5c1cb114e Some tweaks while trying to solve LM-52.
Mikael Hallendal <micke@imendio.com>
parents: 179
diff changeset
   120
 * lm_utils_get_localtime:
179
6cc952969ff1 doc work
hallski <hallski>
parents: 177
diff changeset
   121
 * @stamp: An XMPP timestamp
6cc952969ff1 doc work
hallski <hallski>
parents: 177
diff changeset
   122
 *
6cc952969ff1 doc work
hallski <hallski>
parents: 177
diff changeset
   123
 * Converts an XMPP timestamp to a struct tm showing local time.
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 533
diff changeset
   124
 *
179
6cc952969ff1 doc work
hallski <hallski>
parents: 177
diff changeset
   125
 * Return value: The local time struct.
6cc952969ff1 doc work
hallski <hallski>
parents: 177
diff changeset
   126
 **/
168
ac1affcd5d22 2006-09-01 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 155
diff changeset
   127
struct tm *
1
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
   128
lm_utils_get_localtime (const gchar *stamp)
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
   129
{
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   130
    struct tm tm;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   131
    time_t    t;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   132
    gint      year, month;
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 533
diff changeset
   133
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   134
    g_return_val_if_fail (stamp != NULL, NULL);
168
ac1affcd5d22 2006-09-01 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 155
diff changeset
   135
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   136
    /* 20021209T23:51:30 */
1
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
   137
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 533
diff changeset
   138
    sscanf (stamp, "%4d%2d%2dT%2d:%2d:%2d",
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   139
            &year, &month, &tm.tm_mday, &tm.tm_hour,
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   140
            &tm.tm_min, &tm.tm_sec);
65
e6871fda6fc9 2004-01-08 Richard Hult <richard@imendio.com>
rhult <rhult>
parents: 64
diff changeset
   141
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   142
    tm.tm_year = year - 1900;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   143
    tm.tm_mon = month - 1;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   144
    tm.tm_isdst = -1;
65
e6871fda6fc9 2004-01-08 Richard Hult <richard@imendio.com>
rhult <rhult>
parents: 64
diff changeset
   145
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   146
    t = mktime (&tm);
1
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
   147
65
e6871fda6fc9 2004-01-08 Richard Hult <richard@imendio.com>
rhult <rhult>
parents: 64
diff changeset
   148
#if defined(HAVE_TM_GMTOFF)
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   149
    t += tm.tm_gmtoff;
65
e6871fda6fc9 2004-01-08 Richard Hult <richard@imendio.com>
rhult <rhult>
parents: 64
diff changeset
   150
#elif defined(HAVE_TIMEZONE)
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   151
    t -= timezone;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   152
    if (tm.tm_isdst > 0) {
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   153
        t += 3600;
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   154
    }
607
e2bd14357c9a Some style fixes
Frank Zschockelt <lm@freakysoft.de>
parents: 533
diff changeset
   155
#endif
1
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
   156
518
cdd6a0c5b439 Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents: 516
diff changeset
   157
    return localtime (&t);
1
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
   158
}
50e230cf7818 Initial revision
hallski <hallski>
parents:
diff changeset
   159
155
d24c4392d4e3 2006-06-16 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents: 140
diff changeset
   160