示例#1
0
文件: set.c 项目: Shea690901/gurbalib
void main( string str ) {
  string *names;
  string name;
  string value;
  int i;

  if( !str || str == "" ) {
    /* Print out the list */
    names = this_player()->query_env_indices();
    for( i = 0; i < sizeof( names ); i++ ) {
      out_unmod( names[i] + "=" + this_player()->query_env( names[i] ) + "\n" ); 
    }
  } else {
    if( sscanf( str, "%s %s", name, value ) != 2 ) {
      write( "Usage: set <variable> <value>\n" );
      return;
    } else {
      if( str2val( value ) != -1 ) {
	/* We've got a value */
	this_player()->set_env( name, str2val(value) );
      } else {
	this_player()->set_env( name, value );
      }
    }
  }
}
示例#2
0
int cat_file(string filename) {
   int i, sz;
   string *lines;

   argcheck(filename, 1, "string");

   i = file_exists(filename);
   if (!i) {
      write("No such file.\n");
      return 0;
   }
   if (i == -1) {
      write("Unable to cat directories.\n");
      return 0;
   }
   lines = explode(read_file(filename), "\n");
   for (i = 0, sz = sizeof(lines); i < sz; i++) {
      out_unmod(lines[i] + "\n");
   }
   return 1;
}