예제 #1
0
파일: hcache.c 프로젝트: srg-imperial/mutt
HEADER *
mutt_hcache_restore(const unsigned char *d, HEADER ** oh)
{
  int off = 0;
  HEADER *h = mutt_new_header();
  int convert = !Charset_is_utf8;

  /* skip validate */
  off += sizeof (validate);

  /* skip crc */
  off += sizeof (unsigned int);

  memcpy(h, d + off, sizeof (HEADER));
  off += sizeof (HEADER);

  h->env = mutt_new_envelope();
  restore_envelope(h->env, d, &off, convert);

  h->content = mutt_new_body();
  restore_body(h->content, d, &off, convert);

  restore_char(&h->maildir_flags, d, &off, convert);

  /* this is needed for maildir style mailboxes */
  if (oh)
  {
    h->old = (*oh)->old;
    h->path = safe_strdup((*oh)->path);
    mutt_free_header(oh);
  }

  return h;
}
예제 #2
0
string finger_user(string who) {
    object link, body;
    mixed tmp1, tmp2, tmp3, tmp4, tmp5;
    string msg;
    mapping mail_stat;
    int hibernate;

    link = restore_data(who);
    if (link) body = restore_body(who);

    if (!link || !body) {
	if (sscanf(who, "(%s)", who))
	    return finger_group(who);
	return "Finger: There is no such user.\n";
    }

    msg = LINE1;

    // Line 1: Fingerguy the Utter Novice (Chaotic Neutral)
    if (link->query("wizard")) {
	string al, title = body->getenv( "TITLE" );
	al = body->query("al_title");
	if (!al || al=="") {
	    msg += body->query_title() + "\n";
	} else {
	    if (!title) title = "$N the New Wizard ($A)";
	    title = replace_string(title, "$N", body->query("cap_name"));
	    title = replace_string(title, "$A", al);
	    msg += title + "\n";
	}
    } else
	msg += body->query_title() + "\n";

    // Line 2: Male Human Mage [Level 5]
    // or:    Male Human Necromancer [Lesser Power of Prime]
    msg += capitalize(body->query("gender"));
    msg += " "+capitalize(body->query("race"));

    mail_stat = link->query("Class");
    if (mail_stat) {
	tmp1 = (values(mail_stat))[0];
	msg += ( " " +  capitalize(tmp1) );
    }

    if (wizardp(TP)) {
	if (link->query("wizard")) {
	    if (member_group(body->query("name"), "ambassador")) {
		tmp1 = "Ambassador";
		tmp2 = body->query("ambassador");
		if ((tmp2 != 0) && (tmp2 != ""))
		    tmp1 = tmp1 + " of " + capitalize(tmp2);
	    } else {
		tmp1 = DOMAIN_D->query_domain(link);
		tmp2 = DOMAIN_D->query_domain_level(link);
		if ((tmp1 == 0) || (tmp1 == ""))
		    tmp1 = "Domainless "+tmp2;
		else
		    tmp1 = tmp2 + " of " + tmp1 + " Domain";
	    }
	} else {
	    tmp1 = "Level " + link->query("level");
	}
	tmp1 = " [" + tmp1 + "]\n";
	msg += tmp1;
    } else msg += "\n";

    // Line 3: Gang allegience: The Machiavellian Menagerie
    // or: The Admin (Leader)
    
	tmp1 = "Gang allegience: ";
	tmp2 = body->query("gang");

	if (tmp2) {
	    mail_stat = GANG_D->get_list_map();
	    if (mail_stat[tmp2] == body->query("name"))
	        tmp1 += "Leader of "+cap_all_words(tmp2);
	    else
	        tmp1 += "Member of "+cap_all_words(tmp2);
	       
	} else {
	    tmp1 += "none";
	}
	
   	msg += tmp1 + "\n";

    // Line 4 : Married to Whoever
    tmp1 = body->query("spouse");
    if (tmp1) {
	tmp1 = capitalize(tmp1);
	msg += "Married to "+tmp1+"\n";
    }

    // Line 5 : A cool line to make it all very pretty.
    msg += LINE2;

    // Line 6: In Real Life: Matthew A. Titmus
    // or: In Real Life: ?
    tmp2 = "In Real Life: ";
    if (tmp3 = (string)link->RNAME)
	tmp2 += extract(tmp3, 0, 22);
    else
	tmp2 += "?";

    msg += "Status: ";
    if (member_group(body->query("name"), "root"))
	msg += "Administrator\n";
    else if (member_group(body->query("name"), "adminaccess"))
	msg += "Elder\n";
    else if (member_group(body->query("name"), "ambassador"))
	msg += "Ambassador\n";
    else if (link->query("wizard"))
	msg += "Immortal\n";
    else
	msg += "Player\n";

    if (body->query("email_visible"))
	tmp1 = "[Public]";
    else
	tmp1 = "[Private]";

    if (adminp(TP) || 
      body->query("name")==TP->query("name")) {
	tmp1 = (string)link->query("email")+" "+tmp1;
    } else {
	if (body->query("email_visible")) {
	    tmp1 = (string)link->query("email");
	} else {
	    tmp1 = "[Private]";
	}
    }

    if (tmp1) msg += "Email address: " + tmp1 + "\n";

    tmp1 = (string)link->query("URL");
    if (tmp1) msg += "URL: " + tmp1 + "\n";

    hibernate = (int)link->query("hibernate");

    if (hibernate && time() < hibernate)
	msg += "\n\t[In hibernation until " + ctime(hibernate) + "]\n\n";

    tmp1 = find_player(who);
    if (tmp1) {
	if (!filter_users(tmp1))
	    tmp1 = 0;
    }

    if (!link->query("last_on"))
	msg += (tmp1 ? "On since: " : "Last on: ") + "Unavailable";
    else
	msg += ((tmp1 && !tmp1->query("npc")) ? "On since: " : "Last on: ") +
	ctime((int)link->query("last_on")) ;

    if (wizardp(TP)) 
	msg += ( " from " + (string)link->query("ip") + " \n" );
    else
	msg += "\n";

    if (tmp1) {
	tmp1 = query_idle_string(tmp1, 1);
	if (strlen(tmp1) > 0)
	    msg += tmp1 + "\n";
    }

    mail_stat = (mapping)MAILBOX_D->mail_status(who);
    if (mail_stat["unread"])
	msg += sprintf("%s has not read %d of their %d piece%s of mail.\n",
	  capitalize(who), mail_stat["unread"], mail_stat["total"],
	  (mail_stat["total"] == 1 ? "" : "s"));
    else {
	msg += "No unread mail" ;
	if(this_player()) {
	    if (adminp(getuid(this_player()))) {
		//  msg += " ("+mail_stat["total"]+" pieces)" ;
		msg += sprintf(" (%d piece%s)", mail_stat["total"], (mail_stat["total"] == 1 ? "" : "s"));
	    }
	}
	msg += ".\n" ;
    }

    if (link->query("wizard")) {
	tmp1 = user_path(who) + ".project";
	if (file_size(tmp1) >= 0)
	    msg += "Project: " + read_file(tmp1);

	tmp1 = user_path(who) + ".plan";
	if (file_size(tmp1) >= 0) {
	    msg += "Plan:\n" + read_file(tmp1);
	} else {
	    msg += "No Plan.\n";
	}
    } else {
	if (body->query("session"))
	    tmp1 = iwrap("Session: "+body->query("session"));
	else
	    tmp1 = "No Session.\n";

	msg += tmp1;
    }

    msg += LINE1;

    if (!find_player(who) || !interactive(find_player(who))) {
	link->remove();
	// Some names like .foo weren't getting away.
	if(link) destruct(link);
	if(link) log_file("fingerdest",sprintf("Connection of %s not "+
		"dested by finger daemon, on %s.\n", link->query("name"), 
		ctime(time())));

	if(body) destruct(body);
	if(body) log_file("fingerdest",sprintf("Connection of %s not "+
		"dested by finger daemon, on %s.\n", body->query("name"), 
		ctime(time())));
    }

    return "\n" + msg + "\n";
}