![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Mar 10, 2015 12:47 am |
|
|
Why don't you trouble-shoot the problem ? You have posted a routine
that doesn't work. It's small. Why not debug it and fix it ?
The first thing to do, is make a test program. I did that below.
I used a text search program to search all the files in the TCPIP stack
that you posted for memcmppgm2ram(). I found the line that defines
it as the same as memcmp(). I included string.h because CCS has
memcmp in that file. I put HTTPNeedsAuth() from your post in it.
I added a little code to call it, and made this test program:
Code: |
#include <18F46K20.h>
#fuses INTRC_IO, BROWNOUT, PUT, NOWDT
#use delay(clock=4M)
#use rs232(baud=9600, UART1, ERRORS)
#include "string.h"
#define memcmppgm2ram(a,b,c) memcmp(a,b,c)
//signed int8 memcmppgm2ram(void * s1, rom char *s2, unsigned int8 n);
#define strcmppgm2ram(a,b) strcmp(a,b)
//signed int8 strcmppgm2ram(char *s1, rom char *s2);
BYTE HTTPNeedsAuth(BYTE* cFile)
{
// If the filename begins with the folder "protect", then require auth
if(memcmppgm2ram(cFile, (ROM void*)"protect", 7) == 0)
return 0x00; // Authentication will be needed later
return 0x80;
}
//====================================
void main()
{
int8 result;
int8 filename[] = "protect123abc";
result = HTTPNeedsAuth(filename);
printf("result = %x \r", result);
while(TRUE);
}
|
I can run this program in MPLAB (vs. 8.92) simulator, using UART 1 in the
Debugger/Settings menu, and I get this output in the Sim UART1 window:
That means it didn't get a match between "protect" and the filename.
That's the reason why your Authentication code doesn't work, or maybe
one of the reasons.
So now, trouble-shoot the test program and find out why it doesn't work,
and fix it.
Also, regarding your other post with a million lines of code. No one will
help you with a million lines of code. Delete that other post.
The first thing I would do is look closely at the cast to (ROM void*).
That's because ROM is a CCS extension and maybe it just doesn't
work with memcmp(). If that turns out to be a problem, there are
about 28 lines in the TCPIP stack that use that type of cast. The fix
for the problem would have to work for the other lines as well.
At least some of them should be tested.
When you finish fixing that routine, also check the other routine in your
post, HTTPCheckAuth(). Make a test program and see if it works. |
|
![](templates/subSilver/images/spacer.gif) |
eduardocapaneli
Joined: 05 Mar 2015 Posts: 13
|
|
Posted: Thu Mar 12, 2015 10:50 pm |
|
|
Solved as follows!
http_use_authentication TRUE and added in main.c this:
int1 http_check_authentication(char *fileName, char *user, char *pwd)
{
..
..
..
..
}
thank you. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|