aboutsummaryrefslogtreecommitdiffstats
path: root/libical/src/libicalss
diff options
context:
space:
mode:
authorJP Rosevear <jpr@src.gnome.org>2001-01-24 03:20:44 +0800
committerJP Rosevear <jpr@src.gnome.org>2001-01-24 03:20:44 +0800
commitfd279723663879e742e53d7b3503248f6af91791 (patch)
tree09233c88d6c42b5bb324be7c64a8f8c64ff02846 /libical/src/libicalss
parent34bcd381ce1985cc762a896f15d427e368af95e5 (diff)
downloadgsoc2013-evolution-fd279723663879e742e53d7b3503248f6af91791.tar
gsoc2013-evolution-fd279723663879e742e53d7b3503248f6af91791.tar.gz
gsoc2013-evolution-fd279723663879e742e53d7b3503248f6af91791.tar.bz2
gsoc2013-evolution-fd279723663879e742e53d7b3503248f6af91791.tar.lz
gsoc2013-evolution-fd279723663879e742e53d7b3503248f6af91791.tar.xz
gsoc2013-evolution-fd279723663879e742e53d7b3503248f6af91791.tar.zst
gsoc2013-evolution-fd279723663879e742e53d7b3503248f6af91791.zip
This commit was generated by cvs2svn to compensate for changes in r7747,
which included commits to RCS files with non-trunk default branches. svn path=/trunk/; revision=7748
Diffstat (limited to 'libical/src/libicalss')
-rw-r--r--libical/src/libicalss/icalclassify.c4
-rw-r--r--libical/src/libicalss/icalcstp.c66
-rw-r--r--libical/src/libicalss/icaldirset.c6
-rw-r--r--libical/src/libicalss/icalfileset.c364
-rw-r--r--libical/src/libicalss/icalfileset.h13
-rw-r--r--libical/src/libicalss/icalfilesetimpl.h13
-rw-r--r--libical/src/libicalss/icalgauge.c242
-rw-r--r--libical/src/libicalss/icalgauge.h10
-rw-r--r--libical/src/libicalss/icalgaugeimpl.h38
-rw-r--r--libical/src/libicalss/icalmessage.c22
-rw-r--r--libical/src/libicalss/icalmessage.h5
-rw-r--r--libical/src/libicalss/icalset.c6
-rw-r--r--libical/src/libicalss/icalspanlist.c10
-rw-r--r--libical/src/libicalss/icalsslexer.l12
-rw-r--r--libical/src/libicalss/icalssyacc.h21
-rw-r--r--libical/src/libicalss/icalssyacc.y168
16 files changed, 695 insertions, 305 deletions
diff --git a/libical/src/libicalss/icalclassify.c b/libical/src/libicalss/icalclassify.c
index e0ee710544..89761d8120 100644
--- a/libical/src/libicalss/icalclassify.c
+++ b/libical/src/libicalss/icalclassify.c
@@ -122,7 +122,7 @@ icalparameter_partstat icalclassify_find_attendee(icalcomponent *c,
{
icalproperty *p;
char* lattendee = icalclassify_lowercase(attendee);
- char* upn = index(lattendee,':');
+ char* upn = strchr(lattendee,':');
icalcomponent *inner = icalcomponent_get_first_real_component(c);
for(p = icalcomponent_get_first_property(inner,ICAL_ATTENDEE_PROPERTY);
@@ -131,7 +131,7 @@ icalparameter_partstat icalclassify_find_attendee(icalcomponent *c,
{
const char* this_attendee
= icalclassify_lowercase(icalproperty_get_attendee(p));
- char* this_upn = index(this_attendee,':');
+ char* this_upn = strchr(this_attendee,':');
if(strcmp(this_upn,upn)==0){
diff --git a/libical/src/libicalss/icalcstp.c b/libical/src/libicalss/icalcstp.c
index 2c86ddcc2c..53ee7bdeef 100644
--- a/libical/src/libicalss/icalcstp.c
+++ b/libical/src/libicalss/icalcstp.c
@@ -34,6 +34,8 @@
#include <sys/socket.h> /* For send(), others. */
#include <unistd.h> /* For alarm */
#include <errno.h>
+#include <stdlib.h> /* for malloc */
+#include <string.h>
enum cstps_state {
NO_STATE,
@@ -199,16 +201,43 @@ int line_is_response(char* line);
int line_is_endofdata(char* line);
int line_is_mime(char* line);
-icalerrorenum prep_abort(struct icalcstps_impl* impl, char* data);
-icalerrorenum prep_authenticate(struct icalcstps_impl* impl, char* data);
-icalerrorenum prep_capability(struct icalcstps_impl* impl, char* data);
-icalerrorenum prep_calidexpand(struct icalcstps_impl* impl, char* data);
-icalerrorenum prep_continue(struct icalcstps_impl* impl, char* data);
-icalerrorenum prep_disconnect(struct icalcstps_impl* impl, char* data);
-icalerrorenum prep_identify(struct icalcstps_impl* impl, char* data);
-icalerrorenum prep_starttls(struct icalcstps_impl* impl, char* data);
-icalerrorenum prep_upnexpand(struct icalcstps_impl* impl, char* data);
-icalerrorenum prep_sendata(struct icalcstps_impl* impl, char* data);
+icalerrorenum prep_abort(struct icalcstps_impl* impl, char* data)
+{
+ return ICAL_NO_ERROR;
+}
+icalerrorenum prep_authenticate(struct icalcstps_impl* impl, char* data)
+{ return ICAL_NO_ERROR;
+}
+icalerrorenum prep_capability(struct icalcstps_impl* impl, char* data)
+{ return ICAL_NO_ERROR;
+}
+icalerrorenum prep_calidexpand(struct icalcstps_impl* impl, char* data)
+{
+ return ICAL_NO_ERROR;
+}
+icalerrorenum prep_continue(struct icalcstps_impl* impl, char* data)
+{
+ return ICAL_NO_ERROR;
+}
+icalerrorenum prep_disconnect(struct icalcstps_impl* impl, char* data)
+{
+ return ICAL_NO_ERROR;
+}
+icalerrorenum prep_identify(struct icalcstps_impl* impl, char* data)
+{
+ return ICAL_NO_ERROR;
+}
+icalerrorenum prep_starttls(struct icalcstps_impl* impl, char* data)
+{
+ return ICAL_NO_ERROR;
+}
+icalerrorenum prep_upnexpand(struct icalcstps_impl* impl, char* data)
+{
+ return ICAL_NO_ERROR;
+}
+icalerrorenum prep_sendata(struct icalcstps_impl* impl, char* data)
+{ return ICAL_NO_ERROR;
+}
char* icalcstps_process_incoming(icalcstps* cstp, char* input)
{
@@ -227,7 +256,7 @@ char* icalcstps_process_incoming(icalcstps* cstp, char* input)
return 0;
}
- i = (char*)index(" ",input_cpy);
+ i = (char*)strstr(" ",input_cpy);
cmd_or_resp = input_cpy;
@@ -266,7 +295,7 @@ char* icalcstps_process_incoming(icalcstps* cstp, char* input)
error = prep_sendata(impl,data);
}
-
+ return 0;
}
/* Read data until we get a end of data marker */
@@ -308,11 +337,13 @@ void* icalcstpc_free(icalcstpc* cstpc);
/* Get the next string to send to the server */
char* icalcstpc_next_output(icalcstpc* cstp)
{
+ return 0;
}
/* process the next string to send to the server */
int icalcstpc_next_input(icalcstpc* cstp)
{
+ return 0;
}
/* After icalcstpc_next_input returns a 0, there are responses
@@ -330,45 +361,54 @@ icalerrorenum icalcstpc_abort(icalcstpc* cstp)
impl->next_output = "ABORT";
+ return ICAL_NO_ERROR;
}
icalerrorenum icalcstpc_authenticate(icalcstpc* cstp, char* mechanism,
char* data, char* f(char*))
{
+ return ICAL_NO_ERROR;
}
icalerrorenum icalcstpc_capability(icalcstpc* cstp)
{
-}
+ return ICAL_NO_ERROR;}
icalerrorenum icalcstpc_calidexpand(icalcstpc* cstp,char* calid)
{
+ return ICAL_NO_ERROR;
}
icalerrorenum icalcstpc_continue(icalcstpc* cstp, unsigned int time)
{
+ return ICAL_NO_ERROR;
}
icalerrorenum icalcstpc_disconnect(icalcstpc* cstp)
{
+ return ICAL_NO_ERROR;
}
icalerrorenum icalcstpc_identify(icalcstpc* cstp, char* id)
{
+ return ICAL_NO_ERROR;
}
icalerrorenum icalcstpc_starttls(icalcstpc* cstp, char* command,
char* data, char * f(char*))
{
+ return ICAL_NO_ERROR;
}
icalerrorenum icalcstpc_upnexpand(icalcstpc* cstp,char* calid)
{
+ return ICAL_NO_ERROR;
}
icalerrorenum icalcstpc_sendata(icalcstpc* cstp, unsigned int time,
icalcomponent *comp)
{
+ return ICAL_NO_ERROR;
}
diff --git a/libical/src/libicalss/icaldirset.c b/libical/src/libicalss/icaldirset.c
index b377d54571..78b2373219 100644
--- a/libical/src/libicalss/icaldirset.c
+++ b/libical/src/libicalss/icaldirset.c
@@ -712,10 +712,14 @@ icalcomponent* icaldirset_get_next_component(icaldirset* store)
/* If there is a gauge defined and the component does not
pass the gauge, skip the rest of the loop */
+
+#if 0 /* HACK */
if (impl->gauge != 0 && icalgauge_test(c,impl->gauge) == 0){
continue;
}
-
+#else
+ assert(0); /* icalgauge_test needs to be fixed */
+#endif
/* Either there is no gauge, or the component passed the
gauge, so return it*/
diff --git a/libical/src/libicalss/icalfileset.c b/libical/src/libicalss/icalfileset.c
index a7527ff3e0..52dbc0beda 100644
--- a/libical/src/libicalss/icalfileset.c
+++ b/libical/src/libicalss/icalfileset.c
@@ -31,6 +31,7 @@
#endif
#include "icalfileset.h"
+#include "icalgauge.h"
#include <errno.h>
#include <limits.h> /* For PATH_MAX */
#include <sys/stat.h> /* for stat */
@@ -39,43 +40,44 @@
#include <string.h>
#include <fcntl.h> /* for fcntl */
#include <unistd.h> /* for fcntl */
-
#include "icalfilesetimpl.h"
+extern int errno;
+
int icalfileset_lock(icalfileset *cluster);
int icalfileset_unlock(icalfileset *cluster);
+icalerrorenum icalfileset_read_file(icalfileset* cluster, mode_t mode);
+int icalfileset_filesize(icalfileset* cluster);
icalerrorenum icalfileset_create_cluster(const char *path);
icalfileset* icalfileset_new_impl()
{
struct icalfileset_impl* impl;
-
+
if ( ( impl = (struct icalfileset_impl*)
malloc(sizeof(struct icalfileset_impl))) == 0) {
icalerror_set_errno(ICAL_NEWFAILED_ERROR);
errno = ENOMEM;
return 0;
}
-
+
+ memset(impl,0,sizeof(struct icalfileset_impl));
+
strcpy(impl->id,ICALFILESET_ID);
-
+
return impl;
}
-char* read_from_file(char *s, size_t size, void *d)
+
+icalfileset* icalfileset_new(const char* path)
{
- char *c = fgets(s,size, (FILE*)d);
- return c;
+ return icalfileset_new_open(path, O_RDWR|O_CREAT, 0664);
}
-icalfileset* icalfileset_new(const char* path)
+icalfileset* icalfileset_new_open(const char* path, int flags, mode_t mode)
{
struct icalfileset_impl *impl = icalfileset_new_impl();
- struct stat sbuf;
- int createclusterfile = 0;
- icalerrorenum error = ICAL_NO_ERROR;
- icalparser *parser;
struct icaltimetype tt;
off_t cluster_file_size;
@@ -88,97 +90,131 @@ icalfileset* icalfileset_new(const char* path)
return 0;
}
- /*impl->path = strdup(path); icalfileset_load does this */
- impl->changed = 0;
+ impl->path = strdup(path);
- impl->cluster = 0;
-
- impl->path = 0;
- impl->stream = 0;
+ cluster_file_size = icalfileset_filesize(impl);
- /* Check if the path already exists and if it is a regular file*/
- if (stat(path,&sbuf) != 0){
-
- /* A file by the given name does not exist, or there was
- another error */
- cluster_file_size = 0;
- if (errno == ENOENT) {
- /* It was because the file does not exist */
- createclusterfile = 1;
- } else {
- /* It was because of another error */
- icalerror_set_errno(ICAL_FILE_ERROR);
+ if(cluster_file_size < 0){
+ icalfileset_free(impl);
+ return 0;
+ }
+
+ impl->fd = open(impl->path,flags, mode);
+
+ if (impl->fd < 0){
+ icalerror_set_errno(ICAL_FILE_ERROR);
+ icalfileset_free(impl);
+ return 0;
+ }
+
+ icalfileset_lock(impl);
+
+ if(cluster_file_size > 0 ){
+ icalerrorenum error;
+ if((error = icalfileset_read_file(impl,mode))!= ICAL_NO_ERROR){
+ icalfileset_free(impl);
return 0;
}
- } else {
- /* A file by the given name exists, but is it a regular file */
-
- if (!S_ISREG(sbuf.st_mode)){
- /* Nope, not a directory */
- icalerror_set_errno(ICAL_FILE_ERROR);
- return 0;
- } else {
- /* Lets assume that it is a file of the right type */
- cluster_file_size = sbuf.st_size;
- createclusterfile = 0;
- }
}
+
+ if(impl->cluster == 0){
+ impl->cluster = icalcomponent_new(ICAL_XROOT_COMPONENT);
+ }
- /* if cluster does not already exist, create it */
+ return impl;
+}
+
+char* icalfileset_read_from_file(char *s, size_t size, void *d)
+{
- if (createclusterfile == 1) {
- error = icalfileset_create_cluster(path);
+ char* p = s;
+ int fd = (int)d;
- if (error != ICAL_NO_ERROR){
- icalerror_set_errno(error);
- return 0;
- }
- }
+ /* Simulate fgets -- read single characters and stop at '\n' */
- impl->path = (char*)strdup(path);
+ for(p=s; p<s+size-1;p++){
+
+ if(read(fd,p,1) != 1 || *p=='\n'){
+ break;
+ }
+ }
- errno = 0;
- impl->stream = fopen(impl->path,"r");
+ *(++p) = '\0';
- if (impl->stream ==0 || errno != 0){
- impl->cluster = 0;
- icalerror_set_errno(ICAL_FILE_ERROR); /* Redundant, actually */
+ if(*s == 0){
return 0;
+ } else {
+ return s;
}
- icalfileset_lock(impl);
-
- if(cluster_file_size > 0){
- parser = icalparser_new();
- icalparser_set_gen_data(parser,impl->stream);
- impl->cluster = icalparser_parse(parser,read_from_file);
- icalparser_free(parser);
+}
- if (icalcomponent_isa(impl->cluster) != ICAL_XROOT_COMPONENT){
- /* The parser got a single component, so it did not put it in
- an XROOT. */
- icalcomponent *cl = impl->cluster;
- impl->cluster = icalcomponent_new(ICAL_XROOT_COMPONENT);
- icalcomponent_add_component(impl->cluster,cl);
- }
- } else {
+icalerrorenum icalfileset_read_file(icalfileset* cluster,mode_t mode)
+{
- impl->cluster = icalcomponent_new(ICAL_XROOT_COMPONENT);
- }
+ icalparser *parser;
+ int fd;
+
+ struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
+
+ parser = icalparser_new();
+ icalparser_set_gen_data(parser,(void*)impl->fd);
+ impl->cluster = icalparser_parse(parser,icalfileset_read_from_file);
+ icalparser_free(parser);
- if (impl->cluster == 0){
+ if (impl->cluster == 0 || icalerrno != ICAL_NO_ERROR){
icalerror_set_errno(ICAL_PARSE_ERROR);
- return 0;
+ return ICAL_PARSE_ERROR;
}
-
- if (error != ICAL_NO_ERROR){
- return 0;
+
+ if (icalcomponent_isa(impl->cluster) != ICAL_XROOT_COMPONENT){
+ /* The parser got a single component, so it did not put it in
+ an XROOT. */
+ icalcomponent *cl = impl->cluster;
+ impl->cluster = icalcomponent_new(ICAL_XROOT_COMPONENT);
+ icalcomponent_add_component(impl->cluster,cl);
}
-
- return impl;
+
+ return ICAL_NO_ERROR;
+
}
+
+int icalfileset_filesize(icalfileset* cluster)
+{
+ struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
+ int cluster_file_size;
+ struct stat sbuf;
+
+ if (stat(impl->path,&sbuf) != 0){
+ /* A file by the given name does not exist, or there was
+ another error */
+ cluster_file_size = 0;
+ if (errno == ENOENT) {
+ /* It was because the file does not exist */
+ return 0;
+ } else {
+ /* It was because of another error */
+ icalerror_set_errno(ICAL_FILE_ERROR);
+ return -1;
+ }
+ } else {
+ /* A file by the given name exists, but is it a regular file? */
+
+ if (!S_ISREG(sbuf.st_mode)){
+ /* Nope, not a regular file */
+ icalerror_set_errno(ICAL_FILE_ERROR);
+ return -1;
+ } else {
+ /* Lets assume that it is a file of the right type */
+ return sbuf.st_size;
+ }
+ }
+
+ /*return -1; not reached*/
+}
+
void icalfileset_free(icalfileset* cluster)
{
struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
@@ -191,17 +227,17 @@ void icalfileset_free(icalfileset* cluster)
impl->cluster=0;
}
+ if(impl->fd > 0){
+ icalfileset_unlock(impl);
+ close(impl->fd);
+ impl->fd = -1;
+ }
+
if(impl->path != 0){
free(impl->path);
impl->path = 0;
}
- if(impl->stream != 0){
- icalfileset_unlock(impl);
- fclose(impl->stream);
- impl->stream = 0;
- }
-
free(impl);
}
@@ -218,83 +254,69 @@ int icalfileset_lock(icalfileset *cluster)
{
struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
struct flock lock;
- int fd;
-
- icalerror_check_arg_rz((impl->stream!=0),"impl->stream");
-
- fd = fileno(impl->stream);
+ int rtrn;
+ icalerror_check_arg_rz((impl->fd>0),"impl->fd");
+ errno = 0;
lock.l_type = F_WRLCK; /* F_RDLCK, F_WRLCK, F_UNLCK */
lock.l_start = 0; /* byte offset relative to l_whence */
lock.l_whence = SEEK_SET; /* SEEK_SET, SEEK_CUR, SEEK_END */
lock.l_len = 0; /* #bytes (0 means to EOF) */
- return (fcntl(fd, F_SETLKW, &lock));
+ rtrn = fcntl(impl->fd, F_SETLKW, &lock);
+
+ return rtrn;
}
int icalfileset_unlock(icalfileset *cluster)
{
struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
- int fd;
struct flock lock;
- icalerror_check_arg_rz((impl->stream!=0),"impl->stream");
-
- fd = fileno(impl->stream);
+ icalerror_check_arg_rz((impl->fd>0),"impl->fd");
lock.l_type = F_WRLCK; /* F_RDLCK, F_WRLCK, F_UNLCK */
lock.l_start = 0; /* byte offset relative to l_whence */
lock.l_whence = SEEK_SET; /* SEEK_SET, SEEK_CUR, SEEK_END */
lock.l_len = 0; /* #bytes (0 means to EOF) */
- return (fcntl(fd, F_UNLCK, &lock));
+ return (fcntl(impl->fd, F_UNLCK, &lock));
}
-icalerrorenum icalfileset_create_cluster(const char *path)
-{
-
- FILE* f;
-
- icalerror_clear_errno();
-
- f = fopen(path,"w");
-
- if (f == 0){
- icalerror_set_errno(ICAL_FILE_ERROR);
- return ICAL_FILE_ERROR;
- }
-
-
- /* This used to write data to the file... */
-
-
- fclose(f);
-
- return ICAL_NO_ERROR;
-}
+#ifdef ICAL_SAFESAVES
+int icalfileset_safe_saves=1;
+#else
+int icalfileset_safe_saves=0;
+#endif
icalerrorenum icalfileset_commit(icalfileset* cluster)
{
- FILE *f;
- char tmp[PATH_MAX]; /* HACK Buffer overflow potential */
+ char tmp[PATH_MAX];
char *str;
icalcomponent *c;
+ off_t write_size=0;
struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
-
- icalerror_check_arg_re((impl!=0),"cluster",ICAL_BADARG_ERROR);
+
+ icalerror_check_arg_re((impl!=0),"cluster",ICAL_BADARG_ERROR);
+
+ icalerror_check_arg_re((impl->fd>0),"impl->fd is invalid",
+ ICAL_INTERNAL_ERROR) ;
if (impl->changed == 0 ){
return ICAL_NO_ERROR;
}
-#ifdef ICAL_SAFESAVES
- snprintf(tmp,PATH_MAX,"%s-tmp",impl->path);
-#else
- strcpy(tmp,impl->path);
-#endif
-
- if ( (f = fopen(tmp,"w")) < 0 ){
+ if(icalfileset_safe_saves == 1){
+ snprintf(tmp,PATH_MAX,"cp %s %s.bak",impl->path,impl->path);
+
+ if(system(tmp) < 0){
+ icalerror_set_errno(ICAL_FILE_ERROR);
+ return ICAL_FILE_ERROR;
+ }
+ }
+
+ if(lseek(impl->fd,SEEK_SET,0) < 0){
icalerror_set_errno(ICAL_FILE_ERROR);
return ICAL_FILE_ERROR;
}
@@ -302,21 +324,26 @@ icalerrorenum icalfileset_commit(icalfileset* cluster)
for(c = icalcomponent_get_first_component(impl->cluster,ICAL_ANY_COMPONENT);
c != 0;
c = icalcomponent_get_next_component(impl->cluster,ICAL_ANY_COMPONENT)){
+ int sz;
str = icalcomponent_as_ical_string(c);
- if ( fwrite(str,sizeof(char),strlen(str),f) < strlen(str)){
- fclose(f);
+ sz=write(impl->fd,str,strlen(str));
+
+ if ( sz != strlen(str)){
+ perror("write");
+ icalerror_set_errno(ICAL_FILE_ERROR);
return ICAL_FILE_ERROR;
}
+
+ write_size += sz;
}
- fclose(f);
impl->changed = 0;
-
-#ifdef ICAL_SAFESAVES
- rename(tmp,impl->path); /* HACK, should check for error here */
-#endif
+
+ if(ftruncate(impl->fd,write_size) < 0){
+ return ICAL_FILE_ERROR;
+ }
return ICAL_NO_ERROR;
@@ -333,18 +360,18 @@ void icalfileset_mark(icalfileset* cluster){
}
icalcomponent* icalfileset_get_component(icalfileset* cluster){
- struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
+ struct icalfileset_impl *impl = (struct icalfileset_impl*)cluster;
- icalerror_check_arg_re((impl!=0),"cluster",ICAL_BADARG_ERROR);
+ icalerror_check_arg_re((impl!=0),"cluster",ICAL_BADARG_ERROR);
- return impl->cluster;
+ return impl->cluster;
}
/* manipulate the components in the cluster */
icalerrorenum icalfileset_add_component(icalfileset *cluster,
- icalcomponent* child)
+ icalcomponent* child)
{
struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster;
@@ -360,7 +387,7 @@ icalerrorenum icalfileset_add_component(icalfileset *cluster,
}
icalerrorenum icalfileset_remove_component(icalfileset *cluster,
- icalcomponent* child)
+ icalcomponent* child)
{
struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster;
@@ -387,15 +414,23 @@ int icalfileset_count_components(icalfileset *cluster,
return icalcomponent_count_components(impl->cluster,kind);
}
-icalerrorenum icalfileset_select(icalfileset* cluster, icalcomponent* gauge)
+icalerrorenum icalfileset_select(icalfileset* set, icalgauge* gauge)
{
- assert(0); /* HACK, not implemented */
+ struct icalfileset_impl* impl = (struct icalfileset_impl*)set;
+
+ icalerror_check_arg_re(gauge!=0,"guage",ICAL_BADARG_ERROR);
+
+ impl->gauge = gauge;
+
return ICAL_NO_ERROR;
}
-void icalfileset_clear(icalfileset* cluster)
+void icalfileset_clear(icalfileset* gauge)
{
- assert(0); /* HACK, not implemented */
+ struct icalfileset_impl* impl = (struct icalfileset_impl*)gauge;
+
+ impl->gauge = 0;
+
}
icalcomponent* icalfileset_fetch(icalfileset* store,const char* uid)
@@ -534,7 +569,7 @@ icalcomponent* icalfileset_fetch_match(icalfileset* set, icalcomponent *comp)
icalerrorenum icalfileset_modify(icalfileset* store, icalcomponent *old,
- icalcomponent *new)
+ icalcomponent *new)
{
assert(0); /* HACK, not implemented */
return ICAL_NO_ERROR;
@@ -555,18 +590,49 @@ icalcomponent* icalfileset_get_current_component (icalfileset* cluster)
icalcomponent* icalfileset_get_first_component(icalfileset* cluster)
{
struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster;
+ icalcomponent *c=0;
icalerror_check_arg_rz((cluster!=0),"cluster");
- return icalcomponent_get_first_component(impl->cluster,ICAL_ANY_COMPONENT);
+ do {
+ if (c == 0){
+ c = icalcomponent_get_first_component(impl->cluster,
+ ICAL_ANY_COMPONENT);
+ } else {
+ c = icalcomponent_get_next_component(impl->cluster,
+ ICAL_ANY_COMPONENT);
+ }
+
+ if(c != 0 && (impl->gauge == 0 ||
+ icalgauge_compare(impl->gauge,c) == 1)){
+ return c;
+ }
+
+ } while(c != 0);
+
+
+ return 0;
}
icalcomponent* icalfileset_get_next_component(icalfileset* cluster)
{
struct icalfileset_impl* impl = (struct icalfileset_impl*)cluster;
+ icalcomponent *c;
icalerror_check_arg_rz((cluster!=0),"cluster");
+
+ do {
+ c = icalcomponent_get_next_component(impl->cluster,
+ ICAL_ANY_COMPONENT);
- return icalcomponent_get_next_component(impl->cluster,ICAL_ANY_COMPONENT);
+ if(c != 0 && (impl->gauge == 0 ||
+ icalgauge_compare(impl->gauge,c) == 1)){
+ return c;
+ }
+
+ } while(c != 0);
+
+
+ return 0;
}
diff --git a/libical/src/libicalss/icalfileset.h b/libical/src/libicalss/icalfileset.h
index 4430f1dc74..3b4b87c34d 100644
--- a/libical/src/libicalss/icalfileset.h
+++ b/libical/src/libicalss/icalfileset.h
@@ -30,6 +30,12 @@
#define ICALFILESET_H
#include "ical.h"
+#include "icalgauge.h"
+#include <sys/types.h> /* For open() flags and mode */
+#include <sys/stat.h> /* For open() flags and mode */
+#include <fcntl.h> /* For open() flags and mode */
+
+extern int icalfileset_safe_saves;
typedef void icalfileset;
@@ -41,6 +47,11 @@ typedef void icalfileset;
icalfileset* icalfileset_new(const char* path);
+
+/* Like _new, but takes open() flags for opening the file */
+icalfileset* icalfileset_new_open(const char* path,
+ int flags, mode_t mode);
+
void icalfileset_free(icalfileset* cluster);
const char* icalfileset_path(icalfileset* cluster);
@@ -61,7 +72,7 @@ int icalfileset_count_components(icalfileset* cluster,
/* Restrict the component returned by icalfileset_first, _next to those
that pass the gauge. _clear removes the gauge */
-icalerrorenum icalfileset_select(icalfileset* store, icalcomponent* gauge);
+icalerrorenum icalfileset_select(icalfileset* store, icalgauge* gauge);
void icalfileset_clear(icalfileset* store);
/* Get and search for a component by uid */
diff --git a/libical/src/libicalss/icalfilesetimpl.h b/libical/src/libicalss/icalfilesetimpl.h
index 767dceeadd..fcd3415121 100644
--- a/libical/src/libicalss/icalfilesetimpl.h
+++ b/libical/src/libicalss/icalfilesetimpl.h
@@ -30,6 +30,8 @@
#include "config.h"
#endif
+#include "icalgauge.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*/
@@ -37,10 +39,11 @@
struct icalfileset_impl {
- char id[5]; /*fset*/
- char *path;
- icalcomponent* cluster;
- int changed;
- FILE* stream;
+ char id[5]; /*fset*/
+ char *path;
+ icalcomponent* cluster;
+ icalgauge* gauge;
+ int changed;
+ int fd; /* file descriptor */
};
diff --git a/libical/src/libicalss/icalgauge.c b/libical/src/libicalss/icalgauge.c
index 0bbcd20bfc..b958ecfc9d 100644
--- a/libical/src/libicalss/icalgauge.c
+++ b/libical/src/libicalss/icalgauge.c
@@ -31,7 +31,6 @@
#include "icalgaugeimpl.h"
#include <stdlib.h>
-
extern char* input_buffer;
extern char* input_buffer_p;
int ssparse(void);
@@ -50,9 +49,9 @@ icalgauge* icalgauge_new_from_sql(char* sql)
return 0;
}
- impl->select = icalcomponent_new(ICAL_XROOT_COMPONENT);
- impl->from = icalcomponent_new(ICAL_XROOT_COMPONENT);
- impl->where = icalcomponent_new(ICAL_XROOT_COMPONENT);
+ impl->select = pvl_newlist();
+ impl->from = pvl_newlist();
+ impl->where = pvl_newlist();
icalss_yy_gauge = impl;
@@ -65,6 +64,38 @@ icalgauge* icalgauge_new_from_sql(char* sql)
void icalgauge_free(icalgauge* gauge)
{
+ struct icalgauge_impl *impl = (struct icalgauge_impl*)gauge;
+ struct icalgauge_where *w;
+
+ assert(impl->select != 0);
+ assert(impl->where != 0);
+ assert(impl->from != 0);
+
+ if(impl->select){
+ while( (w=pvl_pop(impl->select)) != 0){
+ if(w->value != 0){
+ free(w->value);
+ }
+ free(w);
+ }
+ pvl_free(impl->select);
+ }
+
+ if(impl->where){
+ while( (w=pvl_pop(impl->where)) != 0){
+
+ if(w->value != 0){
+ free(w->value);
+ }
+ free(w);
+ }
+ pvl_free(impl->where);
+ }
+
+ if(impl->from){
+ pvl_free(impl->from);
+ }
+
}
/* Convert a VQUERY component into a gauge */
@@ -105,7 +136,7 @@ icalcomponent* icalgauge_make_gauge(icalcomponent* query);
*/
-int icalgauge_test_recurse(icalcomponent* comp, icalcomponent* gauge)
+int icalgauge_compare_recurse(icalcomponent* comp, icalcomponent* gauge)
{
int pass = 1,localpass = 0;
icalproperty *p;
@@ -207,7 +238,7 @@ int icalgauge_test_recurse(icalcomponent* comp, icalcomponent* gauge)
}
if(child !=0){
- localpass = icalgauge_test_recurse(child,subgauge);
+ localpass = icalgauge_compare_recurse(child,subgauge);
pass = pass && localpass;
} else {
pass = 0;
@@ -217,29 +248,200 @@ int icalgauge_test_recurse(icalcomponent* comp, icalcomponent* gauge)
return pass;
}
-/* guagecontainer is an XROOT component that holds several gauges. The
- results of comparing against these gauges are ORed together in this
- routine */
-int icalgauge_test(icalcomponent* comp,
- icalcomponent* gaugecontainer)
+
+int icalgauge_compare(icalgauge* gauge,icalcomponent* comp)
{
- int pass = 0;
- icalcomponent *gauge;
+
+ struct icalgauge_impl *impl = (struct icalgauge_impl*)gauge;
+ icalcomponent *inner;
+ int local_pass = 0;
+ int last_clause = 1, this_clause = 1;
+ pvl_elem e;
icalerror_check_arg_rz( (comp!=0), "comp");
icalerror_check_arg_rz( (gauge!=0), "gauge");
- for(gauge = icalcomponent_get_first_component(gaugecontainer,
- ICAL_ANY_COMPONENT);
- gauge != 0;
- gauge = icalcomponent_get_next_component(gaugecontainer,
- ICAL_ANY_COMPONENT)){
+ inner = icalcomponent_get_first_real_component(comp);
+
+ if(inner == 0){
+ icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
+ return 0;
+ }
+
+
+ /* Check that this component is one of the FROM types */
+ local_pass = 0;
+ for(e = pvl_head(impl->from);e!=0;e=pvl_next(e)){
+ icalcomponent_kind k = (icalcomponent_kind)pvl_data(e);
- pass += icalgauge_test_recurse(comp, gauge);
+ if(k == icalcomponent_isa(inner)){
+ local_pass=1;
+ }
+ }
+
+ if(local_pass == 0){
+ return 0;
+ }
+
+
+ /* Check each where clause against the component */
+ for(e = pvl_head(impl->where);e!=0;e=pvl_next(e)){
+ struct icalgauge_where *w = pvl_data(e);
+ icalcomponent *sub_comp;
+ icalvalue *v;
+ icalproperty *prop;
+ icalvalue_kind vk;
+
+ if(w->prop == ICAL_NO_PROPERTY || w->value == 0){
+ icalerror_set_errno(ICAL_INTERNAL_ERROR);
+ return 0;
+ }
+
+ /* First, create a value from the gauge */
+ vk = icalenum_property_kind_to_value_kind(w->prop);
+
+ if(vk == ICAL_NO_VALUE){
+ icalerror_set_errno(ICAL_INTERNAL_ERROR);
+ return 0;
+ }
+
+ v = icalvalue_new_from_string(vk,w->value);
+
+ if (v == 0){
+ /* Keep error set by icalvalue_from-string*/
+ return 0;
+ }
+
+ /* Now find the corresponding property in the component,
+ descending into a sub-component if necessary */
+
+ if(w->comp == ICAL_NO_COMPONENT){
+ sub_comp = inner;
+ } else {
+ sub_comp = icalcomponent_get_first_component(inner,w->comp);
+ if(sub_comp == 0){
+ return 0;
+ }
+ }
+
+ this_clause = 0;
+ local_pass = 0;
+ for(prop = icalcomponent_get_first_property(sub_comp,w->prop);
+ prop != 0;
+ prop = icalcomponent_get_next_property(sub_comp,w->prop)){
+ icalvalue* prop_value;
+ icalgaugecompare relation;
+
+ prop_value = icalproperty_get_value(prop);
+
+ relation = (icalgaugecompare)icalvalue_compare(prop_value,v);
+
+ if (relation == w->compare){
+ local_pass++;
+ } else if (w->compare == ICALGAUGECOMPARE_LESSEQUAL &&
+ ( relation == ICALGAUGECOMPARE_LESS ||
+ relation == ICALGAUGECOMPARE_EQUAL)) {
+ local_pass++;
+ } else if (w->compare == ICALGAUGECOMPARE_GREATEREQUAL &&
+ ( relation == ICALGAUGECOMPARE_GREATER ||
+ relation == ICALGAUGECOMPARE_EQUAL)) {
+ local_pass++;
+ } else if (w->compare == ICALGAUGECOMPARE_NOTEQUAL &&
+ ( relation == ICALGAUGECOMPARE_GREATER ||
+ relation == ICALGAUGECOMPARE_LESS)) {
+ local_pass++;
+ } else {
+ local_pass = 0;
+ }
+ }
+
+ this_clause = local_pass > 0 ? 1 : 0;
+
+ /* Now look at the logic operator for this clause to see how
+ the value should be merge with the previous clause */
+
+ if(w->logic == ICALGAUGELOGIC_AND){
+ last_clause = this_clause && last_clause;
+ } else if(w->logic == ICALGAUGELOGIC_AND) {
+ last_clause = this_clause || last_clause;
+ } else {
+ last_clause = this_clause;
+ }
}
- return pass>0;
+ return last_clause;
}
+void icalgauge_dump(icalcomponent* gauge)
+{
+
+ pvl_elem *p;
+ struct icalgauge_impl *impl = (struct icalgauge_impl*)gauge;
+
+
+ printf("--- Select ---\n");
+ for(p = pvl_head(impl->select);p!=0;p=pvl_next(p)){
+ struct icalgauge_where *w = pvl_data(p);
+
+ if(w->comp != ICAL_NO_COMPONENT){
+ printf("%s ",icalenum_component_kind_to_string(w->comp));
+ }
+
+ if(w->prop != ICAL_NO_PROPERTY){
+ printf("%s ",icalenum_property_kind_to_string(w->prop));
+ }
+
+ if (w->compare != ICALGAUGECOMPARE_NONE){
+ printf("%d ",w->compare);
+ }
+
+
+ if (w->value!=0){
+ printf("%s",w->value);
+ }
+
+
+ printf("\n");
+ }
+
+ printf("--- From ---\n");
+ for(p = pvl_head(impl->from);p!=0;p=pvl_next(p)){
+ icalcomponent_kind k = (icalcomponent_kind)pvl_data(p);
+
+ printf("%s\n",icalenum_component_kind_to_string(k));
+ }
+
+ printf("--- Where ---\n");
+ for(p = pvl_head(impl->where);p!=0;p=pvl_next(p)){
+ struct icalgauge_where *w = pvl_data(p);
+
+ if(w->logic != ICALGAUGELOGIC_NONE){
+ printf("%d ",w->logic);
+ }
+
+ if(w->comp != ICAL_NO_COMPONENT){
+ printf("%s ",icalenum_component_kind_to_string(w->comp));
+ }
+
+ if(w->prop != ICAL_NO_PROPERTY){
+ printf("%s ",icalenum_property_kind_to_string(w->prop));
+ }
+
+ if (w->compare != ICALGAUGECOMPARE_NONE){
+ printf("%d ",w->compare);
+ }
+
+
+ if (w->value!=0){
+ printf("%s",w->value);
+ }
+
+
+ printf("\n");
+ }
+
+
+}
+
diff --git a/libical/src/libicalss/icalgauge.h b/libical/src/libicalss/icalgauge.h
index 2fbb3aab8c..1caf0ac7d1 100644
--- a/libical/src/libicalss/icalgauge.h
+++ b/libical/src/libicalss/icalgauge.h
@@ -37,7 +37,15 @@ void icalgauge_free(icalgauge* gauge);
char* icalgauge_as_sql(icalcomponent* gauge);
-int icalgauge_test(icalcomponent* comp, icalcomponent* gaugecontainer);
+void icalgauge_dump(icalcomponent* gauge);
+/* Return true is comp matches the gauge. The component must be in
+ cannonical form -- a VCALENDAR with one VEVENT, VTODO or VJOURNAL
+ sub component */
+int icalgauge_compare(icalgauge* g, icalcomponent* comp);
+
+/* Clone the component, but only return the properties specified in
+ the gauge */
+icalcomponent* icalgauge_new_clone(icalgauge* g, icalcomponent* comp);
#endif /* ICALGAUGE_H*/
diff --git a/libical/src/libicalss/icalgaugeimpl.h b/libical/src/libicalss/icalgaugeimpl.h
index 927d46ef0a..73a2813242 100644
--- a/libical/src/libicalss/icalgaugeimpl.h
+++ b/libical/src/libicalss/icalgaugeimpl.h
@@ -20,20 +20,44 @@
The Mozilla Public License Version 1.0. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
- The Original Code is eric. The Initial Developer of the Original
- Code is Eric Busboom
-
-
======================================================================*/
#include "ical.h"
+#include "pvl.h"
+
+typedef enum icalgaugecompare {
+ ICALGAUGECOMPARE_EQUAL=ICAL_XLICCOMPARETYPE_EQUAL,
+ ICALGAUGECOMPARE_LESS=ICAL_XLICCOMPARETYPE_LESS,
+ ICALGAUGECOMPARE_LESSEQUAL=ICAL_XLICCOMPARETYPE_LESSEQUAL,
+ ICALGAUGECOMPARE_GREATER=ICAL_XLICCOMPARETYPE_GREATER,
+ ICALGAUGECOMPARE_GREATEREQUAL=ICAL_XLICCOMPARETYPE_GREATEREQUAL,
+ ICALGAUGECOMPARE_NOTEQUAL=ICAL_XLICCOMPARETYPE_NOTEQUAL,
+ ICALGAUGECOMPARE_REGEX=ICAL_XLICCOMPARETYPE_REGEX,
+ ICALGAUGECOMPARE_NONE=0
+} icalgaugecompare;
+
+typedef enum icalgaugelogic {
+ ICALGAUGELOGIC_NONE,
+ ICALGAUGELOGIC_AND,
+ ICALGAUGELOGIC_OR
+} icalgaugelogic;
+
+
+struct icalgauge_where {
+ icalgaugelogic logic;
+ icalcomponent_kind comp;
+ icalproperty_kind prop;
+ icalgaugecompare compare;
+ char* value;
+};
+
struct icalgauge_impl
{
- icalcomponent* select;
- icalcomponent* from;
- icalcomponent* where;
+ pvl_list select; /*Of icalgaugecompare, using only prop and comp fields*/
+ pvl_list from; /* List of component_kinds, as integers */
+ pvl_list where; /* List of icalgaugecompare */
};
diff --git a/libical/src/libicalss/icalmessage.c b/libical/src/libicalss/icalmessage.c
index 4f075ed6bb..e1e8d8015c 100644
--- a/libical/src/libicalss/icalmessage.c
+++ b/libical/src/libicalss/icalmessage.c
@@ -43,17 +43,17 @@ icalcomponent* icalmessage_get_inner(icalcomponent* comp)
char* lowercase(const char* str)
{
char* p = 0;
- char* new = icalmemory_strdup(str);
+ char* n = icalmemory_strdup(str);
if(str ==0){
return 0;
}
- for(p = new; *p!=0; p++){
+ for(p = n; *p!=0; p++){
*p = tolower(*p);
}
- return new;
+ return n;
}
icalproperty* icalmessage_find_attendee(icalcomponent* comp, const char* user)
@@ -122,7 +122,7 @@ icalcomponent *icalmessage_new_reply_base(icalcomponent* c,
icalproperty_new_method(ICAL_METHOD_REPLY),
icalcomponent_vanew(
ICAL_VEVENT_COMPONENT,
- icalproperty_new_dtstamp(icaltime_from_timet(time(0),0,1)),
+ icalproperty_new_dtstamp(icaltime_from_timet(time(0),0)),
0),
0);
@@ -136,7 +136,7 @@ icalcomponent *icalmessage_new_reply_base(icalcomponent* c,
icalmessage_copy_properties(reply,c,ICAL_SUMMARY_PROPERTY);
icalmessage_copy_properties(reply,c,ICAL_SEQUENCE_PROPERTY);
- icalcomponent_set_dtstamp(reply,icaltime_from_timet(time(0),0,1));
+ icalcomponent_set_dtstamp(reply,icaltime_from_timet(time(0),0));
if(msg != 0){
icalcomponent_add_property(inner,icalproperty_new_comment(msg));
@@ -220,21 +220,21 @@ icalcomponent* icalmessage_new_decline_reply(icalcomponent* c,
}
/* New is modified version of old */
-icalcomponent* icalmessage_new_counterpropose_reply(icalcomponent* old,
- icalcomponent* new,
+icalcomponent* icalmessage_new_counterpropose_reply(icalcomponent* oldc,
+ icalcomponent* newc,
const char* user,
const char* msg)
{
icalcomponent *reply;
- icalerror_check_arg_rz(old,"old");
- icalerror_check_arg_rz(new,"new");
+ icalerror_check_arg_rz(oldc,"oldc");
+ icalerror_check_arg_rz(newc,"newc");
- reply = icalcomponent_new_clone(new);
+ reply = icalcomponent_new_clone(newc);
icalcomponent_set_method(reply,ICAL_METHOD_COUNTER);
- return new;
+ return newc;
}
diff --git a/libical/src/libicalss/icalmessage.h b/libical/src/libicalss/icalmessage.h
index 7687db681e..24f1c9f243 100644
--- a/libical/src/libicalss/icalmessage.h
+++ b/libical/src/libicalss/icalmessage.h
@@ -38,8 +38,8 @@ icalcomponent* icalmessage_new_decline_reply(icalcomponent* c,
const char* msg);
/* New is modified version of old */
-icalcomponent* icalmessage_new_counterpropose_reply(icalcomponent* old,
- icalcomponent* new,
+icalcomponent* icalmessage_new_counterpropose_reply(icalcomponent* oldc,
+ icalcomponent* newc,
const char* user,
const char* msg);
@@ -50,7 +50,6 @@ icalcomponent* icalmessage_new_delegate_reply(icalcomponent* c,
const char* msg);
-
icalcomponent* icalmessage_new_cancel_event(icalcomponent* c,
const char* user,
const char* msg);
diff --git a/libical/src/libicalss/icalset.c b/libical/src/libicalss/icalset.c
index 2ffe0deff2..3edbe503c4 100644
--- a/libical/src/libicalss/icalset.c
+++ b/libical/src/libicalss/icalset.c
@@ -263,7 +263,7 @@ icalset* icalset_new_mysql(const char* path)
void icalset_free(icalset* set)
{
struct icalset_impl impl = icalset_get_impl(set);
- return (*(impl.fp->free))(impl.derived_impl);
+ (*(impl.fp->free))(impl.derived_impl);
if(strcmp((char*)set,ICALSET_ID)) {
free(set);
@@ -279,7 +279,7 @@ const char* icalset_path(icalset* set)
void icalset_mark(icalset* set)
{
struct icalset_impl impl = icalset_get_impl(set);
- return (*(impl.fp->mark))(impl.derived_impl);
+ (*(impl.fp->mark))(impl.derived_impl);
}
icalerrorenum icalset_commit(icalset* set)
@@ -315,7 +315,7 @@ icalerrorenum icalset_select(icalset* set, icalcomponent* gauge)
void icalset_clear(icalset* set)
{
struct icalset_impl impl = icalset_get_impl(set);
- return (*(impl.fp->clear))(impl.derived_impl);
+ (*(impl.fp->clear))(impl.derived_impl);
}
icalcomponent* icalset_fetch(icalset* set, const char* uid)
diff --git a/libical/src/libicalss/icalspanlist.c b/libical/src/libicalss/icalspanlist.c
index effab3dca2..cab6a81c68 100644
--- a/libical/src/libicalss/icalspanlist.c
+++ b/libical/src/libicalss/icalspanlist.c
@@ -265,9 +265,9 @@ struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
period.start = t;
if (s->is_busy == 0){
- period.end = icaltime_from_timet(s->start,0,0);
+ period.end = icaltime_from_timet(s->start,0);
} else {
- period.end = icaltime_from_timet(s->end,0,0);
+ period.end = icaltime_from_timet(s->end,0);
}
return period;
@@ -286,12 +286,12 @@ struct icalperiodtype icalspanlist_next_free_time(icalspanlist* sl,
( rangett < s->end || s->end == s->start)){
if (rangett < s->start){
- period.start = icaltime_from_timet(s->start,0,0);
+ period.start = icaltime_from_timet(s->start,0);
} else {
- period.start = icaltime_from_timet(rangett,0,0);
+ period.start = icaltime_from_timet(rangett,0);
}
- period.end = icaltime_from_timet(s->end,0,0);
+ period.end = icaltime_from_timet(s->end,0);
return period;
}
diff --git a/libical/src/libicalss/icalsslexer.l b/libical/src/libicalss/icalsslexer.l
index 0054984c6d..848a9bc74f 100644
--- a/libical/src/libicalss/icalsslexer.l
+++ b/libical/src/libicalss/icalsslexer.l
@@ -6,7 +6,7 @@
DESCRIPTION:
- $Id: icalsslexer.l,v 1.1 2000/12/11 22:06:17 federico Exp $
+ $Id: icalsslexer.l,v 1.1.1.2 2001/01/23 19:20:41 jpr Exp $
$Locker: $
(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
@@ -84,12 +84,10 @@ WHERE { return WHERE; }
">=" { return GREATEREQUALS; }
AND { return AND; }
OR { return OR; }
+\' { return QUOTE; }
[ \t\n\r]+ ;
; { return EOL; }
-[\*A-Za-z0-9\-\.]+ { sslval.v_string= icalmemory_tmp_copy(sstext);
- return STRING; }
-
-'[^'\n]*' {
+\'[\*A-Za-z0-9\-\.]+\' {
int c = input();
unput(c);
if(c!='\''){
@@ -100,6 +98,10 @@ OR { return OR; }
}
}
+[\*A-Za-z0-9\-\.]+ { sslval.v_string= icalmemory_tmp_copy(sstext);
+ return STRING; }
+
+
. { return yytext[0]; }
%%
diff --git a/libical/src/libicalss/icalssyacc.h b/libical/src/libicalss/icalssyacc.h
index 43423f0d50..9a933dc735 100644
--- a/libical/src/libicalss/icalssyacc.h
+++ b/libical/src/libicalss/icalssyacc.h
@@ -6,16 +6,17 @@ typedef union {
#define FROM 259
#define WHERE 260
#define COMMA 261
-#define EQUALS 262
-#define NOTEQUALS 263
-#define LESS 264
-#define GREATER 265
-#define LESSEQUALS 266
-#define GREATEREQUALS 267
-#define AND 268
-#define OR 269
-#define EOL 270
-#define END 271
+#define QUOTE 262
+#define EQUALS 263
+#define NOTEQUALS 264
+#define LESS 265
+#define GREATER 266
+#define LESSEQUALS 267
+#define GREATEREQUALS 268
+#define AND 269
+#define OR 270
+#define EOL 271
+#define END 272
extern YYSTYPE sslval;
diff --git a/libical/src/libicalss/icalssyacc.y b/libical/src/libicalss/icalssyacc.y
index e6efe5da1f..047b158e93 100644
--- a/libical/src/libicalss/icalssyacc.y
+++ b/libical/src/libicalss/icalssyacc.y
@@ -6,7 +6,7 @@
DESCRIPTION:
- $Id: icalssyacc.y,v 1.1 2000/12/11 22:06:18 federico Exp $
+ $Id: icalssyacc.y,v 1.1.1.2 2001/01/23 19:20:41 jpr Exp $
$Locker: $
(C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
@@ -32,16 +32,17 @@
#include <limits.h> /* for SHRT_MAX*/
#include "ical.h"
#include "pvl.h"
+#include "icalgauge.h"
#include "icalgaugeimpl.h"
extern struct icalgauge_impl *icalss_yy_gauge;
-void ssyacc_add_where(struct icalgauge_impl* impl, char* str1,
- enum icalparameter_xliccomparetype compare , char* str2);
+void ssyacc_add_where(struct icalgauge_impl* impl, char* prop,
+ icalgaugecompare compare , char* value);
void ssyacc_add_select(struct icalgauge_impl* impl, char* str1);
void ssyacc_add_from(struct icalgauge_impl* impl, char* str1);
-void move_where(int w);
+void set_logic(struct icalgauge_impl* impl,icalgaugelogic l);
void sserror(char *s); /* Don't know why I need this.... */
@@ -54,7 +55,7 @@ void sserror(char *s); /* Don't know why I need this.... */
%token <v_string> STRING
-%token SELECT FROM WHERE COMMA EQUALS NOTEQUALS LESS GREATER LESSEQUALS
+%token SELECT FROM WHERE COMMA QUOTE EQUALS NOTEQUALS LESS GREATER LESSEQUALS
%token GREATEREQUALS AND OR EOL END
%%
@@ -79,61 +80,114 @@ from_list:
where_clause:
/* Empty */
- | STRING EQUALS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICAL_XLICCOMPARETYPE_EQUAL,$3); }
+ | STRING EQUALS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICALGAUGECOMPARE_EQUAL,$3); }
- | STRING NOTEQUALS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICAL_XLICCOMPARETYPE_NOTEQUAL,$3); }
- | STRING LESS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICAL_XLICCOMPARETYPE_LESS,$3); }
- | STRING GREATER STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICAL_XLICCOMPARETYPE_GREATER,$3); }
- | STRING LESSEQUALS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICAL_XLICCOMPARETYPE_LESSEQUAL,$3); }
- | STRING GREATEREQUALS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICAL_XLICCOMPARETYPE_GREATEREQUAL,$3); }
+ | STRING NOTEQUALS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICALGAUGECOMPARE_NOTEQUAL,$3); }
+ | STRING LESS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICALGAUGECOMPARE_LESS,$3); }
+ | STRING GREATER STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICALGAUGECOMPARE_GREATER,$3); }
+ | STRING LESSEQUALS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICALGAUGECOMPARE_LESSEQUAL,$3); }
+ | STRING GREATEREQUALS STRING {ssyacc_add_where(icalss_yy_gauge,$1,ICALGAUGECOMPARE_GREATEREQUAL,$3); }
;
where_list:
- where_clause {move_where(1);}
- | where_list AND where_clause {move_where(2);}
- | where_list OR where_clause {move_where(3);}
+ where_clause {set_logic(icalss_yy_gauge,ICALGAUGELOGIC_NONE);}
+ | where_list AND where_clause {set_logic(icalss_yy_gauge,ICALGAUGELOGIC_AND);}
+ | where_list OR where_clause {set_logic(icalss_yy_gauge,ICALGAUGELOGIC_OR);}
;
%%
void ssyacc_add_where(struct icalgauge_impl* impl, char* str1,
- enum icalparameter_xliccomparetype compare , char* str2)
+ icalgaugecompare compare , char* value_str)
{
- icalproperty *p;
- icalvalue *v;
- icalproperty_kind kind;
-
- kind = icalenum_string_to_property_kind(str1);
+
+ struct icalgauge_where *where;
+ char *compstr, *propstr, *c, *s,*l;
- if(kind == ICAL_NO_PROPERTY){
- assert(0);
+ if ( (where = malloc(sizeof(struct icalgauge_where))) ==0){
+ icalerror_set_errno(ICAL_NEWFAILED_ERROR);
+ return;
}
- p = icalproperty_new(kind);
+ memset(where,0,sizeof(struct icalgauge_where));
+ where->logic = ICALGAUGELOGIC_NONE;
+ where->compare = ICALGAUGECOMPARE_NONE;
+ where->comp = ICAL_NO_COMPONENT;
+ where->prop = ICAL_NO_PROPERTY;
- v = icalvalue_new_text(str2);
+ /* remove enclosing quotes */
+ s = value_str;
+ if(*s == '\''){
+ s++;
+ }
+ l = s+strlen(s)-1;
+ if(*l == '\''){
+ *l=0;
+ }
+
+ where->value = strdup(s);
- if(v == 0){
- assert(0);
+ /* Is there a period in str1 ? If so, the string specified both a
+ component and a property*/
+ if( (c = strrchr(str1,'.')) != 0){
+ compstr = str1;
+ propstr = c+1;
+ *c = '\0';
+ } else {
+ compstr = 0;
+ propstr = str1;
+ }
+
+
+ /* Handle the case where a component was specified */
+ if(compstr != 0){
+ where->comp = icalenum_string_to_component_kind(compstr);
+ } else {
+ where->comp = ICAL_NO_COMPONENT;
}
- icalproperty_set_value(p,v);
+ where->prop = icalenum_string_to_property_kind(propstr);
- icalproperty_add_parameter(p,icalparameter_new_xliccomparetype(compare));
+ where->compare = compare;
- icalcomponent_add_property(impl->where,p);
+ if(where->value == 0){
+ icalerror_set_errno(ICAL_NEWFAILED_ERROR);
+ free(where->value);
+ return;
+ }
+
+ pvl_push(impl->where,where);
+}
+
+void set_logic(struct icalgauge_impl* impl,icalgaugelogic l)
+{
+ pvl_elem e = pvl_tail(impl->where);
+ struct icalgauge_where *where = pvl_data(e);
+
+ where->logic = l;
+
}
+
+
void ssyacc_add_select(struct icalgauge_impl* impl, char* str1)
{
- icalproperty *p;
- icalproperty_kind pkind;
- icalcomponent_kind ckind = ICAL_NO_COMPONENT;
- char* c;
- char* compstr;
- char* propstr;
+ char *c, *compstr, *propstr;
+ struct icalgauge_where *where;
+ /* Uses only the prop and comp fields of the where structure */
+ if ( (where = malloc(sizeof(struct icalgauge_where))) ==0){
+ icalerror_set_errno(ICAL_NEWFAILED_ERROR);
+ return;
+ }
+
+ memset(where,0,sizeof(struct icalgauge_where));
+ where->logic = ICALGAUGELOGIC_NONE;
+ where->compare = ICALGAUGECOMPARE_NONE;
+ where->comp = ICAL_NO_COMPONENT;
+ where->prop = ICAL_NO_PROPERTY;
+
/* Is there a period in str1 ? If so, the string specified both a
component and a property*/
if( (c = strrchr(str1,'.')) != 0){
@@ -148,50 +202,31 @@ void ssyacc_add_select(struct icalgauge_impl* impl, char* str1)
/* Handle the case where a component was specified */
if(compstr != 0){
- ckind = icalenum_string_to_component_kind(compstr);
-
- if(ckind == ICAL_NO_COMPONENT){
- assert(0);
- }
+ where->comp = icalenum_string_to_component_kind(compstr);
} else {
- ckind = ICAL_NO_COMPONENT;
+ where->comp = ICAL_NO_COMPONENT;
}
/* If the property was '*', then accept all properties */
if(strcmp("*",propstr) == 0) {
- pkind = ICAL_ANY_PROPERTY;
+ where->prop = ICAL_ANY_PROPERTY;
} else {
- pkind = icalenum_string_to_property_kind(str1);
+ where->prop = icalenum_string_to_property_kind(propstr);
}
- if(pkind == ICAL_NO_PROPERTY){
- assert(0);
+ if(where->prop == ICAL_NO_PROPERTY){
+ icalgauge_free(where);
+ icalerror_set_errno(ICAL_BADARG_ERROR);
+ return;
}
-
- if(ckind == ICAL_NO_COMPONENT){
- p = icalproperty_new(pkind);
- assert(p!=0);
- icalcomponent_add_property(impl->select,p);
-
- } else {
- icalcomponent *comp =
- icalcomponent_new(ckind);
- p = icalproperty_new(pkind);
-
- assert(p!=0);
-
- icalcomponent_add_property(comp,p);
- icalcomponent_add_component(impl->select,comp);
-
- }
+ pvl_push(impl->select,where);
}
void ssyacc_add_from(struct icalgauge_impl* impl, char* str1)
{
- icalcomponent *c;
icalcomponent_kind ckind;
ckind = icalenum_string_to_component_kind(str1);
@@ -200,15 +235,10 @@ void ssyacc_add_from(struct icalgauge_impl* impl, char* str1)
assert(0);
}
- c = icalcomponent_new(ckind);
-
- icalcomponent_add_component(impl->from,c);
+ pvl_push(impl->from,(void*)ckind);
}
-void move_where(int w)
-{
-}
void sserror(char *s){
fprintf(stderr,"Parse error \'%s\'\n", s);