예제 #1
0
/*
 * announce
 *
 * Usage: announce message
 *
 *   Broadcasts your message to all logged on users.  Announcements reach all
 *   users and cannot be censored in any way (such as by "set shout 0").
 */
int com_announce(int p, param_list param)
{
	struct player *pp = &player_globals.parray[p];
	int p1;
	int count = 0;

	if (!printablestring(param[0].val.string)) {
		pprintf(p, "Your message contains some unprintable character(s).\n");
		return COM_OK;
	}
	for (p1 = 0; p1 < player_globals.p_num; p1++) {
		if (p1 == p)
			continue;
		if (player_globals.parray[p1].status != PLAYER_PROMPT)
			continue;
		count++;
		pprintf_prompt(p1, "\n\n    **ANNOUNCEMENT** from %s: %s\n\n", pp->name, param[0].val.string);
	}
	pprintf(p, "\n(%d) **ANNOUNCEMENT** from %s: %s\n\n", count, pp->name, param[0].val.string);
	return COM_OK;
}
예제 #2
0
int parse_url( int history_file, double filever, int currrecoff, char *delim, int filesize, char *type, std::vector< URLRec * > &urls  ) {
  char fourbytes[4];
  char hashrecflagsstr[4];
  char eightbytes[8];
  char chr;
  int filenameoff;
  int httpheadersoff;
  int urloff;
  int i;
  int reclen;
  int dirnameoff;
  time_t modtime;
  time_t accesstime;
  char ascmodtime[26], ascaccesstime[26];
  char dirname[9];
  char *url;
  char *filename;
  char *httpheaders;
  int year, mon;
  struct tm *accesstm, *modtm;

  pread( history_file, fourbytes, 4, currrecoff+4 );
  reclen = bah_to_i( fourbytes, 4 )*BLOCK_SIZE; 

  pread( history_file, eightbytes, 8, currrecoff+8 );
  modtime = win_time_to_unix( eightbytes );
  
  pread( history_file, eightbytes, 8, currrecoff+16 );
  accesstime = win_time_to_unix( eightbytes );
 
  accesstm = localtime( &accesstime );
  year = accesstm->tm_year + 1900;
  mon = accesstm->tm_mon + 1;
  sprintf( ascaccesstime, "%02d/%02d/%02d %02d:%02d:%02d", mon, accesstm->tm_mday, year, accesstm->tm_hour, accesstm->tm_min, accesstm->tm_sec );

  modtm = localtime( &modtime );
  year = modtm->tm_year + 1900;
  mon = modtm->tm_mon + 1;
  sprintf( ascmodtime, "%02d/%02d/%02d %02d:%02d:%02d", mon, modtm->tm_mday, year, modtm->tm_hour, modtm->tm_min, modtm->tm_sec );
  
  if (accesstime == 0) {
    ascaccesstime[0] = '\0';
  }

  if (modtime == 0) {
    ascmodtime[0] = '\0';
  }
  
  url = (char *)malloc( reclen+1 );

  if (filever >= 5) {
    pread( history_file, &chr, 1, currrecoff+0x34 );
  } else {
    pread( history_file, &chr, 1, currrecoff+0x38 );    
  }
  urloff = (unsigned char)chr;

  i = 0;
  pread( history_file, &chr, 1, currrecoff+urloff );
  while ( chr != '\0' && currrecoff+urloff+i+1 < filesize ) {
    url[i] = chr;
    pread( history_file, &chr, 1, currrecoff+urloff+i+1 );
    i++; 
  } 
  url[i] = '\0';

  filename = (char *)malloc( reclen+1 );

  if (filever >= 5) {
    pread( history_file, fourbytes, 4, currrecoff+0x3C );
  } else {
    pread( history_file, fourbytes, 4, currrecoff+0x40 );
  }
  filenameoff = bah_to_i( fourbytes, 4 ) + currrecoff; 

  i = 0;
  if (filenameoff > currrecoff+0x3C) {
    pread( history_file, &chr, 1, filenameoff );
    while ( chr != '\0' && filenameoff+i+1 < filesize ) {
      filename[i] = chr;
      pread( history_file, &chr, 1, filenameoff+i+1 );
      i++; 
    } 
  }
  filename[i] = '\0';

  if (filever >= 5.2) {
    pread( history_file, &chr, 1, currrecoff+0x38 );
  } else if (filever >= 5) {
    pread( history_file, &chr, 1, currrecoff+0x39 );
  } else {
    pread( history_file, &chr, 1, currrecoff+0x3C );
  }
  dirnameoff = (unsigned char)chr;

  if (0x50+(12*dirnameoff)+8 < filesize) {
    pread( history_file, dirname, 8, 0x50+(12*dirnameoff) );
    dirname[8] = '\0';
  } else {
    dirname[0] = '\0';
  }

  httpheaders = (char *)malloc( reclen+1 );

  if (filever >= 5) {
    pread( history_file, fourbytes, 4, currrecoff+0x44 );
  } else {
    pread( history_file, fourbytes, 4, currrecoff+0x48 );
  }
  httpheadersoff = bah_to_i( fourbytes, 4 ) + currrecoff; 

  i = 0;
  if (httpheadersoff > currrecoff+0x44) {
    pread( history_file, &chr, 1, httpheadersoff );

    while ( chr != '\0' && httpheadersoff+i+1 < currrecoff+reclen && httpheadersoff+i+1 < filesize ) {
      httpheaders[i] = chr;
      pread( history_file, &chr, 1, httpheadersoff+i+1 );
      i++; 
    }
  } 
  httpheaders[i] = '\0';
 
  printablestring( type );
  printablestring( url );
  printablestring( ascmodtime );
  printablestring( ascaccesstime );
  printablestring( filename );
  printablestring( dirname );
  printablestring( httpheaders );

  if (type[3] == ' ') {
    type[3] = '\0';
  }

  URLRec *urlrec = new URLRec(type, url, ascmodtime, ascaccesstime, filename, dirname, httpheaders);
  urls.push_back(urlrec);


  type[0] = '\0';
  dirname[0] = '\0';
  ascmodtime[0] = '\0';
  ascaccesstime[0] = '\0';

  free( url );
  free( filename );
  free( httpheaders );
}
예제 #3
0
int parse_redr( int history_file, double filever, int currrecoff, char *delim, int filesize, char *type, std::vector< URLRec * > &urls ) {
  char fourbytes[4];
  char hashrecflagsstr[4];
  char chr;
  int filenameoff;
  int httpheadersoff;
  int i;
  int reclen;
  int dirnameoff;
  time_t modtime;
  time_t accesstime;
  char *url;
  char *filename;
  char *httpheaders;
  char ascmodtime[26], ascaccesstime[26];
  char dirname[9];


  pread( history_file, fourbytes, 4, currrecoff+4 );
  reclen = bah_to_i( fourbytes, 4 )*BLOCK_SIZE; 

  url = (char *)malloc( reclen+1 );
            
  i = 0;
  pread( history_file, &chr, 1, currrecoff+0x10 );
  while ( chr != '\0' && currrecoff+0x10+i+1 < filesize ) {
    url[i] = chr;
    pread( history_file, &chr, 1, currrecoff+0x10+i+1 );
    i++; 
  } 
  url[i] = '\0';

  filename = (char *)malloc( 1 );
  filename[0] = '\0';

  httpheaders = (char *)malloc( 1 );
  httpheaders[0] = '\0';

  dirname[0] = '\0';

  ascmodtime[0] = '\0';
  ascaccesstime[0] = '\0';
  dirname[0] = '\0';

  printablestring( type );
  printablestring( url );
  printablestring( ascmodtime );
  printablestring( ascaccesstime );
  printablestring( filename );
  printablestring( dirname );
  printablestring( httpheaders );

  URLRec *urlrec = new URLRec(type, url, ascmodtime, ascaccesstime, filename, dirname, httpheaders);
  urls.push_back(urlrec);

  type[0] = '\0';

  free( url );
  free( filename );
  free( httpheaders );
}