当前位置: 首页>>代码示例>>C++>>正文


C++ UDSEntry::append方法代码示例

本文整理汇总了C++中UDSEntry::append方法的典型用法代码示例。如果您正苦于以下问题:C++ UDSEntry::append方法的具体用法?C++ UDSEntry::append怎么用?C++ UDSEntry::append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UDSEntry的用法示例。


在下文中一共展示了UDSEntry::append方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: stat

//===========================================================================
void SMBSlave::stat( const KURL& kurl )
{
    kdDebug(KIO_SMB) << "SMBSlave::stat on "<< kurl << endl;
    // make a valid URL
    KURL url = checkURL(kurl);

    // if URL is not valid we have to redirect to correct URL
    if (url != kurl)
    {
        kdDebug() << "redirection " << url << endl;
        redirection(url);
        finished();
        return;
    }

    m_current_url = url;

    UDSAtom     udsatom;
    UDSEntry    udsentry;
    // Set name
    udsatom.m_uds = KIO::UDS_NAME;
    udsatom.m_str = kurl.fileName();
    udsentry.append( udsatom );

    switch(m_current_url.getType())
    {
    case SMBURLTYPE_UNKNOWN:
        error(ERR_MALFORMED_URL,m_current_url.prettyURL());
        finished();
        return;

    case SMBURLTYPE_ENTIRE_NETWORK:
    case SMBURLTYPE_WORKGROUP_OR_SERVER:
        udsatom.m_uds = KIO::UDS_FILE_TYPE;
        udsatom.m_long = S_IFDIR;
        udsentry.append(udsatom);
        break;

    case SMBURLTYPE_SHARE_OR_PATH:
        if (browse_stat_path(m_current_url, udsentry, false))
            break;
        else {
            kdDebug(KIO_SMB) << "SMBSlave::stat ERROR!!"<< endl;
            finished();
            return;
        }
    default:
        kdDebug(KIO_SMB) << "SMBSlave::stat UNKNOWN " << url << endl;
        finished();
        return;
    }

    statEntry(udsentry);
    finished();
}
开发者ID:,项目名称:,代码行数:56,代码来源:

示例2: createUDSEntry

void tdeio_isoProtocol::createUDSEntry( const KArchiveEntry * isoEntry, UDSEntry & entry )
{
    UDSAtom atom;

    entry.clear();
    atom.m_uds = UDS_NAME;
    atom.m_str = isoEntry->name();
    entry.append(atom);

    atom.m_uds = UDS_FILE_TYPE;
    atom.m_long = isoEntry->permissions() & S_IFMT; // keep file type only
    entry.append( atom );

    atom.m_uds = UDS_ACCESS;
    atom.m_long = isoEntry->permissions() & 07777; // keep permissions only
    entry.append( atom );

    atom.m_uds = UDS_SIZE;
    if (isoEntry->isFile()) {
        atom.m_long = ((KIsoFile *)isoEntry)->realsize();
        if (!atom.m_long) atom.m_long = ((KIsoFile *)isoEntry)->size();
    } else {
        atom.m_long = 0L;
    }
    entry.append( atom );

    atom.m_uds = UDS_USER;
    atom.m_str = isoEntry->user();
    entry.append( atom );

    atom.m_uds = UDS_GROUP;
    atom.m_str = isoEntry->group();
    entry.append( atom );

    atom.m_uds = UDS_MODIFICATION_TIME;
    atom.m_long = isoEntry->date();
    entry.append( atom );

    atom.m_uds = UDS_ACCESS_TIME;
    atom.m_long = isoEntry->isFile() ? ((KIsoFile *)isoEntry)->adate() :
                                       ((KIsoDirectory *)isoEntry)->adate();
    entry.append( atom );

    atom.m_uds = UDS_CREATION_TIME;
    atom.m_long = isoEntry->isFile() ? ((KIsoFile *)isoEntry)->cdate() :
                                       ((KIsoDirectory *)isoEntry)->cdate();
    entry.append( atom );

    atom.m_uds = UDS_LINK_DEST;
    atom.m_str = isoEntry->symlink();
    entry.append( atom );
}
开发者ID:Fat-Zer,项目名称:tdelibs,代码行数:52,代码来源:iso.cpp

示例3:

