static void read(FileDesc desc, char *path) { FILE *readfile; char filename[MAX_FILENAME], src_path[MAX_PATH], c_size[100]; long long size; char *sEnd; struct FileSource tmp_add; if((readfile = fopen(path, "r"))==NULL) { fprintf(stderr, "Cannot read file list: %s\n", path); exit(1); } tmp_add.next = NULL; tmp_add.back = NULL; while(fscanf(readfile, "%s %s %s", src_path, filename, c_size)!=EOF) { size = strtoll(c_size, &sEnd, 10); tmp_add.src_path = strbuff(src_path, strlen(src_path)); tmp_add.filename = strbuff(filename, strlen(filename)); tmp_add.size = size; //desc->sum_size += size; //desc->count++; enqueue(desc, tmp_add); } }
void var::resize(ulong newsize) { if (vt==DW){ if (newsize==1) { dw&=0xFF; } else if (newsize==2) { dw&=0xFFFF; } } else if (vt==STR){ if (size > newsize) { if (isbuf) { *this = L"#"+strbuff().substr(0,newsize)+L"#"; } else { *this = strbuff().substr(0,newsize); } } } }
int ReadVariablePerson(istream & stream, Person &p){ short length; stream.read(&length, sizeof(length)); if(stream.fail()){ p.LastName[0] = 0; return 0; } char * buffer = new char[length + 1]; stream.read(buffer, length); buffer[length] = 0; istrstream strbuff(buffer); strbuff >> p; return 1; }
bool CLogWnd::plug_IncomingData(IPlug *lpFrom, IPlug *lpTo, bool bSendEvent) { String str; if(!(m_hWnd)) return false; lpFrom->getValue(str); if(!str.empty()) { m_lastlogstr = str; CString strbuff(str.c_str()); int pos, img; do { img = 0; // // Get a line // CString aaa = strbuff.SpanExcluding("\n"); // // Find a header // pos = aaa.Find(">>"); if(pos > 0) { CString header; header = aaa.Left(pos); aaa = aaa.Right(aaa.GetLength() - pos-2); img = GetImageId(header); } // // Insert it into the list of messages // if(aaa.GetLength() > 0) { CString bbb = aaa.SpanExcluding("||"); int ic = m_ListLog.GetItemCount(); m_ListLog.InsertItem(ic , bbb, img); // For now let's do it once... int subi = aaa.Find("||",0); if(subi >= 0) { bbb = aaa.Right(aaa.GetLength() - subi - 2); m_ListLog.SetItemText(ic, 1, bbb); } } // // Go to next one. // pos = strbuff.Find("\n",0); if(pos >= 0) { aaa = strbuff.Right(strbuff.GetLength() - pos-1); strbuff = aaa; } } while(pos >= 0); m_ListLog.EnsureVisible(m_ListLog.GetItemCount()-1, TRUE); } // tell the connected readers that data changed. Set bSendEvent=false if you decide to send this // method by your own. if(bSendEvent) lpTo->flush(); return false; }
IWindowLog* CLogWnd::AddMessage(LPCSTR fmt, ...) { //TODO: Add a way to free this up, later ! static char *fmt2 = NULL; static size_t fmt2_sz = 0; va_list vlist; // Get output string va_start(vlist, fmt); int retval; //size_t sz = strlen(fmt)+1; if(!fmt2) { fmt2_sz = 2048; fmt2 = (char*)malloc(fmt2_sz); } while((retval = _vsnprintf(fmt2, fmt2_sz, fmt, vlist)) < 0) // means there wasn't anough room { fmt2_sz *= 2; if(fmt2) free(fmt2); fmt2 = (char*)malloc(fmt2_sz); } #ifdef USEPLUGS m_pluglogstr.setValue(fmt2); #else m_lastlogstr = fmt2; CString strbuff(m_lastlogstr.c_str()); int pos, img; do { img = 0; // // Get a line // CString aaa = strbuff.SpanExcluding("\n"); // // Find a header // pos = aaa.Find(">>"); if(pos > 0) { CString header; header = aaa.Left(pos); aaa = aaa.Right(aaa.GetLength() - pos-2); img = GetImageId(header); } // // Insert it into the list of messages // if(aaa.GetLength() > 0) { CString bbb = aaa.SpanExcluding("||"); int ic = m_ListLog.GetItemCount(); m_ListLog.InsertItem(ic , bbb, img); // For now let's do it once... int subi = aaa.Find("||",0); if(subi >= 0) { bbb = aaa.Right(aaa.GetLength() - subi - 2); m_ListLog.SetItemText(ic, 1, bbb); } } // // Go to next one. // pos = strbuff.Find("\n",0); if(pos >= 0) { aaa = strbuff.Right(strbuff.GetLength() - pos-1); strbuff = aaa; } } while(pos >= 0); m_ListLog.EnsureVisible(m_ListLog.GetItemCount()-1, TRUE); #endif va_end(vlist); //PeekMyself(); return this; }
wstring var::strclean(void) { return CleanString(strbuff()); }