Exemplo n.º 1
0
int pfs_delete(const char *filename)
{
	char spacket[BUFFER_SIZE]; //Buffer for client data
	strcpy(spacket,"DELETE ");
	strcat(spacket, filename);
	strcat(spacket," END.");
	if (send(mmFD, spacket, sizeof(spacket), 0) == -1)	//DELETE pfs_file1 END.
		perror("Error in sending!");
	char rpacket[BUFFER_SIZE] = ""; //Buffer for client data
	//int size =
	MMR(rpacket, BUFFER_SIZE);//DELETE project2_2 fsoffset sw END.

	//char buf[] = "";
	int fnI = findspace(rpacket, 0, 1); //project2_2
	int fsI = findspace(rpacket, fnI, 1); //0
	int swI = findspace(rpacket, fsI, 1); //4
	int endI = findspace(rpacket, swI, 1); //w
	int os = str2int(rpacket+fsI, swI-fsI-1);
	int sw = str2int(rpacket+swI, endI-swI-1);

	int i;
	for(i=0; i<sw; i++)
	{//Send for each FSs -> DELETE pfs_file1 END.
		if (send(fs[(i+os)%sw].fd, spacket, sizeof(spacket), 0) == -1)
			perror("Error in sending!");
	}

	return 0;
}
Exemplo n.º 2
0
void cavern_level(void)
{
    int i,fx,fy,tx,ty,t,l,e;
    char rsi;

    Level->numrooms = 1;

    if ((Current_Dungeon == E_CAVES) && (Level->depth == CAVELEVELS))
        rsi = RS_GOBLINKING;
    else rsi = RS_CAVERN;
    t = random_range((Level->level_length)/2);
    l = random_range((Level->level_width)/2);
    e = random_range((Level->level_width)/8)+(Level->level_width)/8;
    build_square_room(t,l,e,rsi,0);

    for (i=0; i<16; i++) {
        findspace(&tx,&ty,-1);
        fx = random_range((Level->level_width)-2)+1;
        fy = random_range((Level->level_length)-2)+1;
        straggle_corridor(fx,fy,tx,ty,FLOOR,RS_CORRIDOR);
    }
    while (random_range(3)==1) {
        findspace(&tx,&ty,-1);
        fx = random_range((Level->level_width)-2)+1;
        fy = random_range((Level->level_length)-2)+1;
        straggle_corridor(fx,fy,tx,ty,WATER,RS_PONDS);
    }
    if (Current_Dungeon == E_CAVES) {
        if ((Level->depth == CAVELEVELS) && (State.getCompletedCaves() == false)) {
            findspace(&tx,&ty,-1);
            Level->mlist = ((MonsterList*) checkmalloc(sizeof(MonsterList)));
            Level->mlist->next = NULL;
            Level->mlist->monster =
                Level->site[tx][ty].creature =
                    ((Monster*) make_creature(GOBLIN_KING)); /* goblin king */
            Level->mlist->monster->x = tx;
            Level->mlist->monster->y = ty;
        }
    }
    else if (Current_Environment == E_VOLCANO) {
        if (Level->depth == VOLCANOLEVELS) {
            findspace(&tx,&ty,-1);
            Level->mlist = ((MonsterList*) checkmalloc(sizeof(MonsterList)));
            Level->mlist->next = NULL;
            Level->mlist->monster =
                Level->site[tx][ty].creature =
                    ((Monster*) make_creature(DEMON_EMP)); /* The demon emp */
            Level->mlist->monster->x = tx;
            Level->mlist->monster->y = ty;
        }
    }
}
Exemplo n.º 3
0
//funzione che ritorna il puntatore all'ennesima parola della stringa s
char * parola( char* s, int n ){
   s=findchar(s);
   
   for(; n>0  ; n--){   
      s=findchar(findspace(s));
      
   }
   return s;    
}
Exemplo n.º 4
0
//funzione che ritorna la prima parola della stringa s
char * estraiparola(char *s){
   char *f=findspace(s);
   int dim=f-s+1;
   char* ret=malloc(sizeof(char)*dim);
   int i;
   for(i=0;i<dim-1;i++)
      ret[i]=s[i];
   ret[i]='\0';
   return ret;
}
Exemplo n.º 5
0
int pfs_create(const char *filename, int stripe_width)
{//CREATE project2 4 END.
	char spacket[BUFFER_SIZE] = ""; //Buffer for client data
	char len[10];
	strcat(spacket,"CREATE ");
	strcat(spacket, filename);
	strcat(spacket, " ");
	int2str(min(stripe_width,fsnum),len,10);
	strcat(spacket, len);
	strcat(spacket," END.");
	if (send(mmFD, spacket, sizeof(spacket), 0) == -1)//CREATE pfs_file1 3
		perror("Error in sending!");
	char rpacket[BUFFER_SIZE] = ""; //Buffer for client data
	//int size =
	MMR(rpacket, BUFFER_SIZE);

	char buf[BUFFER_SIZE]; //Buffer for client data
	char FileName[20];
	int fnI = findspace(rpacket, 0, 1); //project2_2
	int osI = findspace(rpacket, fnI, 1); //0
	int swI = findspace(rpacket, osI, 1); //4
	int sI = findspace(rpacket, swI, 1); //0
	//int lI = findspace(rpacket, sI, 1); //0
	strncpy(FileName, rpacket+fnI, osI-fnI-1);
	FileName[osI-fnI-1] = '\0';
	int os = str2int(rpacket+osI,swI-osI-1);
	int sw = str2int(rpacket+swI, sI-swI-1);
	strcpy(buf, "CREATE ");
	strcat(buf, FileName);
	strcat(buf, " END.");
	int i;
	for(i=0; i<sw; i++)
	{//Send for each FSs -> 2 CREATE pfs_file1 0,1,2,3
		if (send(fs[(i+os)%sw].fd, buf, sizeof(buf), 0) == -1)
			perror("Error in sending!");
	}
	return 0;
}
Exemplo n.º 6
0
int release(char* buf, int bufsize)
{//RELEASE pfs_file1 Offset Length END.
	char FileName[20];
	int fnI = findspace(buf, 0, 1); //pfs_file1
	int osI = findspace(buf, fnI, 1); //Offset
	int lI = findspace(buf, osI, 1); //Length
	int endI = findspace(buf, lI, 1); //END.
	strncpy(FileName, buf+fnI, osI-fnI-1);
	FileName[osI-fnI-1] = '\0';
	int ofi = 0;
	while( (ofi<ofnum) && (strncmp(openfiles[ofi]->filename, FileName, osI-fnI-1)) )
		ofi++;
	if(ofi==ofnum)
		return -1;
	//OpenFile* of = openfiles[ofi];
	int i;
	int os = str2int(buf+osI, lI-osI-1);
	int len = str2int(buf+endI, endI-lI-1);
	for(i=os/ONEKB;i<(os+len)/ONEKB;i++)
		if((metacache[i%(CLIENT_CACHE_LINES)][0] > 0) && (metacache[i%(CLIENT_CACHE_LINES)][3] == ofi))
			metacache[i%(CLIENT_CACHE_LINES)][0] = 0;//free or can be 3!
	return 0;
}
Exemplo n.º 7
0
void sewer_level(void)
{
    int i,tx,ty,t,l,e;
    char rsi;
    Symbol lchar;

    Level->numrooms = random_range(3)+3;
    rsi = RS_DRAINED_SEWER;
    for (i=0; i<Level->numrooms; i++) {
        do {
            t = random_range((Level->level_length)-10)+1;
            l = random_range((Level->level_width)-10)+1;
            e = 4;
        } while ((Level->site[l][t].roomnumber == rsi) ||
                 (Level->site[l+e][t].roomnumber == rsi) ||
                 (Level->site[l][t+e].roomnumber == rsi) ||
                 (Level->site[l+e][t+e].roomnumber == rsi));
        if (random_range(5)) {
            lchar = FLOOR;
            rsi = RS_DRAINED_SEWER;
        }
        else {
            lchar = WATER;
            rsi = RS_DROWNED_SEWER;
        }
        build_room(l,t,e,rsi,i);
        sewer_corridor(l,t,-1,-1,lchar);
        sewer_corridor(l+e,t,1,-1,lchar);
        sewer_corridor(l,t+e,-1,1,lchar);
        sewer_corridor(l+e,t+e,1,1,lchar);
    }
    if (Current_Dungeon == E_SEWERS) {
        if ((Level->depth == SEWERLEVELS) && (State.getCompletedSewers() == false)) {
            findspace(&tx,&ty,-1);
            Level->mlist = ((MonsterList*) checkmalloc(sizeof(MonsterList)));
            Level->mlist->next = NULL;
            Level->mlist->monster =
                Level->site[tx][ty].creature =
                    ((Monster*) make_creature(GREAT_WYRM)); /* The Great Wyrm */
            Level->mlist->monster->x = tx;
            Level->mlist->monster->y = ty;
        }
    }
}
Exemplo n.º 8
0
/* if can't find them, just drops player anywhere.... */
void find_stairs(char fromlevel, char tolevel)
{
  int i,j,found=FALSE;
  Symbol sitechar;
  if (fromlevel > tolevel) sitechar = STAIRS_DOWN; else sitechar = STAIRS_UP;
  for(i=0;i<Level->level_width;i++)
    for(j=0;j<Level->level_length;j++) 
      if ((Level->site[i][j].locchar == sitechar) && (! found)) { 
	found = TRUE;
	Player.x = i;
	Player.y = j;
	break;
      }
  if (! found) {
    findspace(&Player.x,&Player.y,-1);
    if (Level->environment != E_ASTRAL) {
      Level->site[Player.x][Player.y].locchar = sitechar;
      lset(Player.x, Player.y, CHANGED);
    }
  }
}
Exemplo n.º 9
0
ConditionalReader::ConditionalReader(PClip _child, const char* filename, const char _varname[], bool _show, IScriptEnvironment* env)
 : GenericVideoFilter(_child), show(_show), variableName(_varname), mode(MODE_UNKNOWN), offset(0), stringcache(0)
{
  FILE * f;
  char *line = 0;
  int lines;

  if ((f = fopen(filename, "rb")) == NULL)
    env->ThrowError("ConditionalReader: Could not open file '%s'.", filename);

  lines = 0;

  try {
    while ((line = readline(f)) != NULL) {
      char *ptr;
      int fields;

      lines++;

      /* We skip spaces */
      ptr = skipspaces(line);

      /* Skip coment lines or empty lines */
      if(iscomment(ptr) || *ptr == '\0') {
        free(line);
        line = 0;
        continue;
      }

      if (mode == MODE_UNKNOWN) {
        // We have not recieved a mode - We expect type.
        char* keyword = ptr;

        ptr = findspace(ptr);
        if (*ptr) {
          *ptr++ = '\0';
          if (!lstrcmpi(keyword, "type")) {
            /* We skip spaces */
            char* type = skipspaces(ptr);

            ptr = findspace(type);
            *ptr = '\0';

            if (!lstrcmpi(type, "int")) {
              mode = MODE_INT;
              intVal = new int[vi.num_frames];
            } else if (!lstrcmpi(type, "float")) {
              mode = MODE_FLOAT;
              floatVal = new float[vi.num_frames];
            } else if (!lstrcmpi(type, "bool")) {
              mode = MODE_BOOL;
              boolVal = new bool[vi.num_frames];
            } else if (!lstrcmpi(type, "string")) {
              mode = MODE_STRING;
              stringVal = new const char*[vi.num_frames];
            } else {
              ThrowLine("ConditionalReader: Unknown 'Type' specified in line %d", lines, env);
            }// end if compare type
            SetRange(0, vi.num_frames-1, AVSValue());
          }// end if compare keyword
        }// end if fields

      } else { // We have a defined mode and allocated the values.

        char* keyword = ptr;
        char* type = findspace(keyword);

        if (*type) *type++ = '\0';

        if (!lstrcmpi(keyword, "default")) {
          AVSValue def = ConvertType(type, lines, env);
          SetRange(0, vi.num_frames-1, def);

        } else if (!lstrcmpi(keyword, "offset")) {
          fields = sscanf(type, "%d", &offset);
          if (fields != 1) 
            ThrowLine("ConditionalReader: Could not read Offset in line %d", lines, env);

        } else if (keyword[0] == 'R' || keyword[0] == 'r') {  // Range
          int start;
          int stop;

          type = skipspaces(type);
          fields = sscanf(type, "%d", &start);

          type = findspace(type);
          type = skipspaces(type);
          fields += sscanf(type, "%d", &stop);

          type = findspace(type);
          if (!*type || fields != 2)
            ThrowLine("ConditionalReader: Could not read Range in line %d", lines, env);

          if (start > stop)
            ThrowLine("ConditionalReader: The Range start frame is after the end frame in line %d", lines, env);

          AVSValue set = ConvertType(type+1, lines, env);
          SetRange(start, stop, set);

        } else if (keyword[0] == 'I' || keyword[0] == 'i') {  // Interpolate
          if (mode == MODE_BOOL)
            ThrowLine("ConditionalReader: Cannot Interpolate booleans in line %d", lines, env);

          if (mode == MODE_STRING)
            ThrowLine("ConditionalReader: Cannot Interpolate strings in line %d", lines, env);

          type = skipspaces(type);
          int start;
          int stop;
          char start_value[64];
          char stop_value[64];
          fields = sscanf(type, "%d %d %63s %63s", &start, &stop, start_value, stop_value);

          if (fields != 4) 
            ThrowLine("ConditionalReader: Could not read Interpolation range in line %d", lines, env);
          if (start > stop)
            ThrowLine("ConditionalReader: The Interpolation start frame is after the end frame in line %d", lines, env);

          start_value[63] = '\0';
          AVSValue set_start = ConvertType(start_value, lines, env);

          stop_value[63] = '\0';
          AVSValue set_stop = ConvertType(stop_value, lines, env);

          const int range = stop-start;
          const double diff = (set_stop.AsFloat() - set_start.AsFloat()) / range;
          for (int i = 0; i<=range; i++) {
            const double n = i * diff + set_start.AsFloat();
            SetFrame(i+start, (mode == MODE_FLOAT)
                    ? AVSValue(n)
                    : AVSValue((int)(n+0.5)));
          }
        } else {
          int cframe;
          fields = sscanf(keyword, "%d", &cframe);
          if (*type && fields == 1) {
            AVSValue set = ConvertType(type, lines, env);
            SetFrame(cframe, set);
          } else {
            ThrowLine("ConditionalReader: Do not understand line %d", lines, env);
          }
        }
      
      } // End we have defined type
      free(line);
      line = 0;
    }// end while still some file left to read.
  }
  catch (...) {
    if (line) free(line);
    fclose(f);
    CleanUp();
    throw;
  }

  /* We are done with the file */
  fclose(f);

  if (mode == MODE_UNKNOWN)
    env->ThrowError("ConditionalReader: Type was not defined!");

}
Exemplo n.º 10
0
static int cmd_parseopt(int argc, const char **argv, const char *prefix)
{
	static int keep_dashdash = 0, stop_at_non_option = 0;
	static char const * const parseopt_usage[] = {
		N_("git rev-parse --parseopt [<options>] -- [<args>...]"),
		NULL
	};
	static struct option parseopt_opts[] = {
		OPT_BOOL(0, "keep-dashdash", &keep_dashdash,
					N_("keep the `--` passed as an arg")),
		OPT_BOOL(0, "stop-at-non-option", &stop_at_non_option,
					N_("stop parsing after the "
					   "first non-option argument")),
		OPT_BOOL(0, "stuck-long", &stuck_long,
					N_("output in stuck long form")),
		OPT_END(),
	};
	static const char * const flag_chars = "*=?!";

	struct strbuf sb = STRBUF_INIT, parsed = STRBUF_INIT;
	const char **usage = NULL;
	struct option *opts = NULL;
	int onb = 0, osz = 0, unb = 0, usz = 0;

	git_config(git_default_config, NULL);
	strbuf_addstr(&parsed, "set --");
	argc = parse_options(argc, argv, prefix, parseopt_opts, parseopt_usage,
	                     PARSE_OPT_KEEP_DASHDASH);
	if (argc < 1 || strcmp(argv[0], "--"))
		usage_with_options(parseopt_usage, parseopt_opts);

	/* get the usage up to the first line with a -- on it */
	for (;;) {
		if (strbuf_getline(&sb, stdin) == EOF)
			die("premature end of input");
		ALLOC_GROW(usage, unb + 1, usz);
		if (!strcmp("--", sb.buf)) {
			if (unb < 1)
				die("no usage string given before the `--' separator");
			usage[unb] = NULL;
			break;
		}
		usage[unb++] = strbuf_detach(&sb, NULL);
	}

	/* parse: (<short>|<short>,<long>|<long>)[*=?!]*<arghint>? SP+ <help> */
	while (strbuf_getline(&sb, stdin) != EOF) {
		const char *s;
		char *help;
		struct option *o;

		if (!sb.len)
			continue;

		ALLOC_GROW(opts, onb + 1, osz);
		memset(opts + onb, 0, sizeof(opts[onb]));

		o = &opts[onb++];
		help = findspace(sb.buf);
		if (!help || sb.buf == help) {
			o->type = OPTION_GROUP;
			o->help = xstrdup(skipspaces(sb.buf));
			continue;
		}

		*help = '\0';

		o->type = OPTION_CALLBACK;
		o->help = xstrdup(skipspaces(help+1));
		o->value = &parsed;
		o->flags = PARSE_OPT_NOARG;
		o->callback = &parseopt_dump;

		/* name(s) */
		s = strpbrk(sb.buf, flag_chars);
		if (s == NULL)
			s = help;

		if (s - sb.buf == 1) /* short option only */
			o->short_name = *sb.buf;
		else if (sb.buf[1] != ',') /* long option only */
			o->long_name = xmemdupz(sb.buf, s - sb.buf);
		else {
			o->short_name = *sb.buf;
			o->long_name = xmemdupz(sb.buf + 2, s - sb.buf - 2);
		}

		/* flags */
		while (s < help) {
			switch (*s++) {
			case '=':
				o->flags &= ~PARSE_OPT_NOARG;
				continue;
			case '?':
				o->flags &= ~PARSE_OPT_NOARG;
				o->flags |= PARSE_OPT_OPTARG;
				continue;
			case '!':
				o->flags |= PARSE_OPT_NONEG;
				continue;
			case '*':
				o->flags |= PARSE_OPT_HIDDEN;
				continue;
			}
			s--;
			break;
		}

		if (s < help)
			o->argh = xmemdupz(s, help - s);
	}
	strbuf_release(&sb);

	/* put an OPT_END() */
	ALLOC_GROW(opts, onb + 1, osz);
	memset(opts + onb, 0, sizeof(opts[onb]));
	argc = parse_options(argc, argv, prefix, opts, usage,
			(keep_dashdash ? PARSE_OPT_KEEP_DASHDASH : 0) |
			(stop_at_non_option ? PARSE_OPT_STOP_AT_NON_OPTION : 0) |
			PARSE_OPT_SHELL_EVAL);

	strbuf_addstr(&parsed, " --");
	sq_quote_argv(&parsed, argv, 0);
	puts(parsed.buf);
	return 0;
}
Exemplo n.º 11
0
int initialize(int argc, char *argv[])
{
	tv.tv_sec = 2;
	tv.tv_usec = 500000;
	FD_ZERO(&list);			// clear list
	FD_ZERO(&list_copy);	// clear temporary sets
	FD_SET(STDIN, &list);	// Add stdin
	fdmax = STDIN; // The biggest file descriptor
	yes = 1;
	ofnum = 0;//number of open files
	fdnum = 0;//number of file descriptors

	int cI;
	for(cI=0;cI<CLIENT_CACHE_LINES;cI++)
	{
		metacache[cI][0] = 0;//free
		metacache[cI][1] = -1;//TAG
		metacache[cI][2] = 0;//LRU
		metacache[cI][3] = -1;//OFi
	}

	srand (time(NULL));//randomize rand function
	int2str(rand() % (65536 - 1025) + 1025, myPORT, 10);//get a random port number for my pfs client
	memset(&hints, 0, sizeof(hints));
	hints.ai_family = AF_UNSPEC;
	hints.ai_socktype = SOCK_STREAM;
	getownip(myIP);	//inet_ntop(remoteaddr.ss_family, get_address((struct sockaddr*)&remoteaddr), myIP, INET6_ADDRSTRLEN);
	printf("My IP address and Port number are %s %s\n",myIP,myPORT);

	if(argc!=4){
		fprintf(stderr,"Usage: pfs filename mmip mmport\n");
		strcpy(mmIP, MMIP);
		strcpy(mmPORT, MMPORT);
		//exit(1);
	} else {
		strcpy(mmIP, argv[2]);
		strcpy(mmPORT, argv[3]);
	}	//MM's IP&PORT

	mmFD = Connect2Server(mmIP, mmPORT);//Connect to Meta-data Manager (MM)
	FD_SET(mmFD, &list);//add to fd list
	fdmax = mmFD; // The biggest file descriptor
	char rpacket[BUFFER_SIZE] = ""; //Buffer for client data
	int size = MMR(rpacket, BUFFER_SIZE);//IMPORT 4 127.0.0.1 10001 127.0.0.1 10002 127.0.0.1 10003 127.0.0.1 10004 END.
	int fsnumI = findspace(rpacket,0,1);//File server number Index
	char packettype[6];
	strncpy(packettype, rpacket, fsnumI-1);
	packettype[fsnum-1] = '\0';
	if(!strcmp(packettype, "IMPORT"))
	{
		int firstI = findspace(rpacket,fsnumI,1);//First file server Index
		int nextI;// = findspace(packet,ffsI,1); //Next file server Index
		fsnum = str2int(rpacket+fsnumI,firstI-fsnumI-1);//number of file servers
		int i;
		for(i=0;i<fsnum;i++)
		{
			nextI = findspace(rpacket,firstI,1);//Port index
			strncpy(fs[i].ip, rpacket + firstI, nextI - firstI - 1);
			fs[i].ip[nextI - firstI - 1] = '\0';
			firstI = findspace(rpacket,nextI,1);//IP index of next file server
			strncpy(fs[i].port, rpacket + nextI, firstI - nextI - 1);
			fs[i].port[firstI - nextI - 1] = '\0';
		}
		for(i=0;i<fsnum;i++)
		{
			fs[i].fd = Connect2Server(fs[i].ip, fs[i].port);//Connect to FS
			FD_SET(fs[i].fd, &list);//add to fd list
			fdmax = fs[i].fd; // The biggest file descriptor
			size = recv(fs[i].fd, rpacket, sizeof(rpacket), 0);
			if (size == -1)
				perror("Error in receiving!");
			rpacket[size] = '\0';
			printf("Server: %s\n",rpacket);//IMPORT 4 127.0.0.1 10001 127.0.0.1 10002 127.0.0.1 10003 127.0.0.1 10004 END.
		}
	}
	else
		printf("No File Servers Imported!");


	pthread_t harvesterThr, flusherThr;	//Buffer Management Threads
	pthread_create(&harvesterThr, NULL, (void *) harvester, NULL); //??? debug it!
	pthread_create(&flusherThr, NULL, (void *) flusher, NULL);
	//pthread_join(harvesterThr, NULL);//every x-sec??? or when falls under threshold!???
	//pthread_join(flusherThr, NULL);//every 30 seconds???

	return 0;
}
Exemplo n.º 12
0
int pfs_open(const char *filename, const char *mode)
{
	char spacket[BUFFER_SIZE]; //Buffer for client data
	//char len[10];
	strcpy(spacket,"OPEN ");
	strcat(spacket, filename);
	strcat(spacket, " ");
	strcat(spacket, mode);
	//int2str(stripe_width,len,10);
	//strcat(spacket, len);
	strcat(spacket," END.");
	if (send(mmFD, spacket, sizeof(spacket), 0) == -1)	//OPEN pfs_file1 w
		perror("Error in sending!");
	char rpacket[BUFFER_SIZE]; //Buffer for client data
	//int size =
	MMR(rpacket, BUFFER_SIZE);

	char buf[BUFFER_SIZE]; //Buffer for client data
	char FileName[20];
	char Mode[5];
	int fnI = findspace(rpacket, 0, 1); //project2_2
	int osI = findspace(rpacket, fnI, 1); //0
	int swI = findspace(rpacket, osI, 1); //4
	int sI = findspace(rpacket, swI, 1); //0
	int lI = findspace(rpacket, sI, 1); //0
	int mI = findspace(rpacket, lI, 1); //w
	int endI = findspace(rpacket, mI, 1);
	strncpy(FileName, rpacket+fnI, osI-fnI-1);
	FileName[osI-fnI-1] = '\0';
	strncpy(Mode, rpacket+mI, endI-mI-1);
	Mode[endI-mI-1] = '\0';
	int os = str2int(rpacket+osI,swI-osI-1);
	int sw = str2int(rpacket+swI, sI-swI-1);
	strcpy(buf, "OPEN ");
	strcat(buf, FileName);
	strcat(buf, " ");
	strcat(buf, Mode);
	strcat(buf, " END.");
	int i;
	for(i=0; i<sw; i++)
	{//Send for each FSs -> OPEN pfs_file1 w END.
		//if (!fork())
		//{ // this is the child process
		//	close(myTFD); // child doesn't need the listener
		if (send(fs[(i+os)%sw].fd, buf, sizeof(buf), 0) == -1)
			perror("Error in sending!");
		//	close(newfd);
		//	exit(0);
		//}
	}
	OpenFile* of = malloc(sizeof(OpenFile));
	strcpy(of->filename, FileName);
	strcpy(of->mode, Mode);
	of->fd = fdnum;
	fdnum++;
	of->fsoffset = os;
	of->stripe_width = sw;
	openfiles[ofnum] = of;
	ofnum++;
	return of->fd;
}