void FilesCnr::getFiles() { PFILEFINDBUF3 pffb = NULL; OString FileSpec(scanDirectory); ULONG bufSize = sizeof(FILEFINDBUF3) * 200; HDIR hdir = HDIR_CREATE; ULONG ulMaxFiles = 200; APIRET rc; freeItems(); FileList.reset(); DosAllocMem((PPVOID)&pffb, bufSize, PAG_READ | PAG_WRITE | PAG_COMMIT); if (!pffb) return; FileSpec + "\\*"; DosError(FERR_DISABLEHARDERR); rc = DosFindFirst(FileSpec.text, &hdir, FILE_NORMAL | FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY, pffb, bufSize, &ulMaxFiles, FIL_STANDARD); while(!rc) { insertFiles(pffb, ulMaxFiles); rc = DosFindNext(hdir, pffb, bufSize, &ulMaxFiles); } DosFindClose(hdir); DosError(FERR_ENABLEHARDERR); DosFreeMem(pffb); }
void skelJointsRecorder::startRecording(int _now, int _duration, int _limit) { freeItems(); playing = false; recording = true; recordStart = _now; recordEnd = recordStart + _duration; recordLimit = _limit; if(recordLimit < 1) recordLimit = 900; // 900 items maximum about 30s x 30fps }
static int loadItems(rdWin *w, char **items) { rdItem *i, *j = 0; char *sep = "\n"; ulong p0 = 0; ulong len, seplen = strlen(sep); char *buf = 0; int n; assert(w); assert(items); while (*items) { i = salloc(sizeof(*i)); i->next = 0; i->p0 = p0; len = strlen(*items); if (j) j->next = i; else w->items = i; j = i; if (rpc_insert(wilyq, w->id, p0, *items)) { DPRINT("Failed to insert list item into wily"); freeItems(w); return -1; } p0 += len; if (rpc_insert(wilyq, w->id, p0, sep)) { DPRINT("Failed to insert list separator into wily"); freeItems(w); return -1; } i->p1 = (p0 += seplen); items++; } w->bodylen = p0; return 0; }
void closeWin(rdWin *w) { assert(w); /* get wily to close the pane */ if (rpc_exec(wilyq, w->id, "Del", "")) { DPRINT("Could not close window"); } /* free up resources */ free(w->title); free(w->body); if (w->wintype == rdList) freeItems(w); /* XXX - currently leak the stateinfo stuff */ freeWin(w); return; }
int main(void) { FILE *file; int switchRun; int endRequested = 0; struct person *list = NULL; file = fopen(FILENAME, "r"); if (file == NULL) { perror("Cant read file"); return 1; } list = loadFromFile(file); printf("- LOADED ---------------------\n"); printPersons(list); while (endRequested == 0) { printf("- MENU ---------------------\n"); printf("[1] - addPerson\n"); printf("[2] - deletePerson\n"); printf("[3] - age\n"); printf("[4] - city == 'Presov'\n"); printf("other - close\n"); scanf("%d", &switchRun); switch (switchRun) { case 1 : list = addPerson(list); break; case 2 : list = delPerson(list); break; case 3 : age(list); break; case 4 : city(list, "Presov"); break; default: endRequested = 1; } } freeItems(list); return 0; }
int setWinList(rdWin *w, char **items) { assert(w); assert(items); if (w->wintype != rdList) { DPRINT("setWinList() called for non-list window"); return 1; } freeItems(w); if (w->bodylen) { if (rpc_delete(wilyq, w->id, 0, w->bodylen)) { DPRINT("Could not delete list body"); return 1; } w->bodylen = 0; } return loadItems(w, items); }
phdFilterManager::~phdFilterManager() { freeItems(); }
phdFilterList::~phdFilterList() { if(autoFreeItems) freeItems(); }
INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwnd); SendMessage(GetDlgItem(hwnd, IDC_SBAR), SB_SETTEXT, 0, (LPARAM)Translate("Enter a string to search the database for")); CheckDlgButton(hwnd, IDC_MODNAME, 1); CheckDlgButton(hwnd, IDC_SETTINGNAME, 1); CheckDlgButton(hwnd, IDC_SETTINGVALUE, 1); CheckDlgButton(hwnd, IDC_FOUND, 1); SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(hInst, MAKEINTRESOURCE(ICO_REGEDIT))); SetWindowLongPtr(GetDlgItem(hwnd, IDC_REPLACE), GWLP_USERDATA, 0); SetWindowLongPtr(GetDlgItem(hwnd, IDC_SEARCH), GWLP_USERDATA, 0); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: SetWindowLongPtr(GetDlgItem(hwnd, IDC_REPLACE), GWLP_USERDATA, 1); case IDC_SEARCH: if (GetWindowLongPtr(GetDlgItem(hwnd, IDC_SEARCH), GWLP_USERDATA)) // stop the search SetWindowLongPtr(GetDlgItem(hwnd, IDC_SEARCH), GWLP_USERDATA, 0); else { char text[256]; char replace[256] = ""; if (!GetDlgItemText(hwnd, IDC_TEXT, text, SIZEOF(text))) break; if (GetWindowLongPtr(GetDlgItem(hwnd, IDC_REPLACE), GWLP_USERDATA) && !GetDlgItemText(hwnd, IDC_REPLACE, replace, SIZEOF(replace)) && !IsDlgButtonChecked(hwnd, IDC_ENTIRELY)) break; if (!IsDlgButtonChecked(hwnd, IDC_MODNAME) && !IsDlgButtonChecked(hwnd, IDC_SETTINGNAME) && !IsDlgButtonChecked(hwnd, IDC_SETTINGVALUE)) break; FindInfo *fi = (FindInfo*)mir_calloc(sizeof(FindInfo)); if (!fi) break; fi->hwnd = GetDlgItem(hwnd, IDC_LIST); fi->options = (IsDlgButtonChecked(hwnd, IDC_CASESENSITIVE) ? FW_CASE : 0) | (IsDlgButtonChecked(hwnd, IDC_EXACT) ? FW_EXACT : 0) | (IsDlgButtonChecked(hwnd, IDC_MODNAME) ? FW_MODNAME : 0) | (IsDlgButtonChecked(hwnd, IDC_SETTINGNAME) ? FW_SETNAME : 0) | (IsDlgButtonChecked(hwnd, IDC_SETTINGVALUE) ? FW_SETVAL : 0); if (GetWindowLongPtr(GetDlgItem(hwnd, IDC_REPLACE), GWLP_USERDATA)) { if (IsDlgButtonChecked(hwnd, IDC_FOUND)) fi->mode = RW_FOUND; else if (IsDlgButtonChecked(hwnd, IDC_MODNAME2)) fi->mode = RW_MODULE; else if (IsDlgButtonChecked(hwnd, IDC_SETTINGNAME2)) fi->mode = RW_SETNAME; else if (IsDlgButtonChecked(hwnd, IDC_SETTINGVALUE2)) fi->mode = RW_SETVAL; if (IsDlgButtonChecked(hwnd, IDC_ENTIRELY)) fi->mode |= RW_FULL; fi->replace = mir_tstrdup(replace); SetWindowText(GetDlgItem(hwnd, IDOK), Translate("Stop")); EnableWindow(GetDlgItem(hwnd, IDC_SEARCH), 0); if (IsDlgButtonChecked(hwnd, IDC_CASESENSITIVE)) fi->mode |= RW_CASE; } else { SetWindowText(GetDlgItem(hwnd, IDC_SEARCH), Translate("Stop")); EnableWindow(GetDlgItem(hwnd, IDOK), 0); } fi->text = mir_tstrdup(text); SendDlgItemMessage(hwnd, IDC_LIST, LB_RESETCONTENT, 0, 0); SetWindowLongPtr(GetDlgItem(hwnd, IDC_SEARCH), GWLP_USERDATA, 1); EnableWindow(GetDlgItem(hwnd, IDCANCEL), 0); forkthread(FindSettings, 0, fi); } break; case IDCANCEL: DestroyWindow(hwnd); break; case IDC_LIST: if (HIWORD(wParam) == LBN_DBLCLK) { int i = SendDlgItemMessage(hwnd, IDC_LIST, LB_GETCURSEL, 0, 0); ItemInfo *ii = (ItemInfo*)SendDlgItemMessage(hwnd, IDC_LIST, LB_GETITEMDATA, i, 0); if (!ii) break; SendMessage(GetParent(hwnd), WM_FINDITEM, (WPARAM)ii, 0); } break; } break; case WM_GETMINMAXINFO: { MINMAXINFO *mmi = (MINMAXINFO*)lParam; mmi->ptMinTrackSize.x = 520; mmi->ptMinTrackSize.y = 300; } return 0; case WM_SIZE: { UTILRESIZEDIALOG urd; ZeroMemory(&urd, sizeof(urd)); urd.cbSize = sizeof(urd); urd.hInstance = hInst; urd.hwndDlg = hwnd; urd.lpTemplate = MAKEINTRESOURCE(IDD_FIND); urd.pfnResizer = FindDialogResize; CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd); } break; case WM_DESTROY: freeItems(hwnd); break; } return 0; }
void __cdecl FindSettings(LPVOID di) { char* text = ((FindInfo*)di)->text; char* replace = ((FindInfo*)di)->replace; int mode = ((FindInfo*)di)->mode; HWND hwnd = ((FindInfo*)di)->hwnd; HWND prnthwnd = GetParent(hwnd); int options = ((FindInfo*)di)->options; ModuleSettingLL ModuleList, SettingList; ModSetLinkLinkItem *module, *setting; HANDLE hContact; DBVARIANT dbv = { 0 }; int caseSensitive = options & FW_CASE; int exactMatch = options & FW_EXACT; int inModuleName = options & FW_MODNAME; int inSettingName = options & FW_SETNAME; int inSettingValue = options & FW_SETVAL; int foundCount = 0; int replaceCount = 0; char szTmp[128]; int settingValue, isNumber, NULLContactDone = 0; freeItems(hwnd); if (!text) return; if (!EnumModules(&ModuleList)) { msg(Translate("Error Loading Module List"), modFullname); mir_free(di); return; } SendMessage(GetDlgItem(GetParent(hwnd), IDC_SBAR), SB_SETTEXT, 0, (LPARAM)Translate("Searching...")); hContact = 0; isNumber = sscanf(text, "%d", &settingValue); while (GetWindowLongPtr(GetDlgItem(prnthwnd, IDC_SEARCH), GWLP_USERDATA)) { if (!hContact) { if (NULLContactDone) break; else { NULLContactDone = 1; hContact = db_find_first(); } } else hContact = db_find_next(hContact); module = ModuleList.first; while (module) { if (IsModuleEmpty(hContact, module->name)) { module = module->next; continue; } if (!EnumSettings(hContact, module->name, &SettingList)) { msg(Translate("Error Loading Setting List"), modFullname); mir_free(text); mir_free(di); FreeModuleSettingLL(&ModuleList); return; } setting = SettingList.first; // check in settings value while (setting) { if (inSettingValue) { dbv.type = 0; // check the setting value if (!GetSetting(hContact, module->name, setting->name, &dbv)) { switch (dbv.type) { case DBVT_UTF8: // no conversion atm case DBVT_ASCIIZ: if ((exactMatch && !(caseSensitive ? strcmp(dbv.pszVal, text) : strcmpi(dbv.pszVal, text))) || (!exactMatch && (caseSensitive ? strstr(dbv.pszVal, text) : StrStrI(dbv.pszVal, text)))) { if ((mode & RW_FOUND) || (mode & RW_SETVAL)) replaceCount += replaceValue(hwnd, hContact, module->name, setting->name, &dbv, text, replace, mode); else ItemFound(hwnd, hContact, module->name, setting->name, dbv.pszVal, FW_SETTINGVALUE); foundCount++; } break; case DBVT_BYTE: if (isNumber && settingValue == dbv.bVal) { if ((mode & RW_FOUND) || (mode & RW_SETVAL)) replaceCount += replaceValue(hwnd, hContact, module->name, setting->name, &dbv, NULL, replace, mode); else ItemFound(hwnd, hContact, module->name, setting->name, text, FW_SETTINGVALUE); foundCount++; } break; case DBVT_WORD: if (isNumber && settingValue == dbv.wVal) { if ((mode & RW_FOUND) || (mode & RW_SETVAL)) replaceCount += replaceValue(hwnd, hContact, module->name, setting->name, &dbv, NULL, replace, mode); else ItemFound(hwnd, hContact, module->name, setting->name, text, FW_SETTINGVALUE); foundCount++; } break; case DBVT_DWORD: if (isNumber && settingValue == (int)dbv.dVal) { if ((mode & RW_FOUND) || (mode & RW_SETVAL)) replaceCount += replaceValue(hwnd, hContact, module->name, setting->name, &dbv, NULL, replace, mode); else ItemFound(hwnd, hContact, module->name, setting->name, text, FW_SETTINGVALUE); foundCount++; } break; } db_free(&dbv); } } // check in setting name if (inSettingName) { if ((exactMatch && !(caseSensitive ? strcmp(setting->name, text) : strcmpi(setting->name, text))) || (!exactMatch && (caseSensitive ? StrStrI(setting->name, text) : StrStrI(setting->name, text)))) { if ((mode & RW_FOUND) || (mode & RW_SETNAME)) { if (!GetSetting(hContact, module->name, setting->name, &dbv)) { replaceCount += replaceSetting(hwnd, hContact, module->name, setting->name, &dbv, text, replace, mode); db_free(&dbv); } } else ItemFound(hwnd, hContact, module->name, setting->name, NULL, FW_SETTINGNAME); foundCount++; } } setting = (ModSetLinkLinkItem *)setting->next; } // check in module name if (inModuleName) { if ((exactMatch && !(caseSensitive ? strcmp(module->name, text) : strcmpi(module->name, text))) || (!exactMatch && (caseSensitive ? strstr(module->name, text) : StrStrI(module->name, text)))) { if ((mode & RW_FOUND) || (mode & RW_MODULE)) replaceCount += replaceModule(hwnd, hContact, module->name, text, replace, mode); else ItemFound(hwnd, hContact, module->name, 0, 0, FW_MODULE); foundCount++; } } FreeModuleSettingLL(&SettingList); module = (ModSetLinkLinkItem *)module->next; } } if (mode) { if (!replace[0]) mir_snprintf(szTmp, SIZEOF(szTmp), Translate("Finished. %d items were found, %d items were deleted."), foundCount, replaceCount); else mir_snprintf(szTmp, SIZEOF(szTmp), Translate("Finished. %d items were found, %d items were replaced."), foundCount, replaceCount); } else mir_snprintf(szTmp, SIZEOF(szTmp), Translate("Finished. %d items were found."), foundCount); SendMessage(GetDlgItem(prnthwnd, IDC_SBAR), SB_SETTEXT, 0, (LPARAM)szTmp); SetWindowLongPtr(GetDlgItem(prnthwnd, IDC_SEARCH), GWLP_USERDATA, 0); if (GetWindowLongPtr(GetDlgItem(prnthwnd, IDC_REPLACE), GWLP_USERDATA)) { SetWindowLongPtr(GetDlgItem(prnthwnd, IDC_REPLACE), GWLP_USERDATA, 0); EnableWindow(GetDlgItem(prnthwnd, IDC_SEARCH), 1); SetWindowText(GetDlgItem(prnthwnd, IDOK), Translate("&Replace")); } else { SetWindowText(GetDlgItem(prnthwnd, IDC_SEARCH), Translate("&Search")); EnableWindow(GetDlgItem(prnthwnd, IDOK), 1); } mir_free(replace); mir_free(text); mir_free(di); FreeModuleSettingLL(&ModuleList); EnableWindow(GetDlgItem(prnthwnd, IDCANCEL), 1); }
phdClipList::~phdClipList() { freeItems(); }
BOOL OContainerBase::freeContainer() { return(freeItems() && freeDetails()); }
phdGeneratorList::~phdGeneratorList() { freeItems(); }
skelJointsRecorder::~skelJointsRecorder() { freeItems(); }
skelJointsHistory::~skelJointsHistory() { curItem = NULL; freeItems(); freeRecord(); }
//-------------------------------------------------------------------------------------------------------------- void phdVisualFile::loadFromFile(string _fileName) { masterOutput.schema.shapes.setFocused(NULL); masterOutput.schema.shapes.setSelected(NULL, true); freeItems(); ifstream _fin; //declare a file stream _fin.open( ofToDataPath(_fileName).c_str() ); //open your text file vector<string> _data; //declare a vector of strings to store data _data.clear(); while(_fin != NULL) { //as long as theres still text to be read string _str = ""; //declare a string for storage getline(_fin, _str); //get a line from the file, put it in the string if(_str != "") { _data.push_back(ofToUpper(_str)); //push the string onto a vector of strings //printf(_str.c_str()); printf("\n"); } } _fin.close(); if(_data.size() == 0) return; // empty file phdDesigner * _designer = NULL; phdWarpShapeSchema * _shapeSchema = NULL; phdWarpLinkSchema * _linkSchema = NULL; phdShapeQuadWarp * _shape = NULL; for(int i = 0; i < _data.size(); i++) { vector<string> _items = ofSplitString(_data[i], ":", true, true); if(_items.size() > 0) { if(_items[0] == "DESIGNERCOUNT") { // resize designer array } else if(_items[0] == "MASTEROUTPUT" && _items.size() == 8) { _designer = &masterOutput; _designer->name = _items[1]; float _x = ofToFloat(_items[2]); float _y = ofToFloat(_items[3]); float _w = ofToFloat(_items[4]); float _h = ofToFloat(_items[5]); _designer->setup(_x,_y,_w,_h, NULL, ofToFloat(_items[6]), ofToFloat(_items[7])); } else if(_items[0] == "DESIGNER" && _items.size() == 8) { _designer = NULL; _designer = (phdDesigner*) addDesigner(new phdDesignerFbo()); _designer->name = ofToUpper(_items[1]); float _x = ofToFloat(_items[2]); float _y = ofToFloat(_items[3]); float _w = ofToFloat(_items[4]); float _h = ofToFloat(_items[5]); _designer->setup(_x,_y,_w,_h, NULL, ofToFloat(_items[6]), ofToFloat(_items[7])); } else if(_items[0] == "SHAPESCHEMA" && _items.size() == 3 && _designer != NULL) { _shapeSchema = &_designer->schema; _shapeSchema->name = _items[1]; } else if(_items[0] == "SHAPE" && _items.size() == 3 && _designer != NULL) {//_shapeSchema != NULL) { _shape = _designer->schema.addShape(_items[1]); //_shape = _shapeSchema->addShape(_items[1]); _shape->faceType = (phdWarpFaceType) ofToInt(_items[2]); } else if(_items[0] == "GIMBAL" && _items.size() == 8 && _shape != NULL) { _shape->gimbal.angle = ofToFloat(_items[1]); _shape->gimbal.cx = ofToFloat(_items[2]); _shape->gimbal.cy = ofToFloat(_items[3]); _shape->gimbal.sx = ofToFloat(_items[4]); _shape->gimbal.sy = ofToFloat(_items[5]); _shape->gimbal.w = ofToFloat(_items[6]); _shape->gimbal.h = ofToFloat(_items[7]); } else if(_items[0] == "VERTEXCOUNT" && _items.size() > 3 && _shape != NULL) { _shape->vertices.vertices.reserve(ofToInt(_items[1])); for(int k = 2; k < _items.size()-1; k += 2) { _shape->addVertex(ofToFloat(_items[k]), ofToFloat(_items[k+1])); } } else if(_items[0] == "LINKSCHEMACOUNT") { } else if(_items[0] == "LINKSCHEMA" && _items.size() == 3) { _linkSchema = addLinkSchema(new phdWarpLinkSchema()); _linkSchema->name = _items[1]; } else if(_items[0] == "LINK" && _items.size() == 7 && _linkSchema != NULL) { phdDesigner * _dgnIN = findDesignerByName(_items[1]); phdDesigner * _dgnOUT = findDesignerByName(_items[3]); if(_dgnOUT == NULL) _dgnOUT = &masterOutput; if(_dgnIN != NULL && _dgnOUT != NULL) { phdShapeQuadWarp * _quadIN = _dgnIN->schema.findByShapeName(_items[2]); phdShapeQuadWarp * _quadOUT = _dgnOUT->schema.findByShapeName(_items[4]); phdWarpLink * _link = _linkSchema->addLink(_quadIN, _dgnIN, _quadOUT, _dgnOUT); _link->horMirror = (_items[5] == "SIM"); _link->verMirror = (_items[6] == "SIM"); _link->updated = true; } } } } if(_linkSchema != NULL) { curLinkSchema = _linkSchema; } else { curLinkSchema = addLinkSchema(new phdWarpLinkSchema()); curLinkSchema->name = "LINKS"; } }
skelTrackedList::~skelTrackedList() { freeItems(); }
phdPopupMenu::~phdPopupMenu() { freeItems(); items.clear(); }
phdGeneratorManager::~phdGeneratorManager() { freeItems(); }