void LDAPProtocol::LDAPEntry2UDSEntry( const TQString &dn, UDSEntry &entry, 
  const LDAPUrl &usrc, bool dir )
{
  UDSAtom atom;
  
  int pos;
  entry.clear();
  atom.m_uds = UDS_NAME;
  atom.m_long = 0;
  TQString name = dn;
  if ( (pos = name.find(",")) > 0 )
    name = name.left( pos );
  if ( (pos = name.find("=")) > 0 )
    name.remove( 0, pos+1 );
  name.replace(' ', "_");
  if ( !dir ) name += ".ldif";
  atom.m_str = name;
  entry.append( atom );

  // the file type
  atom.m_uds = UDS_FILE_TYPE;
  atom.m_str = "";
  atom.m_long = dir ? S_IFDIR : S_IFREG;
  entry.append( atom );
  
  // the mimetype
  if (!dir) {
    atom.m_uds = UDS_MIME_TYPE;
    atom.m_long = 0;
    atom.m_str = "text/plain";
    entry.append( atom );
  }

  atom.m_uds = UDS_ACCESS;
  atom.m_long = dir ? 0500 : 0400;
  entry.append( atom );

  // the url
  atom.m_uds = UDS_URL;
  atom.m_long = 0;
  LDAPUrl url;
  url=usrc;

  url.setPath("/"+dn);
  url.setScope( dir ? LDAPUrl::One : LDAPUrl::Base );
  atom.m_str = url.prettyURL();
  entry.append( atom );
}
开发者ID:Fat-Zer,项目名称:tdebase,代码行数:48,代码来源:tdeio_ldap.cpp

示例4: stat

void LANProtocol::stat( const KURL & url)
{
   kdDebug(7101)<<"LANProtocol::stat: "<<endl;
   UDSEntry entry;
   UDSAtom atom;

   atom.m_uds = KIO::UDS_NAME;
   atom.m_str = url.path();
   entry.append( atom );
   atom.m_uds = KIO::UDS_SIZE;
   atom.m_long = 1024;
   entry.append(atom);

   atom.m_uds = KIO::UDS_ACCESS;
   atom.m_long = S_IRUSR | S_IRGRP | S_IROTH ;
   //atom.m_long = S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
   entry.append(atom);


   QString path( QFile::encodeName(url.path()));
   QStringList pathList=QStringList::split( "/",path);
   if ((pathList.count()==2) && (pathList[1].upper()=="HTTP"))
   {
      atom.m_uds = KIO::UDS_FILE_TYPE;
      atom.m_long=S_IFREG;
      entry.append(atom);
      atom.m_uds = KIO::UDS_MIME_TYPE;
      atom.m_str="text/html";
      //kdDebug(7101)<<"LANProtocol::stat: http is reg file"<<endl;
      entry.append( atom );
   }
   else
   {
      atom.m_uds = KIO::UDS_FILE_TYPE;
      atom.m_long = S_IFDIR; // it is always a directory
      entry.append(atom);
      atom.m_uds = KIO::UDS_MIME_TYPE;
      atom.m_str="inode/directory";
      //kdDebug(7101)<<"LANProtocol::stat: is dir"<<endl;
      entry.append( atom );
   }

   statEntry( entry );
   finished();
}
开发者ID:serghei,项目名称:kde3-kdenetwork,代码行数:45,代码来源:kio_lan.cpp

示例5: statToEntry

UDSEntry kio_afpProtocol::statToEntry(KDE_struct_stat* stat)
{
    UDSEntry entry;
    UDSAtom atom;

      if (S_ISDIR(stat->st_mode)) {
         atom.m_uds = UDS_GUESSED_MIME_TYPE;
         atom.m_str = "inode/directory";
         entry.append( atom );

         atom.m_uds = UDS_FILE_TYPE;
         atom.m_long = S_IFDIR;
         entry.append( atom );
      } else {
         atom.m_uds = UDS_GUESSED_MIME_TYPE;
         atom.m_str = "text/plain";
         entry.append( atom );

         atom.m_uds = UDS_FILE_TYPE;
         atom.m_long = S_IFREG;
         entry.append( atom );
      }

    atom.m_uds = KIO::UDS_ACCESS;
    atom.m_long = stat->st_mode;
    entry.append( atom );

#if 0
    atom.m_uds = KIO::UDS_USER;
    struct passwd * passwd;
    if ((passwd = getpwuid(stat->st_uid))) {
        atom.m_str = passwd->pw_name;;
    } else {
        atom.m_str = "unknown";
    }
    entry.append( atom );
    atom.m_uds = KIO::UDS_GROUP;
    entry.append( atom );
#endif

    return entry;
}
开发者ID:zach-klippenstein,项目名称:afpfs-ng,代码行数:42,代码来源:kafp.cpp

示例6: FPToEntry

