Phase 1 of the Massive WvString Changes: the .str member has been renamed
and should no longer be referred to directly. Typecast (often automatically) to (char *) instead. Also, the auto-typecast to int has been removed -- it was used in exactly one place :) git-svn-id: file:///home/apenwarr/alumnit-svn/public/trunk@43 6619c942-59fa-0310-bf43-a07aaa81d9ac
This commit is contained in:
parent
7741f2dcd1
commit
a463b1723a
|
@ -95,7 +95,7 @@ char * WvDialBrain::check_prompt( const char * buffer )
|
|||
|
||||
} else if( is_login_prompt( buffer ) ) {
|
||||
// We have a login prompt, so send a suitable response.
|
||||
char * send_this = dialer->options.login.str;
|
||||
char * send_this = dialer->options.login;
|
||||
dialer->log( "Looks like a login prompt.\n"
|
||||
"Sending: %s\n", send_this );
|
||||
dialer->reset_offset();
|
||||
|
@ -109,7 +109,7 @@ char * WvDialBrain::check_prompt( const char * buffer )
|
|||
prompt_tries++;
|
||||
sent_login = 1; // yes, we've sent a password:
|
||||
// assume we've sent username too.
|
||||
return( dialer->options.password.str );
|
||||
return( dialer->options.password );
|
||||
|
||||
} else if( is_welcome_msg( buffer ) ) {
|
||||
dialer->log( "Looks like a welcome message.\n" );
|
||||
|
@ -121,7 +121,7 @@ char * WvDialBrain::check_prompt( const char * buffer )
|
|||
return( NULL ); // figure it out next time
|
||||
}
|
||||
|
||||
if( !prompt_response.str[0] )
|
||||
if( !prompt_response[0] )
|
||||
prompt_response = dialer->options.default_reply; // wild guess
|
||||
|
||||
dialer->log( "Hmm... a prompt. Sending \"%s\".\n",
|
||||
|
@ -129,7 +129,7 @@ char * WvDialBrain::check_prompt( const char * buffer )
|
|||
dialer->reset_offset();
|
||||
prompt_tries++;
|
||||
|
||||
return( prompt_response.str );
|
||||
return( prompt_response );
|
||||
|
||||
} else {
|
||||
// not a prompt at all!
|
||||
|
@ -164,7 +164,7 @@ bool WvDialBrain::is_prompt( const char * c,
|
|||
if( !promptstring ) {
|
||||
for( cptr = c + strlen( c ) - 1; cptr >= c; cptr-- ) {
|
||||
if( isnewline( *cptr ) ) {
|
||||
if ( !prompt_response.str[0] )
|
||||
if ( !prompt_response[0] )
|
||||
return( false ); // last line was empty: not a prompt
|
||||
else
|
||||
return( true ); // we have a guess, so use it anyway
|
||||
|
@ -244,16 +244,16 @@ bool WvDialBrain::is_login_prompt( const char * buf )
|
|||
is_prompt( buf, "user.id", true ) ||
|
||||
is_prompt( buf, "signon" ) ||
|
||||
is_prompt( buf, "sign.on", true ) ||
|
||||
( dialer->options.login_prompt.str[0] &&
|
||||
is_prompt( buf, dialer->options.login_prompt.str ) ) );
|
||||
( dialer->options.login_prompt[0] &&
|
||||
is_prompt( buf, dialer->options.login_prompt ) ) );
|
||||
}
|
||||
|
||||
bool WvDialBrain::is_password_prompt( const char * buf )
|
||||
/******************************************************/
|
||||
{
|
||||
return( is_prompt( buf, "password" ) ||
|
||||
( dialer->options.pass_prompt.str[0] &&
|
||||
is_prompt( buf, dialer->options.pass_prompt.str ) ) );
|
||||
( dialer->options.pass_prompt[0] &&
|
||||
is_prompt( buf, dialer->options.pass_prompt ) ) );
|
||||
}
|
||||
|
||||
bool WvDialBrain::is_welcome_msg( const char * buf )
|
||||
|
@ -530,10 +530,10 @@ void WvDialBrain::set_prompt_response( char * str )
|
|||
{
|
||||
WvString n;
|
||||
|
||||
if( strcmp( str, prompt_response.str ) ) {
|
||||
if( strcmp( str, prompt_response ) ) {
|
||||
n.setsize( strlen( str ) + 1 );
|
||||
strcpy( n.str, str );
|
||||
n.str[ strlen( str ) ] = '\0';
|
||||
strcpy( n, str );
|
||||
n[ strlen( str ) ] = '\0';
|
||||
|
||||
dialer->log( "Found a good menu option: \"%s\".\n", n );
|
||||
prompt_response = n;
|
||||
|
|
|
@ -43,14 +43,14 @@ int main(int argc, char **argv)
|
|||
WvModemScan &m = *i.data();
|
||||
WvString fn = m.filename(), init = m.initstr();
|
||||
|
||||
fprintf(stderr, "\nFound a modem on %s.\n", fn.str);
|
||||
fprintf(stderr, "\nFound a modem on %s.\n", (char *)fn);
|
||||
|
||||
WvConf cfg(argv[1]);
|
||||
static char s[]="Dialer Defaults";
|
||||
cfg.set(s, "Modem", fn.str);
|
||||
cfg.set(s, "Modem", fn);
|
||||
cfg.set(s, "Baud", m.maxbaud());
|
||||
cfg.set(s, "Init1", "ATZ");
|
||||
cfg.set(s, "Init2", init.str);
|
||||
cfg.set(s, "Init2", init);
|
||||
|
||||
// insert some entries to let people know what they need to edit
|
||||
if (!cfg.get(s, "Phone"))
|
||||
|
|
22
wvdialer.cc
22
wvdialer.cc
|
@ -85,7 +85,7 @@ WvDialer::WvDialer( WvConf& cfg, WvStringList& sect_list )
|
|||
brain = new WvDialBrain( this );
|
||||
load_options( cfg, sect_list );
|
||||
|
||||
if( !options.modem.str[0] ) {
|
||||
if( !options.modem[0] ) {
|
||||
err( "Configuration does not specify a valid modem device.\n" );
|
||||
stat = ModemError;
|
||||
return; // if we get this error, we already have a problem.
|
||||
|
@ -122,17 +122,17 @@ bool WvDialer::dial()
|
|||
return( false );
|
||||
}
|
||||
|
||||
if( !options.phnum.str[0] ) {
|
||||
if( !options.phnum[0] ) {
|
||||
err( "Configuration does not specify a valid phone number.\n" );
|
||||
stat = OtherError;
|
||||
}
|
||||
|
||||
if( !options.login.str[0] ) {
|
||||
if( !options.login[0] ) {
|
||||
err( "Configuration does not specify a valid login name.\n" );
|
||||
stat = OtherError;
|
||||
}
|
||||
|
||||
if( !options.password.str[0] ) {
|
||||
if( !options.password[0] ) {
|
||||
err( "Configuration does not specify a valid password.\n" );
|
||||
stat = OtherError;
|
||||
}
|
||||
|
@ -403,7 +403,7 @@ bool WvDialer::init_modem()
|
|||
|
||||
// Open the modem...
|
||||
if( !modem ) {
|
||||
modem = new WvModem( options.modem.str, options.baud );
|
||||
modem = new WvModem( options.modem, options.baud );
|
||||
if( !modem->isok() ) {
|
||||
err( "Cannot open %s: %s\n", options.modem, modem->errstr() );
|
||||
return( false );
|
||||
|
@ -433,7 +433,7 @@ bool WvDialer::init_modem()
|
|||
default:
|
||||
this_str = &options.init9; break;
|
||||
}
|
||||
if( this_str->str[0] ) {
|
||||
if( !! *this_str ) {
|
||||
modem->print( "%s\r", *this_str );
|
||||
log( "Sending: %s\n", *this_str );
|
||||
|
||||
|
@ -451,7 +451,7 @@ bool WvDialer::init_modem()
|
|||
|
||||
// If we're using an ISDN modem, allow one second for the SPID
|
||||
// settings to kick in. It dials so fast anyway that no one will care.
|
||||
if( options.isdn.str[0] )
|
||||
if( options.isdn[0] )
|
||||
sleep( 1 );
|
||||
|
||||
// Everything worked fine.
|
||||
|
@ -563,20 +563,20 @@ void WvDialer::start_ppp()
|
|||
WvString addr_colon( "%s:", options.force_addr );
|
||||
|
||||
char *argv[] = {
|
||||
options.where_pppd.str,
|
||||
options.where_pppd,
|
||||
"modem",
|
||||
"crtscts",
|
||||
"defaultroute",
|
||||
"usehostname",
|
||||
"-detach",
|
||||
"user", options.login.str,
|
||||
options.force_addr.str[0] ? addr_colon.str : "noipdefault",
|
||||
"user", options.login,
|
||||
options.force_addr[0] ? (char *)addr_colon : "noipdefault",
|
||||
options.new_pppd ? "call" : NULL,
|
||||
options.new_pppd ? "wvdial" : NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
if( access( options.where_pppd.str, X_OK ) != 0 ) {
|
||||
if( access( options.where_pppd, X_OK ) != 0 ) {
|
||||
err( "Unable to run %s.\n", options.where_pppd );
|
||||
err( "Check permissions, or specify a \"PPPD Path\" option "
|
||||
"in wvdial.conf.\n" );
|
||||
|
|
|
@ -64,7 +64,7 @@ WvString WvModemScan::initstr() const
|
|||
{
|
||||
WvString s;
|
||||
s.setsize(100);
|
||||
strcpy(s.str, "AT");
|
||||
strcpy(s, "AT");
|
||||
|
||||
for (int i = 0; i < NUM_STAGES; i++)
|
||||
{
|
||||
|
@ -75,11 +75,11 @@ WvString WvModemScan::initstr() const
|
|||
if ((commands[i][0]=='Z' || commands[i][0]=='I') && status[i] != Test)
|
||||
continue;
|
||||
|
||||
strcat(s.str, commands[i]);
|
||||
strcat(s.str, " ");
|
||||
strcat(s, commands[i]);
|
||||
strcat(s, " ");
|
||||
}
|
||||
|
||||
return trim_string(s.str);
|
||||
return trim_string(s);
|
||||
}
|
||||
|
||||
|
||||
|
@ -91,7 +91,7 @@ void WvModemScan::execute()
|
|||
{
|
||||
case Startup:
|
||||
assert(!modem);
|
||||
modem = new WvModem(file.str, baud);
|
||||
modem = new WvModem(file, baud);
|
||||
modem->die_fast = true;
|
||||
if (!modem->isok())
|
||||
{
|
||||
|
@ -235,7 +235,7 @@ bool WvModemScan::doresult(const WvString &s, int msec)
|
|||
usleep(50 * 1000); // delay a bit after emptying the buffer
|
||||
modem->write(s);
|
||||
|
||||
debug("%s -- ", trim_string(s.str));
|
||||
debug("%s -- ", trim_string(s));
|
||||
|
||||
len = coagulate(buf, sizeof(buf), msec);
|
||||
|
||||
|
@ -310,13 +310,13 @@ size_t WvModemScan::coagulate(char *buf, size_t size, int msec)
|
|||
|
||||
char *WvModemScan::is_isdn() const
|
||||
{
|
||||
if (!identifier.str)
|
||||
if (!identifier)
|
||||
return NULL;
|
||||
|
||||
if (identifier == "3C882") // 3Com Impact IQ
|
||||
return identifier.str;
|
||||
return identifier;
|
||||
if (identifier == "960") // Motorola BitSurfr
|
||||
return identifier.str;
|
||||
return identifier;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -424,11 +424,11 @@ void WvModemScanList::execute()
|
|||
if (!printed)
|
||||
{
|
||||
const WvString &f = s->filename();
|
||||
const char *cptr = strrchr(f.str, '/');
|
||||
const char *cptr = strrchr(f, '/');
|
||||
if (cptr)
|
||||
cptr++;
|
||||
else
|
||||
cptr = f.str;
|
||||
cptr = f;
|
||||
|
||||
if (!strncmp(cptr, "tty", 3))
|
||||
cptr += 3;
|
||||
|
|
12
wvpapchap.cc
12
wvpapchap.cc
|
@ -21,19 +21,19 @@ void WvPapChap::put_secret( WvString username, WvString password,
|
|||
WvString remote )
|
||||
/*******************************************/
|
||||
{
|
||||
assert( remote.str[0] );
|
||||
assert( remote[0] );
|
||||
|
||||
// PAP secrets:
|
||||
nuke_contents();
|
||||
load_file( PAP_SECRETS );
|
||||
do_secret( username.str, password.str, remote.str );
|
||||
do_secret( username, password, remote );
|
||||
if( write_file( PAP_SECRETS ) == false )
|
||||
pap_success = false;
|
||||
|
||||
// CHAP secrets:
|
||||
nuke_contents();
|
||||
load_file( CHAP_SECRETS );
|
||||
do_secret( username.str, password.str, remote.str );
|
||||
do_secret( username, password, remote );
|
||||
if( write_file( CHAP_SECRETS ) == false )
|
||||
chap_success = false;
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ bool WvPapChap::write_file( char * filename )
|
|||
|
||||
WvStringList::Iter iter( contents );
|
||||
for( iter.rewind(); iter.next(); )
|
||||
file.print( "%s\n", iter.data()->str );
|
||||
file.print( "%s\n", *iter.data() );
|
||||
|
||||
file.close();
|
||||
return( true );
|
||||
|
@ -110,13 +110,13 @@ void WvPapChap::do_secret( char * username, char * password, char * remote )
|
|||
iter.next();
|
||||
while( iter.cur() ) {
|
||||
// Is this line a comment?
|
||||
if( iter.data()->str[0] == '#' ) {
|
||||
if( (*iter.data())[0] == '#' ) {
|
||||
iter.next();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Is the line blank?
|
||||
char * p = iter.data()->str;
|
||||
char * p = *iter.data();
|
||||
do
|
||||
p++;
|
||||
while( *p != '\0' && isspace( *p ) );
|
||||
|
|
Loading…
Reference in New Issue