--- Syncify/Syncify.cpp 2005/04/04 07:33:57 436 +++ Syncify/Syncify.cpp 2005/04/05 23:14:43 438 @@ -51,10 +51,15 @@ extern "C" { void authenticate(const char* srv, const char* shr, char* wg, int wglen, char* un, int unlen, char* pw, int pwlen) { - static ext::String user("Douglas Thrift"), password(::getpass("Password:")); + static ext::Buffer user("Douglas Thrift"), password(::getpass("Password:")); - ::snprintf(un, unlen, "%s", user.NullTerminate()); - ::snprintf(pw, pwlen, "%s", password.NullTerminate()); + _foreach (ext::Buffer, atom, user) + un[_index] = *atom; + _foreach (ext::Buffer, atom, password) + pw[_index] = *atom; + + un[user.GetSize() < size_t(unlen) ? user.GetSize() : unlen - 1] = '\0'; + pw[password.GetSize() < size_t(pwlen) ? password.GetSize() : pwlen - 1] = '\0'; } } @@ -75,26 +80,33 @@ bool Syncify::debug(false); void Syncify::syncify(const ext::String& local, const ext::String& remote) { - Matcher dots("^\\.{1,2}$"); - ext::RedBlackSet directories; - int directory(CheckError(::smbc_opendir(remote.NullTerminate()))); - - for (::smbc_dirent* entity(::smbc_readdir(directory)); entity != NULL; entity = ::smbc_readdir(directory)) switch (entity->smbc_type) + try { - case SMBC_FILE: - if (entity->name == pattern) + Matcher dots("^\\.{1,2}$"); + ext::RedBlackSet directories; + int directory(CheckError(::smbc_opendir(remote.NullTerminate()))); + + for (::smbc_dirent* entity(::smbc_readdir(directory)); entity != NULL; entity = ::smbc_readdir(directory)) switch (entity->smbc_type) { - api::Cout << entity->name << ios::NewLine; + case SMBC_FILE: + if (entity->name == pattern) + { + api::Cout << entity->name << ios::NewLine; + } + break; + case SMBC_DIR: + case SMBC_LINK: + if (entity->name != dots) + directories.Insert(entity->name); } - break; - case SMBC_DIR: - case SMBC_LINK: - if (entity->name != dots) - directories.Insert(entity->name); - } - ::smbc_closedir(directory); + ::smbc_closedir(directory); - _foreach (const ext::RedBlackSet, directory, directories) - syncify(local + "/" + *directory, remote + "/" + *directory); + _foreach (const ext::RedBlackSet, directory, directories) + syncify(local + "/" + *directory, remote + "/" + *directory); + } + catch (const Error& error) + { + api::Cerr << error.GetMessage() << remote << ios::NewLine; + } }