summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllen Winter <allen.winter@kdab.com>2015-04-30 17:57:55 -0400
committerAllen Winter <allen.winter@kdab.com>2015-04-30 17:57:55 -0400
commit68e3fcb0fee03696550a2b8528b031278eec0d14 (patch)
treef1ae88350b729509f0a76def66ccb634a32fe1ab
parenta57d2876baa1c0ce59913de9680bd5ae80f2494b (diff)
downloadlibical-git-68e3fcb0fee03696550a2b8528b031278eec0d14.tar.gz
WIP: more include file cleaning
-rw-r--r--.krazy3
-rw-r--r--ConfigureChecks.cmake3
-rw-r--r--config.h.cmake9
-rw-r--r--src/libical/astime.h94
-rw-r--r--src/libical/icalcomponent.c19
-rw-r--r--src/libical/icalcomponent.h18
-rw-r--r--src/libical/icalenums.c11
-rw-r--r--src/libical/icalerror.c2
-rw-r--r--src/libical/icallangbind.c93
-rw-r--r--src/libical/icallangbind.h15
-rw-r--r--src/libical/icaltz-util.h6
-rw-r--r--src/libical/icalvalue.c1
-rw-r--r--src/libicalcap/client.c243
-rw-r--r--src/libicalcap/icalcap.c26
-rw-r--r--src/libicalcap/icalcap.h24
-rw-r--r--src/libicalcap/icalcap_impl.h16
-rw-r--r--src/libicalcap/icalcap_message.c191
-rw-r--r--src/libicalcap/icalcap_message_impl.h22
-rw-r--r--src/libicalcap/icalcap_rr.c581
-rw-r--r--src/libicalcap/icalcap_server.c29
-rw-r--r--src/libicalcap/icalcap_server.h16
-rw-r--r--src/libicalcap/icalcap_server_impl.h26
-rw-r--r--src/libicalcap/icalcap_session.c33
-rw-r--r--src/libicalcap/icalcap_session.h12
-rw-r--r--src/libicalcap/icalcap_session_impl.h34
-rw-r--r--src/libicalcap/icalcap_utils.c219
-rw-r--r--src/libicalss/icalcalendar.c9
-rw-r--r--src/libicalss/icalcalendar.h9
-rw-r--r--src/libicalss/icalclusterimpl.h5
-rw-r--r--src/libicalss/icaldirsetimpl.h5
-rw-r--r--src/libicalss/icalgaugeimpl.h5
-rw-r--r--src/libicalss/icalspanlist.c6
-rw-r--r--src/libicalss/icalspanlist.h6
-rw-r--r--src/test/copycluster.c7
-rw-r--r--src/test/icaltestparser.c2
-rw-r--r--src/test/recur.c10
-rw-r--r--src/test/testmime.c3
37 files changed, 888 insertions, 925 deletions
diff --git a/.krazy b/.krazy
index 0ac6a65a..74a8898f 100644
--- a/.krazy
+++ b/.krazy
@@ -9,4 +9,7 @@ SKIP /src/libicalvcal/vcaltmp\.
SKIP /src/libicalvcal/vcc\.
SKIP /src/libicalvcal/vobject\.
+#Skip zoneinfo
+SKIP /zoneinfo/
+
STYLE_LINEMAX 100
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 72923c50..178b2d0e 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -5,9 +5,6 @@ check_include_files(endian.h HAVE_ENDIAN_H)
check_include_files(inttypes.h HAVE_INTTYPES_H)
check_include_files(pthread.h HAVE_PTHREAD_H)
check_include_files(stdint.h HAVE_STDINT_H)
-check_include_files(stdlib.h HAVE_STDLIB_H)
-check_include_files(strings.h HAVE_STRINGS_H)
-check_include_files(string.h HAVE_STRING_H)
check_include_files(sys/endian.h HAVE_SYS_ENDIAN_H)
check_include_files(sys/param.h HAVE_SYS_PARAM_H)
check_include_files(sys/utsname.h HAVE_SYS_UTSNAME_H)
diff --git a/config.h.cmake b/config.h.cmake
index 7befde5e..74e542a6 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -60,9 +60,6 @@
/* Define to 1 if you have the <stdint.h> header file. */
#cmakedefine HAVE_STDINT_H 1
-/* Define to 1 if you have the <stdlib.h> header file. */
-#cmakedefine HAVE_STDLIB_H 1
-
/* Define to 1 if you have the `strcasecmp' function. */
#cmakedefine HAVE_STRCASECMP 1
@@ -93,12 +90,6 @@
/* Define to 1 if you have the `_open' function. */
#cmakedefine HAVE__OPEN 1
-/* Define to 1 if you have the <strings.h> header file. */
-#cmakedefine HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the <string.h> header file. */
-#cmakedefine HAVE_STRING_H 1
-
/* Define to 1 if you have the <sys/endian.h> header file. */
#cmakedefine HAVE_SYS_ENDIAN_H 1
diff --git a/src/libical/astime.h b/src/libical/astime.h
index 6962c060..bb41a6fd 100644
--- a/src/libical/astime.h
+++ b/src/libical/astime.h
@@ -1,65 +1,65 @@
/*
- * Copyright (c) 1986-2000, Hiram Clawson
- * All rights reserved.
+ * Copyright (c) 1986-2000, Hiram Clawson
+ * All rights reserved.
*
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
*
- * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
+ * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the
+ * following disclaimer.
*
- * Redistributions in binary form must reproduce the
- * above copyright notice, this list of conditions and
- * the following disclaimer in the documentation and/or
- * other materials provided with the distribution.
+ * Redistributions in binary form must reproduce the
+ * above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.
*
- * Neither name of The Museum of Hiram nor the names of
- * its contributors may be used to endorse or promote products
- * derived from this software without specific prior
- * written permission.
+ * Neither name of The Museum of Hiram nor the names of
+ * its contributors may be used to endorse or promote products
+ * derived from this software without specific prior
+ * written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
- * @file astime.h
+ * @file astime.h
* @brief contains definitions of structures used for time calculations.
*/
-#ifndef _astime_h_
-#define _astime_h_
+#ifndef ICAL_astime_h
+#define ICAL_astime_h
typedef struct ut_instant {
- double j_date; /**< julian decimal date, 0 = 01 Jan 4713 BC 12 HR UT */
- long year; /**< year, valid range [-4,713, +2,147,483,647] */
- int month; /**< [1-12] */
- int day; /**< [1-31] */
- int i_hour; /**< [0-23] */
- int i_minute; /**< [0-59] */
- int i_second; /**< [0-59] */
- double d_hour; /**< [0.0-23.9999] includes minute and second */
- double d_minute; /**< [0.0-59.9999] includes second */
- double d_second; /**< [0.0-59.9999] */
- int weekday; /**< [0-6] */
- int day_of_year; /**< [1-366] */
+ double j_date; /**< julian decimal date, 0 = 01 Jan 4713 BC 12 HR UT */
+ long year; /**< year, valid range [-4,713, +2,147,483,647] */
+ int month; /**< [1-12] */
+ int day; /**< [1-31] */
+ int i_hour; /**< [0-23] */
+ int i_minute; /**< [0-59] */
+ int i_second; /**< [0-59] */
+ double d_hour; /**< [0.0-23.9999] includes minute and second */
+ double d_minute; /**< [0.0-59.9999] includes second */
+ double d_second; /**< [0.0-59.9999] */
+ int weekday; /**< [0-6] */
+ int day_of_year; /**< [1-366] */
} UTinstant, * UTinstantPtr;
-/* Functions in caldate.c */
+/* Functions in caldate.c */
-long caldat( UTinstantPtr ); /** converts julian date to year,mo,da */
-double juldat( UTinstantPtr ); /** returns julian day from year,mo,da */
+long caldat( UTinstantPtr ); /** converts julian date to year,mo,da */
+double juldat( UTinstantPtr ); /** returns julian day from year,mo,da */
-#endif /* _astime_h_ */
+#endif
diff --git a/src/libical/icalcomponent.c b/src/libical/icalcomponent.c
index 7e20a6cf..13f43061 100644
--- a/src/libical/icalcomponent.c
+++ b/src/libical/icalcomponent.c
@@ -53,6 +53,25 @@
#endif
#endif
+struct icalcomponent_impl
+{
+ char id[5];
+ icalcomponent_kind kind;
+ char* x_name;
+ pvl_list properties;
+ pvl_elem property_iterator;
+ pvl_list components;
+ pvl_elem component_iterator;
+ struct icalcomponent_impl *parent;
+
+ /** An array of icaltimezone structs. We use this so we can do fast
+ lookup of timezones using binary searches. timezones_sorted is
+ set to 0 whenever we add a timezone, so we remember to sort the
+ array before doing a binary search. */
+ icalarray* timezones;
+ int timezones_sorted;
+};
+
/* icalproperty functions that only components get to use */
void icalproperty_set_parent(icalproperty* property,
icalcomponent* component);
diff --git a/src/libical/icalcomponent.h b/src/libical/icalcomponent.h
index 9e9ceefe..05777cf9 100644
--- a/src/libical/icalcomponent.h
+++ b/src/libical/icalcomponent.h
@@ -29,24 +29,6 @@
#include "icalproperty.h"
#include "pvl.h"
-struct icalcomponent_impl
-{
- char id[5];
- icalcomponent_kind kind;
- char* x_name;
- pvl_list properties;
- pvl_elem property_iterator;
- pvl_list components;
- pvl_elem component_iterator;
- struct icalcomponent_impl *parent;
-
- /** An array of icaltimezone structs. We use this so we can do fast
- lookup of timezones using binary searches. timezones_sorted is
- set to 0 whenever we add a timezone, so we remember to sort the
- array before doing a binary search. */
- icalarray* timezones;
- int timezones_sorted;
-};
typedef struct icalcomponent_impl icalcomponent;
#ifdef UNCLEAN
diff --git a/src/libical/icalenums.c b/src/libical/icalenums.c
index 4dbd5139..5191345e 100644
--- a/src/libical/icalenums.c
+++ b/src/libical/icalenums.c
@@ -31,17 +31,6 @@
#include "icalenums.h"
#include "icalmemory.h"
-#ifdef UNCLEAN
-#include <stdio.h> /* For fprintf */
-#include <stdio.h> /* For stderr */
-#include <string.h> /* For strncmp */
-#include <assert.h>
-
-#if defined(_MSC_VER)
-#define snprintf _snprintf
-#endif
-#endif
-
/*** @brief Allowed request status values
*/
static const struct {
diff --git a/src/libical/icalerror.c b/src/libical/icalerror.c
index 32e96501..82eb63a0 100644
--- a/src/libical/icalerror.c
+++ b/src/libical/icalerror.c
@@ -32,12 +32,12 @@
#include "icalerror.h"
#include <stdlib.h>
+
#ifdef HAVE_BACKTRACE
#include <execinfo.h>
#endif
#ifdef UNCLEAN
-#include <stdlib.h> /* for malloc() */
#include <string.h> /* for strcmp */
#if defined(_MSC_VER)
#define LIBICAL_EXPORT __declspec(dllexport)
diff --git a/src/libical/icallangbind.c b/src/libical/icallangbind.c
index d67ed92f..3f40205b 100644
--- a/src/libical/icallangbind.c
+++ b/src/libical/icallangbind.c
@@ -2,15 +2,15 @@
======================================================================
FILE: icallangbind.c
CREATOR: eric 15 dec 2000
-
+
DESCRIPTION:
-
+
$Id: icallangbind.c,v 1.24 2008-01-02 20:07:31 dothebart Exp $
$Locker: $
- (C) COPYRIGHT 1999 Eric Busboom
+ (C) COPYRIGHT 1999 Eric Busboom
http://www.softwarestudio.org
-
+
This package is free software and is provided "as is" without
express or implied warranty. It may be used, redistributed and/or
modified under the same terms as perl itself. ( Either the Artistic
@@ -19,7 +19,7 @@
======================================================================*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
#endif
#include "icalcomponent.h"
@@ -46,7 +46,7 @@ void icallangbind_free_array(int* array){
int icallangbind_access_array(int* array, int index) {
return array[index];
-}
+}
/** Iterators to fetch parameters given property */
@@ -54,17 +54,17 @@ icalparameter* icallangbind_get_first_parameter(icalproperty *prop)
{
icalparameter_kind kind = ICAL_ANY_PARAMETER;
-
+
return icalproperty_get_first_parameter(prop,kind);
}
icalparameter* icallangbind_get_next_parameter(icalproperty *prop)
{
icalparameter_kind kind = ICAL_ANY_PARAMETER;
-
+
return icalproperty_get_next_parameter(prop,kind);
}
-
+
/** Like icalcomponent_get_first_component(), but takes a string for the
kind and can iterate over X properties as if each X name was a
@@ -77,24 +77,24 @@ icalproperty* icallangbind_get_first_property(icalcomponent *c,
icalproperty *p;
if (kind == ICAL_NO_PROPERTY){
- return 0;
+ return 0;
}
if(kind == ICAL_X_PROPERTY){
for(p = icalcomponent_get_first_property(c,kind);
p !=0;
p = icalcomponent_get_next_property(c,kind)){
-
+
if(strcmp(icalproperty_get_x_name(p),prop) == 0){
return p;
- }
+ }
}
} else {
p=icalcomponent_get_first_property(c,kind);
return p;
}
-
+
return 0;
}
@@ -106,24 +106,24 @@ icalproperty* icallangbind_get_next_property(icalcomponent *c,
icalproperty *p;
if (kind == ICAL_NO_PROPERTY){
- return 0;
+ return 0;
}
if(kind == ICAL_X_PROPERTY){
for(p = icalcomponent_get_next_property(c,kind);
p !=0;
p = icalcomponent_get_next_property(c,kind)){
-
+
if(strcmp(icalproperty_get_x_name(p),prop) == 0){
return p;
- }
+ }
}
} else {
p=icalcomponent_get_next_property(c,kind);
return p;
}
-
+
return 0;
}
@@ -135,7 +135,7 @@ icalcomponent* icallangbind_get_first_component(icalcomponent *c,
icalcomponent_kind kind = icalenum_string_to_component_kind(comp);
if (kind == ICAL_NO_COMPONENT){
- return 0;
+ return 0;
}
return icalcomponent_get_first_component(c,kind);
}
@@ -146,7 +146,7 @@ icalcomponent* icallangbind_get_next_component(icalcomponent *c,
icalcomponent_kind kind = icalenum_string_to_component_kind(comp);
if (kind == ICAL_NO_COMPONENT){
- return 0;
+ return 0;
}
return icalcomponent_get_next_component(c,kind);
}
@@ -160,16 +160,16 @@ char* icallangbind_property_eval_string_r(icalproperty* prop, char* sep)
{
char tmp[25];
size_t buf_size = 1024;
- char* buf;
- char* buf_ptr;
+ char* buf;
+ char* buf_ptr;
icalparameter *param;
-
+
icalvalue* value;
if( prop == 0){
- return 0;
+ return 0;
}
-
+
buf = icalmemory_new_buffer(buf_size);
buf_ptr = buf;
@@ -201,45 +201,45 @@ char* icallangbind_property_eval_string_r(icalproperty* prop, char* sep)
if(value){
switch (icalvalue_isa(value)){
-
+
case ICAL_ATTACH_VALUE:
- case ICAL_BINARY_VALUE:
+ case ICAL_BINARY_VALUE:
case ICAL_NO_VALUE: {
icalerror_set_errno(ICAL_INTERNAL_ERROR);
break;
}
- default:
+ default:
{
char* str = icalvalue_as_ical_string_r(value);
char* copy = (char*) malloc(strlen(str)+1);
-
+
const char *i;
char *j;
if(copy ==0){
icalerror_set_errno(ICAL_NEWFAILED_ERROR);
- break;
+ break;
}
/* Remove any newlines */
-
+
for(j=copy, i = str; *i != 0; j++,i++){
if(*i=='\n'){
i++;
- }
+ }
*j = *i;
}
-
+
*j = 0;
-
+
APPENDS(", 'value'");
APPENDS(sep);
APPENDC('\'');
APPENDS(copy);
APPENDC('\'');
-
+
free(copy);
- free(str);
+ free(str);
break;
}
@@ -251,7 +251,7 @@ char* icallangbind_property_eval_string_r(icalproperty* prop, char* sep)
for(param = icalproperty_get_first_parameter(prop,ICAL_ANY_PARAMETER);
param != 0;
param = icalproperty_get_next_parameter(prop,ICAL_ANY_PARAMETER)){
-
+
char *copy = icalparameter_as_ical_string_r(param);
char *v;
@@ -278,9 +278,9 @@ char* icallangbind_property_eval_string_r(icalproperty* prop, char* sep)
APPENDC('\'');
APPENDS(sep);
APPENDC('\'');
- APPENDS(v);
+ APPENDS(v);
APPENDC('\'');
- free(copy);
+ free(copy);
}
@@ -292,10 +292,10 @@ char* icallangbind_property_eval_string_r(icalproperty* prop, char* sep)
const char* icallangbind_property_eval_string(icalproperty* prop, char* sep)
{
- char *buf;
- buf = icallangbind_property_eval_string_r(prop, sep);
- icalmemory_add_tmp_buffer(buf);
- return buf;
+ char *buf;
+ buf = icallangbind_property_eval_string_r(prop, sep);
+ icalmemory_add_tmp_buffer(buf);
+ return buf;
}
@@ -325,9 +325,8 @@ char* icallangbind_quote_as_ical_r(const char* str)
const char* icallangbind_quote_as_ical(const char* str)
{
- char *buf;
- buf = icallangbind_quote_as_ical_r(str);
- icalmemory_add_tmp_buffer(buf);
- return(buf);
+ char *buf;
+ buf = icallangbind_quote_as_ical_r(str);
+ icalmemory_add_tmp_buffer(buf);
+ return(buf);
}
-
diff --git a/src/libical/icallangbind.h b/src/libical/icallangbind.h
index ff5129e1..67885b68 100644
--- a/src/libical/icallangbind.h
+++ b/src/libical/icallangbind.h
@@ -2,15 +2,15 @@
======================================================================
FILE: icallangbind.h
CREATOR: eric 25 jan 2001
-
+
DESCRIPTION:
-
+
$Id: icallangbind.h,v 1.8 2008-01-02 20:07:31 dothebart Exp $
$Locker: $
- (C) COPYRIGHT 1999 Eric Busboom
+ (C) COPYRIGHT 1999 Eric Busboom
http://www.softwarestudio.org
-
+
This package is free software and is provided "as is" without
express or implied warranty. It may be used, redistributed and/or
modified under the same terms as perl itself. ( Either the Artistic
@@ -18,8 +18,8 @@
======================================================================*/
-#ifndef __ICALLANGBIND_H__
-#define __ICALLANGBIND_H__
+#ifndef ICALLANGBIND_H
+#define ICALLANGBIND_H
int* icallangbind_new_array(int size);
void icallangbind_free_array(int* array);
@@ -53,4 +53,5 @@ int icallangbind_string_to_open_flag(const char* str);
const char* icallangbind_quote_as_ical(const char* str);
char* icallangbind_quote_as_ical_r(const char* str);
-#endif /*__ICALLANGBIND_H__*/
+
+#endif
diff --git a/src/libical/icaltz-util.h b/src/libical/icaltz-util.h
index 9de6ff6f..7e1c2c4d 100644
--- a/src/libical/icaltz-util.h
+++ b/src/libical/icaltz-util.h
@@ -25,12 +25,6 @@
#include "icalcomponent.h"
-#ifdef UNCLEAN
-#include <stdio.h>
-#include "icaltime.h"
-#include "icalcomponent.h"
-#endif
-
#if defined(sun) && defined(__SVR4)
#define ZONES_TAB_SYSTEM_FILENAME "tab/zone_sun.tab"
#else
diff --git a/src/libical/icalvalue.c b/src/libical/icalvalue.c
index d424c4b6..0d472a0d 100644
--- a/src/libical/icalvalue.c
+++ b/src/libical/icalvalue.c
@@ -52,7 +52,6 @@
#include <stddef.h> /* For offsetof() macro */
#include <errno.h>
#include <time.h> /* for mktime */
-#include <stdlib.h> /* for atoi and atof */
#include <limits.h> /* for SHRT_MAX */
#if defined(_MSC_VER)
diff --git a/src/libicalcap/client.c b/src/libicalcap/client.c
index 8330ecd3..204823c4 100644
--- a/src/libicalcap/client.c
+++ b/src/libicalcap/client.c
@@ -1,7 +1,7 @@
/*-
* $Id: client.c,v 1.3 2008-01-02 20:07:33 dothebart Exp $
*
- * See the file LICENSE for redistribution information.
+ * See the file LICENSE for redistribution information.
* If you have not received a copy of the license, please contact CodeFactory
* by email at info@codefactory.se, or on the web at http://www.codefactory.se/
* You may also write to: CodeFactory AB, SE-903 47, Umeå, Sweden.
@@ -11,14 +11,17 @@
* Copyright (c) 2002 CodeFactory AB. All rights reserved.
*/
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <librr/rr.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
#include "icalcap.h"
#include "icalcap_session.h"
+#include <stdlib.h>
+
+#include <librr/rr.h>
+
#define CLIENT_CAPABILITY \
"Content-Type: text/html\n\n\
BEGIN:VCALENDAR\n\
@@ -47,147 +50,147 @@ END:VCALENDAR\n"
icalcomponent *
icalcap_send_cmd(const icalcap *cap, const gchar *cmd, const gchar *id, int timeout) {
- icalcap_message*capmsg;
- icalcomponent *comp, *ret = NULL;
- icalproperty *prop;
+ icalcap_message*capmsg;
+ icalcomponent *comp, *ret = NULL;
+ icalproperty *prop;
- prop = icalproperty_vanew_cmd(
- icalproperty_string_to_enum(cmd),
- icalparameter_new_id(id),
- 0);
+ prop = icalproperty_vanew_cmd(
+ icalproperty_string_to_enum(cmd),
+ icalparameter_new_id(id),
+ 0);
- if (timeout > 0) {
- char buf[16];
+ if (timeout > 0) {
+ char buf[16];
- snprintf(buf, 16, "%d", timeout);
- icalproperty_add_parameter(prop,
- icalparameter_new_latency(buf));
+ snprintf(buf, 16, "%d", timeout);
+ icalproperty_add_parameter(prop,
+ icalparameter_new_latency(buf));
- icalproperty_add_parameter(prop,
- icalparameter_new_actionparam(ICAL_ACTIONPARAM_ABORT));
- }
+ icalproperty_add_parameter(prop,
+ icalparameter_new_actionparam(ICAL_ACTIONPARAM_ABORT));
+ }
- comp = icalcomponent_vanew(
- ICAL_VCALENDAR_COMPONENT,
- icalproperty_new_version("2.0"),
- icalproperty_new_prodid("-//I.Net spa//NONSGML//EN"),
- prop,
- 0);
+ comp = icalcomponent_vanew(
+ ICAL_VCALENDAR_COMPONENT,
+ icalproperty_new_version("2.0"),
+ icalproperty_new_prodid("-//I.Net spa//NONSGML//EN"),
+ prop,
+ 0);
- capmsg = icalcap_message_new(cap, comp);
- ret = icalcap_message_sync_send(capmsg, timeout);
- icalcap_message_free(capmsg);
- icalcomponent_free(comp);
+ capmsg = icalcap_message_new(cap, comp);
+ ret = icalcap_message_sync_send(capmsg, timeout);
+ icalcap_message_free(capmsg);
+ icalcomponent_free(comp);
- return ret;
+ return ret;
}
icalcomponent *
icalcap_new_reply_component(const char *id, const icalcomponent *comp) {
- if (comp == NULL)
- return NULL;
-
- return icalcomponent_vanew(
- ICAL_VCALENDAR_COMPONENT,
- icalproperty_new_version("2.0"),
- icalproperty_new_prodid("-//I.Net spa//NONSGML//EN"),
- icalproperty_vanew_cmd(
- ICAL_CMD_REPLY,
-/* icalparameter_new_id(id), */
- 0),
- comp,
- 0);
+ if (comp == NULL)
+ return NULL;
+
+ return icalcomponent_vanew(
+ ICAL_VCALENDAR_COMPONENT,
+ icalproperty_new_version("2.0"),
+ icalproperty_new_prodid("-//I.Net spa//NONSGML//EN"),
+ icalproperty_vanew_cmd(
+ ICAL_CMD_REPLY,
+/* icalparameter_new_id(id), */
+ 0),
+ comp,
+ 0);
}
static int
msg_handler(const icalcap_message *capmsg) {
- icalcomponent *reply;
- char *temp;
+ icalcomponent *reply;
+ char *temp;
- temp = icalcomponent_as_ical_string_r(capmsg->comp);
- g_message("Got: %s", temp);
- free(temp);
+ temp = icalcomponent_as_ical_string_r(capmsg->comp);
+ g_message("Got: %s", temp);
+ free(temp);
- /* FIXME Check it's a GET-CAPABILITY */
+ /* FIXME Check it's a GET-CAPABILITY */
- reply = icalcap_new_reply_component(NULL, capmsg->comp);
- if (reply == NULL) {
- return FALSE;
- }
+ reply = icalcap_new_reply_component(NULL, capmsg->comp);
+ if (reply == NULL) {
+ return FALSE;
+ }
- icalcomponent_add_property(reply,
- icalproperty_new_prodid("client"));
+ icalcomponent_add_property(reply,
+ icalproperty_new_prodid("client"));
- icalcomponent_free(reply);
- return TRUE;
+ icalcomponent_free(reply);
+ return TRUE;
}
int
main (gint argc, gchar **argv)
{
- icalcap_session*conn;
- icalcap *cap;
- icalcomponent *comp;
-
- int i, n;
- int verbose = 0;
-
- if ((conn = icalcap_session_new()) == NULL) {
- fprintf(stderr, "Init failed\n");
- exit(0);
- }
-
- if (!icalcap_session_connect(conn, "gundam.inet.it", 0)) {
- fprintf(stderr, "Connect failed\n");
- exit(0);
- }
-
- if (!icalcap_session_login(conn, "user@example.com", "user@example.com", "password")) {
- fprintf(stderr, "Login failed\n");
- exit(0);
- }
-
- if ((cap = icalcap_session_start(conn, msg_handler)) == NULL) {
- fprintf(stderr, "Start failed\n");
- exit(0);
- }
-
- if (argc > 1 && *argv[1] == '1')
- n = 100;
- else
- n = 1;
-
- for (i=0; i<n; i++) {
- g_print("Test 1: %d\n", i);
-
- if ((comp = icalcap_send_cmd(cap, "GET-CAPABILITY", "zero",15))
- == NULL) {
- fprintf(stderr, "Send failed\n");
- exit(0);
- }
-
- if (verbose) {
- char *obj = icalcomponent_as_ical_string_r(comp);
- g_print("Got %s\n", obj);
- g_free(obj);
- }
-
- if (comp)
- icalcomponent_free(comp);
- }
-
- if (!icalcap_stop(cap)) {
- fprintf(stderr, "Stop failed\n");
- exit(0);
- }
-
- if (!icalcap_session_disconnect(conn)) {
- fprintf(stderr, "Disconnect failed\n");
- exit(0);
- }
-
- return 0;
+ icalcap_session*conn;
+ icalcap *cap;
+ icalcomponent *comp;
+
+ int i, n;
+ int verbose = 0;
+
+ if ((conn = icalcap_session_new()) == NULL) {
+ fprintf(stderr, "Init failed\n");
+ exit(0);
+ }
+
+ if (!icalcap_session_connect(conn, "gundam.inet.it", 0)) {
+ fprintf(stderr, "Connect failed\n");
+ exit(0);
+ }
+
+ if (!icalcap_session_login(conn, "user@example.com", "user@example.com", "password")) {
+ fprintf(stderr, "Login failed\n");
+ exit(0);
+ }
+
+ if ((cap = icalcap_session_start(conn, msg_handler)) == NULL) {
+ fprintf(stderr, "Start failed\n");
+ exit(0);
+ }
+
+ if (argc > 1 && *argv[1] == '1')
+ n = 100;
+ else
+ n = 1;
+
+ for (i=0; i<n; i++) {
+ g_print("Test 1: %d\n", i);
+
+ if ((comp = icalcap_send_cmd(cap, "GET-CAPABILITY", "zero",15))
+ == NULL) {
+ fprintf(stderr, "Send failed\n");
+ exit(0);
+ }
+
+ if (verbose) {
+ char *obj = icalcomponent_as_ical_string_r(comp);
+ g_print("Got %s\n", obj);
+ g_free(obj);
+ }
+
+ if (comp)
+ icalcomponent_free(comp);
+ }
+
+ if (!icalcap_stop(cap)) {
+ fprintf(stderr, "Stop failed\n");
+ exit(0);
+ }
+
+ if (!icalcap_session_disconnect(conn)) {
+ fprintf(stderr, "Disconnect failed\n");
+ exit(0);
+ }
+
+ return 0;
}
diff --git a/src/libicalcap/icalcap.c b/src/libicalcap/icalcap.c
index 8d404f0a..4c504078 100644
--- a/src/libicalcap/icalcap.c
+++ b/src/libicalcap/icalcap.c
@@ -1,22 +1,18 @@
-#include "config.h"
-
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
#endif
#include "icalcap.h"
#include "icalcap_impl.h"
-#include "icalcap_session_impl.h" /* FIXME */
+#include "icalcap_session_impl.h" /* FIXME */
+#include <stdlib.h>
void
icalcap_free(icalcap *cap) {
#ifdef WITH_RR
- icalcap_free_rr(cap);
+ icalcap_free_rr(cap);
#endif
}
@@ -24,9 +20,9 @@ int
icalcap_stop(icalcap *cap) {
#ifdef WITH_RR
- return icalcap_stop_rr(cap);
+ return icalcap_stop_rr(cap);
#else
- return 0;
+ return 0;
#endif
}
@@ -34,11 +30,11 @@ const char *
icalcap_get_username(const icalcap *cap) {
#ifdef WITH_RR
- if (cap == NULL || cap->username == NULL)
- return NULL;
+ if (cap == NULL || cap->username == NULL)
+ return NULL;
- return cap->username;
+ return cap->username;
#else
- return NULL;
+ return NULL;
#endif
}
diff --git a/src/libicalcap/icalcap.h b/src/libicalcap/icalcap.h
index de7b471a..8d1928f3 100644
--- a/src/libicalcap/icalcap.h
+++ b/src/libicalcap/icalcap.h
@@ -1,5 +1,5 @@
-#ifndef __ICALCAP_H__
-#define __ICALCAP_H__
+#ifndef ICALCAP_H
+#define ICALCAP_H
#include <libical/ical.h>
@@ -18,8 +18,8 @@ typedef int (*icalcap_msg_handler)(const icalcap_message *msg);
/*
* icalcap member functions
*/
-void icalcap_free(icalcap *cap);
-int icalcap_stop(icalcap *cap);
+void icalcap_free(icalcap *cap);
+int icalcap_stop(icalcap *cap);
const char *icalcap_get_username(const icalcap *cap);
/*
@@ -27,21 +27,21 @@ const char *icalcap_get_username(const icalcap *cap);
*/
struct _icalcap_message {
- icalcap *cap;
- int type;
+ icalcap *cap;
+ int type;
- icalcomponent *comp;
+ icalcomponent *comp;
};
icalcap_message*icalcap_message_new(const icalcap *cap, const icalcomponent *comp);
icalcap_message*icalcap_message_new_reply(const icalcap_message *capmsg, const icalcomponent *comp);
-void icalcap_message_free(icalcap_message *capmsg);
+void icalcap_message_free(icalcap_message *capmsg);
-int icalcap_message_reply_error(const icalcap_message *orig, enum icalrequeststatus status,
- const char *msg, const char *debug);
-int icalcap_message_reply_component(const icalcap_message *orig, icalcomponent *comp);
+int icalcap_message_reply_error(const icalcap_message *orig, enum icalrequeststatus status,
+ const char *msg, const char *debug);
+int icalcap_message_reply_component(const icalcap_message *orig, icalcomponent *comp);
-int icalcap_message_send(icalcap_message *capmsg);
+int icalcap_message_send(icalcap_message *capmsg);
icalcomponent *icalcap_message_sync_send(icalcap_message *capmsg, int timeout);
#endif
diff --git a/src/libicalcap/icalcap_impl.h b/src/libicalcap/icalcap_impl.h
index 19f8c1db..fc3de267 100644
--- a/src/libicalcap/icalcap_impl.h
+++ b/src/libicalcap/icalcap_impl.h
@@ -1,5 +1,5 @@
-#ifndef __ICALCAP_IMPL_H__
-#define __ICALCAP_IMPL_H__
+#ifndef ICALCAP_IMPL_H
+#define ICALCAP_IMPL_H
#include "icalcap_session.h"
@@ -11,19 +11,19 @@
#include <librrcap/rr-cap.h>
struct _icalcap {
- RRCAP *chan;
- const char *username,
- *authname;
+ RRCAP *chan;
+ const char *username,
+ *authname;
};
struct _icalerror {
- GError *err;
+ GError *err;
};
-void icalcap_free_rr(icalcap *cap);
+void icalcap_free_rr(icalcap *cap);
-int icalcap_stop_rr(icalcap *cap);
+int icalcap_stop_rr(icalcap *cap);
icalcomponent *icalcap_send_component_rr(const icalcap *cap, const icalcomponent *comp, int timeout);
diff --git a/src/libicalcap/icalcap_message.c b/src/libicalcap/icalcap_message.c
index b357c309..edfc09ff 100644
--- a/src/libicalcap/icalcap_message.c
+++ b/src/libicalcap/icalcap_message.c
@@ -1,14 +1,11 @@
-#include "config.h"
-
-#ifdef HAVE_STRING_H
-#include <string.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
#endif
#include "ical.h"
#include "icalcap.h"
#include "icalcap_message_impl.h"
-
/**
* constructor
*
@@ -17,14 +14,14 @@
icalcap_message *
icalcap_message_new(const icalcap *cap, const icalcomponent *comp) {
- icalcap_message *ret = NULL;
+ icalcap_message *ret = NULL;
#ifdef WITH_RR
- ret = icalcap_message_new_rr(cap, comp);
+ ret = icalcap_message_new_rr(cap, comp);
#else
- ret = NULL;
+ ret = NULL;
#endif
- return ret;
+ return ret;
}
/**
@@ -36,9 +33,9 @@ icalcap_message *
icalcap_message_new_reply(const icalcap_message *capmsg, const icalcomponent *comp) {
#ifdef WITH_RR
- return icalcap_message_new_reply_rr(capmsg, comp);
+ return icalcap_message_new_reply_rr(capmsg, comp);
#else
- return NULL;
+ return NULL;
#endif
}
@@ -51,7 +48,7 @@ void
icalcap_message_free(icalcap_message *capmsg) {
#ifdef WITH_RR
- icalcap_message_free_rr(capmsg);
+ icalcap_message_free_rr(capmsg);
#else
#endif
}
@@ -64,12 +61,12 @@ icalcap_message_free(icalcap_message *capmsg) {
icalcomponent *
icalcap_message_sync_send(icalcap_message *capmsg, int timeout) {
- g_return_val_if_fail(capmsg, NULL);
+ g_return_val_if_fail(capmsg, NULL);
#ifdef WITH_RR
- return icalcap_message_sync_send_rr(capmsg, timeout);
+ return icalcap_message_sync_send_rr(capmsg, timeout);
#else
- return NULL;
+ return NULL;
#endif
}
@@ -81,7 +78,7 @@ icalcap_message_sync_send(icalcap_message *capmsg, int timeout) {
int
icalcap_message_send(icalcap_message *capmsg)
{
- int rc;
+ int rc;
char *str;
g_return_val_if_fail(capmsg, FALSE);
@@ -104,17 +101,17 @@ icalcap_message_send(icalcap_message *capmsg)
int
icalcap_message_reply_component(const icalcap_message *orig, icalcomponent *in) {
- icalcap_message*reply;
- int rc;
+ icalcap_message*reply;
+ int rc;
- reply = icalcap_message_new_reply(orig, in);
- if (reply == NULL)
- return FALSE;
+ reply = icalcap_message_new_reply(orig, in);
+ if (reply == NULL)
+ return FALSE;
- rc = icalcap_message_send(reply);
- icalcap_message_free(reply);
+ rc = icalcap_message_send(reply);
+ icalcap_message_free(reply);
- return rc;
+ return rc;
}
/* Only used by icalcap_message_reply_error */
@@ -125,46 +122,46 @@ static icalcomponent *new_reply_component(const icalcap_message *capmsg, const i
*/
int
icalcap_message_reply_error(const icalcap_message *orig, enum icalrequeststatus status,
- const char *msg, const char *debug) {
-
- struct icalreqstattype stat;
- icalcomponent *comp, *vreply;
- int rc;
-
- /* Prepare the REQUEST-STATUS */
- stat = icalreqstattype_from_string(
- icalenum_reqstat_code(status));
-
- if (msg != NULL) {
- /* FIXME we used to do
- stat.desc = strdup(msg);
- but this created a memory leak. Maybe the destructor for reqstat? */
- stat.desc = msg;
- } else {
- stat.desc = icalenum_reqstat_desc(status);
- }
-
- if (debug != NULL)
- stat.debug = debug;
-
- /* Prepare a VREPLY component */
- vreply = icalcomponent_vanew(
- ICAL_VREPLY_COMPONENT,
- icalproperty_new_requeststatus(stat),
- 0);
- if (vreply == NULL) {
- /* FIXME */
- return FALSE;
- }
-
- comp = new_reply_component(orig, vreply);
-
- rc = icalcap_message_reply_component(orig, comp);
-
- icalcomponent_free(comp);
- icalcomponent_free(vreply);
-
- return rc;
+ const char *msg, const char *debug) {
+
+ struct icalreqstattype stat;
+ icalcomponent *comp, *vreply;
+ int rc;
+
+ /* Prepare the REQUEST-STATUS */
+ stat = icalreqstattype_from_string(
+ icalenum_reqstat_code(status));
+
+ if (msg != NULL) {
+ /* FIXME we used to do
+ stat.desc = strdup(msg);
+ but this created a memory leak. Maybe the destructor for reqstat? */
+ stat.desc = msg;
+ } else {
+ stat.desc = icalenum_reqstat_desc(status);
+ }
+
+ if (debug != NULL)
+ stat.debug = debug;
+
+ /* Prepare a VREPLY component */
+ vreply = icalcomponent_vanew(
+ ICAL_VREPLY_COMPONENT,
+ icalproperty_new_requeststatus(stat),
+ 0);
+ if (vreply == NULL) {
+ /* FIXME */
+ return FALSE;
+ }
+
+ comp = new_reply_component(orig, vreply);
+
+ rc = icalcap_message_reply_component(orig, comp);
+
+ icalcomponent_free(comp);
+ icalcomponent_free(vreply);
+
+ return rc;
}
@@ -174,52 +171,52 @@ icalcap_message_reply_error(const icalcap_message *orig, enum icalrequeststatus
static const char *
get_id(icalcomponent *comp) {
- icalproperty *prop;
- icalparameter *param;
+ icalproperty *prop;
+ icalparameter *param;
- prop = icalcomponent_get_first_property(comp, ICAL_CMD_PROPERTY);
- if (prop == NULL)
- return NULL;
+ prop = icalcomponent_get_first_property(comp, ICAL_CMD_PROPERTY);
+ if (prop == NULL)
+ return NULL;
- param = icalproperty_get_first_parameter(prop, ICAL_ID_PARAMETER);
- if (param == NULL)
- return NULL;
+ param = icalproperty_get_first_parameter(prop, ICAL_ID_PARAMETER);
+ if (param == NULL)
+ return NULL;
- return icalparameter_get_id(param);
+ return icalparameter_get_id(param);
}
/* only used by icalcap_message_reply_error */
static icalcomponent *
new_reply_component(const icalcap_message *capmsg, const icalcomponent *comp) {
- icalcomponent *clone, *cal, *root;
- icalproperty *cmd;
- const char *id;
+ icalcomponent *clone, *cal, *root;
+ icalproperty *cmd;
+ const char *id;
- cmd = icalproperty_new_cmd(ICAL_CMD_REPLY);
+ cmd = icalproperty_new_cmd(ICAL_CMD_REPLY);
- if (capmsg->comp != NULL) {
- id = get_id(capmsg->comp);
+ if (capmsg->comp != NULL) {
+ id = get_id(capmsg->comp);
- if (id != NULL)
- icalproperty_add_parameter(cmd, icalparameter_new_id(id));
- }
+ if (id != NULL)
+ icalproperty_add_parameter(cmd, icalparameter_new_id(id));
+ }
- cal = icalcomponent_vanew(
- ICAL_VCALENDAR_COMPONENT,
- icalproperty_new_version("2.0"),
- icalproperty_new_prodid("-//I.Net spa//NONSGML//EN"),
- cmd,
- 0);
+ cal = icalcomponent_vanew(
+ ICAL_VCALENDAR_COMPONENT,
+ icalproperty_new_version("2.0"),
+ icalproperty_new_prodid("-//I.Net spa//NONSGML//EN"),
+ cmd,
+ 0);
- if (comp != NULL) {
- clone = icalcomponent_new_clone(comp);
- icalcomponent_add_component(cal, clone);
- }
+ if (comp != NULL) {
+ clone = icalcomponent_new_clone(comp);
+ icalcomponent_add_component(cal, clone);
+ }
- root = icalcomponent_vanew(
- ICAL_XROOT_COMPONENT,
- cal,
- 0);
- return root;
+ root = icalcomponent_vanew(
+ ICAL_XROOT_COMPONENT,
+ cal,
+ 0);
+ return root;
}
diff --git a/src/libicalcap/icalcap_message_impl.h b/src/libicalcap/icalcap_message_impl.h
index fa44f4dc..ca69de87 100644
--- a/src/libicalcap/icalcap_message_impl.h
+++ b/src/libicalcap/icalcap_message_impl.h
@@ -1,29 +1,29 @@
-#ifndef __ICALCAP_MESSAGE_IMPL_H__
-#define __ICALCAP_MESSAGE_IMPL_H__
+#ifndef ICALCAP_MESSAGE_IMPL_H
+#define ICALCAP_MESSAGE_IMPL_H
#ifdef WITH_RR
#include <libical/ical.h>
#include <librr/rr.h>
-#define ICALCAP_MESSAGE_CMD 1
-#define ICALCAP_MESSAGE_REPLY 1
+#define ICALCAP_MESSAGE_CMD 1
+#define ICALCAP_MESSAGE_REPLY 1
struct _icalcap_message_rr {
- const icalcap *cap;
- int type;
+ const icalcap *cap;
+ int type;
- icalcomponent *comp;
+ icalcomponent *comp;
- RRFrame *frame;
- RRMessage *msg;
+ RRFrame *frame;
+ RRMessage *msg;
};
icalcap_message*icalcap_message_new_rr(const icalcap *cap, const icalcomponent *comp);
icalcap_message*icalcap_message_new_reply_rr(const icalcap_message *capmsg, const icalcomponent *comp);
-void icalcap_message_free_rr(icalcap_message *capmsg);
+void icalcap_message_free_rr(icalcap_message *capmsg);
-int icalcap_message_send_reply_rr(icalcap_message *capmsg);
+int icalcap_message_send_reply_rr(icalcap_message *capmsg);
icalcomponent *icalcap_message_sync_send_rr(icalcap_message *capmsg, int timeout);
#else
diff --git a/src/libicalcap/icalcap_rr.c b/src/libicalcap/icalcap_rr.c
index f1e37c5a..61726574 100644
--- a/src/libicalcap/icalcap_rr.c
+++ b/src/libicalcap/icalcap_rr.c
@@ -1,10 +1,5 @@
-#include "config.h"
-
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
#endif
#include "icalcap.h"
@@ -16,10 +11,12 @@
#include "icalcap_session_impl.h"
#include "icalcap_server_impl.h"
+#include <stdlib.h>
+
icalcomponent *icalcap_component_new_from_string(const char *data);
-static int default_msg_handler(RRCAP *cap, RRFrame *frame, GError **error);
-static void client_final_handler(RRCAP *cap);
+static int default_msg_handler(RRCAP *cap, RRFrame *frame, GError **error);
+static void client_final_handler(RRCAP *cap);
/**
* Implementation of functions in icalcap
@@ -27,15 +24,15 @@ static void client_final_handler(RRCAP *cap);
void
icalcap_free_rr(icalcap *cap) {
- g_return_if_fail(cap);
+ g_return_if_fail(cap);
- if (cap->username)
- free(cap->username);
+ if (cap->username)
+ free(cap->username);
- if (cap->authname)
- free(cap->authname);
+ if (cap->authname)
+ free(cap->authname);
- g_free(cap);
+ g_free(cap);
}
/**
@@ -44,140 +41,140 @@ icalcap_free_rr(icalcap *cap) {
icalcap_session *
icalcap_session_new_rr(void) {
- icalcap_session *sess;
- GError *error = NULL;
+ icalcap_session *sess;
+ GError *error = NULL;
- /* Initialize roadrunner */
- if (!rr_init(0, NULL, &error))
- return 0;
+ /* Initialize roadrunner */
+ if (!rr_init(0, NULL, &error))
+ return 0;
- if ((sess = g_new0(icalcap_session, 1)) == NULL) {
- /* FIXME return an error */
- return NULL;
- }
+ if ((sess = g_new0(icalcap_session, 1)) == NULL) {
+ /* FIXME return an error */
+ return NULL;
+ }
- sess->cfg = rr_cap_config_new();
+ sess->cfg = rr_cap_config_new();
- /* Tell roadrunner which profiles we want to support */
- sess->profreg = rr_profile_registry_new();
- rr_profile_registry_add_profile(sess->profreg, RR_TYPE_CAP, NULL);
- rr_profile_registry_add_profile(sess->profreg, RR_TYPE_TLS, NULL);
- rr_profile_registry_add_profile(sess->profreg, RR_TYPE_SASL_DIGEST_MD5, NULL);
+ /* Tell roadrunner which profiles we want to support */
+ sess->profreg = rr_profile_registry_new();
+ rr_profile_registry_add_profile(sess->profreg, RR_TYPE_CAP, NULL);
+ rr_profile_registry_add_profile(sess->profreg, RR_TYPE_TLS, NULL);
+ rr_profile_registry_add_profile(sess->profreg, RR_TYPE_SASL_DIGEST_MD5, NULL);
- return sess;
+ return sess;
}
int
icalcap_session_connect_rr(icalcap_session *sess, const char *hostname, const int port) {
- GError *error = NULL;
+ GError *error = NULL;
- if (sess == NULL) {
- /* FIXME return the error */
- return FALSE;
- }
+ if (sess == NULL) {
+ /* FIXME return the error */
+ return FALSE;
+ }
- /* Create a connection object */
- sess->connection = rr_tcp_connection_new(sess->profreg, hostname, port, &error);
- if (sess->connection == NULL) {
- /* FIXME return the error */
- return FALSE;
- }
+ /* Create a connection object */
+ sess->connection = rr_tcp_connection_new(sess->profreg, hostname, port, &error);
+ if (sess->connection == NULL) {
+ /* FIXME return the error */
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
int
icalcap_session_login_rr(icalcap_session *sess, const char *username, const char *authname,
- const char *password) {
+ const char *password) {
- /* assert cap != NULL */
- GError *error = NULL;
+ /* assert cap != NULL */
+ GError *error = NULL;
- rr_sasl_set_username(sess->connection, username);
- rr_sasl_set_authname(sess->connection, authname);
- rr_sasl_set_password(sess->connection, password);
+ rr_sasl_set_username(sess->connection, username);
+ rr_sasl_set_authname(sess->connection, authname);
+ rr_sasl_set_password(sess->connection, password);
- /* FIXME */
- if (!rr_sasl_login(sess->connection, RR_TYPE_SASL_DIGEST_MD5,
- "foo.example.com", NULL, &error)) {
- /* FIXME return the error */
- return 0;
- }
+ /* FIXME */
+ if (!rr_sasl_login(sess->connection, RR_TYPE_SASL_DIGEST_MD5,
+ "foo.example.com", NULL, &error)) {
+ /* FIXME return the error */
+ return 0;
+ }
- return 1;
+ return 1;
}
icalcap *
icalcap_session_start_rr(const icalcap_session *sess, icalcap_msg_handler handler) {
- /* assert sess != NULL */
- icalcap *cap;
- RRCAP *channel;
- GError *error = NULL;
+ /* assert sess != NULL */
+ icalcap *cap;
+ RRCAP *channel;
+ GError *error = NULL;
- if ((cap = g_new0(icalcap, 1)) == NULL) {
- /* FIXME return an error */
- return NULL;
- }
+ if ((cap = g_new0(icalcap, 1)) == NULL) {
+ /* FIXME return an error */
+ return NULL;
+ }
- if (handler != NULL) {
- rr_cap_config_set_msg_handler(sess->cfg, default_msg_handler, (void *)handler);
- /* FIXME rr_cap_config_set_final_handler(cfg, client_final_handler); */
- }
+ if (handler != NULL) {
+ rr_cap_config_set_msg_handler(sess->cfg, default_msg_handler, (void *)handler);
+ /* FIXME rr_cap_config_set_final_handler(cfg, client_final_handler); */
+ }
- if ((channel = rr_cap_client_start(sess->connection, sess->cfg, &error)) == NULL) {
- /* FIXME return the error */
- goto FAILED;
- }
+ if ((channel = rr_cap_client_start(sess->connection, sess->cfg, &error)) == NULL) {
+ /* FIXME return the error */
+ goto FAILED;
+ }
- cap->chan = channel;
- channel->hl = cap;
+ cap->chan = channel;
+ channel->hl = cap;
- return cap;
+ return cap;
FAILED:
- g_free(cap);
- return NULL;
+ g_free(cap);
+ return NULL;
}
int
icalcap_stop_rr(icalcap *cap) {
- /* assert cap != NULL */
- GError *error = NULL;
+ /* assert cap != NULL */
+ GError *error = NULL;
- if (!rr_cap_close(cap->chan, &error)) {
- /* FIXME return the error */
- return 0;
- }
+ if (!rr_cap_close(cap->chan, &error)) {
+ /* FIXME return the error */
+ return 0;
+ }
- cap->chan = NULL;
- g_free(cap);
+ cap->chan = NULL;
+ g_free(cap);
- return 1;
+ return 1;
}
int
icalcap_session_disconnect_rr(icalcap_session *sess) {
- /* assert cap != NULL */
- GError *error = NULL;
+ /* assert cap != NULL */
+ GError *error = NULL;
- if (!rr_connection_disconnect(sess->connection, &error)) {
- /* FIXME return the error */
- return 0;
- }
+ if (!rr_connection_disconnect(sess->connection, &error)) {
+ /* FIXME return the error */
+ return 0;
+ }
- sess->connection = NULL;
- g_free(sess);
+ sess->connection = NULL;
+ g_free(sess);
- if (!rr_exit(&error)) {
- /* FIXME return the error */
- return 0;
- }
+ if (!rr_exit(&error)) {
+ /* FIXME return the error */
+ return 0;
+ }
- return 1;
+ return 1;
}
/**
@@ -191,71 +188,71 @@ icalcap_session_disconnect_rr(icalcap_session *sess) {
static int
server_init_handler(RRCAP *chan, const gchar *piggyback, GError **error) {
- icalcap *cap;
- RRConnection *connection;
+ icalcap *cap;
+ RRConnection *connection;
- icalcap_auth_handler func;
- const gchar *username, *authname;
- int rc;
+ icalcap_auth_handler func;
+ const gchar *username, *authname;
+ int rc;
- g_return_val_if_fail(chan, FALSE);
- g_return_val_if_fail(chan->cfg, FALSE);
- g_return_val_if_fail(chan->cfg->server_init_data, FALSE);
+ g_return_val_if_fail(chan, FALSE);
+ g_return_val_if_fail(chan->cfg, FALSE);
+ g_return_val_if_fail(chan->cfg->server_init_data, FALSE);
- connection = rr_channel_get_connection(RR_CHANNEL(chan));
- if ((username = rr_sasl_get_username(connection)) == NULL)
- return FALSE;
- if ((authname = rr_sasl_get_authname(connection)) == NULL)
- return FALSE;
+ connection = rr_channel_get_connection(RR_CHANNEL(chan));
+ if ((username = rr_sasl_get_username(connection)) == NULL)
+ return FALSE;
+ if ((authname = rr_sasl_get_authname(connection)) == NULL)
+ return FALSE;
- if ((cap = g_new0(icalcap, 1)) == NULL) {
- return FALSE;
- }
+ if ((cap = g_new0(icalcap, 1)) == NULL) {
+ return FALSE;
+ }
- cap->chan = chan;
- chan->hl = cap;
+ cap->chan = chan;
+ chan->hl = cap;
- cap->username = strdup(username);
- cap->authname = strdup(authname);
+ cap->username = strdup(username);
+ cap->authname = strdup(authname);
- func = (icalcap_auth_handler)chan->cfg->server_init_data;
- return func(cap, piggyback);
+ func = (icalcap_auth_handler)chan->cfg->server_init_data;
+ return func(cap, piggyback);
}
static void
server_confirmation_handler(RRCAP *chan) {
- icalcap_chanup_handler func;
+ icalcap_chanup_handler func;
- g_return_if_fail(chan);
- g_return_if_fail(chan->cfg);
- g_return_if_fail(chan->cfg->server_confirmation_data);
+ g_return_if_fail(chan);
+ g_return_if_fail(chan->cfg);
+ g_return_if_fail(chan->cfg->server_confirmation_data);
- func = (icalcap_chanup_handler)chan->cfg->server_confirmation_data;
+ func = (icalcap_chanup_handler)chan->cfg->server_confirmation_data;
- func(chan->hl);
+ func(chan->hl);
}
static gboolean
server_frame_handler(RRCAP *cap, RRFrame *frame, GError **error)
{
- if (frame->type == RR_FRAME_TYPE_MSG)
- /* FIXME */
- return default_msg_handler(cap, frame, error);
- else
- return FALSE;
+ if (frame->type == RR_FRAME_TYPE_MSG)
+ /* FIXME */
+ return default_msg_handler(cap, frame, error);
+ else
+ return FALSE;
}
static void
server_final_handler(RRCAP *cap)
{
- g_return_if_fail(cap);
- g_return_if_fail(RR_CAP(cap));
+ g_return_if_fail(cap);
+ g_return_if_fail(RR_CAP(cap));
- if (cap->hl != NULL) {
- icalcap_free(cap->hl);
- cap->hl = NULL;
- }
+ if (cap->hl != NULL) {
+ icalcap_free(cap->hl);
+ cap->hl = NULL;
+ }
}
/*
@@ -263,84 +260,84 @@ server_final_handler(RRCAP *cap)
*/
icalcap_server *
icalcap_server_new_rr(icalcap_auth_handler auth_cb, icalcap_chanup_handler chanup_cb,
- icalcap_msg_handler msg_cb) {
-
- icalcap_server *serv;
- GError *error = NULL;
-
- /* Initialize roadrunner */
- if (!rr_init(0, NULL, &error))
- return 0;
-
- if ((serv = g_new0(icalcap_server, 1)) == NULL) {
- /* FIXME return an error */
- return NULL;
- }
- serv->handler = msg_cb;
-
- /* This is somewhat hackish */
- serv->cfg = rr_cap_config_new();
- rr_cap_config_set_msg_handler(serv->cfg, NULL, (void *)msg_cb);
- rr_cap_config_set_frame_handler(serv->cfg, server_frame_handler);
- rr_cap_config_set_final_handler(serv->cfg, server_final_handler);
- rr_cap_config_set_server_init_handler(serv->cfg, server_init_handler, (void *)auth_cb);
- rr_cap_config_set_server_confirmation_handler(serv->cfg,
- server_confirmation_handler, (void *)chanup_cb);
-
- /* Tell roadrunner which profiles we want to support */
- serv->profreg = rr_profile_registry_new();
- rr_profile_registry_add_profile(serv->profreg, RR_TYPE_CAP, serv->cfg);
- rr_profile_registry_add_profile(serv->profreg, RR_TYPE_TLS, NULL);
- rr_profile_registry_add_profile(serv->profreg, RR_TYPE_SASL_DIGEST_MD5, NULL);
-
- return serv;
+ icalcap_msg_handler msg_cb) {
+
+ icalcap_server *serv;
+ GError *error = NULL;
+
+ /* Initialize roadrunner */
+ if (!rr_init(0, NULL, &error))
+ return 0;
+
+ if ((serv = g_new0(icalcap_server, 1)) == NULL) {
+ /* FIXME return an error */
+ return NULL;
+ }
+ serv->handler = msg_cb;
+
+ /* This is somewhat hackish */
+ serv->cfg = rr_cap_config_new();
+ rr_cap_config_set_msg_handler(serv->cfg, NULL, (void *)msg_cb);
+ rr_cap_config_set_frame_handler(serv->cfg, server_frame_handler);
+ rr_cap_config_set_final_handler(serv->cfg, server_final_handler);
+ rr_cap_config_set_server_init_handler(serv->cfg, server_init_handler, (void *)auth_cb);
+ rr_cap_config_set_server_confirmation_handler(serv->cfg,
+ server_confirmation_handler, (void *)chanup_cb);
+
+ /* Tell roadrunner which profiles we want to support */
+ serv->profreg = rr_profile_registry_new();
+ rr_profile_registry_add_profile(serv->profreg, RR_TYPE_CAP, serv->cfg);
+ rr_profile_registry_add_profile(serv->profreg, RR_TYPE_TLS, NULL);
+ rr_profile_registry_add_profile(serv->profreg, RR_TYPE_SASL_DIGEST_MD5, NULL);
+
+ return serv;
}
int
icalcap_server_listen_rr(icalcap_server *serv, const char *hostname, const int port) {
- GError *error = NULL;
- g_return_val_if_fail(serv, FALSE);
+ GError *error = NULL;
+ g_return_val_if_fail(serv, FALSE);
- /* Create a listener object */
- serv->listener = rr_tcp_listener_new(serv->profreg, hostname, port, &error);
- if (serv->listener == NULL) {
- /* FIXME return the error */
- return FALSE;
- }
+ /* Create a listener object */
+ serv->listener = rr_tcp_listener_new(serv->profreg, hostname, port, &error);
+ if (serv->listener == NULL) {
+ /* FIXME return the error */
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
int
icalcap_server_run_rr(const icalcap_server *serv) {
- /* assert cap != NULL */
- GError *error = NULL;
+ /* assert cap != NULL */
+ GError *error = NULL;
- if (!rr_wait_until_done(&error)) {
- /* FIXME return the error */
- return FALSE;
- }
+ if (!rr_wait_until_done(&error)) {
+ /* FIXME return the error */
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
int
icalcap_server_shutdown_rr(icalcap_server *serv) {
- /* assert cap != NULL */
- GError *error = NULL;
+ /* assert cap != NULL */
+ GError *error = NULL;
- if (!rr_listener_shutdown(serv->listener, &error)) {
- /* FIXME return the error */
- return 0;
- }
+ if (!rr_listener_shutdown(serv->listener, &error)) {
+ /* FIXME return the error */
+ return 0;
+ }
- serv->listener = NULL;
- g_free(serv);
+ serv->listener = NULL;
+ g_free(serv);
- return 1;
+ return 1;
}
/*
@@ -353,62 +350,62 @@ icalcap_server_shutdown_rr(icalcap_server *serv) {
static struct _icalcap_message_rr *
_icalcap_message_new_from_component_rr(const icalcap *cap, int type, icalcomponent *comp) {
- struct _icalcap_message_rr *ret;
+ struct _icalcap_message_rr *ret;
- if ((ret = g_new0(struct _icalcap_message_rr, 1)) == NULL) {
- /* FIXME return an error */
- return NULL;
- }
+ if ((ret = g_new0(struct _icalcap_message_rr, 1)) == NULL) {
+ /* FIXME return an error */
+ return NULL;
+ }
- ret->cap = cap;
- ret->type = type;
+ ret->cap = cap;
+ ret->type = type;
- ret->comp = comp;
+ ret->comp = comp;
- return ret;
+ return ret;
}
static icalcap_message *
_icalcap_message_new_from_frame_rr(const icalcap *cap, int type, RRFrame *frame) {
- struct _icalcap_message_rr *ret;
+ struct _icalcap_message_rr *ret;
- if ((ret = g_new0(struct _icalcap_message_rr, 1)) == NULL) {
- /* FIXME return an error */
- return NULL;
- }
+ if ((ret = g_new0(struct _icalcap_message_rr, 1)) == NULL) {
+ /* FIXME return an error */
+ return NULL;
+ }
- ret->cap = cap;
- ret->type = type;
- ret->frame = frame;
+ ret->cap = cap;
+ ret->type = type;
+ ret->frame = frame;
- ret->comp = icalcap_component_new_from_string(ret->frame->payload);
+ ret->comp = icalcap_component_new_from_string(ret->frame->payload);
- return (icalcap_message *)ret;
+ return (icalcap_message *)ret;
}
icalcap_message *
icalcap_message_new_rr(const icalcap *cap, const icalcomponent *comp) {
- struct _icalcap_message_rr *ret;
- gchar *str, *obj;
+ struct _icalcap_message_rr *ret;
+ gchar *str, *obj;
- if (comp == NULL) {
- /* FIXME return an error */
- return NULL;
- }
+ if (comp == NULL) {
+ /* FIXME return an error */
+ return NULL;
+ }
- ret = _icalcap_message_new_from_component_rr(cap, ICALCAP_MESSAGE_CMD, NULL);
+ ret = _icalcap_message_new_from_component_rr(cap, ICALCAP_MESSAGE_CMD, NULL);
- obj = icalcomponent_as_ical_string_r(comp);
- str = g_strdup_printf("%s\n\n%s",
- "Content-Type: text/calendar",
- obj);
- free(obj);
+ obj = icalcomponent_as_ical_string_r(comp);
+ str = g_strdup_printf("%s\n\n%s",
+ "Content-Type: text/calendar",
+ obj);
+ free(obj);
- ret->msg = rr_message_static_new(RR_FRAME_TYPE_MSG, str, strlen(str), TRUE);
+ ret->msg = rr_message_static_new(RR_FRAME_TYPE_MSG, str, strlen(str), TRUE);
- return (icalcap_message *)ret;
+ return (icalcap_message *)ret;
}
/*
@@ -418,85 +415,85 @@ icalcap_message_new_rr(const icalcap *cap, const icalcomponent *comp) {
icalcap_message *
icalcap_message_new_reply_rr(const icalcap_message *orig, const icalcomponent *comp) {
- struct _icalcap_message_rr *in, *ret;
- icalcomponent *cc;
- GString *str;
+ struct _icalcap_message_rr *in, *ret;
+ icalcomponent *cc;
+ GString *str;
- if ((in = (struct _icalcap_message_rr *)orig) == NULL) {
- /* FIXME return an error */
- return NULL;
- }
+ if ((in = (struct _icalcap_message_rr *)orig) == NULL) {
+ /* FIXME return an error */
+ return NULL;
+ }
- ret = _icalcap_message_new_from_component_rr(in->cap, ICALCAP_MESSAGE_REPLY, NULL);
+ ret = _icalcap_message_new_from_component_rr(in->cap, ICALCAP_MESSAGE_REPLY, NULL);
- /* FIXME */
- if (icalcomponent_isa(comp) != ICAL_XROOT_COMPONENT)
- return NULL;
+ /* FIXME */
+ if (icalcomponent_isa(comp) != ICAL_XROOT_COMPONENT)
+ return NULL;
- /* FIXME don't hardcode */
- str = g_string_new("Content-Type: text/calendar\n\n");
+ /* FIXME don't hardcode */
+ str = g_string_new("Content-Type: text/calendar\n\n");
- for (cc = icalcomponent_get_first_component(comp,
- ICAL_VCALENDAR_COMPONENT);
- cc != NULL;
- cc = icalcomponent_get_next_component(comp,
- ICAL_VCALENDAR_COMPONENT)) {
- char *obj;
- obj = icalcomponent_as_ical_string_r(cc);
- g_string_append(str, obj);
- free(obj);
- }
+ for (cc = icalcomponent_get_first_component(comp,
+ ICAL_VCALENDAR_COMPONENT);
+ cc != NULL;
+ cc = icalcomponent_get_next_component(comp,
+ ICAL_VCALENDAR_COMPONENT)) {
+ char *obj;
+ obj = icalcomponent_as_ical_string_r(cc);
+ g_string_append(str, obj);
+ free(obj);
+ }
- ret->msg = rr_message_static_new(RR_FRAME_TYPE_RPY, str->str, strlen(str->str), TRUE);
- /* FIXME this should now be ok but if change the API we need to change */
- ret->msg->msgno = in->frame->msgno;
+ ret->msg = rr_message_static_new(RR_FRAME_TYPE_RPY, str->str, strlen(str->str), TRUE);
+ /* FIXME this should now be ok but if change the API we need to change */
+ ret->msg->msgno = in->frame->msgno;
- return (icalcap_message *)ret;
+ return (icalcap_message *)ret;
}
void
icalcap_message_free_rr(icalcap_message *in) {
- struct _icalcap_message_rr *capmsg = (struct _icalcap_message_rr *)in;
- g_return_if_fail(capmsg);
+ struct _icalcap_message_rr *capmsg = (struct _icalcap_message_rr *)in;
+ g_return_if_fail(capmsg);
- if (capmsg->comp != NULL) {
- icalcomponent_free(capmsg->comp);
- capmsg->comp = NULL;
- }
+ if (capmsg->comp != NULL) {
+ icalcomponent_free(capmsg->comp);
+ capmsg->comp = NULL;
+ }
- if (capmsg->msg != NULL) {
- g_free(capmsg->msg);
- }
+ if (capmsg->msg != NULL) {
+ g_free(capmsg->msg);
+ }
- g_free(capmsg);
+ g_free(capmsg);
}
int
icalcap_message_send_reply_rr(icalcap_message *in) {
- struct _icalcap_message_rr *capmsg = (struct _icalcap_message_rr *)in;
- GError *error = NULL;
- int rc;
+ struct _icalcap_message_rr *capmsg = (struct _icalcap_message_rr *)in;
+ GError *error = NULL;
+ int rc;
- if ((rc = rr_channel_send_message(RR_CHANNEL(capmsg->cap->chan), capmsg->msg, &error)) == 0)
- g_message("error = %s", error->message);
- /* FIXME handle error */
+ if ((rc = rr_channel_send_message(RR_CHANNEL(capmsg->cap->chan), capmsg->msg, &error)) == 0)
+ g_message("error = %s", error->message);
+ /* FIXME handle error */
- capmsg->msg = NULL;
+ capmsg->msg = NULL;
- return rc;
+ return rc;
}
icalcomponent *
icalcap_message_sync_send_rr(icalcap_message *in, int timeout)
{
struct _icalcap_message_rr *capmsg = (struct _icalcap_message_rr *)in;
- icalcomponent *comp;
+ icalcomponent *comp;
- gchar *str2;
- GError *error = NULL;
- int rc;
+ gchar *str2;
+ GError *error = NULL;
+ int rc;
/* FIXME */
rc = rr_cap_cmd(capmsg->cap->chan, capmsg->msg, 3 * timeout, &str2, &error);
@@ -523,25 +520,25 @@ icalcap_message_sync_send_rr(icalcap_message *in, int timeout)
int
default_msg_handler(RRCAP *cap, RRFrame *frame, GError **error) {
- icalcap_msg_handler func;
- icalcap_message *msg;
- int ret;
+ icalcap_msg_handler func;
+ icalcap_message *msg;
+ int ret;
- g_return_val_if_fail(cap, FALSE);
- g_return_val_if_fail(cap->cfg, FALSE);
- g_return_val_if_fail(cap->cfg->msg_handler_data, FALSE);
+ g_return_val_if_fail(cap, FALSE);
+ g_return_val_if_fail(cap->cfg, FALSE);
+ g_return_val_if_fail(cap->cfg->msg_handler_data, FALSE);
- func = (icalcap_msg_handler)cap->cfg->msg_handler_data;
+ func = (icalcap_msg_handler)cap->cfg->msg_handler_data;
- msg = _icalcap_message_new_from_frame_rr(cap->hl, ICALCAP_MESSAGE_CMD, frame);
- if (msg == NULL) {
- /* FIXME */
- g_message("error");
- return FALSE;
- }
+ msg = _icalcap_message_new_from_frame_rr(cap->hl, ICALCAP_MESSAGE_CMD, frame);
+ if (msg == NULL) {
+ /* FIXME */
+ g_message("error");
+ return FALSE;
+ }
- ret = func(msg);
- icalcap_message_free(msg);
+ ret = func(msg);
+ icalcap_message_free(msg);
- return ret;
+ return ret;
}
diff --git a/src/libicalcap/icalcap_server.c b/src/libicalcap/icalcap_server.c
index 77b84845..61475f15 100644
--- a/src/libicalcap/icalcap_server.c
+++ b/src/libicalcap/icalcap_server.c
@@ -1,33 +1,34 @@
-#include "config.h"
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
#include "icalcap.h"
#include "icalcap_server.h"
#include "icalcap_server_impl.h"
-
icalcap_server *
icalcap_server_new(icalcap_auth_handler auth_cb, icalcap_chanup_handler chanup_cb,
- icalcap_msg_handler msg_cb) {
+ icalcap_msg_handler msg_cb) {
#ifdef WITH_RR
- return icalcap_server_new_rr(auth_cb, chanup_cb, msg_cb);
+ return icalcap_server_new_rr(auth_cb, chanup_cb, msg_cb);
#else
- return NULL;
+ return NULL;
#endif
}
int
icalcap_server_listen(icalcap_server *cap, const char *hostname, const int _port) {
- int port = _port;
+ int port = _port;
- if (port <= 0)
- port = 1026;
+ if (port <= 0)
+ port = 1026;
#ifdef WITH_RR
- return icalcap_server_listen_rr(cap, hostname, port);
+ return icalcap_server_listen_rr(cap, hostname, port);
#else
- return 0;
+ return 0;
#endif
}
@@ -35,9 +36,9 @@ int
icalcap_server_run(const icalcap_server *cap) {
#ifdef WITH_RR
- return icalcap_server_run_rr(cap);
+ return icalcap_server_run_rr(cap);
#else
- return 0;
+ return 0;
#endif
}
@@ -45,8 +46,8 @@ int
icalcap_server_shutdown(icalcap_server *cap) {
#ifdef WITH_RR
- return icalcap_server_shutdown_rr(cap);
+ return icalcap_server_shutdown_rr(cap);
#else
- return 0;
+ return 0;
#endif
}
diff --git a/src/libicalcap/icalcap_server.h b/src/libicalcap/icalcap_server.h
index 53c73d3b..08fa350b 100644
--- a/src/libicalcap/icalcap_server.h
+++ b/src/libicalcap/icalcap_server.h
@@ -1,5 +1,5 @@
-#ifndef __ICALCAP_SERVER_H__
-#define __ICALCAP_SERVER_H__
+#ifndef ICALCAP_SERVER_H
+#define ICALCAP_SERVER_H
#include "icalcap.h"
@@ -8,12 +8,12 @@ typedef struct _icalcap_server icalcap_server;
typedef int (*icalcap_auth_handler)(const icalcap *cap, const char *piggyback);
typedef void (*icalcap_chanup_handler)(const icalcap *cap);
-icalcap_server*icalcap_server_new(icalcap_auth_handler auth_cb,
- icalcap_chanup_handler chanup_cb,
- icalcap_msg_handler msg_cb);
+icalcap_server*icalcap_server_new(icalcap_auth_handler auth_cb,
+ icalcap_chanup_handler chanup_cb,
+ icalcap_msg_handler msg_cb);
-int icalcap_server_listen(icalcap_server *cap, const char *hostname, const int port);
-int icalcap_server_run(const icalcap_server *cap);
-int icalcap_server_shutdown(icalcap_server *cap);
+int icalcap_server_listen(icalcap_server *cap, const char *hostname, const int port);
+int icalcap_server_run(const icalcap_server *cap);
+int icalcap_server_shutdown(icalcap_server *cap);
#endif
diff --git a/src/libicalcap/icalcap_server_impl.h b/src/libicalcap/icalcap_server_impl.h
index c5d527d2..8f784878 100644
--- a/src/libicalcap/icalcap_server_impl.h
+++ b/src/libicalcap/icalcap_server_impl.h
@@ -1,5 +1,5 @@
-#ifndef __ICALCAP_SERVER_IMPL_H__
-#define __ICALCAP_SERVER_IMPL_H__
+#ifndef ICALCAP_SERVER_IMPL_H
+#define ICALCAP_SERVER_IMPL_H
#ifdef WITH_RR
@@ -9,20 +9,20 @@
#include <librrcap/rr-cap.h>
struct _icalcap_server {
- RRProfileRegistry *profreg;
- RRListener *listener;
- RRCAPConfig *cfg;
- icalcap_msg_handler handler;
+ RRProfileRegistry *profreg;
+ RRListener *listener;
+ RRCAPConfig *cfg;
+ icalcap_msg_handler handler;
};
icalcap_server *icalcap_server_new_rr(icalcap_auth_handler auth_cb,
- icalcap_chanup_handler chanup_cb,
- icalcap_msg_handler msg_cb);
-int icalcap_server_listen_rr(icalcap_server *cap,
- const char *hostname,
- const int port);
-int icalcap_server_run_rr(const icalcap_server *cap);
-int icalcap_server_shutdown_rr(icalcap_server *cap);
+ icalcap_chanup_handler chanup_cb,
+ icalcap_msg_handler msg_cb);
+int icalcap_server_listen_rr(icalcap_server *cap,
+ const char *hostname,
+ const int port);
+int icalcap_server_run_rr(const icalcap_server *cap);
+int icalcap_server_shutdown_rr(icalcap_server *cap);
#else
#error "No implementation of icalcap found!"
diff --git a/src/libicalcap/icalcap_session.c b/src/libicalcap/icalcap_session.c
index 2f8fb2a7..fd21ad54 100644
--- a/src/libicalcap/icalcap_session.c
+++ b/src/libicalcap/icalcap_session.c
@@ -1,43 +1,44 @@
-#include "config.h"
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
#include "icalcap.h"
#include "icalcap_session.h"
#include "icalcap_session_impl.h"
-
icalcap_session *
icalcap_session_new(void) {
#ifdef WITH_RR
- return icalcap_session_new_rr();
+ return icalcap_session_new_rr();
#else
- return NULL;
+ return NULL;
#endif
}
int
icalcap_session_connect(icalcap_session *sess, const char *hostname, const int _port) {
- int port = _port;
+ int port = _port;
- if (port <= 0)
- port = 1026;
+ if (port <= 0)
+ port = 1026;
#ifdef WITH_RR
- return icalcap_session_connect_rr(sess, hostname, port);
+ return icalcap_session_connect_rr(sess, hostname, port);
#else
- return 0;
+ return 0;
#endif
}
int
icalcap_session_login(icalcap_session *sess, const char *username, const char *authname,
- const char *password) {
+ const char *password) {
#ifdef WITH_RR
- return icalcap_session_login_rr(sess, username, authname, password);
+ return icalcap_session_login_rr(sess, username, authname, password);
#else
- return 0;
+ return 0;
#endif
}
@@ -45,9 +46,9 @@ icalcap *
icalcap_session_start(const icalcap_session *sess, icalcap_msg_handler handler) {
#ifdef WITH_RR
- return icalcap_session_start_rr(sess, handler);
+ return icalcap_session_start_rr(sess, handler);
#else
- return 0;
+ return 0;
#endif
}
@@ -55,8 +56,8 @@ int
icalcap_session_disconnect(icalcap_session *sess) {
#ifdef WITH_RR
- return icalcap_session_disconnect_rr(sess);
+ return icalcap_session_disconnect_rr(sess);
#else
- return 0;
+ return 0;
#endif
}
diff --git a/src/libicalcap/icalcap_session.h b/src/libicalcap/icalcap_session.h
index c12d434b..01ad5a38 100644
--- a/src/libicalcap/icalcap_session.h
+++ b/src/libicalcap/icalcap_session.h
@@ -1,15 +1,15 @@
-#ifndef __ICALCAP_SESSION_H__
-#define __ICALCAP_SESSION_H__
+#ifndef ICALCAP_SESSION_H
+#define ICALCAP_SESSION_H
#include "icalcap.h"
typedef struct _icalcap_session icalcap_session;
icalcap_session*icalcap_session_new(void);
-int icalcap_session_connect(icalcap_session *cap, const char *hostname, const int port);
-int icalcap_session_login(icalcap_session *cap, const char *username, const char *authname,
- const char *password);
+int icalcap_session_connect(icalcap_session *cap, const char *hostname, const int port);
+int icalcap_session_login(icalcap_session *cap, const char *username, const char *authname,
+ const char *password);
icalcap*icalcap_session_start(const icalcap_session *cap, icalcap_msg_handler handler);
-int icalcap_session_disconnect(icalcap_session *cap);
+int icalcap_session_disconnect(icalcap_session *cap);
#endif
diff --git a/src/libicalcap/icalcap_session_impl.h b/src/libicalcap/icalcap_session_impl.h
index 26bb7d10..23390809 100644
--- a/src/libicalcap/icalcap_session_impl.h
+++ b/src/libicalcap/icalcap_session_impl.h
@@ -1,5 +1,5 @@
-#ifndef __ICALCAP_SESSION_IMPL_H__
-#define __ICALCAP_SESSION_IMPL_H__
+#ifndef ICALCAP_SESSION_IMPL_H
+#define ICALCAP_SESSION_IMPL_H
#ifdef WITH_RR
@@ -9,25 +9,25 @@
#include <librrcap/rr-cap.h>
struct _icalcap_session {
- RRProfileRegistry *profreg;
- RRConnection *connection;
- RRCAPConfig *cfg;
- icalcap_msg_handler handler;
+ RRProfileRegistry *profreg;
+ RRConnection *connection;
+ RRCAPConfig *cfg;
+ icalcap_msg_handler handler;
- char *username;
+ char *username;
};
icalcap_session*icalcap_session_new_rr(void);
-int icalcap_session_connect_rr(icalcap_session *cap,
- const char *hostname,
- const int port);
-int icalcap_session_login_rr(icalcap_session *cap,
- const char *username,
- const char *authname,
- const char *password);
-icalcap *icalcap_session_start_rr(const icalcap_session *cap,
- icalcap_msg_handler handler);
-int icalcap_session_disconnect_rr(icalcap_session *cap);
+int icalcap_session_connect_rr(icalcap_session *cap,
+ const char *hostname,
+ const int port);
+int icalcap_session_login_rr(icalcap_session *cap,
+ const char *username,
+ const char *authname,
+ const char *password);
+icalcap *icalcap_session_start_rr(const icalcap_session *cap,
+ icalcap_msg_handler handler);
+int icalcap_session_disconnect_rr(icalcap_session *cap);
#else
#error "No implementation of icalcap found!"
diff --git a/src/libicalcap/icalcap_utils.c b/src/libicalcap/icalcap_utils.c
index 7308f8fb..799b10f1 100644
--- a/src/libicalcap/icalcap_utils.c
+++ b/src/libicalcap/icalcap_utils.c
@@ -1,145 +1,142 @@
/*-
* $Id: icalcap_utils.c,v 1.3 2008-01-02 20:07:38 dothebart Exp $
*
- * See the file LICENSE for redistribution information.
+ * See the file LICENSE for redistribution information.
*
* Copyright (c) 2002 Andrea Campi <a.campi@inet.it>
*/
-#include "config.h"
-
-#ifdef HAVE_STRING_H
-#include <string.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
#endif
#include "icalcap.h"
-#define CONTENT_TYPE "Content-Type: text/calendar"
-
+#define CONTENT_TYPE "Content-Type: text/calendar"
icalcomponent *
icalcap_component_new_from_string(const char *data) {
- icalcomponent *ret = NULL;
- char *mtype;
+ icalcomponent *ret = NULL;
+ char *mtype;
- /* FIXME split the check */
- if (strncmp(data, CONTENT_TYPE, strlen(CONTENT_TYPE))) {
- return NULL;
- }
+ /* FIXME split the check */
+ if (strncmp(data, CONTENT_TYPE, strlen(CONTENT_TYPE))) {
+ return NULL;
+ }
- mtype = (char *)data+strlen(CONTENT_TYPE);
+ mtype = (char *)data+strlen(CONTENT_TYPE);
- ret = icalcomponent_new_from_string(mtype);
- if (ret == NULL) {
- return NULL;
- }
+ ret = icalcomponent_new_from_string(mtype);
+ if (ret == NULL) {
+ return NULL;
+ }
#ifdef DEBUG
- g_message("icalcap_component_new_from_string icalcomponent_new_from_string = %p", ret);
+ g_message("icalcap_component_new_from_string icalcomponent_new_from_string = %p", ret);
#endif
- /* FIXME
- * Validate here: should check at least the version
- */
- if (icalcomponent_isa(ret) != ICAL_VCALENDAR_COMPONENT &&
- icalcomponent_isa(ret) != ICAL_XROOT_COMPONENT) {
- icalcomponent_free(ret);
+ /* FIXME
+ * Validate here: should check at least the version
+ */
+ if (icalcomponent_isa(ret) != ICAL_VCALENDAR_COMPONENT &&
+ icalcomponent_isa(ret) != ICAL_XROOT_COMPONENT) {
+ icalcomponent_free(ret);
- return NULL;
- }
+ return NULL;
+ }
- return ret;
+ return ret;
}
#if 0
RRCAPCmdArgs *
msg_parse(RRCAP *cap, icalcomponent *comp) {
- icalproperty *prop;
- icalparameter *param;
- icalvalue *value;
- RRCAPCmdArgs *ret = g_new0(RRCAPCmdArgs, 1);
- char *str;
-
- ret->comp = comp;
-
- /* Find the command */
- if ((prop = icalcomponent_get_first_property(comp, ICAL_CMD_PROPERTY)) == NULL) {
- rr_cap_send_error(cap, NULL, ICAL_9_0_UNRECOGNIZED_COMMAND,
- "No CMD sent", NULL);
- goto FAILED;
- }
- if ((value = icalproperty_get_value(prop)) == NULL) {
- str = icalproperty_as_ical_string_r(prop);
- rr_cap_send_error(cap, NULL, ICAL_9_0_UNRECOGNIZED_COMMAND,
- "CMD has no value", str);
- free(str);
- goto FAILED;
- }
- ret->cmd = icalvalue_get_cmd(value);
-
- /* Look for params */
-
- /* ID */
- if ((param = icalproperty_get_first_parameter(prop,
- ICAL_ID_PARAMETER)) != NULL) {
- if ((ret->id = icalparameter_get_id(param)) == NULL) {
- str = icalproperty_as_ical_string_r(prop);
- rr_cap_send_error(cap, NULL,
- ICAL_9_0_UNRECOGNIZED_COMMAND,
- "ID param is garbled",
- str);
- free(str);
- goto FAILED;
- }
- }
-
- /* LATENCY */
- if ((param = icalproperty_get_first_parameter(prop,
- ICAL_LATENCY_PARAMETER)) != NULL) {
- const char *tmp;
- if ((tmp = icalparameter_get_latency(param)) == NULL) {
- str = icalproperty_as_ical_string_r(prop);
- rr_cap_send_error(cap, NULL,
- ICAL_9_0_UNRECOGNIZED_COMMAND,
- "LATENCY is garbled",
- str);
- free(str);
- goto FAILED;
- }
-
- ret->latency = atoi(tmp);
- }
-
- /* ACTION */
- if ((param = icalproperty_get_first_parameter(prop,
- ICAL_ACTIONPARAM_PARAMETER)) != NULL) {
- if ((ret->action = icalparameter_get_actionparam(param))
- == NULL) {
- str = icalproperty_as_ical_string_r(prop);
- rr_cap_send_error(cap, NULL,
- ICAL_9_0_UNRECOGNIZED_COMMAND,
- "ACTION is garbled",
- str);
- free(str);
- goto FAILED;
- }
- }
-
- if ((ret->latency >= 0) ^ (ret->action != ICAL_ACTIONPARAM_NONE)) {
- str = icalproperty_as_ical_string_r(prop);
- rr_cap_send_error(cap, NULL, ICAL_9_0_UNRECOGNIZED_COMMAND,
- "LATENCY and ACTION must be both present",
- str);
- free(str);
- goto FAILED;
- }
-
- return ret;
+ icalproperty *prop;
+ icalparameter *param;
+ icalvalue *value;
+ RRCAPCmdArgs *ret = g_new0(RRCAPCmdArgs, 1);
+ char *str;
+
+ ret->comp = comp;
+
+ /* Find the command */
+ if ((prop = icalcomponent_get_first_property(comp, ICAL_CMD_PROPERTY)) == NULL) {
+ rr_cap_send_error(cap, NULL, ICAL_9_0_UNRECOGNIZED_COMMAND,
+ "No CMD sent", NULL);
+ goto FAILED;
+ }
+ if ((value = icalproperty_get_value(prop)) == NULL) {
+ str = icalproperty_as_ical_string_r(prop);
+ rr_cap_send_error(cap, NULL, ICAL_9_0_UNRECOGNIZED_COMMAND,
+ "CMD has no value", str);
+ free(str);
+ goto FAILED;
+ }
+ ret->cmd = icalvalue_get_cmd(value);
+
+ /* Look for params */
+
+ /* ID */
+ if ((param = icalproperty_get_first_parameter(prop,
+ ICAL_ID_PARAMETER)) != NULL) {
+ if ((ret->id = icalparameter_get_id(param)) == NULL) {
+ str = icalproperty_as_ical_string_r(prop);
+ rr_cap_send_error(cap, NULL,
+ ICAL_9_0_UNRECOGNIZED_COMMAND,
+ "ID param is garbled",
+ str);
+ free(str);
+ goto FAILED;
+ }
+ }
+
+ /* LATENCY */
+ if ((param = icalproperty_get_first_parameter(prop,
+ ICAL_LATENCY_PARAMETER)) != NULL) {
+ const char *tmp;
+ if ((tmp = icalparameter_get_latency(param)) == NULL) {
+ str = icalproperty_as_ical_string_r(prop);
+ rr_cap_send_error(cap, NULL,
+ ICAL_9_0_UNRECOGNIZED_COMMAND,
+ "LATENCY is garbled",
+ str);
+ free(str);
+ goto FAILED;
+ }
+
+ ret->latency = atoi(tmp);
+ }
+
+ /* ACTION */
+ if ((param = icalproperty_get_first_parameter(prop,
+ ICAL_ACTIONPARAM_PARAMETER)) != NULL) {
+ if ((ret->action = icalparameter_get_actionparam(param))
+ == NULL) {
+ str = icalproperty_as_ical_string_r(prop);
+ rr_cap_send_error(cap, NULL,
+ ICAL_9_0_UNRECOGNIZED_COMMAND,
+ "ACTION is garbled",
+ str);
+ free(str);
+ goto FAILED;
+ }
+ }
+
+ if ((ret->latency >= 0) ^ (ret->action != ICAL_ACTIONPARAM_NONE)) {
+ str = icalproperty_as_ical_string_r(prop);
+ rr_cap_send_error(cap, NULL, ICAL_9_0_UNRECOGNIZED_COMMAND,
+ "LATENCY and ACTION must be both present",
+ str);
+ free(str);
+ goto FAILED;
+ }
+
+ return ret;
FAILED:
- g_free(ret);
- return NULL;
+ g_free(ret);
+ return NULL;
}
#endif
diff --git a/src/libicalss/icalcalendar.c b/src/libicalss/icalcalendar.c
index 9131f783..873a0707 100644
--- a/src/libicalss/icalcalendar.c
+++ b/src/libicalss/icalcalendar.c
@@ -55,6 +55,15 @@
#define PROP_FILE "properties.ics"
#define FBLIST_FILE "freebusy.ics"
+struct icalcalendar_impl
+{
+ char* dir;
+ icalset* freebusy;
+ icalset* properties;
+ icalset* booked;
+ icalset* incoming;
+};
+
struct icalcalendar_impl* icalcalendar_new_impl(void)
{
struct icalcalendar_impl* impl;
diff --git a/src/libicalss/icalcalendar.h b/src/libicalss/icalcalendar.h
index ee68a279..47392e08 100644
--- a/src/libicalss/icalcalendar.h
+++ b/src/libicalss/icalcalendar.h
@@ -37,15 +37,6 @@
* components. It also has interfaces to access the free/busy list
* and a list of calendar properties */
-struct icalcalendar_impl
-{
- char* dir;
- icalset* freebusy;
- icalset* properties;
- icalset* booked;
- icalset* incoming;
-};
-
typedef struct icalcalendar_impl icalcalendar;
icalcalendar* icalcalendar_new(char* dir);
diff --git a/src/libicalss/icalclusterimpl.h b/src/libicalss/icalclusterimpl.h
index 0427d132..af1fa560 100644
--- a/src/libicalss/icalclusterimpl.h
+++ b/src/libicalss/icalclusterimpl.h
@@ -25,6 +25,9 @@
======================================================================*/
+#ifndef ICALCLUSTERIMPL_H
+#define ICALCLUSTERIMPL_H
+
/* This definition is in its own file so it can be kept out of the
main header file, but used by "friend classes" like icaldirset*/
@@ -38,3 +41,5 @@ struct icalcluster_impl {
icalcomponent *data;
int changed;
};
+
+#endif
diff --git a/src/libicalss/icaldirsetimpl.h b/src/libicalss/icaldirsetimpl.h
index 32b0dc2b..16295c25 100644
--- a/src/libicalss/icaldirsetimpl.h
+++ b/src/libicalss/icaldirsetimpl.h
@@ -25,6 +25,9 @@
======================================================================*/
+#ifndef ICALDIRSETIMPL_H
+#define ICALDIRSETIMPL_H
+
#include "icalcluster.h"
/* This definition is in its own file so it can be kept out of the
@@ -41,3 +44,5 @@ struct icaldirset_impl
pvl_list directory; /**< ??? */
pvl_elem directory_iterator; /**< ??? */
};
+
+#endif
diff --git a/src/libicalss/icalgaugeimpl.h b/src/libicalss/icalgaugeimpl.h
index aa24696d..9f55c7b9 100644
--- a/src/libicalss/icalgaugeimpl.h
+++ b/src/libicalss/icalgaugeimpl.h
@@ -22,6 +22,9 @@
======================================================================*/
+#ifndef ICALGAUGEIMPL_H
+#define ICALGAUGEIMPL_H
+
#include "icalcomponent.h"
typedef enum icalgaugecompare {
@@ -59,3 +62,5 @@ struct icalgauge_impl
pvl_list where; /**< List of icalgaugecompare */
int expand;
};
+
+#endif
diff --git a/src/libicalss/icalspanlist.c b/src/libicalss/icalspanlist.c
index cb8dfaac..9790e45d 100644
--- a/src/libicalss/icalspanlist.c
+++ b/src/libicalss/icalspanlist.c
@@ -31,6 +31,12 @@
#include <stdlib.h>
+struct icalspanlist_impl {
+ pvl_list spans; /**< list of icaltime_span data **/
+ struct icaltimetype start; /**< start time of span **/
+ struct icaltimetype end; /**< end time of span **/
+};
+
/** @brief Internal comparison function for two spans
*
* @param a a spanlist.
diff --git a/src/libicalss/icalspanlist.h b/src/libicalss/icalspanlist.h
index 67bb97e7..2a517a59 100644
--- a/src/libicalss/icalspanlist.h
+++ b/src/libicalss/icalspanlist.h
@@ -31,12 +31,6 @@
* @brief Code that supports collections of free/busy spans of time
*/
-struct icalspanlist_impl {
- pvl_list spans; /**< list of icaltime_span data **/
- struct icaltimetype start; /**< start time of span **/
- struct icaltimetype end; /**< end time of span **/
-};
-
typedef struct icalspanlist_impl icalspanlist;
diff --git a/src/test/copycluster.c b/src/test/copycluster.c
index d180e511..836d2b80 100644
--- a/src/test/copycluster.c
+++ b/src/test/copycluster.c
@@ -39,19 +39,14 @@
#if defined(HAVE_UNISTD_H)
#include <unistd.h> /* for alarm */
#endif
-#include <stdlib.h> /* for exit */
-
-#include <libical/ical.h>
-#include <libicalss/icalss.h>
#endif
-#if defined(SIGALRM)
+#if defined(SIGALRM)
static void sig_alrm(int i){
(void)i;/*unused*/
fprintf(stderr,"Could not get lock on file\n");
exit(1);
}
-
#endif
/* This program copies a file that holds iCal components to an other file. */
diff --git a/src/test/icaltestparser.c b/src/test/icaltestparser.c
index 34c240e2..3ff2d3ff 100644
--- a/src/test/icaltestparser.c
+++ b/src/test/icaltestparser.c
@@ -32,9 +32,7 @@
#include "libical/ical.h"
#ifdef UNCLEAN
-#include <stdio.h>
#include <errno.h>
-#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#endif
diff --git a/src/test/recur.c b/src/test/recur.c
index c1381506..ff1d0758 100644
--- a/src/test/recur.c
+++ b/src/test/recur.c
@@ -37,21 +37,13 @@
#ifdef UNCLEAN
#include <assert.h>
#include <string.h> /* for strdup */
-#include <stdlib.h> /* for malloc */
-#include <stdio.h> /* for printf */
#include <time.h> /* for time() */
#include <signal.h> /* for signal */
#ifndef WIN32
#include <unistd.h> /* for alarm */
#endif
-
-#ifdef WIN32
-#define snprintf _snprintf
-#endif
-#ifdef _MSC_VER
-#define strcasecmp stricmp
-#endif
#endif
+
#ifndef WIN32
static void sig_alrm(int i){
(void)i;/*unused*/
diff --git a/src/test/testmime.c b/src/test/testmime.c
index ed0515bc..bfa82241 100644
--- a/src/test/testmime.c
+++ b/src/test/testmime.c
@@ -42,9 +42,6 @@
#include <stdlib.h>
#ifdef UNCLEAN
-
-#include <stdlib.h> /* For rand */
-#include <string.h> /* for strrchr, strdup*/
#if defined(HAVE_UNISTD_H)
#include <unistd.h> /* for getopt, sleep */
#endif