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:
apenwarr 1998-11-14 21:13:08 +00:00
parent 7741f2dcd1
commit a463b1723a
5 changed files with 43 additions and 43 deletions

View File

@ -95,7 +95,7 @@ char * WvDialBrain::check_prompt( const char * buffer )
} else if( is_login_prompt( buffer ) ) { } else if( is_login_prompt( buffer ) ) {
// We have a login prompt, so send a suitable response. // 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" dialer->log( "Looks like a login prompt.\n"
"Sending: %s\n", send_this ); "Sending: %s\n", send_this );
dialer->reset_offset(); dialer->reset_offset();
@ -109,7 +109,7 @@ char * WvDialBrain::check_prompt( const char * buffer )
prompt_tries++; prompt_tries++;
sent_login = 1; // yes, we've sent a password: sent_login = 1; // yes, we've sent a password:
// assume we've sent username too. // assume we've sent username too.
return( dialer->options.password.str ); return( dialer->options.password );
} else if( is_welcome_msg( buffer ) ) { } else if( is_welcome_msg( buffer ) ) {
dialer->log( "Looks like a welcome message.\n" ); 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 return( NULL ); // figure it out next time
} }
if( !prompt_response.str[0] ) if( !prompt_response[0] )
prompt_response = dialer->options.default_reply; // wild guess prompt_response = dialer->options.default_reply; // wild guess
dialer->log( "Hmm... a prompt. Sending \"%s\".\n", dialer->log( "Hmm... a prompt. Sending \"%s\".\n",
@ -129,7 +129,7 @@ char * WvDialBrain::check_prompt( const char * buffer )
dialer->reset_offset(); dialer->reset_offset();
prompt_tries++; prompt_tries++;
return( prompt_response.str ); return( prompt_response );
} else { } else {
// not a prompt at all! // not a prompt at all!
@ -164,7 +164,7 @@ bool WvDialBrain::is_prompt( const char * c,
if( !promptstring ) { if( !promptstring ) {
for( cptr = c + strlen( c ) - 1; cptr >= c; cptr-- ) { for( cptr = c + strlen( c ) - 1; cptr >= c; cptr-- ) {
if( isnewline( *cptr ) ) { if( isnewline( *cptr ) ) {
if ( !prompt_response.str[0] ) if ( !prompt_response[0] )
return( false ); // last line was empty: not a prompt return( false ); // last line was empty: not a prompt
else else
return( true ); // we have a guess, so use it anyway 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, "user.id", true ) ||
is_prompt( buf, "signon" ) || is_prompt( buf, "signon" ) ||
is_prompt( buf, "sign.on", true ) || is_prompt( buf, "sign.on", true ) ||
( dialer->options.login_prompt.str[0] && ( dialer->options.login_prompt[0] &&
is_prompt( buf, dialer->options.login_prompt.str ) ) ); is_prompt( buf, dialer->options.login_prompt ) ) );
} }
bool WvDialBrain::is_password_prompt( const char * buf ) bool WvDialBrain::is_password_prompt( const char * buf )
/******************************************************/ /******************************************************/
{ {
return( is_prompt( buf, "password" ) || return( is_prompt( buf, "password" ) ||
( dialer->options.pass_prompt.str[0] && ( dialer->options.pass_prompt[0] &&
is_prompt( buf, dialer->options.pass_prompt.str ) ) ); is_prompt( buf, dialer->options.pass_prompt ) ) );
} }
bool WvDialBrain::is_welcome_msg( const char * buf ) bool WvDialBrain::is_welcome_msg( const char * buf )
@ -530,10 +530,10 @@ void WvDialBrain::set_prompt_response( char * str )
{ {
WvString n; WvString n;
if( strcmp( str, prompt_response.str ) ) { if( strcmp( str, prompt_response ) ) {
n.setsize( strlen( str ) + 1 ); n.setsize( strlen( str ) + 1 );
strcpy( n.str, str ); strcpy( n, str );
n.str[ strlen( str ) ] = '\0'; n[ strlen( str ) ] = '\0';
dialer->log( "Found a good menu option: \"%s\".\n", n ); dialer->log( "Found a good menu option: \"%s\".\n", n );
prompt_response = n; prompt_response = n;

View File

@ -43,14 +43,14 @@ int main(int argc, char **argv)
WvModemScan &m = *i.data(); WvModemScan &m = *i.data();
WvString fn = m.filename(), init = m.initstr(); 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]); WvConf cfg(argv[1]);
static char s[]="Dialer Defaults"; 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, "Baud", m.maxbaud());
cfg.set(s, "Init1", "ATZ"); 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 // insert some entries to let people know what they need to edit
if (!cfg.get(s, "Phone")) if (!cfg.get(s, "Phone"))

View File

@ -85,7 +85,7 @@ WvDialer::WvDialer( WvConf& cfg, WvStringList& sect_list )
brain = new WvDialBrain( this ); brain = new WvDialBrain( this );
load_options( cfg, sect_list ); load_options( cfg, sect_list );
if( !options.modem.str[0] ) { if( !options.modem[0] ) {
err( "Configuration does not specify a valid modem device.\n" ); err( "Configuration does not specify a valid modem device.\n" );
stat = ModemError; stat = ModemError;
return; // if we get this error, we already have a problem. return; // if we get this error, we already have a problem.
@ -122,17 +122,17 @@ bool WvDialer::dial()
return( false ); return( false );
} }
if( !options.phnum.str[0] ) { if( !options.phnum[0] ) {
err( "Configuration does not specify a valid phone number.\n" ); err( "Configuration does not specify a valid phone number.\n" );
stat = OtherError; stat = OtherError;
} }
if( !options.login.str[0] ) { if( !options.login[0] ) {
err( "Configuration does not specify a valid login name.\n" ); err( "Configuration does not specify a valid login name.\n" );
stat = OtherError; stat = OtherError;
} }
if( !options.password.str[0] ) { if( !options.password[0] ) {
err( "Configuration does not specify a valid password.\n" ); err( "Configuration does not specify a valid password.\n" );
stat = OtherError; stat = OtherError;
} }
@ -403,7 +403,7 @@ bool WvDialer::init_modem()
// Open the modem... // Open the modem...
if( !modem ) { if( !modem ) {
modem = new WvModem( options.modem.str, options.baud ); modem = new WvModem( options.modem, options.baud );
if( !modem->isok() ) { if( !modem->isok() ) {
err( "Cannot open %s: %s\n", options.modem, modem->errstr() ); err( "Cannot open %s: %s\n", options.modem, modem->errstr() );
return( false ); return( false );
@ -433,7 +433,7 @@ bool WvDialer::init_modem()
default: default:
this_str = &options.init9; break; this_str = &options.init9; break;
} }
if( this_str->str[0] ) { if( !! *this_str ) {
modem->print( "%s\r", *this_str ); modem->print( "%s\r", *this_str );
log( "Sending: %s\n", *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 // 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. // 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 ); sleep( 1 );
// Everything worked fine. // Everything worked fine.
@ -563,20 +563,20 @@ void WvDialer::start_ppp()
WvString addr_colon( "%s:", options.force_addr ); WvString addr_colon( "%s:", options.force_addr );
char *argv[] = { char *argv[] = {
options.where_pppd.str, options.where_pppd,
"modem", "modem",
"crtscts", "crtscts",
"defaultroute", "defaultroute",
"usehostname", "usehostname",
"-detach", "-detach",
"user", options.login.str, "user", options.login,
options.force_addr.str[0] ? addr_colon.str : "noipdefault", options.force_addr[0] ? (char *)addr_colon : "noipdefault",
options.new_pppd ? "call" : NULL, options.new_pppd ? "call" : NULL,
options.new_pppd ? "wvdial" : NULL, options.new_pppd ? "wvdial" : NULL,
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( "Unable to run %s.\n", options.where_pppd );
err( "Check permissions, or specify a \"PPPD Path\" option " err( "Check permissions, or specify a \"PPPD Path\" option "
"in wvdial.conf.\n" ); "in wvdial.conf.\n" );

View File

@ -64,7 +64,7 @@ WvString WvModemScan::initstr() const
{ {
WvString s; WvString s;
s.setsize(100); s.setsize(100);
strcpy(s.str, "AT"); strcpy(s, "AT");
for (int i = 0; i < NUM_STAGES; i++) 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) if ((commands[i][0]=='Z' || commands[i][0]=='I') && status[i] != Test)
continue; continue;
strcat(s.str, commands[i]); strcat(s, commands[i]);
strcat(s.str, " "); strcat(s, " ");
} }
return trim_string(s.str); return trim_string(s);
} }
@ -91,7 +91,7 @@ void WvModemScan::execute()
{ {
case Startup: case Startup:
assert(!modem); assert(!modem);
modem = new WvModem(file.str, baud); modem = new WvModem(file, baud);
modem->die_fast = true; modem->die_fast = true;
if (!modem->isok()) 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 usleep(50 * 1000); // delay a bit after emptying the buffer
modem->write(s); modem->write(s);
debug("%s -- ", trim_string(s.str)); debug("%s -- ", trim_string(s));
len = coagulate(buf, sizeof(buf), msec); 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 char *WvModemScan::is_isdn() const
{ {
if (!identifier.str) if (!identifier)
return NULL; return NULL;
if (identifier == "3C882") // 3Com Impact IQ if (identifier == "3C882") // 3Com Impact IQ
return identifier.str; return identifier;
if (identifier == "960") // Motorola BitSurfr if (identifier == "960") // Motorola BitSurfr
return identifier.str; return identifier;
return NULL; return NULL;
} }
@ -424,11 +424,11 @@ void WvModemScanList::execute()
if (!printed) if (!printed)
{ {
const WvString &f = s->filename(); const WvString &f = s->filename();
const char *cptr = strrchr(f.str, '/'); const char *cptr = strrchr(f, '/');
if (cptr) if (cptr)
cptr++; cptr++;
else else
cptr = f.str; cptr = f;
if (!strncmp(cptr, "tty", 3)) if (!strncmp(cptr, "tty", 3))
cptr += 3; cptr += 3;

View File

@ -21,19 +21,19 @@ void WvPapChap::put_secret( WvString username, WvString password,
WvString remote ) WvString remote )
/*******************************************/ /*******************************************/
{ {
assert( remote.str[0] ); assert( remote[0] );
// PAP secrets: // PAP secrets:
nuke_contents(); nuke_contents();
load_file( PAP_SECRETS ); load_file( PAP_SECRETS );
do_secret( username.str, password.str, remote.str ); do_secret( username, password, remote );
if( write_file( PAP_SECRETS ) == false ) if( write_file( PAP_SECRETS ) == false )
pap_success = false; pap_success = false;
// CHAP secrets: // CHAP secrets:
nuke_contents(); nuke_contents();
load_file( CHAP_SECRETS ); load_file( CHAP_SECRETS );
do_secret( username.str, password.str, remote.str ); do_secret( username, password, remote );
if( write_file( CHAP_SECRETS ) == false ) if( write_file( CHAP_SECRETS ) == false )
chap_success = false; chap_success = false;
} }
@ -87,7 +87,7 @@ bool WvPapChap::write_file( char * filename )
WvStringList::Iter iter( contents ); WvStringList::Iter iter( contents );
for( iter.rewind(); iter.next(); ) for( iter.rewind(); iter.next(); )
file.print( "%s\n", iter.data()->str ); file.print( "%s\n", *iter.data() );
file.close(); file.close();
return( true ); return( true );
@ -110,13 +110,13 @@ void WvPapChap::do_secret( char * username, char * password, char * remote )
iter.next(); iter.next();
while( iter.cur() ) { while( iter.cur() ) {
// Is this line a comment? // Is this line a comment?
if( iter.data()->str[0] == '#' ) { if( (*iter.data())[0] == '#' ) {
iter.next(); iter.next();
continue; continue;
} }
// Is the line blank? // Is the line blank?
char * p = iter.data()->str; char * p = *iter.data();
do do
p++; p++;
while( *p != '\0' && isspace( *p ) ); while( *p != '\0' && isspace( *p ) );