Oracle Calendar/iCal downloader
The following C++ program will connect to an Oracle Calendar server and retrive an iCal file for a particular user. The program is hard-coded with the Oracle Calendar used at Case. At execution time, the program binds to the Oracle Calendar server as the user defined by the CALENDAR_USER environment variable who has the password set with the CALENDAR_PASSWORD environment variable.
This program requires the Oracle Calendar SDK to compile and run.
If you use this program, please leave a comment.
//Oracle Calendar iCal downloader #include <time.h> #include <stdio.h> #include <stdlib.h> #include <string.h> /* Required with ctapi.h to import functions from the CAPI shared library */ #ifdef WIN32 #define CAPI_FUNC(a) __declspec(dllimport) a #else #define CAPI_FUNC(a) a #endif #define CSDK_USE_OLD_NAMES #include "ctapi.h" #define MAX_HANDLES 32 #include <iostream> using namespace std; int main () { //initialize the calendar variables //CAPIStatus stat = CSDK_SetConfigFile("capi.ini", "capi.log"); CAPIStatus stat = NULL; CAPISession session = NULL; stat = CSDK_CreateSession(CAPI_FLAGS_NONE, &session); stat = CSDK_Connect(session, CAPI_FLAG_NONE, "calendar.case.edu"); stat = CSDK_Authenticate(session, CSDK_FLAG_NONE, getenv("CALENDAR_USER"), getenv("CALENDAR_PASSWORD")); CAPIHandle currUser = CSDK_HANDLE_INITIALIZER; stat = CSDK_GetHandle(session, NULL, CAPI_FLAG_NONE, &currUser); CAPIStream stream = NULL; CSDKRequestResult *result= 0; const char * iCaldata; stat = CSDK_CreateMemoryStream(session, &stream, NULL, &iCaldata, CSDK_FLAG_NONE); stat = CSDK_FetchEventsByRange(session, CSDK_FLAG_NONE, NULL, "20000101", "20300101", NULL, stream, result); cout << iCaldata; return 0; }
