/* * Called when loading data from callog file. * Types of data to be stored in the tree and list structures * depends on the version of the callog file. */ extern CSA_return_code _DtCmsSetFileVersion(_DtCmsCalendar *cal, int version) { cal->fversion = version; if (version == 1) { if (!(cal->tree = rb_create(_DtCmsGetApptKey, _DtCmsCompareAppt))) { return (CSA_E_INSUFFICIENT_MEMORY); } if (!(cal->list = hc_create(_DtCmsGetApptKey, _DtCmsCompareRptAppt))) { return (CSA_E_INSUFFICIENT_MEMORY); } } else { if (!(cal->tree = rb_create(_DtCmsGetEntryKey, _DtCmsCompareEntry))) { return (CSA_E_INSUFFICIENT_MEMORY); } if (!(cal->list = hc_create(_DtCmsGetEntryKey, _DtCmsCompareRptEntry))) { return (CSA_E_INSUFFICIENT_MEMORY); } if (init_cal_attrs(cal) != CSA_SUCCESS) return (CSA_E_INSUFFICIENT_MEMORY); if ((cal->types = (int *)calloc(1, sizeof(int) * (_DtCm_entry_name_tbl->size + 1))) == NULL) { _DtCmsFreeCalendar(cal); return (0); } else _DtCm_get_attribute_types(_DtCm_entry_name_tbl->size, cal->types); } cal->cal_tbl = _DtCm_cal_name_tbl; cal->entry_tbl = _DtCm_entry_name_tbl; return (CSA_SUCCESS); }
int main() { int na = 6; HTN ht; ht = hc_init(na); hc_print_ht(ht, na); hc_create(ht, na); hc_print_ht(ht, na); hc_print_cw(hc_encode(ht, na), na); puts(hc_uncode(ht, na, "1101001")); hc_destory(ht); system("pause"); return 0; }
int main(int argc, const char **argv) { struct hc_hcascade hc; struct nd_image *f; int fcount; int w, h; char *next; if (argc < 5) { fprintf(stderr, "Too few arguments.\n"); return 1; } w = strtol(argv[1], &next, 0); if (argv[1] == next) { fprintf(stderr, "Wrong format of width.\n"); return 1; } h = strtol(argv[2], &next, 0); if (argv[2] == next) { fprintf(stderr, "Wrong format of height.\n"); return 1; } if (loadfeatures(argv[3], &f, &fcount) < 0) { fprintf(stderr, "Cannot load features.\n"); return 1; } if (hc_create(&hc, w, h, f, fcount) < 0) { fprintf(stderr, nd_geterrormessage()); return 1; } if (hc_hcascadewrite(&hc, argv[4]) < 0) { fprintf(stderr, nd_geterrormessage()); return 1; } return 0; }
/*! \breif Receive an incoming connection */ static void hs_accept(void* _server) { Socket* client; HttpServer* server = _server; /* accept the conenction */ client = sock_accept(server->sock); /* check for error */ if(client == NULL) { return; } log(INFO, "New connection accepted %p", server->sock); /* create the http connection */ hc_create(server, client); }
extern _DtCmsCalendar * _DtCmsMakeCalendar(char *owner, char *name) { _DtCmsCalendar *cal; if ((cal = (_DtCmsCalendar *)calloc(1, sizeof(_DtCmsCalendar))) == NULL) { return (NULL); } cal->fversion = _DtCMS_VERSION4; if (init_cal_attrs(cal) != CSA_SUCCESS) { free(cal); return (NULL); } if (_DtCm_set_string_attrval(owner, &cal->attrs[CSA_CAL_ATTR_CALENDAR_OWNER_I].value, CSA_VALUE_CALENDAR_USER)) { _DtCmsFreeCalendar(cal); return (NULL); } if ((cal->owner = strdup(cal->attrs[CSA_CAL_ATTR_CALENDAR_OWNER_I].\ value->item.string_value)) == NULL) { _DtCmsFreeCalendar(cal); return (NULL); } if (_DtCm_set_string_attrval(name, &cal->attrs[CSA_CAL_ATTR_CALENDAR_NAME_I].value, CSA_VALUE_STRING)) { _DtCmsFreeCalendar(cal); return (NULL); } if ((cal->calendar = get_calname(name)) == NULL) { _DtCmsFreeCalendar(cal); return (NULL); } if ((cal->types = (int *)calloc(1, sizeof(int) * (_DtCm_entry_name_tbl->size + 1))) == NULL) { _DtCmsFreeCalendar(cal); return (NULL); } else _DtCm_get_attribute_types(_DtCm_entry_name_tbl->size, cal->types); if (!(cal->tree = rb_create(_DtCmsGetEntryKey, _DtCmsCompareEntry))) { _DtCmsFreeCalendar(cal); return (NULL); } if (!(cal->list = hc_create(_DtCmsGetEntryKey, _DtCmsCompareRptEntry))) { _DtCmsFreeCalendar(cal); return (NULL); } cal->cal_tbl = _DtCm_cal_name_tbl; cal->entry_tbl = _DtCm_entry_name_tbl; cal->num_entry_attrs = _DtCm_entry_name_tbl->size; cal->getattrfuncs = _GetAttrFuncPtrs; return (cal); }