UDSEntry kio_afpProtocol::FPToEntry(struct afp_file_info_basic * fp)
{
    UDSEntry entry;
    UDSAtom atom;

    atom.m_uds = UDS_NAME;
    atom.m_str = fp->name;
    entry.append( atom );

      if (S_ISDIR(fp->unixprivs.permissions)) {
         atom.m_uds = UDS_GUESSED_MIME_TYPE;
         atom.m_str = "inode/directory";
         entry.append( atom );

         atom.m_uds = UDS_FILE_TYPE;
         atom.m_long = S_IFDIR;
         entry.append( atom );
      } else {
         atom.m_uds = UDS_GUESSED_MIME_TYPE;
         atom.m_str = "text/plain";
         entry.append( atom );

         atom.m_uds = UDS_FILE_TYPE;
         atom.m_long = S_IFREG;
         entry.append( atom );
      }

      atom.m_uds = UDS_SIZE;
      atom.m_long = fp->size;
      entry.append( atom );

      atom.m_uds = UDS_MODIFICATION_TIME;
      atom.m_long = fp->modification_date;
      entry.append( atom );

      atom.m_uds = UDS_ACCESS;
    //  atom.m_long = fp->unixprivs.permissions;
    atom.m_long = S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
      entry.append( atom );

      atom.m_uds = UDS_USER;
      atom.m_str = fp->unixprivs.uid;
      entry.append( atom );

    atom.m_uds = KIO::UDS_USER;
    struct passwd * passwd;
    if ((passwd = getpwuid(fp->unixprivs.uid))) {
        atom.m_str = passwd->pw_name;;
    } else {
        atom.m_str = "unknown";
    }
    entry.append( atom );
    atom.m_uds = KIO::UDS_GROUP;
    entry.append( atom );

    return entry;
}
开发者ID:zach-klippenstein,项目名称:afpfs-ng,代码行数:57,代码来源:kafp.cpp

示例7: listRealDir

int kio_afpProtocol::listRealDir( const KURL & url ) 
{
  afpURL afpurl(url);
  int ret;
  unsigned int numfiles, total=0;
  int eod;
  struct afp_file_info_basic * fpb;
  struct afp_url afp_url;

  kdDebug(7101) << "*** list realdir" << endl ;

  QString kafpurl = url.url(0,0);
  afp_default_url(&afp_url);
  afp_parse_url(&afp_url,kafpurl,0);

  if (attachvolume(&afp_url)==false) return -1;

  QString localpath(afp_url.path);
  QString newpath = translated_path(localpath);

kdDebug(7101) << "Translated path is " << newpath << endl;

  DIR *dp = NULL;
  KDE_struct_dirent *ep;

  dp = opendir(newpath.data());

  if (dp==0) {
printf("error opening dir %s\n",newpath.data());
    return -1;
  }

  UDSEntry entry;
  KDE_struct_stat s;

  char curdir[PATH_MAX];

  getcwd(curdir,PATH_MAX-1);

  chdir(newpath.data());

  while ((ep=KDE_readdir(dp))!=0) {
printf("got file %s\n",ep->d_name);
    entry.clear();

    QString localpath(ep->d_name);
    ret = KDE_lstat(localpath,&s);
    entry=statToEntry(&s);

    UDSAtom atom;

    atom.m_uds = UDS_NAME;
    atom.m_str = ep->d_name;
    entry.append( atom );

    listEntry(entry,false);

  }
    listEntry(entry,true);
printf("done with readdir\n");
  closedir(dp);

  chdir(curdir);

#if 0
  while(1) {
  kdDebug(7101) << "*** about to readdir " << endl ;
    ret = afp_sl_readdir(&connection,NULL,NULL,&afp_url,total,10,&numfiles,
		&fpb,&eod);
    total+=numfiles;
    if (ret!=AFP_SERVER_RESULT_OKAY) break;

    for (unsigned int i=0;i<numfiles;i++) {
      entry=FPToEntry(fpb);

      listEntry (entry, false);
      fpb++;
    }

    if (eod) break;
  }
  listEntry (entry, true);
#endif

  finished();

  return 0;
}
开发者ID:zach-klippenstein,项目名称:afpfs-ng,代码行数:88,代码来源:kafp.cpp

示例8: listVolumes

