Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
tintin++ ogg sound player script for linux
Author: Robert Smith
Submitted by: Vladaar
6Dragons ogg Soundpack
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.4
Author: Vladaar
Submitted by: Vladaar
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
Users Online
CommonCrawl, Bing

Members: 0
Guests: 6
Stats
Files
Topics
Posts
Members
Newest Member
481
3,734
19,366
618
Micheal64X
Today's Birthdays
Vintar (28)
Related Links
» SmaugMuds.org » General » Coding » New Auth by Rantic
Forum Rules | Mark all | Recent Posts

New Auth by Rantic
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Oct 3, 2012, 4:19 pm
Go to the top of the page
Go to the bottom of the page

thatjdguy
Fledgling
GroupMembers
Posts14
JoinedJul 2, 2012

I'm trying to implement Rantic's new auth system and getting a LOT of errors in new_auth.c when compiling.
new_auth.c: In function ‘AUTH_LIST* fread_auth(FILE*)’:
new_auth.c:184:13: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
new_auth.c:188:13: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
new_auth.c:200:13: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
new_auth.c: In function ‘void add_to_auth(CHAR_DATA*)’:
new_auth.c:358:24: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
new_auth.c: In function ‘void check_auth_state(CHAR_DATA*)’:
new_auth.c:385:40: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
new_auth.c: In function ‘void do_authorize(CHAR_DATA*, const char*)’:
new_auth.c:450:40: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
new_auth.c:564:31: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
new_auth.c:587:31: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
new_auth.c:647:31: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
new_auth.c: In function ‘void do_name(CHAR_DATA*, const char*)’:
new_auth.c:695:18: error: assignment of read-only location ‘* argument’
new_auth.c:697:42: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
new_auth.c:46:6: error:   initializing argument 1 of ‘bool check_parse_name(char*, bool)’ [-fpermissive]
new_auth.c:737:22: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
new_auth.c: In function ‘void do_mpapplyb(CHAR_DATA*, const char*)’:
new_auth.c:757:40: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
new_auth.c: In function ‘void auth_update()’:
new_auth.c:819:40: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]


To save post length, new_auth.c code to follow.
       
Post is unread #2 Oct 3, 2012, 4:21 pm
Go to the top of the page
Go to the bottom of the page

thatjdguy
Fledgling
GroupMembers
Posts14
JoinedJul 2, 2012

AUTH_LIST *fread_auth( FILE * fp )
{
   AUTH_LIST *new_auth;
   bool fMatch;
   const char *word;

   CREATE( new_auth, AUTH_LIST, 1 );

   new_auth->authed_by = NULL;
   new_auth->change_by = NULL;

   for( ;; )
   {
      word = feof( fp ) ? "End" : fread_word( fp );
      fMatch = FALSE;
      switch ( UPPER( word[0] ) )
      {
         case '*':
            fMatch = TRUE;
            fread_to_eol( fp );
            break;

         case 'A':
            KEY( "AuthedBy", new_auth->authed_by, fread_string( fp ) ); <-- Offending Line
            break;

         case 'C':
            KEY( "Change", new_auth->change_by, fread_string( fp ) ); <-- Offending Line
            break;

         case 'E':
            if( !str_cmp( word, "End" ) )
            {
               LINK( new_auth, first_auth_name, last_auth_name, next, prev );
               return new_auth;
            }
            break;

         case 'N':
            KEY( "Name", new_auth->name, fread_string( fp ) ); <-- Offending Line
            break;

         case 'S':
            if( !str_cmp( word, "State" ) )
            {
               new_auth->state = fread_number( fp );
               /*
                * Crash proofing. Can't be online when 
                */
               /*
                * booting up. Would suck for do_auth   
                */
               if( new_auth->state == AUTH_ONLINE || new_auth->state == AUTH_LINK_DEAD )
                  new_auth->state = AUTH_OFFLINE;
               fMatch = TRUE;
               break;
            }
            break;
      }
      if( !fMatch )
         bug( "%s: no match: %s", __FUNCTION__, word );
   }
}
       
Post is unread #3 Oct 3, 2012, 4:25 pm
Go to the top of the page
Go to the bottom of the page

thatjdguy
Fledgling
GroupMembers
Posts14
JoinedJul 2, 2012

void add_to_auth( CHAR_DATA * ch )
{
   AUTH_LIST *new_name;

   new_name = get_auth_name( ch->name );
   if( new_name != NULL )
      return;
   else
   {
      CREATE( new_name, AUTH_LIST, 1 );
      new_name->name = STRALLOC( ch->name ); <-- Offending Line
      new_name->state = AUTH_ONLINE;   /* Just entered the game */
      LINK( new_name, first_auth_name, last_auth_name, next, prev );
      save_auth_list(  );
   }
}
       
Post is unread #4 Oct 3, 2012, 4:27 pm
Go to the top of the page
Go to the bottom of the page

thatjdguy
Fledgling
GroupMembers
Posts14
JoinedJul 2, 2012

void check_auth_state( CHAR_DATA * ch )
{
   AUTH_LIST *old_auth;
   CMDTYPE *command;
   int level = LEVEL_IMMORTAL;

   command = find_command( "authorize" ); <-- Offending Line
   if( !command )
      level = LEVEL_IMMORTAL;
   else
      level = command->level;


Of course there are more, but I believe I can fix the rest if I can get these figured out. Thanks in advance.
       
Post is unread #5 Oct 3, 2012, 6:34 pm
Go to the top of the page
Go to the bottom of the page

Quixadhal
Conjurer
GroupMembers
Posts398
JoinedMar 8, 2005

This is the classic error that gcc has started being more picky on, and will likely continue to get more picky about.

The constant string "authorize" is being passed into the function find_command(), which is almost certainly declared as a writeable string (char *). The compiler is telling you that this isn't safe, since the function might try to modify it, which would result in a runtime error if the string is actually in a write protected memory space.

There's two approaches to fixing these. You can change the function declaration to be (const char *), if you know it doesn't actually try to write to that parameter. That's usually best. If you know it DOES modify it, the other option is to declare local storage and copy your string into it, passing in the writeable copy.
       
Pages:<< prev 1 next >>