|
Hello gurus.
I'm currently programming am application for windows 2000 (in Visual Studio C++ 6.0).
It's a program that creates LDIF files that will be used to update a LDAP entries. (openLDAP)
I've run into one problem tough. Is there a function/library in VSC++ that is similar to the unix crypt()? (using md5 or the ldap {crypt})
Yes, I'm a beginner, but I'm learning.
|
|
|
|
|
Franz Granlund wrote:
Hello gurus.
Hi there.
Franz Granlund wrote:
Is there a function/library in VSC++ that is similar to the unix crypt()?
Try to use CryptoAPI. Maybe you will find it too complex, but it should fulfil your requirements.
|
|
|
|
|
Thank you for your answer, but that is way to complex for me.. =)
Do you know of any other library? Or could you help me get started? It's such a small application, that I don't wan't to spend to much time figuring the crypto-world out. (Yes, I wan't to learn someday, but not today. )
|
|
|
|
|
I am not sure if using some library would be easier. Try to write short pseudocode, what you are doing in your UNIX code and I will reply with MS Crypto API version.
|
|
|
|
|
First, thank you very much for trying to help me out!
Well, I wan't a crypt() functionality of a linux system that uses PAM and MD5 password enabled. (The linux dist is Redhat 7.3)
A short code written and compiled under linux:
#include <crypt.h>
int main()
{
char p[100]; // Allocate this dynamically later..
char s[100];
char *e;
strcpy(p, "fan");
strcpy(s, "xe");
e = crypt(p, s);
printf("Password: %s\nEncrypted: %s\n",p, e);
return 0;
}
The output:
$ ./m
Password: fan
Encrypted: xeY7nbSvmz7jU
Hope you get some information from this code..
Again, thank you for trying to help.
|
|
|
|
|
Well, when it is Linux, you have to have sources for it, including crypt() function, have you tried to port to Win32? And, do you expect to get the same result (xeY7nbSvmz7jU), or you just do not care and encrypted password is enough for you (I mean, you do not require interoperability then between your new code on Windows and old code on Linux)?
|
|
|
|
|
try crypto++. i think there is a tutorial somewhere on this site for it.
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
Franz,
See this article.
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Anyone have free HTML Syntax Hilighting Class (MFC or ATL)? I found one at CP, but its not the best implementation...
Thank you!
|
|
|
|
|
I would like to ask two technical questions on a problem that I have bumped into and it is the following:
First Question:
Can you build a Windows DLL from implementations that are resident in a .hpp/.h file[ NOT corresponding .cpp dll implementation files like Jeffrey Richter assumes ], where the implementation is a template<> class and/or collection of template<> classes?
The concern is that I am building a middleware backend that has classes designed preliminarily with templates and parameterized polymorphic class types and of course all its implementation is in the header file, but Jeffrey Richter, the author of the well known Microsoft Systems Programming books has his samples on building DLLs using a classical non template classes where the header files do this:
//->DLL_Lib.h
#if !defined _DLL_LIB_H
#define DLL_LIB_H
#if defined DLL_LIB_INTER
//->the #define for the extern “C” __declspec( dllexport ) is in .cpp file
#else
#define DLL_LIB_INTER extern “C” __declspec( dllimport )
#endif //->DLL_LIB_INTER
#include <string> //->includes STL std::string
//->Define exported/imported( if DLL_LIB.h not in .cpp file function prototypes now
DLL_LIB_INTER void foo( std::string& token );
DLL_LIB_INTER void fooBar( std::string& token );
DLL_LIB_INTER void fooBarFoo( std::string& token );
DLL_LIB_INTER void fooBarFooBoo( std::string& token );
//->Define exported C++ class type definitions
DLL_LIB_INTER class Foo_ed { … }; //->DLL_LIB_INTER the class members also?
DLL_LIB_INTER class FooBar_ed { … };
DLL_LIB_INTER class FooBarFooBoo_ed { … };
#endif //->_DLL_LIB_H
and the corresponding source files are as below for example:
#include <iostream>
#include <windows.h>
#define DLL_LIB_INTER extern “C” __declspec( dllexport )
//->Now include the DLL_Lib.h header file to read the #define up top
#include “DLL_Lib.h”
//->DLL_LIB_INTER omitted from class member function and non-class functions //->This is OK. Windows compiler records DLL_LIB_INTER macro flag from the
//->DLL_Lib.h header file.
void foo( std::string& token ) { /* Impl */ }
void fooBar( std::string& token ) { /* Impl */ }
void fooBarFoo( std::string& token ) { /* Impl */ }
void fooBarFooBoo( std::string& token ) { /* Impl */ }
//->Define exported C++ class type definitions
Foo_ed::Foo_ed() { /* Impl */ }
~Foo_ed::Foo_ed() { /* Impl */ }
Foo_ed::Foo_ed( const Foo_ed& rhs ) { /* Impl */ }
bool Foo_ed::interpolate( std::string& tokenBlock ) { /* Impl */ }
//->Foo_ed:: member functions defined
FooBar_ed::FooBar_ed() { /* Impl */ }
~FooBar_ed::FooBar_ed() { /* Impl */ }
FooBar_ed::FooBar_ed( const FooBar_ed& rhs ) { /* Impl */ }
bool FooBar_ed::interpolate( std::string& tokenBlock ) { /* Impl */ }
//->FooBar_ed:: member functions defined
FooBarFooBoo_ed:: FooBarFooBoo_ed () { /* Impl */ }
~FooBarFooBoo_ed:: FooBarFooBoo_ed () { /* Impl */ }
FooBarFooBoo_ed:: FooBarFooBoo_ed ( const FooBarFooBoo& rhs ) { /* Impl */ }
bool FooBarFooBoo_ed::interpolate( std::string& tokenBlock ) { /* Impl */ }
//->FooBarFooBoo_ed:: member functions defined
But, with templates, the C++ export keyword to separate the C++ template interfaces in the .hpp/.h header file from a secluded and hidden support implementation in the .cpp SOURCE IS NOT supported globally yet, especially with the compiler the project I am working on, which has firmly decided on, Visual C++ 6.0 with Service Pack 5 OR even Visual C++ 7.0 .NET( at least not yet: if Lippman and Sutter have anything to say about it ).
Question: If I cannot use the export templates model to separate class templates intefaces from their implemenations, how CAN I BUILD Windows DLLS from solely C++ template header implementations or from a combination of C++ templates .hpp/.h files and auxillary .cpp files? CAN THIS BE ACCOMPLISHED?
Does the DLL NEED a corresponding .cpp file assuming all DLL implementations are in a templates class?
You help would be greatly needed and appreciated for my own learning.
LAST QUESTION:
When building C++ templates in their .hpp/.h files, and I say have a SINGLETON class that itself is a templatized version of the Singleton, where does the static class data members get initialized?
a) Outside the template Singleton class, but in the same .hpp/.h header file as the template class itself ?
OR
b) like non-template classes holding static data members outside the class definition( unless it is an integral type ).h header file and into the .cpp file at the top of the file, before its use?
AS A SIDE QUESTION?
*Do I need to extern “C” __declspec( dllimport/dllimport ) the individual C++ member functions, static functions, static data variables, and class data instance variables?
Thank You for help,
|
|
|
|
|
First question: Yes, the thing can be done. You've got to explicitly instantiate the template for the types you're interested in in an auxiliary .cpp file The MSDN article HOWTO: Exporting STL Components Inside & Outside of a Class (Q168958) explains the process in detail.
Second question: Could you be more specific? Maybe if you post some code the question would be clearer.
Side question: No, you needn't.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I truly appreciate your investigation on the problem #1.
Problem #2: You wanted an sample:
//->TemplateSingleton.hpp
#if !defined( __TEMPLATE_SINGLETON_H_INCLUDED__ )
#define __TEMPLATE_SINGLETON_H_INCLUDED__ )
template< typename BUILD_TYPE >
class TemplateSingleton {
public:
static BUILD_TYPE * build() {
if ( m_builtTYPE == 0 ) {
m_builtTYPE = new BUILD_TYPE;
}
return m_builtTYPE;
}
//->more STATIC API below
protected:
TemplateSingleton() { }
~TemplateSingleton() { }
private:
static BUILD_TYPE * m_builtTYPE; //->Initialized how?->1
};
->1: Like below in the same header file, because it is a template and not a non-template, but outside the class definition?
template < typename BUILD_TYPE >
BUILD_TYPE * TemplateSingleton< BUILD_TYPE >::m_builtTYPE = 0;
OR
->2: Like all static variables defined in the C++ class they must be initialized explicitly in the corresponding .cpp file as such:
//->TemplateSingletonImpl.cpp
#include "TemplateSingleton.hpp"
template < typename BUILD_TYPE >
BUILD_TYPE * TemplateSingleton< BUILD_TYPE >::m_builtTYPE = 0;
By the way could you give a small sample for the first question I posed to you about designing user defined template classes in DLLs for example with a trivial class named Foo<>?
By the way, how can I say make a DLL named DLL_X that depends on DLL_Y for functions it needs to call on and have DLL_Y depend on DLL_X for functions it needs to call on from ? In other words mutually dependent DLLs, do I need to write a DEF file? Or can I still use the extern "C" __declspec( dllexport/dllimport ) syntax as you stated in reply numero uno? Are there any small samples here as well that you can show me, since these questions are NOT documented clearly in even the best Windows books like Ricthers.
|
|
|
|
|
I truly appreciate your investigation on the problem #1.
Problem #2: You wanted an sample:
//->TemplateSingleton.hpp
#if !defined( __TEMPLATE_SINGLETON_H_INCLUDED__ )
#define __TEMPLATE_SINGLETON_H_INCLUDED__ )
template< typename BUILD_TYPE >
class TemplateSingleton {
public:
static BUILD_TYPE * build() {
if ( m_builtTYPE == 0 ) {
m_builtTYPE = new BUILD_TYPE;
}
return m_builtTYPE;
}
//->more STATIC API below
protected:
TemplateSingleton() { }
~TemplateSingleton() { }
private:
static BUILD_TYPE * m_builtTYPE; //->Initialized how?->1
};
->1: Like below in the same header file, because it is a template and not a non-template, but outside the class definition?
template < typename BUILD_TYPE >
BUILD_TYPE * TemplateSingleton< BUILD_TYPE >::m_builtTYPE = 0;
OR
->2: Like all static variables defined in the C++ class they must be initialized explicitly in the corresponding .cpp file as such:
//->TemplateSingletonImpl.cpp
#include "TemplateSingleton.hpp"
template < typename BUILD_TYPE >
BUILD_TYPE * TemplateSingleton< BUILD_TYPE >::m_builtTYPE = 0;
By the way could you give a small sample for the first question I posed to you about designing user defined template classes in DLLs for example with a trivial class named Foo<>?
By the way, how can I say make a DLL named DLL_X that depends on DLL_Y for functions it needs to call on and have DLL_Y depend on DLL_X for functions it needs to call on from ? In other words mutually dependent DLLs, do I need to write a DEF file? Or can I still use the extern "C" __declspec( dllexport/dllimport ) syntax as you stated in reply numero uno? Are there any small samples here as well that you can show me, since these questions are NOT documented clearly in even the best Windows books like Ricthers.
|
|
|
|
|
SLIGHT TYPO:
I truly appreciate your investigation on the problem #1.
Problem #2: You wanted an sample:
//->TemplateSingleton.hpp
#if !defined( __TEMPLATE_SINGLETON_HPP_INCLUDED__ )
#define __TEMPLATE_SINGLETON_HPP_INCLUDED__
template< typename BUILD_TYPE >
class TemplateSingleton {
public:
static BUILD_TYPE * build() {
if ( m_builtTYPE == 0 ) {
m_builtTYPE = new BUILD_TYPE;
}
return m_builtTYPE;
}
//->more STATIC API below
protected:
TemplateSingleton() { }
~TemplateSingleton() { }
private:
static BUILD_TYPE * m_builtTYPE; //->Initialized how?->1
};
->1: Like below in the same header file, because it is a template and not a non-template, but outside the class definition?
template < typename BUILD_TYPE >
BUILD_TYPE * TemplateSingleton< BUILD_TYPE >::m_builtTYPE = 0;
#endif //->__TEMPLATE_SINGLETON_HPP_INCLUDED__
OR
->2: Like all static variables defined in the C++ class they must be initialized explicitly in the corresponding .cpp file as such:
//->TemplateSingletonImpl.cpp
#include "TemplateSingleton.hpp"
template < typename BUILD_TYPE >
BUILD_TYPE * TemplateSingleton< BUILD_TYPE >::m_builtTYPE = 0;
By the way could you give a small sample for the first question I posed to you about designing user defined template classes in DLLs for example with a trivial class named Foo<>?
By the way, how can I say make a DLL named DLL_X that depends on DLL_Y for functions it needs to call on and have DLL_Y depend on DLL_X for functions it needs to call on from ? In other words mutually dependent DLLs, do I need to write a DEF file? Or can I still use the extern "C" __declspec( dllexport/dllimport ) syntax as you stated in reply numero uno? Are there any small samples here as well that you can show me, since these questions are NOT documented clearly in even the best Windows books like Ricthers.
|
|
|
|
|
What should I do when I want add OLE server to my MDI software?
|
|
|
|
|
Hi,
I have a DIALOG BOX(1) that calls other dialog box(2). Any change in the called dialog box(2) will affect the initial DIALOG BOX(1). So, when I open the DIALOG BOX(1), and call dialog box(2), DIALOG BOX(1) will be behind the dialog box(2).The problem is, when some changes is made on the dialog box(2), the DIALOG BOX(1) do not change immediately. I have to reopen the DIALOG BOX(1) to see the changes made previously. I think this is something about "redraw" the DIALOG BOX(1) immediately after the changes is made on dialog box(2) or some other thing on how to update the DIALOG BOX(1) immediately after dialog box(2) is closed. Is there any possible way for me to solve this problem?
I'm still learning...
|
|
|
|
|
if Dialog2 is modal (you launch it with DoModal), then there's no (easy) way to do this.
what you really want is for Dialog2 to be "modeless". that's a whole other set of problems. but, if you need the functionality you describe, it's the best way to do it.
there are modeless dialog examples on CP. look in the "dialog" section.
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
I made this macro in VC++ 6:
Sub Temp()
Set Doc = ActiveDocument.Selection
Set FSO = CreateObject("Scripting.FileSystemObject")
End Sub
When I try to run it, I get "ActiveX component can't create object Scripting.FileSystemObject".
What to do? =(.
Vitaly Belman
|
|
|
|
|
that's not VC++
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
Ehm, where would you put it then?? That's neither VB cuz in Visual Basic the same line works fine. The question applies only to VC++ macros.
Vitaly Belman
|
|
|
|
|
ohh... it's an IDE macro?
that's different, i guess.
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
Is there source code available that shows how to append two wave (.wav) files, and how can information be extracted from a wave file (similar to the wavread and wavwrite functions in Matlab)
|
|
|
|
|
The wav format is a file format, which may contain several sound formats or encoding (one per file). That's why adding two wav file may need a conversion between two different sound formats, with a different sample frequencies and with different sample sizes. That's why it's not that easy to concatenate wav files.
You may find nice info about wav format at www.tsp.ece.mcgill.ca/Docs/AudioFormats/WAVE/WAVE.html
HTH,
We do not inherit the Earth from our ancestors. We borrow it from our children.
Antoine de Saint Exupéry (1900-1944)
|
|
|
|
|
tx.
if the sampling rate and the bits per sampling is the same for both files, wouldn't it then be easier to concatenate?
|
|
|
|
|
Hi,
I got this modeless Dialog wich is created as a child of the main Frame ?
How can I make this Dialog always have the same focus as the Parent ? (the CMainFrame)
thx & greetz
I used to have a life ... now I have a computer
|
|
|
|