|
Is your display name taken from the ZX Spectrum game of same name?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I think you're right. at present i've 2 threads using the same file handle.
after reading 'duplex' i thought it would work, but for what i want to do i
guess the only solution is to set up 2 pipes and 2 file names.
...and yes Hungry Horace is from the Spectrum game - the golden age of PC games !
|
|
|
|
|
HungryHorace wrote: after reading 'duplex' i thought it would work, but for what i want to do i
guess the only solution is to set up 2 pipes and 2 file names.
You should be able to do it with a single pipe - but allow multiple instances. Then you can open two instances in the server (one for reading, one for writing) and open a reading file handle and a writing file handle (both opening the same pipe name) in the client. The only issue then is coordinating all those end-points!
HungryHorace wrote: Hungry Horace
First computer game I ever played
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,
I have to do some work with TCP/IP was Looking at MFC presentation of this.
One was The CAsyncSocket Class
I was lookig at a article one this and it mseems the Class Wizard gearates a
pointer to a Cdialog object
Why??? seems the notifications come from the Server/Client come by way of
Window messages
isn't this a bit of overhead as far as perfomance (would thought MicroSoft would issue
notification via a CEvent Class )
Does anyone have experince with performance regarding CAsyncSocket vs
WinSock
Thankx
|
|
|
|
|
|
Use a list-view[^] (aka CListCtrl[^]) and process its NM_CLICK[^] or LVN_ITEMCHANGING[^] notifications? The second one will be fired when an item is going to be selected, so you could cancel that and change its state? You cancel the change by returning TRUE from the nmotification handler, I believe, although that page doesn't say so - the Windows Mobile equivalent page[^] does say so!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
All what i need is to use a modified CFontDialog which has font, font style, and size fields this modified font dialog should be called from an sdi application (Class edit view).
|
|
|
|
|
Did you see my link I think it was your answer?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
i saw it but it did not help.
|
|
|
|
|
Why I saw it,that article was for remove some controls of CFontDialog and your question was it(if you want to customize this dialog you need to a dialogbox template resource.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Hi!
I'm looking for a way to make a bitmap that is already displayed in the dialog become transparent, when a button is clicked and vice-versa..
or just make it disappear and then make it appear again just in the same place..
is that possible? can you help me please?
|
|
|
|
|
Praystation2 wrote: make a bitmap that is already displayed in the dialog
How is the bitmap displayed?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
the bitmap is loaded when the dialog is initialized, but is defined as not visible, and i want to make it visible when i click a button.
i don't know if it's the best way since i'm a beginner in using MFC.
the point is to make it appear and disappear using a button, but it needs to start invisible
(sorry about my english)
|
|
|
|
|
Praystation2 wrote: bitmap is loaded
Into a control on the dialog?
If so, then one of CWnd::ShowWindow[^] (if you have a variable for the control) or ShowWindow[^] (if you just have a control ID) should be what you want.
Call the appropriate one with the nCmdShow parameter set to SW_SHOW or SW_HIDE to show/hide the bitmap's window.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I'm using a picture control and it's ID is IDC_casa_luz.
can you give the code i should use inside the button function to make it appear/disappear?
|
|
|
|
|
Praystation2 wrote: can you give the code
//Disappear
GetDlgItem(IDC_casa_luz)->ShowWindow(SW_HIDE);
//Appear
GetDlgItem(IDC_casa_luz)->ShowWindow(SW_SHOW);
|
|
|
|
|
thanks thanks thanks thanks thanks thanks!!!!!
|
|
|
|
|
Praystation2 wrote: can you give the code i should use inside the button function to make it appear/disappear?
What Madhu[^] said
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
i am writing a milter which decrypts the email message.
For decryption i am using GMP library...
The code which gives the error is as follows:
mpz_t bigbody,encbody,decbody,n,d,e;
mpz_init_set_str (e, "5", 10);
mpz_init_set_str (n, "81072118814004638617775947138239917744589505176471539666269773100315781097546894455560658571445286325125766632676152452856383447352821337178984474781813475276075048299705214136395672502245955793627681061360075723595075874516950614187016991430293887968216015097675955399134514678660046996064181098182893072761", 10);
mpz_init_set_str (d, "32428847525601855447110378855295967097835802070588615866507909240126312439018757782224263428578114530050306653070460981142553378941128534871593789912725382636961637010791821646038659077539848411532121133465246631106852802485583932352673149866783600963924490576147444236696494852521901563664557493382382127469", 10);
char *STR;
STR=(char*)malloc(1000);
mpz_t array[10];
//mpz_array_init (array, 10, 308);
mpz_t array1[10];
//mpz_array_init (array1, 10, 100000);
char substring[400];
int i=0,lower=0,upper=308;
while(i<noofblocks)
{
="" strncpy(substring,="" data_buffer="" +="" lower,="" upper);
="" *(substring+308)="\0" ;
="" syslog(="" log_info,="" "conn#="" %d="" -="" substring="%s"," cd-="">connection_num, substring );
lower=upper;
upper=upper+308;
mpz_init_set_str(array[i],substring,10);
mpz_get_str (STR, 10, array[i]);
strcat(STR,"\0");
syslog( LOG_INFO, "conn# %d - Encrypted-Biginteger = %s", cd->connection_num, STR );
mpz_init(array1[i]);
mpz_powm (array1[i], array[i], d, n);
mpz_get_str (STR, 10, array1[i]);
syslog( LOG_INFO, "conn# %d - Decrypted-Biginteger = %s", cd->connection_num, STR );
size_t length;
void *ret;
char *decrypted;
decrypted=(char*)malloc(1000);
ret=mpz_export (decrypted, &length, 1,sizeof(data_buffer[0]), 0, 0, array1[i]);
//ret=mpz_export (decrypted, &length, 1,sizeof(data_buffer[0]), 0, 0, array1[i]);
strncpy(decrypted,ret,length);
*(decrypted+length)='\0';
syslog( LOG_INFO, "conn# %d - size decrypted = %d Decrypted = %s", cd->connection_num,length, (char *)ret );
fflush(stdout);
free(decrypted);
fflush(stdin);
mpz_clear(array[i]);
mpz_clear(array1[i]);
i++;
}
This code executes for 2 iterations and then give segmentation fault at mpz_powm( )
|
|
|
|
|
shrims4u wrote: ...then give segmentation fault at mpz_powm( )
What are the values of array1[i] , array[i] , d , and n at that point?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
the value of array[i] is a bignumber....
Also d and n are initialised...
The error is at mpz_powm....
you want me to write the values in numbers????
Actually it differs each time according to the message
|
|
|
|
|
My, point, although subtle, was to ensure that the values you are passing to that function are valid. Some functions/libraries place the onus of validation solely on the caller (rather than handle the bad input and fail gracefully)
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
yah the values that are passed are proper...
The gdb output is as follows....
[New Thread -1208882288 (LWP 9012)]
[New Thread -1208879424 (LWP 9009)]
[New Thread -1219372144 (LWP 9017)]
GNU MP: Cannot allocate memory (size=3368600780)
Program received signal SIGABRT, Aborted.
[Switching to Thread -1219372144 (LWP 9017)]
0x00110402 in __kernel_vsyscall ()
|
|
|
|
|
shrims4u wrote: GNU MP: Cannot allocate memory (size=3368600780)
I would guess that this is related to the problem. It's tried to allocate 3 Gb of memory, and failed...
As to why it's trying to allocate such a big chunk of memory, I couldn't say, but maybe stepping through until you get that error might help pin it down.
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
ill mail the whole program to uall
Actually it is a milter which decrypts the incoming mail messages...
<br />
<br />
<br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <unistd.h><br />
#include <string.h><br />
#include <pthread.h><br />
#include <syslog.h><br />
#include <sys/types.h><br />
#include <sys/socket.h><br />
#include <netinet/in.h><br />
#include <arpa/inet.h><br />
#include <sys/stat.h><br />
#include <fcntl.h><br />
<br />
#include <glib.h><br />
#include <gmime/gmime.h><br />
<br />
#include "libmilter/mfapi.h"<br />
<br />
#include "gmp.h"<br />
<br />
<br />
<br />
<br />
static void usage( void );<br />
static sfsistat sample_connect( SMFICTX* ctx, char* connhost, _SOCK_ADDR* connaddr );<br />
static sfsistat sample_helo( SMFICTX* ctx, char* helohost );<br />
static sfsistat sample_envfrom( SMFICTX* ctx, char** fromargs );<br />
static sfsistat sample_envrcpt( SMFICTX* ctx, char** rcptargs );<br />
static sfsistat sample_header( SMFICTX* ctx, char* name, char* value );<br />
static sfsistat sample_eoh( SMFICTX* ctx );<br />
static sfsistat sample_body( SMFICTX* ctx, unsigned char* bytes, size_t len );<br />
static sfsistat sample_eom( SMFICTX* ctx );<br />
static sfsistat sample_abort( SMFICTX* ctx );<br />
static sfsistat sample_close( SMFICTX* ctx );<br />
static void thread_data_destructor( void* data );<br />
<br />
int smfi_replacebody(<br />
SMFICTX *ctx,<br />
unsigned char *bodyp,<br />
int bodylen<br />
);<br />
<br />
<br />
int smfi_chgheader(<br />
SMFICTX *ctx,<br />
char *name,<br />
int hdridx,<br />
char *value<br />
);<br />
<br />
<br />
<br />
<br />
static char* argv0;<br />
static pthread_key_t key;<br />
static int connections;<br />
static char* data_buffer, *contentTypeBuffer;<br />
void *ret;
size_t size;<br />
int flag=0;<br />
<br />
GMimeMessage *message;<br />
GMimeStream *stream;<br />
GMimeParser *parser;<br />
GMimeMultipart *multipart;<br />
GMimePart *mime_part,*mime_part0;<br />
GMimeContentType *contentType,*contentType1;<br />
<br />
static struct smfiDesc smfilter =<br />
{<br />
"SAMPLE", <br />
SMFI_VERSION, <br />
SMFIF_CHGBODY | SMFIF_CHGHDRS, <br />
sample_connect, <br />
sample_helo, <br />
sample_envfrom, <br />
sample_envrcpt, <br />
sample_header, <br />
sample_eoh, <br />
sample_body, <br />
sample_eom, <br />
sample_abort, <br />
sample_close <br />
};<br />
<br />
<br />
int<br />
main( int argc, char** argv )<br />
{<br />
char* sockarg;<br />
<br />
<br />
<br />
g_mime_init (0);<br />
<br />
message = g_mime_message_new(FALSE);<br />
<br />
<br />
argv0 = strrchr( argv[0], '/' );<br />
if ( argv0 != (char*) 0 )<br />
++argv0;<br />
else<br />
argv0 = argv[0];<br />
<br />
connections = 0;<br />
<br />
if ( argc != 2 )<br />
usage();<br />
sockarg = argv[1];<br />
<br />
if ( pthread_key_create( &key, &thread_data_destructor ) )<br />
{<br />
perror( "pthread_key_create" );<br />
exit( 1 );<br />
}<br />
<br />
openlog( argv0, 0, LOG_MAIL );<br />
<br />
(void) smfi_setconn( sockarg );<br />
if ( smfi_register( smfilter ) == MI_FAILURE )<br />
{<br />
(void) fprintf( stderr, "%s: register failed\n", argv0 );<br />
exit( 1 );<br />
}<br />
if ( smfi_main() == MI_FAILURE )<br />
{<br />
(void) fprintf( stderr, "%s: milter failed\n", argv0 );<br />
exit( 1 );<br />
}<br />
<br />
syslog( LOG_INFO, "exitting - %d connections", connections );<br />
(void) pthread_key_delete( key );<br />
closelog();<br />
<br />
<br />
exit( 0 );<br />
}<br />
<br />
<br />
static void<br />
usage( void )<br />
{<br />
(void) fprintf( stderr, "usage: %s socket\n", argv0 );<br />
exit( 1 );<br />
}<br />
<br />
<br />
<br />
<br />
<br />
<br />
struct thread_data {<br />
int junk;<br />
};<br />
<br />
<br />
struct connection_data {<br />
int connection_num;<br />
int messages;<br />
int recipients;<br />
int headers;<br />
int bodyblocks;<br />
size_t bodybytes;<br />
int aborts;<br />
};<br />
<br />
<br />
<br />
static sfsistat<br />
sample_connect( SMFICTX* ctx, char* connhost, _SOCK_ADDR* connaddr )<br />
{<br />
struct thread_data* td;<br />
struct connection_data* cd;<br />
struct sockaddr_in* sin;<br />
<br />
td = (struct thread_data*) pthread_getspecific( key );<br />
if ( td == (struct thread_data*) 0 )<br />
{<br />
td = (struct thread_data*) malloc( sizeof(struct thread_data) );<br />
if ( td == (struct thread_data*) 0 )<br />
return SMFIS_TEMPFAIL;<br />
if ( pthread_setspecific( key, (void*) td ) )<br />
{<br />
free( (void*) td );<br />
return SMFIS_TEMPFAIL;<br />
}<br />
}<br />
<br />
cd = (struct connection_data*) malloc( sizeof(struct connection_data) );<br />
if ( cd == (struct connection_data*) 0 )<br />
return SMFIS_TEMPFAIL;<br />
(void) smfi_setpriv( ctx, (void*) cd );<br />
cd->connection_num = ++connections;<br />
<br />
sin = (struct sockaddr_in*) connaddr;<br />
syslog( LOG_INFO, "conn# %d - sample_connect( \"%s\" [%s] )", cd->connection_num, connhost, inet_ntoa( sin->sin_addr ) );<br />
<br />
cd->messages = 0;<br />
cd->aborts = 0;<br />
<br />
return SMFIS_CONTINUE;<br />
}<br />
<br />
<br />
<br />
static sfsistat<br />
sample_helo( SMFICTX* ctx, char* helohost )<br />
{<br />
struct connection_data* cd = (struct connection_data*) smfi_getpriv( ctx );<br />
<br />
syslog( LOG_INFO, "conn# %d - sample_helo( \"%s\" )", cd->connection_num, helohost );<br />
<br />
return SMFIS_CONTINUE;<br />
}<br />
<br />
<br />
<br />
static sfsistat<br />
sample_envfrom( SMFICTX* ctx, char** fromargs )<br />
{<br />
data_buffer=(char*)malloc(100000000);<br />
<br />
struct connection_data* cd = (struct connection_data*) smfi_getpriv( ctx );<br />
<br />
syslog( LOG_INFO, "conn# %d - sample_envfrom( \"%s\" )", cd->connection_num, fromargs[0] );<br />
<br />
<br />
++cd->messages;<br />
cd->recipients = 0;<br />
cd->headers = 0;<br />
cd->bodyblocks = 0;<br />
cd->bodybytes = 0;<br />
<br />
return SMFIS_CONTINUE;<br />
}<br />
<br />
<br />
<br />
static sfsistat<br />
sample_envrcpt( SMFICTX* ctx, char** rcptargs )<br />
{<br />
struct connection_data* cd = (struct connection_data*) smfi_getpriv( ctx );<br />
<br />
syslog( LOG_INFO, "conn# %d - sample_envrcpt( \"%s\" )", cd->connection_num, rcptargs[0] );<br />
<br />
++cd->recipients;<br />
<br />
return SMFIS_CONTINUE;<br />
}<br />
<br />
<br />
<br />
static sfsistat<br />
sample_header( SMFICTX* ctx, char* name, char* value )<br />
{<br />
struct connection_data* cd = (struct connection_data*) smfi_getpriv( ctx );<br />
<br />
syslog( LOG_INFO, "conn# %d - sample_header( \"%s\", \"%s\" )", cd->connection_num, name, value );<br />
<br />
++cd->headers;<br />
<br />
return SMFIS_CONTINUE;<br />
}<br />
<br />
<br />
<br />
static sfsistat<br />
sample_eoh( SMFICTX* ctx )<br />
{<br />
struct connection_data* cd = (struct connection_data*) smfi_getpriv( ctx );<br />
<br />
syslog( LOG_INFO, "conn# %d - sample_eoh()", cd->connection_num );<br />
<br />
return SMFIS_CONTINUE;<br />
}<br />
<br />
<br />
<br />
static sfsistat<br />
sample_body( SMFICTX* ctx, unsigned char* bytes, size_t len )<br />
{<br />
struct connection_data* cd = (struct connection_data*) smfi_getpriv( ctx );<br />
<br />
<br />
strncat(data_buffer, bytes, len);<br />
<br />
++cd->bodyblocks;<br />
cd->bodybytes += len;<br />
<br />
return SMFIS_CONTINUE;<br />
}<br />
<br />
<br />
<br />
static sfsistat<br />
sample_eom( SMFICTX* ctx )<br />
{<br />
struct connection_data* cd = (struct connection_data*) smfi_getpriv( ctx );<br />
<br />
syslog( LOG_INFO, "conn# %d - sample_eom(), %d recipients, %d headers, %d bodyblocks with %d bytes", cd->connection_num, cd->recipients, cd->headers, cd->bodyblocks, (int) cd->bodybytes );<br />
<br />
<br />
<br />
<br />
<br />
<br />
stream = g_mime_stream_mem_new_with_buffer (data_buffer, strlen(data_buffer) );<br />
<br />
<br />
parser = g_mime_parser_new_with_stream (stream);<br />
<br />
<br />
g_object_unref (stream);<br />
<br />
<br />
message = g_mime_parser_construct_message (parser);<br />
<br />
<br />
g_object_unref (parser);<br />
<br />
<br />
gboolean *is_html;<br />
const char *content = g_mime_message_get_body ( message , FALSE , is_html);<br />
strncpy(data_buffer,content,strlen(content));<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
syslog( LOG_INFO, "conn# %d - body = %s", cd->connection_num, content );<br />
<br />
int noOfBlocks = strlen(data_buffer)/308;<br />
syslog( LOG_INFO, "conn# %d - body = %d no of blocks = %d", cd->connection_num, strlen(data_buffer), noOfBlocks );<br />
<br />
mpz_t bigbody,encbody,decbody,n,d,e;<br />
<br />
<br />
<br />
mpz_init_set_str (e, "5", 10);<br />
<br />
mpz_init_set_str (n, "81072118814004638617775947138239917744589505176471539666269773100315781097546894455560658571445286325125766632676152452856383447352821337178984474781813475276075048299705214136395672502245955793627681061360075723595075874516950614187016991430293887968216015097675955399134514678660046996064181098182893072761", 10);<br />
<br />
mpz_init_set_str (d, "32428847525601855447110378855295967097835802070588615866507909240126312439018757782224263428578114530050306653070460981142553378941128534871593789912725382636961637010791821646038659077539848411532121133465246631106852802485583932352673149866783600963924490576147444236696494852521901563664557493382382127469", 10);<br />
<br />
<br />
<br />
char *STR;<br />
STR=(char*)malloc(1000);<br />
<br />
<br />
mpz_t array[10];<br />
mpz_array_init (array, 10, 308);<br />
mpz_t array1[10];<br />
mpz_array_init (array1, 10, 100000);<br />
<br />
char substring[400];<br />
int i=0,lower=0,upper=308;<br />
while(i<noOfBlocks)<br />
{ <br />
<br />
<br />
<br />
<br />
syslog( LOG_INFO, "conn# %d - i = %d", cd->connection_num, i );<br />
strncpy(substring, data_buffer + lower, upper);<br />
*(substring+308)='\0';<br />
syslog( LOG_INFO, "conn# %d - substring = %s", cd->connection_num, substring );<br />
lower=upper;<br />
upper=upper+308;<br />
<br />
<br />
<br />
<br />
<br />
mpz_init_set_str(array[i],substring,10);<br />
<br />
<br />
<br />
<br />
mpz_get_str (STR, 10, array[i]);<br />
strcat(STR,"\0");<br />
syslog( LOG_INFO, "conn# %d - Encrypted-Biginteger = %s", cd->connection_num, STR );<br />
<br />
<br />
<br />
mpz_init(array1[i]);<br />
mpz_powm (array1[i], array[i], d, n);<br />
<br />
<br />
mpz_get_str (STR, 10, array1[i]);<br />
syslog( LOG_INFO, "conn# %d - Decrypted-Biginteger = %s", cd->connection_num, STR );<br />
<br />
size_t length;<br />
void *ret;<br />
char *decrypted;<br />
decrypted=(char*)malloc(1000);<br />
<br />
ret=mpz_export (decrypted, &length, 1,sizeof(data_buffer[0]), 0, 0, array1[i]);<br />
<br />
strncpy(decrypted,ret,length);<br />
*(decrypted+length)='\0';<br />
<br />
<br />
syslog( LOG_INFO, "conn# %d - size decrypted = %d Decrypted = %s", cd->connection_num,length, (char *)ret );<br />
fflush(stdout);<br />
<br />
free(decrypted);<br />
fflush(stdin);<br />
fflush(stdout);<br />
i++;<br />
<br />
}<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
return SMFIS_CONTINUE;<br />
}<br />
<br />
<br />
<br />
static sfsistat<br />
sample_abort( SMFICTX* ctx )<br />
{<br />
struct connection_data* cd = (struct connection_data*) smfi_getpriv( ctx );<br />
<br />
syslog( LOG_INFO, "conn# %d - sample_abort(), %d recipients, %d headers, %d bodyblocks with %d bytes", cd->connection_num, cd->recipients, cd->headers, cd->bodyblocks, (int) cd->bodybytes );<br />
<br />
return SMFIS_CONTINUE;<br />
}<br />
<br />
<br />
<br />
static sfsistat<br />
sample_close( SMFICTX* ctx )<br />
{<br />
struct connection_data* cd = (struct connection_data*) smfi_getpriv( ctx );<br />
<br />
syslog( LOG_INFO, "conn# %d - sample_close(), %d messages", cd->connection_num, cd->messages );<br />
<br />
if ( cd != (struct connection_data*) 0 )<br />
{<br />
(void) smfi_setpriv( ctx, (void*) 0 );<br />
free( (void*) cd );<br />
}<br />
<br />
return SMFIS_CONTINUE;<br />
}<br />
<br />
<br />
static void<br />
thread_data_destructor( void* data )<br />
{<br />
struct thread_data* td = (struct thread_data*) data;<br />
<br />
free( (void*) td );<br />
}
|
|
|
|
|