void initAudioDevices(SIPX_INSTANCE_DATA& pInst) { #if defined(_WIN32) WAVEOUTCAPS outcaps; WAVEINCAPS incaps; int numDevices; MMRESULT result; numDevices = waveInGetNumDevs(); for (int i = 0; i < numDevices && i < MAX_AUDIO_DEVICES; i++) { result = waveInGetDevCaps(i, &incaps, sizeof(WAVEINCAPS)); assert(result == MMSYSERR_NOERROR); pInst.inputAudioDevices[i] = SAFE_STRDUP(incaps.szPname); } pInst.nInputAudioDevices = numDevices; numDevices = waveOutGetNumDevs(); for (int i = 0; i < numDevices && i < MAX_AUDIO_DEVICES; i++) { result = waveOutGetDevCaps(i, &outcaps, sizeof(WAVEOUTCAPS)); assert(result == MMSYSERR_NOERROR); pInst.outputAudioDevices[i] = SAFE_STRDUP(outcaps.szPname) ; } pInst.nOutputAudioDevices = numDevices; #else pInst.inputAudioDevices[0] = SAFE_STRDUP("Default"); pInst.outputAudioDevices[0] = SAFE_STRDUP("Default"); #endif }
void cals_stmt_fill_rrule(sqlite3_stmt *stmt,cal_sch_full_t *sch_record) { char *until_datetime; char buf[8] = {0}; const unsigned char *temp; int count = 0; sch_record->rrule_id = sqlite3_column_int(stmt,count++); sqlite3_column_int(stmt,count++); // event_id sch_record->freq = sqlite3_column_int(stmt,count++); sch_record->range_type = sqlite3_column_int(stmt,count++); sch_record->until_type = sqlite3_column_int(stmt,count++); sch_record->until_utime = sqlite3_column_int64(stmt, count++); temp = sqlite3_column_text(stmt, count++); if (temp) { until_datetime = SAFE_STRDUP(temp); snprintf(buf, strlen("YYYY") + 1, "%s", &until_datetime[0]); sch_record->until_year = atoi(buf); snprintf(buf, strlen("MM") + 1, "%s", &until_datetime[4]); sch_record->until_month = atoi(buf); snprintf(buf, strlen("DD") + 1, "%s", &until_datetime[6]); sch_record->until_mday = atoi(buf); if (until_datetime) free(until_datetime); } sch_record->count = sqlite3_column_int(stmt,count++); sch_record->interval = sqlite3_column_int(stmt,count++); temp = sqlite3_column_text(stmt, count++); sch_record->bysecond = SAFE_STRDUP(temp); temp = sqlite3_column_text(stmt, count++); sch_record->byminute = SAFE_STRDUP(temp); temp = sqlite3_column_text(stmt, count++); sch_record->byhour = SAFE_STRDUP(temp); temp = sqlite3_column_text(stmt, count++); sch_record->byday = SAFE_STRDUP(temp); temp = sqlite3_column_text(stmt, count++); sch_record->bymonthday = SAFE_STRDUP(temp); temp = sqlite3_column_text(stmt, count++); sch_record->byyearday = SAFE_STRDUP(temp); temp = sqlite3_column_text(stmt, count++); sch_record->byweekno = SAFE_STRDUP(temp); temp = sqlite3_column_text(stmt, count++); sch_record->bymonth = SAFE_STRDUP(temp); temp = sqlite3_column_text(stmt, count++); sch_record->bysetpos = SAFE_STRDUP(temp); sch_record->wkst = sqlite3_column_int(stmt,count++); }
void SipXKeepaliveEventListener::handleKeepaliveEvent(SIPX_KEEPALIVE_EVENT event, SIPX_KEEPALIVE_CAUSE cause, SIPX_KEEPALIVE_TYPE type, const char* szRemoteAddress, int remotePort, int keepAliveSecs, const char* szFeedbackAddress, int feedbackPort) { OsSysLog::add(FAC_SIPXTAPI, PRI_DEBUG, "handleKeepaliveEvent src=%p event=%s:%s type=%s remote=%s:%d keepalive=%ds mapped=%s:%d\n", m_pInst, sipxKeepaliveEventToString(event), sipxKeepaliveCauseToString(cause), convertKeepaliveTypeToString(type), szRemoteAddress ? szRemoteAddress : "", remotePort, keepAliveSecs, szFeedbackAddress ? szFeedbackAddress : "", feedbackPort); SIPX_KEEPALIVE_INFO keepaliveInfo; memset(&keepaliveInfo, 0, sizeof(SIPX_KEEPALIVE_INFO)); keepaliveInfo.nSize = sizeof(SIPX_KEEPALIVE_INFO); keepaliveInfo.event = event; keepaliveInfo.cause = cause; keepaliveInfo.type = type; keepaliveInfo.szRemoteAddress = SAFE_STRDUP(szRemoteAddress); keepaliveInfo.remotePort = remotePort; keepaliveInfo.keepAliveSecs = keepAliveSecs; keepaliveInfo.szFeedbackAddress = SAFE_STRDUP(szFeedbackAddress); keepaliveInfo.feedbackPort = feedbackPort; SipXEventDispatcher::dispatchEvent(m_pInst, EVENT_CATEGORY_KEEPALIVE, &keepaliveInfo); // free doesn't mind NULL value free((void*)keepaliveInfo.szRemoteAddress); free((void*)keepaliveInfo.szFeedbackAddress); }
/* * return the name of the interface. * used to deal with unicode under Windows */ static char *iface_name(const char *s) { char *buf; #if defined(OS_WINDOWS) || defined(OS_CYGWIN) size_t len = wcslen ((const wchar_t*)s); if (!s[1]) { /* should probably use IsTextUnicode() ... */ SAFE_CALLOC(buf, len + 1, sizeof(char)); sprintf (buf, "%S", s); DEBUG_MSG("iface_name: '%S', is_unicode '%s'", s, buf); return buf; } #endif SAFE_STRDUP(buf, s); return buf; }
int file_relative_path(char *fullpath, char *base_path, char **relative_path) { char *laststr; if (!fullpath || !relative_path) FATAL_ERROR("%s: wrong parameters [fullpath %p][relative_path %p]", __func__, fullpath, relative_path ); laststr = strstr(fullpath, base_path) + strlen(base_path); if (laststr[0] == '/') laststr++; SAFE_STRDUP(*relative_path, laststr); DEBUG_MSG(D_INFO, "%s [relative_path %s]", __func__, *relative_path); return ESUCCESS; }
void cals_stmt_get_full_schedule(sqlite3_stmt *stmt,cal_sch_full_t *sch_record, bool is_utc) { int count = 0; char *dtstart_datetime; char *dtend_datetime; char buf[8] = {0}; const unsigned char *temp; sch_record->index = sqlite3_column_int(stmt, count++); sch_record->account_id = sqlite3_column_int(stmt, count++); sch_record->cal_type = sqlite3_column_int(stmt, count++); temp = sqlite3_column_text(stmt, count++); sch_record->summary = SAFE_STRDUP(temp); temp = sqlite3_column_text(stmt, count++); sch_record->description = SAFE_STRDUP(temp); temp = sqlite3_column_text(stmt, count++); sch_record->location = SAFE_STRDUP(temp); temp = sqlite3_column_text(stmt, count++); sch_record->categories = SAFE_STRDUP(temp); temp = sqlite3_column_text(stmt, count++); sch_record->exdate = SAFE_STRDUP(temp); sch_record->missed = sqlite3_column_int(stmt, count++); sch_record->task_status = sqlite3_column_int(stmt, count++); sch_record->priority = sqlite3_column_int(stmt, count++); sch_record->timezone = sqlite3_column_int(stmt, count++); sch_record->file_id = sqlite3_column_int(stmt, count++); sch_record->contact_id = sqlite3_column_int(stmt, count++); sch_record->busy_status = sqlite3_column_int(stmt, count++); sch_record->sensitivity = sqlite3_column_int(stmt, count++); temp = sqlite3_column_text(stmt, count++); sch_record->uid = SAFE_STRDUP(temp); sch_record->calendar_type = sqlite3_column_int(stmt, count++); temp = sqlite3_column_text(stmt, count++); sch_record->organizer_name = SAFE_STRDUP(temp); temp = sqlite3_column_text(stmt, count++); sch_record->organizer_email = SAFE_STRDUP(temp); sch_record->meeting_status = sqlite3_column_int(stmt, count++); temp = sqlite3_column_text(stmt, count++); sch_record->gcal_id = SAFE_STRDUP(temp); temp = sqlite3_column_text(stmt, count++); sch_record->updated = SAFE_STRDUP(temp); sch_record->location_type = sqlite3_column_int(stmt, count++); temp = sqlite3_column_text(stmt, count++); sch_record->location_summary = SAFE_STRDUP(temp); temp = sqlite3_column_text(stmt, count++); sch_record->etag = SAFE_STRDUP(temp); sch_record->calendar_id = sqlite3_column_int(stmt, count++); sch_record->sync_status = sqlite3_column_int(stmt, count++); temp = sqlite3_column_text(stmt, count++); sch_record->edit_uri = SAFE_STRDUP(temp); temp = sqlite3_column_text(stmt, count++); sch_record->gevent_id = SAFE_STRDUP(temp); sch_record->dst = sqlite3_column_int(stmt, count++); sch_record->original_event_id = sqlite3_column_int(stmt, count++); sch_record->latitude = sqlite3_column_double(stmt,count++); sch_record->longitude = sqlite3_column_double(stmt,count++); sch_record->email_id = sqlite3_column_int(stmt, count++); sch_record->availability = sqlite3_column_int(stmt, count++); sch_record->created_time = sqlite3_column_int64(stmt, count++); sch_record->completed_time = sqlite3_column_int64(stmt, count++); sch_record->progress = sqlite3_column_int(stmt,count++); sqlite3_column_int(stmt,count++); sqlite3_column_int(stmt,count++); sch_record->is_deleted = sqlite3_column_int(stmt,count++); sch_record->dtstart_type = sqlite3_column_int(stmt,count++); sch_record->dtstart_utime = sqlite3_column_int64(stmt,count++); temp = sqlite3_column_text(stmt, count++); if (temp) { dtstart_datetime = SAFE_STRDUP(temp); snprintf(buf, strlen("YYYY") + 1, "%s", &dtstart_datetime[0]); sch_record->dtstart_year = atoi(buf); snprintf(buf, strlen("MM") + 1, "%s", &dtstart_datetime[4]); sch_record->dtstart_month = atoi(buf); snprintf(buf, strlen("DD") + 1, "%s", &dtstart_datetime[6]); sch_record->dtstart_mday = atoi(buf); if (dtstart_datetime) free(dtstart_datetime); } temp = sqlite3_column_text(stmt, count++); sch_record->dtstart_tzid = SAFE_STRDUP(temp); sch_record->dtend_type = sqlite3_column_int(stmt, count++); sch_record->dtend_utime = sqlite3_column_int64(stmt, count++); temp = sqlite3_column_text(stmt, count++); if (temp) { dtend_datetime = SAFE_STRDUP(temp); snprintf(buf, strlen("YYYY") + 1, "%s", &dtend_datetime[0]); sch_record->dtend_year = atoi(buf); snprintf(buf, strlen("MM") + 1, "%s", &dtend_datetime[4]); sch_record->dtend_month = atoi(buf); snprintf(buf, strlen("DD") + 1, "%s", &dtend_datetime[6]); sch_record->dtend_mday = atoi(buf); if (dtend_datetime) free(dtend_datetime); } temp = sqlite3_column_text(stmt, count++); sch_record->dtend_tzid = SAFE_STRDUP(temp); sch_record->last_mod = sqlite3_column_int64(stmt,count++); sch_record->rrule_id = sqlite3_column_int(stmt,count++); }
int cals_stmt_get_filted_schedule(sqlite3_stmt *stmt, cal_sch_full_t *sch_record, const char *select_field) { int count = 0; const unsigned char *temp; const char *start, *result; retv_if(NULL == stmt, CAL_ERR_ARG_NULL); retv_if(NULL == sch_record, CAL_ERR_ARG_NULL); retv_if(NULL == select_field, CAL_ERR_ARG_NULL); start = select_field; if((result = strstr(start, CAL_VALUE_INT_INDEX))) { sch_record->index = sqlite3_column_int(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_INT_ACCOUNT_ID))) { sch_record->account_id = sqlite3_column_int(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_INT_TYPE))) { sch_record->cal_type = sqlite3_column_int(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_TXT_SUMMARY))) { temp = sqlite3_column_text(stmt, count++); sch_record->summary = SAFE_STRDUP(temp); start = result; } if((result = strstr(start,CAL_VALUE_TXT_DESCRIPTION))) { temp = sqlite3_column_text(stmt, count++); sch_record->description = SAFE_STRDUP(temp); start = result; } if((result = strstr(start,CAL_VALUE_TXT_LOCATION))) { temp = sqlite3_column_text(stmt, count++); sch_record->location = SAFE_STRDUP(temp); start = result; } if((result = strstr(start, CAL_VALUE_TXT_CATEGORIES))) { temp = sqlite3_column_text(stmt, count++); sch_record->categories = SAFE_STRDUP(temp); start = result; } if((result = strstr(start, CAL_VALUE_TXT_EXDATE))) { temp = sqlite3_column_text(stmt, count++); sch_record->exdate = SAFE_STRDUP(temp); start = result; } if((result = strstr(start,CAL_VALUE_INT_MISSED))) { sch_record->missed = sqlite3_column_int(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_INT_TASK_STATUS))) { sch_record->task_status = sqlite3_column_int(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_INT_PRIORITY))) { sch_record->priority = sqlite3_column_int(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_INT_TIMEZONE))) { sch_record->timezone = sqlite3_column_int(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_INT_FILE_ID))) { sch_record->file_id = sqlite3_column_int(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_INT_CONTACT_ID))) { sch_record->contact_id = sqlite3_column_int(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_INT_BUSY_STATUS))) { sch_record->busy_status = sqlite3_column_int(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_INT_SENSITIVITY))) { sch_record->sensitivity = sqlite3_column_int(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_TXT_UID))) { temp = sqlite3_column_text(stmt, count++); sch_record->uid = SAFE_STRDUP(temp); start = result; } if((result = strstr(start,CAL_VALUE_INT_CALENDAR_TYPE))) { sch_record->calendar_type = sqlite3_column_int(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_INT_CALENDAR_TYPE))) { sch_record->calendar_type = sqlite3_column_int(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_TXT_ORGANIZER_NAME))) { temp = sqlite3_column_text(stmt, count++); sch_record->organizer_name = SAFE_STRDUP(temp); start = result; } if((result = strstr(start,CAL_VALUE_TXT_ORGANIZER_EMAIL))) { temp = sqlite3_column_text(stmt, count++); sch_record->organizer_email = SAFE_STRDUP(temp); start = result; } if((result = strstr(start, CAL_VALUE_INT_MEETING_STATUS))) { sch_record->meeting_status = sqlite3_column_int(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_TXT_GCAL_ID))) { temp = sqlite3_column_text(stmt, count++); sch_record->gcal_id = SAFE_STRDUP(temp); start = result; } if((result = strstr(start,CAL_VALUE_TXT_UPDATED))) { temp = sqlite3_column_text(stmt, count++); sch_record->updated = SAFE_STRDUP(temp); start = result; } if((result = strstr(start,CAL_VALUE_INT_LOCATION_TYPE))) { sch_record->location_type = sqlite3_column_int(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_TXT_LOCATION_SUMMARY))) { temp = sqlite3_column_text(stmt, count++); sch_record->location_summary = SAFE_STRDUP(temp); start = result; } if((result = strstr(start,CAL_VALUE_TXT_ETAG))) { temp = sqlite3_column_text(stmt, count++); sch_record->etag = SAFE_STRDUP(temp); start = result; } if((result = strstr(start,CAL_VALUE_INT_CALENDAR_ID))) { sch_record->calendar_id = sqlite3_column_int(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_INT_SYNC_STATUS))) { sch_record->sync_status = sqlite3_column_int(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_TXT_EDIT_URL))) { temp = sqlite3_column_text(stmt, count++); sch_record->edit_uri = SAFE_STRDUP(temp); start = result; } if((result = strstr(start,CAL_VALUE_TXT_GEDERID))) { temp = sqlite3_column_text(stmt, count++); sch_record->gevent_id = SAFE_STRDUP(temp); start = result; } if((result = strstr(start,CAL_VALUE_INT_DST))) { sch_record->dst = sqlite3_column_int(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_INT_ORIGINAL_EVENT_ID))) { sch_record->original_event_id = sqlite3_column_int(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_DBL_LATITUDE))) { sch_record->latitude = sqlite3_column_double(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_DBL_LONGITUDE))) { sch_record->longitude = sqlite3_column_double(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_INT_EMAIL_ID))) { sch_record->email_id = sqlite3_column_int(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_INT_AVAILABILITY))) { sch_record->availability = sqlite3_column_int(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_LLI_CREATED_TIME))) { sch_record->created_time = sqlite3_column_int64(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_LLI_COMPLETED_TIME))) { sch_record->completed_time = sqlite3_column_int64(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_INT_PROGRESS))) { sch_record->progress = sqlite3_column_int(stmt, count++); start = result; } if((result = strstr(start,CAL_VALUE_INT_IS_DELETED))) { sch_record->is_deleted = sqlite3_column_int(stmt, count++); start = result; } return CAL_SUCCESS; }
int cals_get_alarm_info(const int event_id, GList **alarm_list) { int ret = -1; GList *result = NULL; sqlite3_stmt *stmt = NULL; cal_value * cvalue = NULL; char query[CALS_SQL_MAX_LEN] = {0}; cal_alarm_info_t* alarm_info = NULL; retv_if(NULL == alarm_list, CAL_ERR_ARG_NULL); sprintf(query, "SELECT * FROM %s WHERE event_id=%d", CALS_TABLE_ALARM, event_id); stmt = cals_query_prepare(query); retvm_if(NULL == stmt, CAL_ERR_DB_FAILED, "cals_query_prepare() Failed"); ret = cals_stmt_step(stmt); if (ret < CAL_SUCCESS) { sqlite3_finalize(stmt); ERR("cals_stmt_step() Failed(%d)", ret); return ret; } while (CAL_TRUE == ret) { cvalue = calloc(1, sizeof(cal_value)); if (NULL == cvalue) { sqlite3_finalize(stmt); g_list_foreach(result, _cals_alarm_value_free, NULL); g_list_free(result); ERR("calloc() Failed(%d)", errno); return CAL_ERR_OUT_OF_MEMORY; } cvalue->v_type = CAL_EVENT_ALARM; cvalue->user_data = alarm_info = calloc(1, sizeof(cal_alarm_info_t)); if (NULL == alarm_info) { sqlite3_finalize(stmt); g_list_foreach(result, _cals_alarm_value_free, NULL); g_list_free(result); free(cvalue); ERR("calloc() Failed(%d)", errno); return CAL_ERR_OUT_OF_MEMORY; } alarm_info->event_id = sqlite3_column_int(stmt, 0); alarm_info->alarm_time = sqlite3_column_int64(stmt, 1); alarm_info->remind_tick = sqlite3_column_int(stmt, 2); alarm_info->remind_tick_unit = sqlite3_column_int(stmt, 3); alarm_info->alarm_tone = SAFE_STRDUP(sqlite3_column_text(stmt, 4)); alarm_info->alarm_description = SAFE_STRDUP(sqlite3_column_text(stmt, 5)); alarm_info->alarm_type = sqlite3_column_int(stmt, 6); alarm_info->alarm_id = sqlite3_column_int(stmt, 7); result = g_list_append(result, cvalue); ret = cals_stmt_step(stmt); } sqlite3_finalize(stmt); *alarm_list = result; return CAL_SUCCESS; }
int proxy_null(BIO **cbio, BIO **sbio, char *header) { char data[READ_BUFF_SIZE]; int len, written; char *host, *p; /* retrieve the host tag */ host = strcasestr(header, HTTP_HOST_TAG); if (host == NULL) return -EINVALID; SAFE_STRDUP(host, host + strlen(HTTP_HOST_TAG)); /* trim the eol */ if ((p = strchr(host, '\r')) != NULL) *p = 0; if ((p = strchr(host, '\n')) != NULL) *p = 0; /* connect to the real server */ *sbio = BIO_new(BIO_s_connect()); BIO_set_conn_hostname(*sbio, host); BIO_set_conn_port(*sbio, "http"); if (BIO_do_connect(*sbio) <= 0) { DEBUG_MSG(D_ERROR, "Cannot connect to [%s]", host); SAFE_FREE(host); return -ENOADDRESS; } DEBUG_MSG(D_INFO, "Connection to [%s]", host); /* * sanitize the header to avoid strange reply from the server. * we don't want to cope with keep-alive !!! */ sanitize_header(header); /* send the request to the server */ BIO_puts(*sbio, header); memset(data, 0, sizeof(data)); written = 0; /* read the reply header from the server */ LOOP { len = BIO_read(*sbio, data + written, sizeof(char)); if (len <= 0) break; written += len; if (strstr(data, CR LF CR LF) || strstr(data, LF LF)) break; } /* send the headers to the client, the data will be sent in the callee function */ BIO_write(*cbio, data, written); SAFE_FREE(host); return ESUCCESS; }