CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

CREATE User Authentication page and password ENC28J60+PIC18f
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 10, 2015 12:47 am     Reply with quote

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:
Quote:
result = 80

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.
eduardocapaneli



Joined: 05 Mar 2015
Posts: 13

View user's profile Send private message

PostPosted: Thu Mar 12, 2015 10:50 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
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