• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KIO

  • kio
  • kssl
ksslutils.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 *
3 * Copyright (C) 2000,2001 George Staikos <staikos@kde.org>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21
22#include "ksslutils.h"
23
24#include <QtCore/QString>
25#include <kglobal.h>
26#include <klocale.h>
27#include <QtCore/QDate>
28
29#include "kopenssl.h"
30
31#ifdef KSSL_HAVE_SSL
32// This code is mostly taken from OpenSSL v0.9.5a
33// by Eric Young
34QDateTime ASN1_UTCTIME_QDateTime(ASN1_UTCTIME *tm, int *isGmt) {
35QDateTime qdt;
36char *v;
37int gmt=0;
38int i;
39int y=0,M=0,d=0,h=0,m=0,s=0;
40QDate qdate;
41QTime qtime;
42
43 i = tm->length;
44 v = (char *)tm->data;
45
46 if (i < 10) goto auq_err;
47 if (v[i-1] == 'Z') gmt=1;
48 for (i=0; i<10; ++i)
49 if ((v[i] > '9') || (v[i] < '0')) goto auq_err;
50 y = (v[0]-'0')*10+(v[1]-'0');
51 if (y < 50) y+=100;
52 M = (v[2]-'0')*10+(v[3]-'0');
53 if ((M > 12) || (M < 1)) goto auq_err;
54 d = (v[4]-'0')*10+(v[5]-'0');
55 h = (v[6]-'0')*10+(v[7]-'0');
56 m = (v[8]-'0')*10+(v[9]-'0');
57 if ( (v[10] >= '0') && (v[10] <= '9') &&
58 (v[11] >= '0') && (v[11] <= '9'))
59 s = (v[10]-'0')*10+(v[11]-'0');
60
61 // localize the date and display it.
62 qdate.setYMD(y+1900, M, d);
63 qtime.setHMS(h,m,s);
64 qdt.setDate(qdate); qdt.setTime(qtime);
65 auq_err:
66 if (isGmt) *isGmt = gmt;
67return qdt;
68}
69
70
71QString ASN1_UTCTIME_QString(ASN1_UTCTIME *tm) {
72 QString qstr;
73 int gmt;
74 QDateTime qdt = ASN1_UTCTIME_QDateTime(tm, &gmt);
75 qstr = KGlobal::locale()->formatDateTime(qdt, KLocale::LongDate, true);
76 if (gmt) {
77 qstr += ' ';
78 qstr += i18n("GMT");
79 }
80 return qstr;
81}
82
83
84QString ASN1_INTEGER_QString(ASN1_INTEGER *aint) {
85char *rep = KOSSL::self()->i2s_ASN1_INTEGER(NULL, aint);
86QString yy = rep;
87KOSSL::self()->OPENSSL_free(rep);
88return yy;
89}
90
91
92#endif
93
KLocale::formatDateTime
QString formatDateTime(const KDateTime &dateTime, DateFormat format=ShortDate, DateTimeFormatOptions options=0) const
KLocale::LongDate
LongDate
M
#define M(h, p)
kglobal.h
klocale.h
i18n
QString i18n(const char *text)
kopenssl.h
ksslutils.h
KGlobal::locale
KLocale * locale()
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal