예제 #1
0
int make_list_string(const DirEntry &entr,GridFTP_Commands::list_mode_t mode,
                     unsigned char* buf,int size,const char *prefix) {
  std::string str;
  switch(mode) {
    case GridFTP_Commands::list_mlsd_mode: {
      if(entr.is_file) { str+="type=file;"; }
      else { str+="type=dir;"; };
      str+="size="+Arc::tostring(entr.size)+";";
      str+="modify="+timetostring_rfc3659(entr.modified)+";";
      str+="perm=";
      if(entr.is_file) {
        if(entr.may_append) str+="a";
        if(entr.may_delete) str+="d";
        if(entr.may_rename) str+="f";
        if(entr.may_read)   str+="r";
        if(entr.may_write)  str+="w";
      }
      else {
        if(entr.may_create) str+="c";
        if(entr.may_delete) str+="d";
        if(entr.may_chdir)  str+="e";
        if(entr.may_rename) str+="f";
        if(entr.may_dirlist)str+="l";
        if(entr.may_purge)  str+="p";
      };
      str+="; ";
      str+=prefix+entr.name;
    }; break;
    case GridFTP_Commands::list_list_mode: {
      if(entr.is_file) {
        str="-------   1 user     group  "+timetostring(entr.modified)+" "+
            Arc::tostring(entr.size,16)+"  "+prefix+entr.name;
      }
      else {
        str="d------   1 user     group  "+timetostring(entr.modified)+" "+
            Arc::tostring(entr.size,16)+"  "+prefix+entr.name;
      };
    }; break;
    case GridFTP_Commands::list_nlst_mode: {
      str=prefix+entr.name;
    }; break;
    default: {
    }; break;
  };
  int len = str.length();
  if(len > (size-3)) { str.resize(size-6); str+="..."; len=size-3; };
  strcpy((char*)buf,str.c_str()); 
  buf[len]='\r'; len++; buf[len]='\n'; len++; buf[len]=0;
  return len; 
}
예제 #2
0
void display::updatedt( const ts &dt, byte updatemask, bool timevalid )
{
	char	lcdbuffer[13], *lbp( lcdbuffer );

	if( updatemask & 0x38 ) {
		setCursor(0,0);
		datetostring( lbp, dt.year, dt.mon, dt.mday, dt.wday, 0, true, '.', '/' ); *lbp = 0;
		print( lcdbuffer );
	}

	if( updatemask & 7 ) {
		setCursor(0,1);
		lbp = lcdbuffer;
		timetostring( lbp, dt.hour, dt.min, dt.sec, ':' ); *lbp++ = 0;
		print( lcdbuffer);
	}

	if(updatemask & 0x40) {
		setCursor(7,0);
		print(timevalid ? ' ' : '!');
	}

}