Exemplo n.º 1
0
char *LYgetTableString( int code )
{
  int eax;
  int mask = decode_mono_code( code );
  int second = encode_color_attr( mask );
  int pair = ( second & 65280 ) >> 8;
  int mono = 0;
  int fg = lynx_color_pairs[ pair ].fg;
  int bg = lynx_color_pairs[ pair ].bg;
  unsigned int n;
  char *result = 0;
  if ( WWW_TraceFlag )
  {
    fprintf( TraceFP( ), "LYgetTableString(%d)\n", code );
  }
  if ( fg == 0 && bg == 0 )
    fg = 7;
  if ( WWW_TraceFlag )
  {
    fprintf( TraceFP( ), "%#x -> %#x (mono %#x pair %d) fg=%d, bg=%d\n", mask, second, mono, pair, fg, bg );
  }
  n = 0;
  for ( ; n <= 6; n++ )
  {
    if ( Mono_Attrs[ n ].code & mono )
    {
      if ( result )
        HTSACat( &result, "+" );
      HTSACat( &result, Mono_Attrs[ n ].name );
    }
    // n++;
  }
  if ( result == 0 )
    HTSACopy( &result, "normal" );
  HTSACat( &result, ":" );
  HTSACat( &result, lookup_color( fg ) );
  if ( bg >= 0 )
  {
    HTSACat( &result, ":" );
    HTSACat( &result, lookup_color( bg ) );
  }
  if ( WWW_TraceFlag )
  {
    fprintf( TraceFP( ), "-&gt;%s\n", result );
  }
  return result;
}
Exemplo n.º 2
0
int LYUpload( char *line )
{
  int eax;
  char *method, *directory;
  int method_number;
  int count;
  char *the_upload = 0;
  char tmpbuf[256];
  char *filename = 0;
  lynx_list_item_type *upload_command = 0;
  char *the_command = 0;
  directory = strstr( line, "TO=" );
  if ( directory != 0 )
  {
    directory[ -1 ] = 0;
    directory += 3;
    method = strstr( line, "UPLOAD=" );
    if ( method != 0 )
    {
      method += 7;
      method_number = atoi( method );
      count = 0;
      upload_command = uploaders;
      for ( ; count < method_number; upload_command = &upload_command )
      {
        count++;
        //upload_command = &upload_command;
      }
      if ( upload_command->command == 0 )
      {
        HTAlert( gettext( "ERROR! - upload command is misconfigured" ) );
      }
      if ( HTCountCommandArgs( upload_command->command ) != 0 )
      {
        mustshow = 1;
        statusline( gettext( "Enter a filename: " ) );
        do
        {
          tmpbuf[0] = 0;
          if ( LYgetstr( tmpbuf, 0, 256, 0 ) >= 0 && ( tmpbuf[0] & 255 ) != 0 )
          {
            if ( strstr( tmpbuf, "../" ) != 0 )
            {
              HTAlert( gettext( "Illegal redirection \"../\" found! Request ignored." ) );
            }
            if ( strchr( tmpbuf, 47 ) != 0 )
            {
              HTAlert( gettext( "Illegal character \"/\" found! Request ignored." ) );
            }
            if ( tmpbuf[0] == '~' )
            {
              HTAlert( gettext( "Illegal redirection using \"~\" found! Request ignored." ) );
            }
            HTSprintf0( &filename, "%s/%s", directory, tmpbuf[0] );
            if ( filename[0] == '|' )
            {
              HTAlert( gettext( "Cannot write to file." ) );
              mustshow = 1;
              statusline( gettext( "Enter a new filename: " ) );
            }
            switch ( LYValidateOutput( filename ) )
            {
            case 89:
              if ( ( WWW_TraceFlag & 255 ) != 0 )
              {
                fprintf( TraceFP( ), "LYUpload: filename is %s", filename );
              }
              break;
            default:
              HTInfoMsg( gettext( "Cancelling!" ) );
              if ( ( 0 ^ 0 ) != 0 )
              {
                __stack_chk_fail( );
                break;
              }
              break;
            }
          }
        }
        while ( ( LYCanWriteFile( filename ) & 255 ) == 0 );
        HTAddParam( &the_upload, upload_command->command, 1, filename );
        HTEndParam( &the_upload, upload_command->command, 1 );
      }
      else
      {
        HTSACopy( &the_upload, upload_command->command );
        HTAddParam( &the_command, "cd %s ; ", 1, directory );
        HTEndParam( &the_command, "cd %s ; ", 1 );
        HTSACat( &the_command, the_upload );
        if ( ( WWW_TraceFlag & 255 ) != 0 )
        {
          fprintf( TraceFP( ), "command: %s\n", the_command );
        }
        stop_curses( );
        LYSystem( the_command );
        start_curses( );
        if ( the_command != 0 )
        {
          free( the_command );
          the_command = 0;
        }
        if ( the_upload != 0 )
        {
          free( the_upload );
          the_upload = 0;
        }
        if ( filename != 0 )
          chmod( filename, 384 );
        if ( filename != 0 )
        {
          free( filename );
          filename = 0;
        }
      }
    }
  }
  HTAlert( gettext( "Unable to upload file." ) );
}
Exemplo n.º 3
0
HTStream *HTCompressed( HTPresentation *pres, HTParentAnchor *anchor, HTStream *sink )
{
  int eax;
  HTStream *me;
  HTFormat format;
  char *type = 0;
  HTPresentation *Pres = 0;
  HTPresentation *Pnow = 0;
  int n, i;
  BOOLEAN can_present = 0;
  char fnam[256];
  char temp[256];
  char *suffix;
  char *uncompress_mask = 0;
  char *compress_suffix = "";
  char *middle;
  if ( anchor == 0 || anchor->content_encoding == 0 || anchor->content_type == 0 )
  {
    format = HTAtom_for( "application/octet-stream" );
    me = HTStreamStack( format, &pres->rep_out, &sink->isa->name[0], anchor );
    return me;
  }
  else
  {
    n = HTList_count( HTPresentations );
    i = 0;
    for ( ; i < n; i++ )
    {
      Pnow = (HTPresentation*)HTList_objectAt( HTPresentations, i );
      if ( strcasecomp( (char*)Pnow->rep_out, &anchor->content_type ) == 0 && Pnow->rep_out == HTAtom_for( "www/present" ) )
      {
        char *program = "";
        if ( Pres == 0 )
          Pres = Pnow;
        else
        if ( Pres->quality <= Pnow->quality )
          Pres = Pnow;
        can_present = 1;
        switch ( HTEncodingToCompressType( &anchor->content_encoding ) )
        {
        case 2:
          program = HTGetProgramPath( 6 );
          if ( program )
          {
            HTSACopy( &uncompress_mask, program );
            HTSACat( &uncompress_mask, " -d --no-name %s" );
            compress_suffix = "gz";
          }
          break;
        case 4:
          program = HTGetProgramPath( 7 );
          if ( program )
          {
            HTSACopy( &uncompress_mask, program );
            HTSACat( &uncompress_mask, " %s" );
            compress_suffix = "zz";
          }
          break;
        case 3:
          program = HTGetProgramPath( 1 );
          if ( program )
          {
            HTSACopy( &uncompress_mask, program );
            HTSACat( &uncompress_mask, " -d %s" );
            compress_suffix = "bz2";
          }
          break;
        case 1:
          program = HTGetProgramPath( 19 );
          if ( program )
          {
            HTSACopy( &uncompress_mask, program );
            HTSACat( &uncompress_mask, " %s" );
            compress_suffix = "Z";
          }
          break;
        }
      }
      // i++;
    }
    if ( can_present == 0 || uncompress_mask == 0 || strchr( &anchor->content_type, ';' ) || HTOutputFormat == HTAtom_for( "www/download" ) || !strcasecomp( &pres->rep_out->name, "www/download" ) || ( traversal && strcasecomp( &anchor->content_type, "text/html" ) && strcasecomp( &anchor->content_type, "text/plain" ) ) )
    {
      if ( strchr( &anchor->content_encoding, '/' ) == 0 )
      {
        if ( strncasecomp( &anchor->content_encoding, "x-", 2 ) == 0 )
          HTSACopy( &type, "application/" );
        else
          HTSACopy( &type, "application/x-" );
        HTSACat( &type, &anchor->content_encoding );
      }
      else
        HTSACopy( &type, &anchor->content_encoding );
      format = HTAtom_for( type );
      if ( type )
      {
        free( type );
        type = 0;
      }
      if ( uncompress_mask )
      {
        free( uncompress_mask );
        uncompress_mask = 0;
      }
      me = HTStreamStack( format, &pres->rep_out, &sink->isa->name[0], anchor );
      return me;
    }
    else
    {
      me = calloc( 1, sizeof( HTStream ) );
      if ( me == 0 )
        outofmem( "./HTFWriter.c", "HTCompressed" );
      me->isa->name[0] = HTFWriter.name;
      me->input_format = pres->rep->next;
      me->output_format = pres->rep_out;
      me->anchor = anchor;
      me->sink = sink;
      if ( anchor->FileCache )
      {
        LYRemoveTemp( &anchor->FileCache );
        if ( anchor->FileCache )
        {
          free( &anchor->FileCache );
          anchor->FileCache = 0;
        }
      }
      middle = 0;
      if ( strcasecomp( &anchor->content_type, "text/html" ) == 0 )
      {
        middle = ".html";
        middle++;
      }
      else
      {
        if ( strncasecomp( &anchor->content_type, "text/", 5 ) == 0 )
          middle = "txt";
        else
        {
          if ( strncasecomp( &anchor->content_type, "application/", 12 ) == 0 )
            middle = "bin";
          else
          {
            suffix = HTFileSuffix( HTAtom_for( &anchor->content_type ), 0 );
            if ( suffix && suffix[0] == '.' )
              middle = &suffix[1];
          }
        }
      }
      temp[0] = 0;
      if ( middle )
      {
        memcpy( temp[0] + strlen( temp ) );
        strcat( temp, middle );
        strcat( temp, "." );
      }
      strcat( temp, compress_suffix );
      me->fp = LYOpenTemp( fnam, temp, "wb" );
      if ( me->fp == 0 )
      {
        HTAlert( gettext( "Can't open temporary file!" ) );
        if ( uncompress_mask )
        {
          free( uncompress_mask );
          uncompress_mask = 0;
        }
        if ( me )
        {
          free( me );
          me = 0;
        }
        return 0;
      }
      else
      {
        if ( dump_output_immediately == 0 && traversal == 0 && ( Pres->quality < 999.000000000000 || ( no_exec == 0 && ( local_exec || ( local_exec_on_local_files && ( LYJumpFileURL || strncmp( &anchor->address, "file://localhost", 16 ) == 0 ) ) ) ) ) )
          HTSACopy( &me->viewer_command, &Pres->command );
        if ( compress_suffix[0] == 'g' && me->viewer_command == 0 )
          HTSACopy( &me->end_command, "" );
        else
        {
          *(int*)&me->end_command = 0;
          HTAddParam( &me->end_command, uncompress_mask, 1, fnam );
          HTEndParam( &me->end_command, uncompress_mask, 1 );
        }
        if ( uncompress_mask )
        {
          free( uncompress_mask );
          uncompress_mask = 0;
        }
        *(int*)&me->remove_command = 0;
        HTAddParam( &me->remove_command, "%s", 1, fnam );
        HTEndParam( &me->remove_command, "%s", 1 );
        HTSACopy( &anchor->FileCache, fnam );
        return me;
      }
    }
  }
}
Exemplo n.º 4
0
int LYShowInfo( DocInfo *doc, DocInfo *newdoc, char *owner_address )
{
  int eax;
  int edx;
  static char tempfile[256];
  int url_type;
  FILE *fp0;
  char *Title = 0;
  char *cp;
  char *temp = 0;
  BOOLEAN LYInfoAdvanced = user_mode == 2;
  struct stat dir_info;
  static char *name;
  if ( LYReuseTempfiles )
  {
    fp0 = LYOpenTempRewrite( tempfile, ".html", "w" );
  }
  else
  {
    LYRemoveTemp( tempfile );
    fp0 = LYOpenTemp( tempfile, ".html", "w" );
  }
  if ( fp0 == 0 )
  {
    HTAlert( gettext( "Can't open temporary file!" ) );
    return -1;
  }
  else
  {
    LYLocalFileToURL( &newdoc->address, tempfile );
    if ( nlinks > 0 && links[ doc->link ] )
    {
      url_type = is_url( links[ doc->link ].lname );
      switch ( url_type )
      {
      case 26:
      case 27:
      {
        char *last_slash = strrchr( links[ doc->link ].lname, '/' );
        int next_to_last = strlen( links[ doc->link ].lname ) + -1;
        if ( next_to_last == last_slash - links[ doc->link ].lname )
          links[ doc->link ].lname[ ebp_1152 ] = 0;
      }
        break;
      }
    }
    label_columns = 9;
    WriteInternalTitle( fp0, gettext( "Information about the current document" ) );
    fprintf( fp0, "&lt;h1&gt;%s %s (%s) (&lt;a href=\"%s\"&gt;%s&lt;/a&gt;)", "Lynx", "2.8.7dev.11", LYVersionDate( ), "http://lynx.isc.org/current/", LYVersionStatus( ) );
    fwrite( "&lt;/h1&gt;\n", 1, 6, fp0 );
    if ( lynx_edit_mode && nlinks > 0 )
    {
      fprintf( fp0, "&lt;h2&gt;%s&lt;/h2&gt;\n&lt;dl compact&gt;", gettext( "Directory that you are currently viewing" ) );
      temp = HTnameOfFile_WWW( &doc->address, 0, 1 );
      dt_String( fp0, gettext( "Name:" ), temp );
      if ( temp )
      {
        free( temp );
        temp = 0;
      }
      dt_String( fp0, gettext( "URL:" ), &doc->address );
      fwrite( "\n&lt;/dl&gt;\n", 1, 7, fp0 );
      temp = HTnameOfFile_WWW( links[ doc->link ].lname, 0, 1 );
      if ( lstat64( temp, &dir_info.st_dev ) == -1 )
      {
        if ( WWW_TraceFlag )
        {
          fprintf( TraceFP( ), "lstat(%s) failed, errno=%d\n", temp, *(int*)(__errno_location( )) );
        }
        HTAlert( gettext( "Failed to obtain status of current link!" ) );
      }
      else
      {
        char modes[80];
        label_columns = 16;
        if ( ( dir_info.st_mode & 61440 ) == 16384 )
        {
          fprintf( fp0, "&lt;h2&gt;%s&lt;/h2&gt;\n&lt;dl compact&gt;", gettext( "Directory that you have currently selected" ) );
        }
        else
        if ( ( dir_info.st_mode & 61440 ) == 32768 )
        {
          fprintf( fp0, "&lt;h2&gt;%s&lt;/h2&gt;\n&lt;dl compact&gt;", gettext( "File that you have currently selected" ) );
        }
        else
        if ( ( dir_info.st_mode & 61440 ) == 40960 )
        {
          fprintf( fp0, "&lt;h2&gt;%s&lt;/h2&gt;\n&lt;dl compact&gt;", gettext( "Symbolic link that you have currently selected" ) );
        }
        else
        {
          fprintf( fp0, "&lt;h2&gt;%s&lt;/h2&gt;\n&lt;dl compact&gt;", gettext( "Item that you have currently selected" ) );
        }
        dt_String( fp0, gettext( "Full name:" ), temp );
        if ( ( dir_info.st_mode & 61440 ) == 40960 )
        {
          char buf[1024];
          int buf_size = readlink( temp, buf, 1023 );
          if ( buf_size != -1 )
            buf[ buf_size ] = 0;
          else
          {
            sprintf( buf, "%.*s", 1023, gettext( "Unable to follow link" ) );
          }
          dt_String( fp0, gettext( "Points to file:" ), buf );
        }
        name = HTAA_UidToName( (int)dir_info.st_uid );
        if ( name[0] )
        {
          dt_String( fp0, gettext( "Name of owner:" ), name );
        }
        name = HTAA_GidToName( (int)dir_info.st_gid );
        if ( name[0] )
        {
          dt_String( fp0, gettext( "Group name:" ), name );
        }
        if ( ( dir_info.st_mode & 61440 ) == 32768 )
        {
          dt_Number( fp0, gettext( "File size:" ), (int)( (long)(dir_info.st_size & 0xFFFFFFFF) ), gettext( "(bytes)" ) );
        }
        dt_String( fp0, gettext( "Creation date:" ), ctime( &dir_info.st_ctim.tv_sec ) );
        dt_String( fp0, gettext( "Last modified:" ), ctime( &dir_info.st_mtim.tv_sec ) );
        dt_String( fp0, gettext( "Last accessed:" ), ctime( &dir_info.st_atim.tv_sec ) );
        fwrite( "\n&lt;/dl&gt;\n", 1, 7, fp0 );
        label_columns = 9;
        fprintf( fp0, "&lt;h2&gt;%s&lt;/h2&gt;\n&lt;dl compact&gt;", gettext( "Access Permissions" ) );
        modes[0] = 0;
        modes[1] = 0;
        modes[2] = 0;
        if ( dir_info.st_mode & 256 )
        {
          memcpy( modes[0] + strlen( modes ) );
        }
        if ( dir_info.st_mode & 128 )
        {
          memcpy( modes[0] + strlen( modes ) );
        }
        if ( dir_info.st_mode & 64 )
        {
          if ( ( dir_info.st_mode & 61440 ) == 16384 )
          {
            memcpy( modes[0] + strlen( modes ) );
          }
          else
          {
            memcpy( modes[0] + strlen( modes ) );
            if ( dir_info.st_mode & 2048 )
            {
              memcpy( modes[0] + strlen( modes ) );
            }
          }
        }
        dt_String( fp0, gettext( "Owner:" ), &modes[2] );
        modes[0] = 0;
        modes[1] = 0;
        modes[2] = 0;
        if ( dir_info.st_mode & 32 )
        {
          memcpy( modes[0] + strlen( modes ) );
        }
        if ( dir_info.st_mode & 16 )
        {
          memcpy( modes[0] + strlen( modes ) );
        }
        if ( dir_info.st_mode & 8 )
        {
          if ( ( dir_info.st_mode & 61440 ) == 16384 )
          {
            memcpy( modes[0] + strlen( modes ) );
          }
          else
          {
            memcpy( modes[0] + strlen( modes ) );
            if ( dir_info.st_mode & 1024 )
            {
              memcpy( modes[0] + strlen( modes ) );
            }
          }
        }
        dt_String( fp0, gettext( "Group:" ), &modes[2] );
        modes[0] = 0;
        modes[1] = 0;
        modes[2] = 0;
        if ( dir_info.st_mode & 4 )
        {
          memcpy( modes[0] + strlen( modes ) );
        }
        if ( dir_info.st_mode & 2 )
        {
          memcpy( modes[0] + strlen( modes ) );
        }
        if ( dir_info.st_mode & 1 )
        {
          if ( ( dir_info.st_mode & 61440 ) == 16384 )
          {
            memcpy( modes[0] + strlen( modes ) );
          }
          else
          {
            memcpy( modes[0] + strlen( modes ) );
            if ( dir_info.st_mode & 512 )
            {
              memcpy( modes[0] + strlen( modes ) );
            }
          }
        }
        dt_String( fp0, gettext( "World:" ), &modes[2] );
        fwrite( "\n&lt;/dl&gt;\n", 1, 7, fp0 );
      }
      if ( temp )
      {
        free( temp );
        temp = 0;
      }
    }
    else
    {
      fprintf( fp0, "&lt;h2&gt;%s&lt;/h2&gt;\n&lt;dl compact&gt;", gettext( "File that you are currently viewing" ) );
      LYformTitle( &Title, &doc->title[0] );
      HTSprintf( &temp, "%s%s", Title, "" );
      dt_String( fp0, gettext( "Linkname:" ), temp );
      if ( temp )
      {
        free( temp );
        temp = 0;
      }
      dt_String( fp0, "URL:", &doc->address );
      if ( HTLoadedDocumentCharset( ) )
      {
        dt_String( fp0, gettext( "Charset:" ), HTLoadedDocumentCharset( ) );
      }
      else
      {
        LYUCcharset *p_in = HTAnchor_getUCInfoStage( HTMainAnchor, 1 );
        if ( p_in == 0 || p_in->MIMEname == 0 || p_in->MIMEname[0] == 0 || HTAnchor_getUCLYhndl( HTMainAnchor, 1 ) < 0 )
        {
          p_in = HTAnchor_getUCInfoStage( HTMainAnchor, 0 );
        }
        if ( p_in && p_in->MIMEname && p_in->MIMEname[0] && HTAnchor_getUCLYhndl( HTMainAnchor, 0 ) >= 0 )
        {
          HTSprintf( &temp, "%s %s", p_in->MIMEname, gettext( "(assumed)" ) );
          dt_String( fp0, gettext( "Charset:" ), &p_in->MIMEname );
          if ( temp )
          {
            free( temp );
            temp = 0;
          }
        }
      }
      cp = HText_getServer( );
      if ( cp && cp[0] )
      {
        dt_String( fp0, gettext( "Server:" ), cp );
      }
      cp = HText_getDate( );
      if ( cp && cp[0] )
      {
        dt_String( fp0, gettext( "Date:" ), cp );
      }
      cp = HText_getLastModified( );
      if ( cp && cp[0] )
      {
        dt_String( fp0, gettext( "Last Mod:" ), cp );
      }
      if ( LYInfoAdvanced )
      {
        if ( HTMainAnchor && HTMainAnchor->expires )
        {
          dt_String( fp0, gettext( "Expires:" ), &HTMainAnchor->expires );
        }
        if ( HTMainAnchor && HTMainAnchor->cache_control )
        {
          dt_String( fp0, gettext( "Cache-Control:" ), &HTMainAnchor->cache_control );
        }
        if ( HTMainAnchor && HTMainAnchor->content_length > 0 )
        {
          dt_Number( fp0, gettext( "Content-Length:" ), HTMainAnchor->content_length, gettext( "bytes" ) );
        }
        else
        {
          dt_Number( fp0, gettext( "Length:" ), HText_getNumOfBytes( ), gettext( "bytes" ) );
        }
        if ( HTMainAnchor && HTMainAnchor->content_language )
        {
          dt_String( fp0, gettext( "Language:" ), &HTMainAnchor->content_language );
        }
      }
      if ( doc->post_data )
      {
        fprintf( fp0, "&lt;dt&gt;&lt;em&gt;%s&lt;/em&gt; &lt;xmp&gt;%.*s&lt;/xmp&gt;\n", gettext( "Post Data:" ), 0, 0 );
        dt_String( fp0, gettext( "Post Content Type:" ), &doc->post_content_type );
      }
      dt_String( fp0, gettext( "Owner(s):" ), owner_address ? owner_address : gettext( "Owner(s):" ) );
      dt_Number( fp0, gettext( "size:" ), HText_getNumOfLines( ), gettext( "lines" ) );
      if ( lynx_mode != 2 )
      {
        if ( HTisDocumentSource( ) )
        {
        }
        else
        {
        }
      }
      else
      {
      }
      HTSACopy( &temp, gettext( "source" ) );
      if ( doc->safe )
      {
        HTSACat( &temp, gettext( ", safe" ) );
      }
      if ( doc->internal_link )
      {
        HTSACat( &temp, gettext( ", via internal link" ) );
      }
      if ( LYInfoAdvanced )
      {
        if ( HText_hasNoCacheSet( HTMainText ) & 255 )
        {
          HTSACat( &temp, gettext( ", no-cache" ) );
        }
        if ( HTAnchor_isISMAPScript( (int)( &HTMainAnchor->parent->parent ) ) & 255 )
        {
          HTSACat( &temp, gettext( ", ISMAP script" ) );
        }
        if ( doc->bookmark )
        {
          HTSACat( &temp, gettext( ", bookmark file" ) );
        }
      }
      dt_String( fp0, gettext( "mode:" ), temp );
      if ( temp )
      {
        free( temp );
        temp = 0;
      }
      fwrite( "\n&lt;/dl&gt;\n", 1, 7, fp0 );
      if ( nlinks > 0 )
      {
        fprintf( fp0, "&lt;h2&gt;%s&lt;/h2&gt;\n&lt;dl compact&gt;", gettext( "Link that you currently have selected" ) );
        dt_String( fp0, gettext( "Linkname:" ), LYGetHiliteStr( doc->link, 0 ) );
        if ( lynx_mode == 2 && links[ doc->link ].type == 1 )
        {
          if ( links[ doc->link ].l_form->submit_method )
          {
            int method = links[ doc->link ].l_form->submit_method;
            char *enctype = &links[ doc->link ].l_form->submit_enctype;
            dt_String( fp0, gettext( "Method:" ), "POST" );
            dt_String( fp0, gettext( "Enctype:" ), "application/x-www-form-urlencoded" );
          }
          if ( links[ doc->link ].l_form->submit_action )
          {
            dt_String( fp0, gettext( "Action:" ), &links[ doc->link ].l_form->submit_action );
          }
          if ( links[ doc->link ].l_form->submit_method == 0 || links[ doc->link ].l_form->submit_action == 0 )
          {
            fprintf( fp0, "&lt;dt&gt;&nbsp;%s\n", gettext( "(Form field)" ) );
          }
        }
        else
        {
          dt_String( fp0, "URL:", "" );
        }
        fwrite( "\n&lt;/dl&gt;\n", 1, 7, fp0 );
      }
      else
      {
        fprintf( fp0, "&lt;h2&gt;%s&lt;/h2&gt;", gettext( "No Links on the current page" ) );
      }
    }
    EndInternalPage( fp0 );
    LYrefresh( );
    LYCloseTemp( tempfile );
    if ( Title )
    {
      free( Title );
      Title = 0;
    }
    return 0;
  }
}
Exemplo n.º 5
0
int remote_session( char *acc_method, char *host )
{
  char *program;
  char *user = host;
  char *password = 0;
  char *cp;
  char *hostname;
  char *port;
  char *command = 0;
  enum _login_protocol  login_protocol = rlogin;
  cp = host;
  for ( ; cp[0]; cp++ )
  {
    if ( !( *(short*)(*(int*)(__ctype_b_loc( )) + ( cp[0] * 2 )) & 8 ) && cp[0] != '_' && cp[0] != '-' && cp[0] != ':' && cp[0] != '.' && cp[0] != '@' )
    {
      cp[0] = 0;
      break;
    }
    else
    {
      // cp++;
    }
  }
  hostname = strchr( host, '@' );
  if ( hostname )
  {
    hostname[0] = 0;
    hostname++;
  }
  else
  {
    hostname = host;
    user = 0;
  }
  port = strchr( hostname, ':' );
  if ( port )
  {
    port[0] = 0;
    port++;
  }
  if ( hostname == 0 || hostname[0] == 0 )
  {
    if ( WWW_TraceFlag )
    {
      fprintf( TraceFP( ), "HTTelnet: No host specified!\n" );
    }
    return -204;
  }
  else
  {
    if ( ( valid_hostname( hostname ) & 255 ) == 0 )
    {
      char *prefix = 0;
      char *line = 0;
      if ( WWW_TraceFlag )
      {
        fprintf( TraceFP( ), "HTTelnet: Invalid hostname %s!\n", host );
      }
      HTSprintf0( &prefix, gettext( "remote %s session:" ), acc_method );
      HTSprintf0( &line, gettext( "Invalid hostname %s" ), host );
      HTAlwaysAlert( prefix, line );
      if ( prefix )
      {
        free( prefix );
        prefix = 0;
      }
      if ( line )
      {
        free( line );
        line = 0;
      }
      return -204;
    }
    else
    {
      if ( user )
      {
        password = strchr( user, ':' );
        if ( password )
        {
          password[0] = 0;
          password++;
        }
      }
      if ( HTSecure )
      {
        puts( "\n\nSorry, but the service you have selected is one" );
        puts( "to which you have to log in.  If you were running www" );
        puts( "on your own computer, you would be automatically connected." );
        puts( "For security reasons, this is not allowed when" );
        puts( "you log in to this information service remotely.\n" );
        printf( "You can manually connect to this service using %s\n", acc_method );
        printf( "to host %s", hostname );
        if ( user )
          printf( ", user name %s", user );
        if ( password )
          printf( ", password %s", password );
        if ( port )
          printf( ", port %s", port );
        puts( ".\n" );
        return -204;
      }
      else
      {
        if ( user && login_protocol != rlogin )
          printf( "When you are connected, log in as:  %s\n", user );
        if ( password && login_protocol != rlogin )
          printf( "                  The password is:  %s\n", password );
        fflush( stdout );
        switch ( login_protocol )
        {
        case rlogin:
          program = HTGetProgramPath( 11 );
          if ( program == 0 )
          {
            LYSystem( command );
            return -204;
          }
          HTAddParam( &command, "%s %s%s%s", 1, program );
          HTAddParam( &command, "%s %s%s%s", 2, hostname );
          HTSACat( &command, "" );
          HTAddParam( &command, "%s %s%s%s", 4, user );
          HTEndParam( &command, "%s %s%s%s", 4 );
          break;
        case tn3270:
          program = HTGetProgramPath( 17 );
          if ( program == 0 )
          {
            LYSystem( command );
            return -204;
          }
          HTAddParam( &command, "%s %s %s", 1, program );
          HTAddParam( &command, "%s %s %s", 2, hostname );
          HTAddParam( &command, "%s %s %s", 3, port );
          HTEndParam( &command, "%s %s %s", 3 );
          break;
        case telnet:
          program = HTGetProgramPath( 16 );
          if ( program == 0 )
          {
            LYSystem( command );
            return -204;
          }
          HTAddParam( &command, "%s %s %s", 1, program );
          HTAddParam( &command, "%s %s %s", 2, hostname );
          HTAddParam( &command, "%s %s %s", 3, port );
          HTEndParam( &command, "%s %s %s", 3 );
          break;
        }
      }
    }
  }
}
Exemplo n.º 6
0
void read_rc( FILE *fp )
{
  char *buffer = 0;
  char rcfile[256];
  char MBM_line[256];
  int n;
  if ( fp == 0 )
  {
    LYAddPathToHome( rcfile, 256, ".lynxrc" );
    fp = fopen64( rcfile, "r" );
    if ( fp )
    {
      if ( WWW_TraceFlag )
      {
        fprintf( TraceFP( ), "read_rc opened %s\n", rcfile );
        while ( LYSafeGets( &buffer, fp ) == 0 )
        {
          char *name, *value, *notes;
          Config_Type *tbl;
          ParseUnion *q;
          LYTrimTrailing( buffer );
          name = LYSkipBlanks( buffer );
          if ( !( *(short*)(*(int*)(__ctype_b_loc( )) + ( name[0] * 2 )) & 4 ) && name[0] )
          {
            value = strchr( name, '=' );
            if ( value == 0 )
            {
              if ( WWW_TraceFlag )
              {
                fprintf( TraceFP( ), "LYrcFile: missing '=' %s\n", name );
              }
            }
            else
            {
              value[0] = 0;
              value++;
              LYTrimTrailing( name );
              value = LYSkipBlanks( value );
              if ( WWW_TraceFlag && ( WWW_TraceMask & 8 ) )
              {
                fprintf( TraceFP( ), "LYrcFile %s:%s\n", name, value );
              }
              tbl = lookup_config( name );
              if ( tbl->name[0] == 0 )
              {
                char *special = "multi_bookmark";
                if ( strncasecomp( name, special, strlen( special ) ) == 0 )
                {
                  tbl = lookup_config( special );
                }
                if ( tbl->name[0] == 0 )
                {
                  if ( WWW_TraceFlag )
                  {
                    fprintf( TraceFP( ), "LYrcFile: ignored %s=%s\n", name, value );
                  }
                }
              }
              q = &tbl->value;
              switch ( tbl->type )
              {
              case 0:
                break;
              case 2:
                if ( q->add_value[0] )
                {
                  q->override_primary_action = getBool( value );
                }
                break;
              case 3:
                if ( q->add_value[0] )
                {
                  ;
                }
                break;
              case 1:
                n = 0;
                for ( ; tbl->strings[ n ]; n++ )
                {
                  if ( strcasecomp( value, &tbl->strings[ n ] ) == 0 )
                  {
                    q->add_value = &n;
                  }
                  else
                  {
                    // n++;
                  }
                }
                break;
              case 5:
                if ( tbl->table )
                {
                  LYgetEnum( &tbl->table, value, (int*)q->add_value[0] );
                }
                break;
              case 4:
                if ( q->add_value[0] && sscanf( value, value, "%d", ival ) == 1 )
                {
                  q->add_value = &ival;
                }
                break;
              case 6:
                if ( q->add_value[0] )
                {
                  if ( q->add_value )
                    HTSACat( (int)( &q->add_value[0]->next ), "," );
                  HTSACat( (int)( &q->add_value[0]->next ), value );
                }
                break;
              case 7:
                n = 1;
                for ( ; n <= 25; n++ )
                {
                  sprintf( MBM_line, "multi_bookmark%c", LYindex2MBM( n ) );
                  if ( strcasecomp( name, MBM_line ) == 0 )
                  {
                    notes = strchr( value, ',' );
                    if ( notes )
                    {
                      notes = 0;
                      notes++;
                      LYTrimTrailing( value );
                      notes = LYSkipBlanks( notes );
                    }
                    else
                    {
                      notes = value + strlen( value );
                    }
                    HTSACopy( &MBM_A_subbookmark[ n ], value );
                    HTSACopy( &MBM_A_subdescript[ n ], notes );
                  }
                  else
                  {
                    // n++;
                  }
                }
                break;
              case 8:
                if ( q->add_value[0] )
                {
                  HTSACopy( (int)( &q->add_value[0]->next ), value );
                }
                break;
              }
            }
          }
        }
      }
    }
  }
  else
  if ( WWW_TraceFlag )
  {
    fprintf( TraceFP( ), "read_rc used passed-in stream\n" );
  }
  return;
}