bool kio_afpProtocol::listVolumes(const KURL & url)
{
  UDSEntry entry;
  struct afp_volume_summary vols[KIO_NUM_VOLS];
  int ret;
  struct afp_url afp_url;
  unsigned int num;
  QString kafpurl = url.url(0,0);
  afp_default_url(&afp_url);
  afp_parse_url(&afp_url,kafpurl,0);

    kdDebug(7101) << "*** list volumes " << endl ;
printf("lv1\n");

	if (afpLogin(&afp_url)) {
		kdDebug(7101) << "*** Cannot login, so can't list volumes" << endl ;
		return false;
	}

	ret = afp_sl_getvols(&afp_url,0,10,&num,vols);

	switch(ret) {
	case AFP_SERVER_RESULT_AFPFSD_ERROR:
		infoMessage(i18n("Could not continue, could not connect to afpfsd."));
		return false;
	case 0:
		break;
	default:
	     kdDebug(7101) << "problem with getvols, " << ret << endl;
	     return false;
	};

printf("got %d vols\n",num);

  struct afp_volume_summary *v;
  for (unsigned int i=0;i<num;i++) {
  //  char * name = data[i * AFP_VOLUME_NAME_LEN];
    v=&vols[i];
    char * name = v->volume_name_printable;
printf("volume: %s\n",name);

    entry.clear();
    UDSAtom atom;
    atom.m_uds = UDS_NAME;
    atom.m_str = name;
    entry.append( atom );

    atom.m_uds = KIO::UDS_FILE_TYPE;
    atom.m_long = S_IFDIR;
    entry.append( atom );

    atom.m_uds = KIO::UDS_ACCESS;
    atom.m_long = S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
    entry.append( atom );

    atom.m_uds = KIO::UDS_USER;
    atom.m_str = "root";
    entry.append( atom );
    atom.m_uds = KIO::UDS_GROUP;
    entry.append( atom );

    atom.m_uds = UDS_USER;
    atom.m_str = "root";
    entry.append( atom );

    atom.m_uds = UDS_GROUP;
    atom.m_str = "root";
    entry.append( atom );

    listEntry(entry,false);
  }
  listEntry(entry,true );
  statEntry( entry );

  return true;
}
开发者ID:zach-klippenstein,项目名称:afpfs-ng,代码行数:76,代码来源:kafp.cpp

示例9: stat

void kio_afpProtocol::stat(const KURL &url)
{

    kdDebug(7101) << "\n\nstat " << url.prettyURL() << endl;
    struct afp_url afp_url;
    QString kafpurl = url.url(0,0);
    afp_default_url(&afp_url);
    afp_parse_url(&afp_url,kafpurl,0);

    if (afpLogin(&afp_url)) {
       kdDebug(7101) << "*** Cannot login, so can't stat" << endl ;
       finished();
       return;
    }

    if (url.path().isEmpty()) {
kdDebug(7101) << "Just a server" << endl;
       statServer();
       finished();
       return;
    }

    afpURL afpurl(url);

    if (afpurl.afp_path().isEmpty()) {
       // We have just a volume
kdDebug(7101) << "Just a volume" << endl;
       statVolume();
       finished();
       return;
    }

    if (attachvolume(&afp_url)==false) {
    kdDebug(7101) << "could not attach in stat " << url.prettyURL() << endl;
       finished();
       return;
    }

    struct stat stat;
    int ret;

    ret = afp_sl_stat(NULL,NULL,&afp_url,&stat);

    UDSEntry entry;
// = statToEntry(&stat);
    UDSAtom atom;

    atom.m_uds = KIO::UDS_NAME;
    atom.m_str = url.fileName();
    entry.append( atom );

// Added
    atom.m_uds = KIO::UDS_FILE_TYPE;
    atom.m_long = S_IFDIR;
    entry.append( atom );

    atom.m_uds = KIO::UDS_ACCESS;
    atom.m_long = S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
    entry.append( atom );

    atom.m_uds = KIO::UDS_USER;
    atom.m_str = "root";
    entry.append( atom );
    atom.m_str = "root";
    atom.m_uds = KIO::UDS_GROUP;
    entry.append( atom );


    statEntry( entry );
    finished();
    return;
}
开发者ID:zach-klippenstein,项目名称:afpfs-ng,代码行数:72,代码来源:kafp.cpp

示例10: checkHost

