+ char *contenttype;
+ struct fh_data fh = {
+ retbuf,
+ 0,
+ SIZ
+ };
+
+ curl = curl_easy_init();
+ if (!curl) {
+ CtdlLogPrintf(CTDL_ALERT, "Unable to initialize libcurl.\n");
+ return 1;
+ }
+
+ curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
+ curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, fh);
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, extnotify_callback); /* don't care..*/
+ curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errmsg);
+ curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
+
+ pchs = strchr(remoteurl, ':');
+ pche = strchr(remoteurl, '@');
+ if ((pche != NULL) &&
+ (pchs != NULL) &&
+ (pchs < pche) && ((pche - pchs) < SIZ)) {
+ memcpy(userpass, pchs + 3, pche - pchs - 3);
+
+ userpass[pche - pchs - 3] = '\0';
+ curl_easy_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC);
+ curl_easy_setopt(curl, CURLOPT_USERPWD, userpass);
+
+ }
+#ifdef CURLOPT_HTTP_CONTENT_DECODING
+ curl_easy_setopt(curl, CURLOPT_HTTP_CONTENT_DECODING, 1);
+ curl_easy_setopt(curl, CURLOPT_ENCODING, "");
+#endif
+ curl_easy_setopt(curl, CURLOPT_USERAGENT, CITADEL);
+ curl_easy_setopt(curl, CURLOPT_TIMEOUT, 180); /* die after 180 seconds */
+ if (!IsEmptyStr(config.c_ip_addr)) {
+ curl_easy_setopt(curl, CURLOPT_INTERFACE, config.c_ip_addr);
+ }
+
+ headers = curl_slist_append(headers,"Accept: application/soap+xml, application/dime, multipart/related, text/*");
+ headers = curl_slist_append(headers,"Pragma: no-cache");
+
+ if (tlen > 0) {
+ /* Load the template message. Get mallocs done too */
+ FILE *Ftemplate = NULL;
+ const char *mimetype;
+
+ Ftemplate = fopen(template, "r");
+ mimetype = GuessMimeByFilename(template, tlen);
+ if (template == NULL) {
+ char buf[SIZ];
+
+ snprintf(buf, SIZ,
+ "Cannot load template file %s [%s]won't send notification\r\n",
+ file_funambol_msg, strerror(errno));
+ CtdlLogPrintf(CTDL_ERR, buf);
+
+ aide_message(buf, "External notifier unable to find message template!");
+ goto free;
+ }
+ snprintf(msgnumstr, 128, "%ld", MsgNum);
+
+ buf = malloc(SIZ);
+ memset(buf, 0, SIZ);
+ SOAPMessage = malloc(3072);
+ memset(SOAPMessage, 0, 3072);
+
+ while(fgets(buf, SIZ, Ftemplate) != NULL) {
+ strcat(SOAPMessage, buf);
+ }
+ fclose(Ftemplate);