Logo Search packages:      
Sourcecode: libical version File versions  Download package

icalset* icalset_new ( icalset_kind  kind,
const char *  dsn,
void *  options 
)

Generic icalset constructor.

Parameters:
kind The type of icalset to create
dsn Data Source Name - usually a pathname or DB handle
options Any implementation specific options
Returns:
A valid icalset reference or NULL if error.
This creates any of the icalset types available.

unimplemented

call the implementation specific initializer

Definition at line 241 of file icalset.c.

                                                                        {
  icalset *data = NULL;
  icalset *ret = NULL;

#ifdef _DLOPEN_TEST
    pvl_elem      e;
    icalset    *impl;

    if (!icalset_init_done)
      icalset_init();

    for(e = pvl_head(icalset_kinds); e!=0; e = pvl_next(e)) {
      impl = (icalset*)pvl_data(e);
      if (impl->kind == kind)
          break;
    }
    if (e == 0) {
      icalerror_set_errno(ICAL_UNIMPLEMENTED_ERROR);
      return(NULL);
    }

    data = (icalset*)malloc(impl->size);
    if (data == 0) {
      icalerror_set_errno(ICAL_NEWFAILED_ERROR);
      errno = ENOMEM;
      return 0;
    }

    /* The first member of the derived class must be an icalset. */
    memset(data,0,impl->size);
    /* *data = *impl; */
    memcpy(data, impl, sizeof(icalset));

    data->dsn     = strdup(dsn);
#else
  switch(kind) {
  case ICAL_FILE_SET:
    data = (icalset*) malloc(sizeof(icalfileset));
    if (data == 0) {
            icalerror_set_errno(ICAL_NEWFAILED_ERROR);
      errno = ENOMEM;
      return 0;
    }
    memset(data,0,sizeof(icalfileset));
    *data = icalset_fileset_init;
    break;
  case ICAL_DIR_SET:
    data = (icalset*) malloc(sizeof(icaldirset));
    if (data == 0) {
            icalerror_set_errno(ICAL_NEWFAILED_ERROR);
      errno = ENOMEM;
      return 0;
    }
    memset(data,0,sizeof(icaldirset));
    *data = icalset_dirset_init;
    break;
#ifdef WITH_BDB4
  case ICAL_BDB_SET:
    data = (icalset*) malloc(sizeof(icalbdbset));
    if (data == 0) {
            icalerror_set_errno(ICAL_NEWFAILED_ERROR);
      errno = ENOMEM;
      return 0;
    }
    memset(data,0,sizeof(icalbdbset));
    *data = icalset_bdbset_init;
    break;
#endif
    
  default:
    icalerror_set_errno(ICAL_UNIMPLEMENTED_ERROR);
    /** unimplemented **/
    return(NULL);
  }

  if ( data == 0) {
    icalerror_set_errno(ICAL_NEWFAILED_ERROR);
    return 0;
  }
  data->kind    = kind;
  data->dsn     = strdup(dsn);
#endif

  /** call the implementation specific initializer **/
  if ((ret = data->init(data, dsn, options)) == NULL)
    icalset_free(data);

  return ret;
}


Generated by  Doxygen 1.6.0   Back to index