int LANProtocol::checkHost(const QString& host)
{
   kdDebug(7101)<<"LAN::checkHost() "<<host<<endl;

   QString hostUpper=host.upper();
   HostInfo* hostInfo=m_hostInfoCache[hostUpper];
   if (hostInfo!=0)
   {
      kdDebug(7101)<<"LAN::checkHost() getting from cache"<<endl;
      //this entry is too old, we delete it !
      if ((time(0)-hostInfo->created)>m_maxAge)
      {
         kdDebug(7101)<<"LAN::checkHost() cache content too old, deleting it"<<endl;
         m_hostInfoCache.remove(hostUpper);
         hostInfo=0;
      }
   }
   if (hostInfo==0)
   {
      hostInfo=new HostInfo;
      in_addr ip;

      struct hostent *hp=gethostbyname(host.latin1());
      if (hp==0)
      {
         error( ERR_UNKNOWN_HOST, host.latin1() );
         delete hostInfo;
         return 0;
      }
      memcpy(&ip, hp->h_addr, sizeof(ip));

      for (int i=0; i<KIOLAN_MAX; i++)
      {
         int result(0);
         if (m_protocolInfo[i].enabled==PORTSETTINGS_DISABLE)
            result=0;
         else if (m_protocolInfo[i].enabled==PORTSETTINGS_PROVIDE)
            result=1;
         else if (m_protocolInfo[i].enabled==PORTSETTINGS_CHECK)
            result=checkPort(m_protocolInfo[i].ports,ip);

         //host not reachable
         if (result==-1)
         {
            delete hostInfo;
            hostInfo=0;
            error( ERR_UNKNOWN_HOST, host.latin1() );
            return 0;
         }
         hostInfo->services[i]=result;
      }
      hostInfo->created=time(0);
      m_hostInfoCache.insert(hostUpper,hostInfo);
   }
   //here hostInfo is always != 0
   if (hostInfo==0)
   {
      error( ERR_INTERNAL, "hostInfo==0" );
      return 0;
   }

   UDSEntry entry;
   for (int i=0; i<KIOLAN_MAX; i++)
   {
      if (hostInfo->services[i]==1)
      {
         kdDebug(7101)<<"LAN::checkHost(): Host ["<<hostUpper<<"] Service ["<<m_protocolInfo[i].name<<"]"<<endl;
         UDSAtom atom;
         // name
         atom.m_uds = KIO::UDS_NAME;
         atom.m_str = m_protocolInfo[i].name;
         entry.append( atom );
         // size
         atom.m_uds = KIO::UDS_SIZE;
         atom.m_long = 1024;
         entry.append(atom);
         // access permissions
         atom.m_uds = KIO::UDS_ACCESS;
         atom.m_long = S_IRUSR | S_IRGRP | S_IROTH ;
         //atom.m_long = S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
         entry.append(atom);
         // file type
         atom.m_uds = KIO::UDS_FILE_TYPE;
         if (strcmp(m_protocolInfo[i].name,"HTTP")==0)
         {
            // normal file -- if we called stat(2) on this,
            // this flag would be set in the st_mode field of struct stat
            atom.m_long=S_IFREG;
            entry.append(atom);

            // also define the mime-type for this file
            atom.m_uds = KIO::UDS_MIME_TYPE;
            atom.m_str="text/html";
            entry.append( atom );
         }
         else
         {
            // directory -- if we called stat(2) on this, then this
            // flag would be set in the st_mode field of the struct stat
            atom.m_long = S_IFDIR; // it is always a directory
//.........这里部分代码省略.........
开发者ID:serghei,项目名称:kde3-kdenetwork,代码行数:101,代码来源:kio_lan.cpp

示例11: rlanReadDataFromServer


//.........这里部分代码省略.........
      if (FD_ISSET(sockFD,&tmpFDs))
      {
         bytesRead=::read(sockFD,tmpBuf,64*1024);
         kdDebug(7101)<<"RLANProtocol::readDataFromServer: read "<<bytesRead<<" bytes"<<endl;

         if (bytesRead>0)
         {
            char *newBuf=new char[receivedBytes+bytesRead];
            if (receiveBuffer!=0) memcpy(newBuf,receiveBuffer,receivedBytes);
            memcpy(newBuf+receivedBytes,tmpBuf,bytesRead);
            receivedBytes+=bytesRead;
            if (receiveBuffer!=0) delete [] receiveBuffer;
            receiveBuffer=newBuf;
         }
      }
   } while (bytesRead>0);
   ::close(sockFD);


   if ((bytesRead<0) || (receivedBytes<4))
   {
      delete [] receiveBuffer;
      error(ERR_CANNOT_OPEN_FOR_READING,socketname);
      return 0;
   }

   UDSEntry entry;

   char *currentBuf=receiveBuffer;
   int bytesLeft=receivedBytes;
   //this should be large enough for a name
   char tmpName[4*1024];
   //this should be large enough for the hostname
   char tmpHostname[4*1024];
   while (bytesLeft>0)
   {
      int tmpIP=2;
      tmpName[0]='\0';
      if ((memchr(currentBuf,0,bytesLeft)==0) || (memchr(currentBuf,int('\n'),bytesLeft)==0))
      {
         delete [] receiveBuffer;
         error(ERR_INTERNAL_SERVER,i18n("Received unexpected data from %1").arg(socketname));
         return 0;
      }
      kdDebug(7101)<<"RLANProtocol::readDataFromServer: processing "<<currentBuf;
      //since we check for 0 and \n with memchr() we can be sure
      //at this point that tmpBuf is correctly terminated
      int length=strlen(currentBuf)+1;
      if (length<(4*1024))
         sscanf(currentBuf,"%u %s\n",&tmpIP,tmpName);
      else
      {
        kdDebug(7101)<<"RLANProtocol::readDataFromServer:  buffer overflow attempt detected, aborting"<<endl;
        break;
      }

      bytesLeft-=length;
      currentBuf+=length;
      if ((bytesLeft==0) && ((tmpIP==0) ||(tmpIP==1)) && (strstr(tmpName,"succeeded")!=0))
      {
         kdDebug(7101)<<"RLANProtocol::readDataFromServer: succeeded"<<endl;
      }
      else if (tmpIP!=2)
      {
         kdDebug(7101)<<"RLANProtocol::readDataFromServer: listing host: "<<tmpName<<" with ip: "<<tmpIP<<endl;
         UDSAtom atom;

         atom.m_uds = KIO::UDS_NAME;
         if (m_shortHostnames)
         {
            if (inet_addr(tmpName)!=-1)
               atom.m_str=tmpName;
            else
            {
               sscanf(tmpName,"%[^.]",tmpHostname);
               kdDebug(7101)<<"LANProtocol::lanReadDataFromServer: Hostname of " << tmpName <<  " is " << tmpHostname << "\n";
               atom.m_str = tmpHostname;
            }
         }
         else
            atom.m_str = tmpName;
         entry.append( atom );
         atom.m_uds = KIO::UDS_SIZE;
         atom.m_long = 1024;
         entry.append(atom);
         atom.m_uds = KIO::UDS_ACCESS;
         atom.m_long = S_IRUSR | S_IRGRP | S_IROTH ;
         //atom.m_long = S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
         entry.append(atom);
         atom.m_uds = KIO::UDS_FILE_TYPE;
         atom.m_long = S_IFDIR; // it is always a directory
         entry.append( atom );
         listEntry(entry,false);
      }
   }

   listEntry( entry, true ); // ready
   delete [] receiveBuffer;
   return 1;
}
开发者ID:serghei,项目名称:kde3-kdenetwork,代码行数:101,代码来源:kio_lan.cpp

示例12: lanReadDataFromServer


//.........这里部分代码省略.........
      select(m_iSock+1,&tmpFDs,0,0,&tv);
      if (FD_ISSET(m_iSock,&tmpFDs))
      {
         bytesRead=read(tmpBuf,64*1024);
         kdDebug(7101)<<"LANProtocol::lanReadDataFromServer: read "<<bytesRead<<" bytes"<<endl;

         if (bytesRead>0)
         {
            char *newBuf=new char[receivedBytes+bytesRead];
            if (receiveBuffer!=0) memcpy(newBuf,receiveBuffer,receivedBytes);
            memcpy(newBuf+receivedBytes,tmpBuf,bytesRead);
            receivedBytes+=bytesRead;
            if (receiveBuffer!=0) delete [] receiveBuffer;
            receiveBuffer=newBuf;
         }
      }
   } while (bytesRead>0);
   closeDescriptor();
   if ((bytesRead<0) || (receivedBytes<4))
   {
      delete [] receiveBuffer;
      error(ERR_INTERNAL_SERVER,i18n("Received unexpected data from %1").arg(m_currentHost));
      return 0;
   }

   UDSEntry entry;

   char *currentBuf=receiveBuffer;
   int bytesLeft=receivedBytes;
   //this should be large enough for a name
   char tmpName[4*1024];
   //this should be large enough for the hostname
   char tmpHostname[4*1024];
   while (bytesLeft>0)
   {
      int tmpIP=2;
      tmpName[0]='\0';
      if ((memchr(currentBuf,0,bytesLeft)==0) || (memchr(currentBuf,int('\n'),bytesLeft)==0))
      {
         delete [] receiveBuffer;
         error(ERR_INTERNAL_SERVER,i18n("Received unexpected data from %1").arg(m_currentHost));
         return 0;
      }
      kdDebug(7101)<<"LANProtocol::lanReadDataFromServer: processing "<<currentBuf;
      //since we check for 0 and \n with memchr() we can be sure
      //at this point that tmpBuf is correctly terminated
      int length=strlen(currentBuf)+1;
      if (length<(4*1024))
         sscanf(currentBuf,"%u %s\n",&tmpIP,tmpName);
      else
      {
        kdDebug(7101)<<"LANProtocol::lanReadDataFromServer:  buffer overflow attempt detected, aborting"<<endl;
        break;
      }

      bytesLeft-=length;
      currentBuf+=length;
      if ((bytesLeft==0) && ((tmpIP==0) ||(tmpIP==1)) && (strstr(tmpName,"succeeded")!=0))
      {
         kdDebug(7101)<<"LANProtocol::lanReadDataFromServer: succeeded"<<endl;
      }
      else if (tmpIP!=2)
      {
         kdDebug(7101)<<"LANProtocol::lanReadDataFromServer: listing host: "<<tmpName<<" with ip: "<<tmpIP<<endl;
         UDSAtom atom;

         atom.m_uds = KIO::UDS_NAME;
         if (m_shortHostnames)
         {
            if (inet_addr(tmpName)!=-1)
               atom.m_str=tmpName;
            else
            {
               sscanf(tmpName,"%[^.]",tmpHostname);
               kdDebug(7101)<<"LANProtocol::lanReadDataFromServer: Hostname of " << tmpName <<  " is " << tmpHostname << "\n";
               atom.m_str = tmpHostname;
            }
         }
         else
            atom.m_str = tmpName;

         entry.append( atom );
         atom.m_uds = KIO::UDS_SIZE;
         atom.m_long = 1024;
         entry.append(atom);
         atom.m_uds = KIO::UDS_ACCESS;
         atom.m_long = S_IRUSR | S_IRGRP | S_IROTH ;
         //atom.m_long = S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
         entry.append(atom);
         atom.m_uds = KIO::UDS_FILE_TYPE;
         atom.m_long = S_IFDIR; // it is always a directory
         entry.append( atom );
         listEntry(entry,false);
      }
   }

   listEntry( entry, true ); // ready
   delete [] receiveBuffer;
   return 1;
}
开发者ID:serghei,项目名称:kde3-kdenetwork,代码行数:101,代码来源:kio_lan.cpp

示例13: browse_stat_path

//---------------------------------------------------------------------------
bool SMBSlave::browse_stat_path(const SMBUrl &_url, UDSEntry &udsentry, bool ignore_errors)
// Returns: true on success, false on failure
{
    UDSAtom udsatom;

    SMBUrl url = _url;

    if(cache_stat(url, &st) == 0)
    {
        if(!S_ISDIR(st.st_mode) && !S_ISREG(st.st_mode))
        {
            kdDebug(KIO_SMB) << "SMBSlave::browse_stat_path mode: " << st.st_mode << endl;
            warning(i18n("%1:\n"
                         "Unknown file type, neither directory or file.")
                        .arg(url.prettyURL()));
            return false;
        }

        udsatom.m_uds = KIO::UDS_FILE_TYPE;
        udsatom.m_long = st.st_mode & S_IFMT;
        udsentry.append(udsatom);

        udsatom.m_uds = KIO::UDS_SIZE;
        udsatom.m_long = st.st_size;
        udsentry.append(udsatom);

        udsatom.m_uds = KIO::UDS_USER;
        uid_t uid = st.st_uid;
        struct passwd *user = getpwuid(uid);
        if(user)
            udsatom.m_str = user->pw_name;
        else
            udsatom.m_str = QString::number(uid);
        udsentry.append(udsatom);

        udsatom.m_uds = KIO::UDS_GROUP;
        gid_t gid = st.st_gid;
        struct group *grp = getgrgid(gid);
        if(grp)
            udsatom.m_str = grp->gr_name;
        else
            udsatom.m_str = QString::number(gid);
        udsentry.append(udsatom);

        udsatom.m_uds = KIO::UDS_ACCESS;
        udsatom.m_long = st.st_mode & 07777;
        udsentry.append(udsatom);

        udsatom.m_uds = UDS_MODIFICATION_TIME;
        udsatom.m_long = st.st_mtime;
        udsentry.append(udsatom);

        udsatom.m_uds = UDS_ACCESS_TIME;
        udsatom.m_long = st.st_atime;
        udsentry.append(udsatom);

        udsatom.m_uds = UDS_CREATION_TIME;
        udsatom.m_long = st.st_ctime;
        udsentry.append(udsatom);
    }
    else
    {
        if(!ignore_errors)
        {
            if(errno == EPERM || errno == EACCES)
                if(checkPassword(url))
                {
                    redirection(url);
                    return false;
                }

            reportError(url);
        }
        else if(errno == ENOENT || errno == ENOTDIR)
        {
            warning(i18n("File does not exist: %1").arg(url.url()));
        }
        kdDebug(KIO_SMB) << "SMBSlave::browse_stat_path ERROR!!" << endl;
        return false;
    }

    return true;
}
开发者ID:serghei,项目名称:kde3-kdebase,代码行数:84,代码来源:kio_smb_browse.cpp

示例14: listDir

//===========================================================================
void SMBSlave::listDir(const KURL &kurl)
{
    kdDebug(KIO_SMB) << "SMBSlave::listDir on " << kurl << endl;

    // check (correct) URL
    KURL url = checkURL(kurl);
    // if URL is not valid we have to redirect to correct URL
    if(url != kurl)
    {
        redirection(url);
        finished();
        return;
    }

    m_current_url = kurl;

    int dirfd;
    struct smbc_dirent *dirp = NULL;
    UDSEntry udsentry;
    UDSAtom atom;

    dirfd = smbc_opendir(m_current_url.toSmbcUrl());
    kdDebug(KIO_SMB) << "SMBSlave::listDir open " << m_current_url.toSmbcUrl() << " " << m_current_url.getType() << " " << dirfd << endl;
    if(dirfd >= 0)
    {
        do
        {
            kdDebug(KIO_SMB) << "smbc_readdir " << endl;
            dirp = smbc_readdir(dirfd);
            if(dirp == 0)
                break;

            // Set name
            atom.m_uds = KIO::UDS_NAME;
            QString dirpName = QString::fromUtf8(dirp->name);
            // We cannot trust dirp->commentlen has it might be with or without the NUL character
            // See KDE bug #111430 and Samba bug #3030
            QString comment = QString::fromUtf8(dirp->comment);
            if(dirp->smbc_type == SMBC_SERVER || dirp->smbc_type == SMBC_WORKGROUP)
            {
                atom.m_str = dirpName.lower();
                atom.m_str.at(0) = dirpName.at(0).upper();
                if(!comment.isEmpty() && dirp->smbc_type == SMBC_SERVER)
                    atom.m_str += " (" + comment + ")";
            }
            else
                atom.m_str = dirpName;

            kdDebug(KIO_SMB) << "dirp->name " << dirp->name << " " << dirpName << " '" << comment << "'"
                             << " " << dirp->smbc_type << endl;

            udsentry.append(atom);
            if(atom.m_str.upper() == "IPC$" || atom.m_str == "." || atom.m_str == ".." || atom.m_str.upper() == "ADMIN$"
               || atom.m_str.lower() == "printer$" || atom.m_str.lower() == "print$")
            {
                //            fprintf(stderr,"----------- hide: -%s-\n",dirp->name);
                // do nothing and hide the hidden shares
            }
            else if(dirp->smbc_type == SMBC_FILE)
            {
                // Set stat information
                m_current_url.addPath(dirpName);
                browse_stat_path(m_current_url, udsentry, true);
                m_current_url.cd("..");

                // Call base class to list entry
                listEntry(udsentry, false);
            }
            else if(dirp->smbc_type == SMBC_DIR)
            {
                m_current_url.addPath(dirpName);
                browse_stat_path(m_current_url, udsentry, true);
                m_current_url.cd("..");

                // Call base class to list entry
                listEntry(udsentry, false);
            }
            else if(dirp->smbc_type == SMBC_SERVER || dirp->smbc_type == SMBC_FILE_SHARE)
            {
                // Set type
                atom.m_uds = KIO::UDS_FILE_TYPE;
                atom.m_long = S_IFDIR;
                udsentry.append(atom);

                // Set permissions
                atom.m_uds = KIO::UDS_ACCESS;
                atom.m_long = (S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH);
                udsentry.append(atom);

                if(dirp->smbc_type == SMBC_SERVER)
                {
                    atom.m_uds = KIO::UDS_URL;
                    // QString workgroup = m_current_url.host().upper();
                    KURL u("smb:/");
                    u.setHost(dirpName);
                    atom.m_str = u.url();

                    // when libsmbclient knows
                    // atom.m_str = QString("smb://%1?WORKGROUP=%2").arg(dirpName).arg(workgroup.upper());
//.........这里部分代码省略.........
开发者ID:serghei,项目名称:kde3-kdebase,代码行数:101,代码来源:kio_smb_browse.cpp


注:本文中的UDSEntry::append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。