예제 #1
0
파일: g28.c 프로젝트: 8l/csolve
void realbrklkg(int g1,int g2,int s1,int s2){ /* break link from g1 to g2 (s1 part of g2) at s2 */
/* break it even if other conns */
   int i,j,ptr,ldtmp;

   if(g1 == g2)return;
   i = fdir[s2];	/* see if any g2's next to s2 */
   for(ldtmp = ldir[i]; i < ldtmp; ++i)
      if(board[s2+nbr[i]] == g2){	/* found g2 near. */
         for(j = 0; j < 4; ++j)	/* are any g1's far? */
            if(board[sqrbrd[s2][j]] == g1 &&
               (dstbrd[s2][j] == 2 )){
               return;
               }
         break;
         }
   for(ptr = grcnp[g1]; ptr != EOL; ptr = links[ptr]){
      i = list[ptr];
      if(cngr1[i] == g1 && cngr2[i] == g2 ||
         cngr1[i] == g2 && cngr2[i] == g1){
         if(!dellist(s2,&cnllptr[i])){
            }
         else {
            --cnllnum[i];
             }
         dellist(i,&llbrd[s2]);
         if(cnlknum[i] == 0 && cncnum[i] == 0 && cnllnum[i] == 0){
	    delconnrec(i);
            }
         else if(cnllnum[i] < 3)
               addlist(i,&cnchgd);
         return;
         }
      }
   }
예제 #2
0
파일: g28.c 프로젝트: 8l/csolve
void brkconns(int s){   /* break all connections through s */
   int i,ptr;

   for(ptr = cnbrd[s]; ptr != EOL; ptr = links[ptr]){
      i = list[ptr];
      dellist(s,&cnptr[i]);
      cncnum[i]--;
      if(cncnum[i] == 0 && cnlknum[i] == 0 && cnllnum[i] == 0){
	       delconnrec(i);
	       }
      else if(cncnum[i] == 1)
         addlist(i,&cnchgd);
      }
   for(ptr = lkbrd[s]; ptr != EOL; ptr = links[ptr]){
      i = list[ptr];
      dellist(s,&cnlkptr[i]);
      cnlknum[i]--;
      if(cncnum[i] == 0 && cnlknum[i] == 0 && cnllnum[i] == 0){
	       delconnrec(i);
	       }
      }
   for(ptr = llbrd[s]; ptr != EOL; ptr = links[ptr]){
      i = list[ptr];
      dellist(s,&cnllptr[i]);
      cnllnum[i]--;
      if(cncnum[i] == 0 && cnlknum[i] == 0 && cnllnum[i] == 0){

	       delconnrec(i);
	       }
      }
   killist(&llbrd[s]);
   killist(&cnbrd[s]);
   killist(&lkbrd[s]);

   }
예제 #3
0
파일: g22.c 프로젝트: 8l/csolve
void lresurrect(int g){     /* bring back group g */
   int lptr,s,i,ldtmp,sn,g2,c;
   c = grcolor[g];
   lptr = grpieces[g];
   while(lptr != -1){
       s = mvs[lptr];
       board[s] = g;
       i = fdir[s];
       for(ldtmp = ldir[i]; i < ldtmp; ++i ){
          sn = s + nbr[i];
          ++lnbf[sn][c];
          --lnbn[sn];
          dellist(s,&nblbp[sn]);
          g2 = board[sn];
          if(g2 == NOGROUP)continue;
          if(g2 == g)continue;
          if(dellist(s,&grlbp[g2])){
             grlibs[g2]--;
             }
          addlist(g2,&grnbp[g]);
          addlist(g,&grnbp[g2]);
          } 
       lptr = mvnext[lptr]; 
       }
   }
예제 #4
0
파일: g28.c 프로젝트: 8l/csolve
void delconnrec(int i){
	dellist(i,&grcnp[cngr1[i]]);
	dellist(i,&grcnp[cngr2[i]]);
	adflist(i,&cnfreelist);
	if(grldr[NUMGROUPS+i] != EOL)kill_ldrflags(NUMGROUPS+i);
	if(cnprot[i] >= AJI_CONNECT){
		addlist(mvs[grpieces[cngr1[i]]],&charmy);
		addlist(mvs[grpieces[cngr2[i]]],&charmy);
		}
	}
예제 #5
0
파일: multi.c 프로젝트: dancrossnyc/harvey
void
sortname(File *f)
{
	int i, cmp, w;
	int dupwarned;

	w = whichmenu(f);
	dupwarned = FALSE;
	dellist(&file, w);
	if(f == cmd)
		i = 0;
	else{
		for(i=0; i<file.nused; i++){
			cmp = Strcmp(&f->name, &file.filepptr[i]->name);
			if(cmp==0 && !dupwarned){
				dupwarned = TRUE;
				warn_S(Wdupname, &f->name);
			}else if(cmp<0 && (i>0 || cmd==0))
				break;
		}
	}
	inslist(&file, i, f);
	if(downloaded)
		outTsS(Hmovname, f->tag, &f->name);
}
예제 #6
0
파일: g22.c 프로젝트: 8l/csolve
void lkilgrp(int g){
   int lptr,s,i,sn,g2,ldtmp,c;
   c = grcolor[g];
   lptr = grnbp[g]; 
   while(lptr != EOL){
      dellist(g,&grnbp[list[lptr]]);
      lptr = links[lptr];
      } 
   lptr = grpieces[g];
   killist(&grnbp[g]); 
   while(lptr != -1){
      s = mvs[lptr];
      board[s] = NOGROUP; 
      i = fdir[s];
      for(ldtmp = ldir[i]; i < ldtmp; ++i){ 
         sn = s + nbr[i]; 
         --lnbf[sn][c];
         ++lnbn[sn];
         addlist(s,&nblbp[sn]);
         g2 = board[sn];
         if(g2 == NOGROUP)continue; 
         if(g2 == g)continue; 
         if(addlist(s,&grlbp[g2])){ 
           ++grlibs[g2];
           }
         }
      lptr = mvnext[lptr];
      }
  }
예제 #7
0
파일: disc.c 프로젝트: 4ad/sam
void
bkfree(Disc *d, int n)
{
	Discdesc *dd = d->desc;

	inslist(&dd->free, dd->free.nused, d->block.blkptr[n].bnum);
	dellist(&d->block, n);
}
예제 #8
0
파일: g22.c 프로젝트: 8l/csolve
int lsplit(int ptr,int j) {
   int lptr,lptr2,ptr2,tlist,g2,gret,c; 
   tlist = EOL; 
   c = grcolor[list[ptr]];
   ptr2 = ptr;
   while(ptr2 != EOL){
      g2 = list[ptr2];
      if(grcolor[g2] != c)break;
      adflist(list[ptr2],&tlist); 
      ptr2 = links[ptr2];
      } 
   ptr = tlist; 
   gret = list[tlist];
   killist(&grlbp[j]); 
   lptr = grnbp[j];
   while(lptr != EOL){
      dellist(j,&grnbp[list[lptr]]);
      lptr = links[lptr];
      }
   if(grnbp[j] != EOL)
	   killist(&grnbp[j]);
  
   --maxgr;              /* group j is gone! */
  
   lptr = mvnext[grpieces[j]];   /* unlink pieces list */
   ptr2 = ptr;
   g2 = list[ptr2];
   ptr2 = links[ptr2];
   lptr2 = grpieces[list[ptr2]];
   while(lptr != -1){
      board[mvs[lptr]] = g2;
      if(mvnext[lptr] == lptr2){
         mvnext[lptr] = -1;
         lptr = lptr2;
         g2 = list[ptr2]; 
         ptr2 = links[ptr2]; 
         if(ptr2 == EOL)
            lptr2 = -2; 
         else 
            lptr2 = grpieces[list[ptr2]]; 
         }
      else lptr = mvnext[lptr]; 
      } 
  
  
   ptr2 = ptr;
   while(ptr2 != EOL){   /* fix neighbors */
      g2 = list[ptr2];
      lptr = grnbp[g2]; 
      ptr2 = links[ptr2];
      while(lptr != EOL){ 
         addlist(g2,&grnbp[list[lptr]]);
         lptr = links[lptr];
         }
      }
   killist(&tlist);
   return(gret);
   }
예제 #9
0
void main(void)
{
	LIST *l;

	puts("AmigaRobots Statistik V" VERSION);
	l=daten_lesen();
	datendump(l);
	dellist(l);
}
예제 #10
0
파일: g2eye.c 프로젝트: palmerc/lab
void deallocate_eye(int rn){
	int ptr,i,ldtmp;

	for(ptr = eyeptr[rn]; ptr != EOL; ptr = links[ptr]){
		eyerec[list[ptr]] = 0;
		i = fdir[list[ptr]];
            	for(ldtmp = ldiag[i]; i < ldtmp; ++i)
               		dellist(list[ptr],&eyesdiags[list[ptr]+diags[i]]);
		if(grldr[NUMGROUPS+NUMCONNS+list[ptr]] != EOL)
			kill_ldrflags(NUMGROUPS+NUMCONNS+list[ptr]);
		}
	killist(&eyeptr[rn]);
	for(ptr = eyevital[rn]; ptr != EOL; ptr = links[ptr])
		dellist(rn,&eyevitrec[list[ptr]]);
	killist(&eyevital[rn]);
	eyetype[rn] = NOEYE;
	adflist(rn,&eyefreelist);
	eyeval[rn] = eyepot[rn] = eyemin[rn] = 0;
	}
// Pre-condition: p points to a linked list.
// Post-condition: All the memory for the linked list pointed to by p is
//                 freed for use.
void dellist(struct ll *p) {

  struct ll *temp;

  // Recursively free each element in the list.
  if (p !=NULL) {
    temp = p -> next;
    dellist(temp);
    free(p);
  }
}
예제 #12
0
/*
Inputs:  A pointer to a priority table and a user.
Outputs: Zero if user found, else 1, and priority table is modified.
Effects: All occurences of <user> in the priority table will be removed.
	 (There should only be one at most.)
*/
int del_user ( struct user_priority * ppri_tbl, char * user )
{
    int		limit;

    for (limit = PRI_MIN; limit <= PRI_MAX; limit++)
	if (searchlist(user, ppri_tbl->users[limit - PRI_MIN]))
	{
	    dellist (&(ppri_tbl->users[limit - PRI_MIN]), user);
	    return (0);
	}
    return (1);
}
예제 #13
0
파일: multi.c 프로젝트: dancrossnyc/harvey
void
delfile(File *f)
{
	int w = whichmenu(f);

	if(w < 0)	/* e.g. x/./D */
		return;
	if(downloaded)
		outTs(Hdelname, f->tag);
	dellist(&file, w);
	fileclose(f);
}
예제 #14
0
파일: g28.c 프로젝트: 8l/csolve
void brklink(int g1,int g2,int s1,int s2){ /* break link from g1 to g2 (s1 part of g2) at s2 */
/* don'y break it if multiple links same square */
   int i,j,ptr,ldtmp,cflag;

   if(g1 == g2)return;
   cflag = FALSE;
   i = fdir[s2];	/* see if any g2's next to s2 */
   for(ldtmp = ldir[i]; i < ldtmp; ++i)
      if(board[s2+nbr[i]] == g2){
         cflag = TRUE;
         break;
         }
      for(j = 0; j < 4; ++j){
         if(sqrbrd[s2][j] != s1 &&
            (board[sqrbrd[s2][j]] == g2 ||
             (cflag && board[sqrbrd[s2][j]] == g1)) && 
            (dstbrd[s2][j] == 1 /* || dstbrd[s2][j] == 2 */)){
            return;
            }
         }
   for(ptr = grcnp[g1]; ptr != EOL; ptr = links[ptr]){
      i = list[ptr];
      if(cngr1[i] == g1 && cngr2[i] == g2 ||
         cngr1[i] == g2 && cngr2[i] == g1){
         if(!dellist(s2,&cnlkptr[i])){
            }
         else {
            --cnlknum[i];
            }
         dellist(i,&lkbrd[s2]);
         if(cnlknum[i] == 0 && cncnum[i] == 0 && cnllnum[i] == 0){

	    delconnrec(i);
            }
	 else if(cnlknum[i] < 3)
		 addlist(i,&cnchgd);
         return;
         }
      }
   }
예제 #15
0
파일: g28.c 프로젝트: 8l/csolve
int brconn(int g,int s){  /* break all connections to g through s */
   int i,ptr,tmplist,flag;

   flag = FALSE;
   tmplist = EOL;
   cpylist(cnbrd[s],&tmplist);
   for(ptr = tmplist; ptr != EOL; ptr = links[ptr]){
      i = list[ptr];
      if(cngr1[i] == g || cngr2[i] == g){
         --cncnum[i];
         dellist(s,&cnptr[i]);
         dellist(i,&cnbrd[s]);
         if(cncnum[i] == 0 && cnlknum[i] == 0 && cnllnum[i] == 0){
	       delconnrec(i);
	       }
         else if(cncnum[i] == 1)
            addlist(i,&cnchgd);
         }
      }
   killist(&tmplist);
   return(flag);
   }
예제 #16
0
파일: g22.c 프로젝트: 8l/csolve
int lcombine(int nlist,int upptr){
  int lptr,g,nptr,g2;

  g = maxgr++;
  grsize[g] = 0;
  nptr = nlist;
  while(nptr != EOL){
      g2 = list[nptr];
      nptr = links[nptr];
      grsize[g] += grsize[g2];
      adflist(g2,&mvconn[upptr]);
      lptr = grnbp[g2];
      while(lptr != EOL){
         dellist(g2,&grnbp[list[lptr]]);
         addlist(g,&grnbp[list[lptr]]);
         lptr = links[lptr];
         }
      }
   g2 = list[nlist];
   grcolor[g] = grcolor[g2];
   cpylist(grlbp[g2],&grlbp[g]);
   grlibs[g] = grlibs[g2];
   cpylist(grnbp[g2],&grnbp[g]);
   grpieces[g] = grpieces[g2];
   lptr = grpieces[g];
   nptr = links[nlist];
   while(nptr != EOL){
      g2 = list[nptr];
      grlibs[g] += mrglist(grlbp[g2],&grlbp[g]);
      mrglist(grnbp[g2],&grnbp[g]); 
      while(mvnext[lptr] != -1){ 
         board[mvs[lptr]] = g;
         lptr = mvnext[lptr]; 
         }
      board[mvs[lptr]] = g; 
      mvnext[lptr] = grpieces[g2];
      lptr = grpieces[g2];
      nptr = links[nptr];
      }
   while(lptr != -1){
      board[mvs[lptr]] = g;
      lptr = mvnext[lptr];
      }
  
  
  
   return(g);
  }
예제 #17
0
파일: myndbm.c 프로젝트: rdebath/cvs
void
mydbm_close (DBM *db)
{
    if (db->modified)
    {
	FILE *fp;
	fp = CVS_FOPEN (db->name, FOPEN_BINARY_WRITE);
	if (fp == NULL)
	    error (1, errno, "cannot write %s", db->name);
	walklist (db->dbm_list, write_item, fp);
	if (fclose (fp) < 0)
	    error (0, errno, "cannot close %s", db->name);
    }
    free (db->name);
    dellist (&db->dbm_list);
    free (db);
}
예제 #18
0
/* The shutdown function for a multi-source buffer.  */
static int
ms_buffer_shutdown (struct buffer *buf)
{
    struct ms_buffer *mb = buf->closure;
    Node *p;
    int err = 0;

    assert (mb->cur);
    err += buf_shutdown (mb->cur);
    buf_free (mb->cur);
    for (p = mb->bufs->list->next; p != mb->bufs->list; p = p->next)
    {
	assert (p);
	err += buf_shutdown (p->data);
    }

    dellist (&mb->bufs);
    return err;
}
예제 #19
0
파일: job.c 프로젝트: CoryXie/opensolaris
papi_status_t
papiJobCommit(papi_service_t handle, char *printer, int32_t id)
{
	papi_status_t status = PAPI_OK;
	service_t *svc = handle;
	REQUEST *r = NULL;
	char *metadata_file;
	char *dest;

	if ((svc == NULL) || (printer == NULL))
		return (PAPI_BAD_ARGUMENT);

	dest = printer_name_from_uri_id(printer, id);
	/* tell the scheduler that we want to change the job */
	status = lpsched_start_change(svc, dest, id, &metadata_file);
	if (status != PAPI_OK)
		return (status);

	if ((r = getrequest(metadata_file)) != NULL) {
		r->actions &= ~ACT_RESUME;
		r->actions |= ACT_RESUME;
		dellist(&r->file_list, DUMMY_FILE);

		if (putrequest(metadata_file, r) < 0) {
			detailed_error(svc,
			    gettext("failed to write job: %s: %s"),
			    metadata_file, strerror(errno));
			freerequest(r);
			return (PAPI_DEVICE_ERROR);
		}
	} else {
		detailed_error(svc, gettext("failed to read job: %s: %s"),
		    metadata_file, strerror(errno));
		return (PAPI_DEVICE_ERROR);
	}

	status = lpsched_end_change(svc, dest, id);
	freerequest(r);

	return (status);
}
예제 #20
0
파일: ls.c 프로젝트: gosudream/netbsd-src
/* A delproc for a List Node containing a List *.  */
static void
ls_delproc (Node *p)
{
    dellist ((List **)&p->data);
}
예제 #21
0
파일: recurse.cpp 프로젝트: acml/cvsnt
/* Start a recursive command.

   Command line arguments (ARGC, ARGV) dictate the directories and
   files on which we operate.  In the special case of no arguments, we
   default to ".".  */
int start_recursion (FILEPROC fileproc, FILESDONEPROC filesdoneproc,
    PREDIRENTPROC predirentproc, DIRENTPROC direntproc, DIRLEAVEPROC dirleaveproc,
    void *callerdat,

    int argc,
    char **argv,
    int local,

    /* This specifies the kind of recursion.  There are several cases:

       1.  W_LOCAL is not set but W_REPOS is.  The current
       directory when we are called must be the repository and
       recursion proceeds according to what exists in the repository.

       2a.  W_LOCAL is set but W_REPOS is not.  The
       current directory when we are called must be the working
       directory.  Recursion proceeds according to what exists in the
       working directory, never (I think) consulting any part of the
       repository which does not correspond to the working directory
       ("correspond" == Name_Repository).

       2b.  W_LOCAL is set and so is W_REPOS.  This is the
       weird one.  The current directory when we are called must be
       the working directory.  We recurse through working directories,
       but we recurse into a directory if it is exists in the working
       directory *or* it exists in the repository.  If a directory
       does not exist in the working directory, the direntproc must
       either tell us to skip it (R_SKIP_ALL), or must create it (I
       think those are the only two cases).  */
    int which,

    int aflag,
    int readlock,
    const char *update_preload,
	const char *repos_preload,
    int dosrcs,
    PERMPROC permproc,
    const char *tag)
{
    int i, err = 0;
    List *args_to_send_when_finished = NULL;
    List *files_by_dir = NULL;
    struct recursion_frame frame;

	TRACE(3,"start_recursion()");	

    frame.fileproc = fileproc;
    frame.filesdoneproc = filesdoneproc;
	frame.predirentproc = predirentproc;
    frame.direntproc = direntproc;
    frame.dirleaveproc = dirleaveproc;
    frame.callerdat = callerdat;
    frame.flags = local ? R_SKIP_DIRS : R_PROCESS;
    frame.which = which;
    frame.aflag = aflag;
    frame.readlock = readlock;
    frame.dosrcs = dosrcs;
    frame.permproc = permproc;
    frame.tag = tag;

    expand_wild (argc, argv, &argc, &argv);

    if (update_preload == NULL)
	update_dir = xstrdup ("");
    else
	update_dir = xstrdup (update_preload);

    /* clean up from any previous calls to start_recursion */
	xfree (repository);
    if (filelist)
	dellist (&filelist); /* FIXME-krp: no longer correct. */
    if (dirlist)
	dellist (&dirlist);

	update_repos = xstrdup(repos_preload);

	for (i = 0; i < argc; ++i)
	{
#ifdef SERVER_SUPPORT
	    if (server_active)
		    server_pathname_check (argv[i]);
		else
#endif
			if(isabsolute(argv[i]))
				error(1,0,"Absolute filenames not allowed");
    }

    if (argc == 0)
    {
	int just_subdirs = (which & W_LOCAL) && !noexec && !isdir (CVSADM);

	if (!just_subdirs
	    && CVSroot_cmdline == NULL
	    && current_parsed_root->isremote)
	{
	    char *root = Name_Root (NULL, update_dir);
	    if (root && strcmp (root, current_parsed_root->original) != 0)
		/* We're skipping this directory because it is for
		   a different root.  Therefore, we just want to
		   do the subdirectories only.  Processing files would
		   cause a working directory from one repository to be
		   processed against a different repository, which could
		   cause all kinds of spurious conflicts and such.

		   Question: what about the case of "cvs update foo"
		   where we process foo/bar and not foo itself?  That
		   seems to be handled somewhere (else) but why should
		   it be a separate case?  Needs investigation...  */
		just_subdirs = 1;
	    xfree (root);
	}

	/*
	 * There were no arguments, so we'll probably just recurse. The
	 * exception to the rule is when we are called from a directory
	 * without any CVS administration files.  That has always meant to
	 * process each of the sub-directories, so we pretend like we were
	 * called with the list of sub-dirs of the current dir as args
	 */
	if (just_subdirs)
	{
	    dirlist = Find_Directories ((char *) NULL, W_LOCAL, (List *) NULL, NULL);
	    /* If there are no sub-directories, there is a certain logic in
	       favor of doing nothing, but in fact probably the user is just
	       confused about what directory they are in, or whether they
	       cvs add'd a new directory.  In the case of at least one
	       sub-directory, at least when we recurse into them we
	       notice (hopefully) whether they are under CVS control.  */
	    if (list_isempty (dirlist) && !noexec)
	    {
		if (update_dir[0] == '\0')
		    error (0, 0, "in directory .:");
		else
		    error (0, 0, "in directory %s:", update_dir);
		error (1, 0,
		       "there is no version here; run '%s checkout' first",
		       program_name);
	    }
	    else if (current_parsed_root->isremote && server_started)
	    {
		/* In the the case "cvs update foo bar baz", a call to
		   send_file_names in update.c will have sent the
		   appropriate "Argument" commands to the server.  In
		   this case, that won't have happened, so we need to
		   do it here.  While this example uses "update", this
		   generalizes to other commands.  */

		/* This is the same call to Find_Directories as above.
                   FIXME: perhaps it would be better to write a
                   function that duplicates a list. */
		args_to_send_when_finished = Find_Directories ((char *) NULL,
							       W_LOCAL,
							       (List *) NULL, NULL);
	    }
	}
	else
	{
	    addlist (&dirlist, ".");
	}

	goto do_the_work;
    }


    /*
     * There were arguments, so we have to handle them by hand. To do
     * that, we set up the filelist and dirlist with the arguments and
     * call do_recursion.  do_recursion recognizes the fact that the
     * lists are non-null when it starts and doesn't update them.
     *
     * explicitly named directories are stored in dirlist.
     * explicitly named files are stored in filelist.
     * other possibility is named entities whicha are not currently in
     * the working directory.
     */
    
    for (i = 0; i < argc; i++)
    {
	/* if this argument is a directory, then add it to the list of
	   directories. */

	if (isdir (argv[i]))
	{
	    strip_trailing_slashes (argv[i]);
	    addlist (&dirlist, argv[i]);
	}
	else
	{
	    /* otherwise, split argument into directory and component names. */
	    char *dir;
	    char *comp;
	    char *file_to_try;

	    /* Now break out argv[i] into directory part (DIR) and file part (COMP).
		   DIR and COMP will each point to a newly malloc'd string.  */
	    dir = xstrdup (argv[i]);
	    comp = (char*)last_component (dir);
	    if (comp == dir)
	    {
		/* no dir component.  What we have is an implied "./" */
		dir = xstrdup(".");
	    }
	    else
	    {
		char *p = comp;

		p[-1] = '\0';
		comp = xstrdup (p);
	    }

	    /* if this argument exists as a file in the current
	       working directory tree, then add it to the files list.  */

	    if (!(which & W_LOCAL))
	    {
		/* If doing rtag, we've done a chdir to the repository. */
		file_to_try = (char*)xmalloc (strlen (argv[i]) + sizeof (RCSEXT) + 5);
		sprintf (file_to_try, "%s%s", argv[i], RCSEXT);
	    }
	    else
		file_to_try = xstrdup (argv[i]);

	    if (isfile (file_to_try))
	    {
			const char *tag;
			const char *date;
			int nonbranch;
			const char *message;
			const char *v_type;
			/* before we do anything else, see if we have any
			   per-directory tags */

			ParseTag_Dir (dir, &tag, &date, &nonbranch, NULL);
			
	        if (! verify_access (frame.permproc, dir, file_to_try, update_dir,tag,&message,&v_type))
			{
				if(tag && !quiet && !(which&W_QUIET))
					error (0, 0, "User %s is unable to %s %s/%s on branch/tag %s - ignoring",CVS_Username,v_type,dir,file_to_try?file_to_try:"",tag);
				else if(!quiet && !(which&W_QUIET))
					error (0, 0, "User %s is unable to %s %s/%s - ignoring",CVS_Username,v_type,dir,file_to_try?file_to_try:"");
				if(message && !quiet && !(which&W_QUIET))
					error (0, 0, "%s", message);
			}
			else
		{
		   addfile (&files_by_dir, dir, comp);
		}
	    }
	    else if (isdir (dir))
	    {
		if ((which & W_LOCAL) && isdir (CVSADM)
		    && !current_parsed_root->isremote
		    )
		{
		    /* otherwise, look for it in the repository. */
		    char *tmp_update_dir;
		    char *repos;
		    char *reposfile;

		    tmp_update_dir = (char*)xmalloc (strlen (update_dir)
					      + strlen (dir)
					      + 5);
		    strcpy (tmp_update_dir, update_dir);

		    if (*tmp_update_dir != '\0')
			(void) strcat (tmp_update_dir, "/");

		    (void) strcat (tmp_update_dir, dir);

		    /* look for it in the repository. */
		    repos = Name_Repository (dir, tmp_update_dir);
		    reposfile = (char*)xmalloc (strlen (repos)
					 + strlen (comp)
					 + 5);
		    (void) sprintf (reposfile, "%s/%s", repos, comp);
		    xfree (repos);

		    if (isdir (reposfile))
			{
			addlist (&dirlist, argv[i]);
			}
		    else
			addfile (&files_by_dir, dir, comp);

		    xfree (tmp_update_dir);
		    xfree (reposfile);
		}
		else
		    addfile (&files_by_dir, dir, comp);
	    }
	    else
		{
			error (1, 0, "no such directory `%s'", dir);
		}

	    xfree (file_to_try);
	    xfree (dir);
	    xfree (comp);
	}
    }

    /* At this point we have looped over all named arguments and built
       a coupla lists.  Now we unroll the lists, setting up and
       calling do_recursion. */

    err += walklist (files_by_dir, unroll_files_proc, (void *) &frame);
    if (files_by_dir)
    dellist(&files_by_dir);

    /* then do_recursion on the dirlist. */
    if (dirlist != NULL)
    {
    do_the_work:
	err += do_recursion (&frame, 1);
    }
	
    /* Free the data which expand_wild allocated.  */
    free_names (&argc, argv);

    xfree (update_dir);
	xfree (update_repos);

    if (args_to_send_when_finished != NULL)
    {
	/* FIXME (njc): in the multiroot case, we don't want to send
	   argument commands for those top-level directories which do
	   not contain any subdirectories which have files checked out
	   from current_parsed_root->original.  If we do, and two repositories
	   have a module with the same name, nasty things could happen.

	   This is hard.  Perhaps we should send the Argument commands
	   later in this procedure, after we've had a chance to notice
	   which directores we're using (after do_recursion has been
	   called once).  This means a _lot_ of rewriting, however.

	   What we need to do for that to happen is descend the tree
	   and construct a list of directories which are checked out
	   from current_cvsroot.  Now, we eliminate from the list all
	   of those directories which are immediate subdirectories of
	   another directory in the list.  To say that the opposite
	   way, we keep the directories which are not immediate
	   subdirectories of any other in the list.  Here's a picture:

			      a
			     / \
			    B   C
			   / \
			  D   e
			     / \
			    F   G
			       / \
			      H   I

	   The node in capitals are those directories which are
	   checked out from current_cvsroot.  We want the list to
	   contain B, C, F, and G.  D, H, and I are not included,
	   because their parents are also checked out from
	   current_cvsroot.

	   The algorithm should be:
		   
	   1) construct a tree of all directory names where each
	   element contains a directory name and a flag which notes if
	   that directory is checked out from current_cvsroot

			      a0
			     / \
			    B1  C1
			   / \
			  D1  e0
			     / \
			    F1  G1
			       / \
			      H1  I1

	   2) Recursively descend the tree.  For each node, recurse
	   before processing the node.  If the flag is zero, do
	   nothing.  If the flag is 1, check the node's parent.  If
	   the parent's flag is one, change the current entry's flag
	   to zero.

			      a0
			     / \
			    B1  C1
			   / \
			  D0  e0
			     / \
			    F1  G1
			       / \
			      H0  I0

	   3) Walk the tree and spit out "Argument" commands to tell
	   the server which directories to munge.
		   
	   Yuck.  It's not clear this is worth spending time on, since
	   we might want to disable cvs commands entirely from
	   directories that do not have CVSADM files...

	   Anyways, the solution as it stands has modified server.c
	   (dirswitch) to create admin files [via server.c
	   (create_adm_p)] in all path elements for a client's
	   "Directory xxx" command, which forces the server to descend
	   and serve the files there.  client.c (send_file_names) has
	   also been modified to send only those arguments which are
	   appropriate to current_parsed_root->original.

	*/
		
	/* Construct a fake argc/argv pair. */
		
	int our_argc = 0, i;
	char **our_argv = NULL;

	if (! list_isempty (args_to_send_when_finished))
	{
	    Node *head, *p;

	    head = args_to_send_when_finished->list;

	    /* count the number of nodes */
	    i = 0;
	    for (p = head->next; p != head; p = p->next)
		i++;
	    our_argc = i;

	    /* create the argument vector */
	    our_argv = (char **) xmalloc (sizeof (char *) * our_argc);

	    /* populate it */
	    i = 0;
	    for (p = head->next; p != head; p = p->next)
		our_argv[i++] = xstrdup (p->key);
	}

	/* We don't want to expand widcards, since we've just created
	   a list of directories directly from the filesystem. */
	send_file_names (our_argc, our_argv, 0);

	/* Free our argc/argv. */
	if (our_argv != NULL)
	{
	    for (i = 0; i < our_argc; i++)
		xfree (our_argv[i]);
	    xfree (our_argv);
	}

	if (args_to_send_when_finished)
	dellist (&args_to_send_when_finished);
    }
    
    return (err);
}
예제 #22
0
파일: g22.c 프로젝트: 8l/csolve
void ldndate(int dnptr){
   int i,s,sn,lptr,c,g,splflag,ptr,tmp,ldtmp,g2;
   kosquare = kosave[dnptr];
   s = mvs[dnptr];
   if(s == PASS){  /* pass */
      return;
      }
   g = board[s];
   c = grcolor[g];
   splflag = FALSE;
   board[s] = NOGROUP;
   if(mvconn[dnptr] != EOL){
      ptr = mvconn[dnptr];      /* bring back combined groups */
      g = lsplit(ptr,g);
      splflag = TRUE;
      }
   for(ptr = mvcapt[dnptr]; ptr != EOL; ptr = links[ptr]){
         g2 = list[ptr]; /* bring back killed groups */
             lresurrect(g2);  /* resurrect enemy group */
         }
  
   if(!splflag){        /* remove piece from group */
      grsize[g]--;
      if(grsize[g] == 0){  /* only one piece in group */
         --maxgr;           /* delete group */
         killist(&grlbp[g]);     /* return liberties to free list */
         lptr = grnbp[g];
         while(lptr != EOL){
            dellist(g,&grnbp[list[lptr]]);
            lptr = links[lptr];
            }
         if(grnbp[g] != EOL)
		 killist(&grnbp[g]); /* return neighbors to free list */
         }
      else {                  /* take piece away from group */
         grpieces[g] = mvnext[grpieces[g]]; 
         ptr = lbply[dnptr];
         while(ptr != EOL){ 
            dellist(list[ptr],&grlbp[g]); 
            --grlibs[g];
            ptr = links[ptr];
            } 
         killist(&lbply[dnptr]); 
         ptr = nbply[dnptr];
         while(ptr != EOL){ 
            tmp = list[ptr];
            dellist(tmp,&grnbp[g]); 
            dellist(g,&grnbp[tmp]); 
            ptr = links[ptr];
            } 
         if(nbply[dnptr] != EOL)
		 killist(&nbply[dnptr]); 
         }
      if(edge[s] < 2){
         i = fdir[s]; 
         for(ldtmp = ldir[i]; i < ldtmp; ++i){
            sn = s + nbr[i];
            --lnbf[sn][c];
            ++lnbn[sn]; 
            addlist(s,&nblbp[sn]);
            g = board[sn];
            if(g == NOGROUP)continue;
            if(addlist(s,&grlbp[g])){
              ++grlibs[g];
              }
            }
         }
      else{
         --lnbf[s+1][c];
         ++lnbn[s+1];
         addlist(s,&nblbp[s+1]);
         --lnbf[s-1][c];
         ++lnbn[s-1];
         addlist(s,&nblbp[s-1]);
         --lnbf[s+boardsize][c];
         ++lnbn[s+boardsize];
         addlist(s,&nblbp[s+boardsize]);
         --lnbf[s-boardsize][c];
         ++lnbn[s-boardsize];
         addlist(s,&nblbp[s-boardsize]);
         g = board[s+1];
         if(g != NOGROUP )
            if(addlist(s,&grlbp[g]))++grlibs[g];
         g = board[s-1];
         if(g != NOGROUP )
            if(addlist(s,&grlbp[g]))++grlibs[g];
         g = board[s+boardsize];
         if(g != NOGROUP )
            if(addlist(s,&grlbp[g]))++grlibs[g];
         g = board[s-boardsize];
         if(g != NOGROUP )
            if(addlist(s,&grlbp[g]))++grlibs[g];
         }
      }
   else {
      if(edge[s] < 2){
         i = fdir[s];
         for(ldtmp = ldir[i]; i < ldtmp; ++i){
            sn = s + nbr[i];
            --lnbf[sn][c];
            ++lnbn[sn];
            addlist(s,&nblbp[sn]);
            g = board[sn];
            if(grcolor[g] != 1-c)continue;
            if(addlist(s,&grlbp[g])){
              ++grlibs[g];
              }
            }
         }
      else{
         --lnbf[s+1][c];
         ++lnbn[s+1];
         addlist(s,&nblbp[s+1]);
         --lnbf[s-1][c];
         ++lnbn[s-1];
         addlist(s,&nblbp[s-1]);
         --lnbf[s+boardsize][c];
         ++lnbn[s+boardsize];
         addlist(s,&nblbp[s+boardsize]);
         --lnbf[s-boardsize][c];
         ++lnbn[s-boardsize];
         addlist(s,&nblbp[s-boardsize]);
         g = board[s+1];
         if(grcolor[g] == 1-c)
            if(addlist(s,&grlbp[g]))++grlibs[g];
         g = board[s-1];
         if(grcolor[g] == 1-c)
            if(addlist(s,&grlbp[g]))++grlibs[g];
         g = board[s+boardsize];
         if(grcolor[g] == 1-c)
            if(addlist(s,&grlbp[g]))++grlibs[g];
         g = board[s-boardsize];
         if(grcolor[g] == 1-c)
            if(addlist(s,&grlbp[g]))++grlibs[g];
         }
      }
   }
예제 #23
0
파일: recurse.cpp 프로젝트: acml/cvsnt
static int unroll_files_proc (Node *p, void *closure)
{
	int directory_opened = 0;
    Node *n;
    struct recursion_frame *frame = (struct recursion_frame *) closure;
    int err = 0;
    List *save_dirlist;
    char *save_update_dir = NULL;
    struct saved_cwd cwd;
	char *dir = p->key;

    /* if this dir was also an explicitly named argument, then skip
       it.  We'll catch it later when we do dirs. */
    n = findnode_fn (dirlist, dir);
    if (n != NULL)
	return (0);

    /* otherwise, call dorecusion for this list of files. */
    filelist = (List *) p->data;
    p->data = NULL;
    save_dirlist = dirlist;
    dirlist = NULL;

    if (strcmp(dir, ".") != 0)
    {
        if (save_cwd (&cwd))
	    error_exit ();
	if ( CVS_CHDIR (dir) < 0)
	    error (1, errno, "could not chdir to %s", dir);

	save_update_dir = update_dir;
	update_dir = (char*)xmalloc (strlen (save_update_dir)
				  + strlen (dir)
				  + 5);
	strcpy (update_dir, save_update_dir);

	if (*update_dir != '\0')
	    (void) strcat (update_dir, "/");

	(void) strcat (update_dir, dir);
    }


	if(frame->which&W_LOCAL)
	{
		int directory_opened_status=-1;
		const char *version;
		const char *tag;
		const char *date;
		int nonbranch;
		char *repository = Name_Repository(NULL,update_dir);

		ParseTag(&tag, &date, &nonbranch, &version);
		directory_opened_status=open_directory(repository,".",tag,date,nonbranch,version,current_parsed_root->isremote);
		if (directory_opened_status!=-1)
			directory_opened = 1;
		xfree(repository);
		xfree(version);
		xfree(tag);
		xfree(date);
	}
	else
	{
		int directory_opened_status=-1;
		/* we can't simply call Name_Repository() here, if we do we get:
		-> Name_Repository((null),cvsnt/src)
		cvs server: in directory cvsnt/src:
		cvs [server aborted]: CVS directory without administration files present.  Cannot continue until this directory is deleted or renamed.
		*/
		directory_opened_status=open_directory(NULL,".",NULL,NULL,0,NULL,1); /* We want to open the directory anyway, so treat it as 'remote'.  This only affects rlog, etc. */
		if (directory_opened_status!=-1)
			directory_opened = 1;
	}

    err += do_recursion (frame, 1);

	if(directory_opened)
		close_directory();

    if (save_update_dir != NULL)
    {
	xfree (update_dir);
	update_dir = save_update_dir;

	if (restore_cwd (&cwd, NULL))
	    error_exit ();
	free_cwd (&cwd);
    }

    dirlist = save_dirlist;
    if (filelist)
	dellist (&filelist);
    return(err);
}
예제 #24
0
파일: root.c 프로젝트: gokzy/netbsd-src
void
root_allow_free (void)
{
    dellist (&root_allow);
}
예제 #25
0
파일: recurse.cpp 프로젝트: acml/cvsnt
/*
 * Implement the recursive policies on the local directory.  This may be
 * called directly, or may be called by start_recursion
 */
static int do_recursion (struct recursion_frame *frame, int top_level)
{
    int err = 0;
    int dodoneproc = 1;
    char *srepository;
    List *entries = NULL;
    int should_readlock;
    int process_this_directory = 1;

    /* do nothing if told */
    if (frame->flags == R_SKIP_ALL)
	return (0);

    should_readlock = noexec ? 0 : frame->readlock;

    /* Check the value in CVSADM_ROOT and see if it's in the list.  If
       not, add it to our lists of CVS/Root directories and do not
       process the files in this directory.  Otherwise, continue as
       usual.  THIS_ROOT might be NULL if we're doing an initial
       checkout -- check before using it.  The default should be that
       we process a directory's contents and only skip those contents
       if a CVS/Root file exists. 

       If we're running the server, we want to process all
       directories, since we're guaranteed to have only one CVSROOT --
       our own.  */

	/* If -d was specified, it should override CVS/Root.

	   In the single-repository case, it is long-standing CVS behavior
	   and makes sense - the user might want another access method,
	   another server (which mounts the same repository), &c.

	   In the multiple-repository case, -d overrides all CVS/Root
	   files.  That is the only plausible generalization I can
	   think of.  */
	if(!(frame->which&W_FAKE) && CVSroot_cmdline == NULL && ! server_active)
    {
	char *this_root = Name_Root ((char *) NULL, update_dir);
	if (this_root != NULL)
	{
	    if (findnode_fn (root_directories, this_root) == NULL)
	    {
		/* Add it to our list. */

		Node *n = getnode ();
		n->type = NT_UNKNOWN;
		n->key = xstrdup (this_root);

		if (addnode (root_directories, n))
		    error (1, 0, "cannot add new CVSROOT %s", this_root);
	
	    }
	
	    process_this_directory =
		    (fncmp (current_parsed_root->original, this_root) == 0);

	    xfree (this_root);
	}
    }

    /*
     * Fill in repository with the current repository
     */
    if (frame->which & W_LOCAL)
    {
		if (isdir (CVSADM))
			repository = Name_Repository ((char *) NULL, update_dir);
		else
			repository = NULL;
    }
    else
	{
		if(update_repos) /* May have been preloaded by checkout */
			repository = xstrdup(update_repos);
		else
		{
			repository = (char*)xmalloc(strlen(current_parsed_root->directory)+strlen(update_dir)+10);
			sprintf(repository,"%s/%s",current_parsed_root->directory,update_dir);
		}
    }

	if(repository && ISDIRSEP(repository[strlen(repository)-1]))
		repository[strlen(repository)-1]='\0';
    srepository = repository;		/* remember what to free */

	if(repository && !current_parsed_root->isremote)
	{
		mapped_repository = map_repository(repository);
	}
	else
	{
		mapped_repository=xstrdup(repository);
	}

	xfree(last_repository);
	last_repository = xstrdup(mapped_repository);

    /*
     * Do we have access to this directory?
     */
	/* Note that for a recursion this is done already in do_dir_proc... */
	if(top_level)
	{
		if(repository && !current_parsed_root->isremote)
		{
			const char *tag;
			const char *message;
			const char *v_msg;

			ParseTag(&tag, NULL, NULL, NULL);

			if (! verify_access(frame->permproc, mapped_repository, NULL, update_dir,frame->tag?frame->tag:tag,&message, &v_msg))
			{
				if(tag)
					error (0, 0, "User '%s' cannot %s %s on tag/branch %s", CVS_Username, v_msg, fn_root(repository), tag);
				else
					error (0, 0, "User '%s' cannot %s %s", CVS_Username, v_msg, fn_root(repository));
				if(message)
					error (0, 0, "%s", message);
				return (1);
			}
			xfree(tag);
			fileattr_startdir (mapped_repository);
		}
	}

    /*
     * The filesdoneproc needs to be called for each directory where files
     * processed, or each directory that is processed by a call where no
     * directories were passed in.  In fact, the only time we don't want to
     * call back the filesdoneproc is when we are processing directories that
     * were passed in on the command line (or in the special case of `.' when
     * we were called with no args
     */
    if (dirlist != NULL && filelist == NULL)
		dodoneproc = 0;

    /*
     * If filelist or dirlist is already set, we don't look again. Otherwise,
     * find the files and directories
     */
    if (filelist == NULL && dirlist == NULL)
    {
	/* both lists were NULL, so start from scratch */
	if (frame->fileproc != NULL && frame->flags != R_SKIP_FILES)
	{
	    int lwhich = frame->which;

	    /* In the !(which & W_LOCAL) case, we filled in repository
	       earlier in the function.  In the (which & W_LOCAL) case,
	       the Find_Names function is going to look through the
	       Entries file.  If we do not have a repository, that
	       does not make sense, so we insist upon having a
	       repository at this point.  Name_Repository will give a
	       reasonable error message.  */
	    if (repository == NULL)
			repository = Name_Repository ((char *) NULL, update_dir);
		else
		if(mapped_repository == NULL)
			mapped_repository = map_repository(repository);

	    /* find the files and fill in entries if appropriate */
	    if (process_this_directory)
	    {
			filelist = Find_Names (mapped_repository, lwhich, frame->aflag,
						&entries, repository);
			if (filelist == NULL)
			{
				error (0, 0, "skipping directory %s", update_dir);
				/* Note that Find_Directories and the filesdoneproc
				in particular would do bad things ("? foo.c" in
				the case of some filesdoneproc's).  */
				goto skip_directory;
			}
	    }
	}

	if (frame->flags == R_SKIP_DIRS && !(frame->which&W_LOCAL) && nonrecursive_module(repository))
		frame->flags = R_SKIP_DIRS;

	/* find sub-directories if we will recurse */
	if (frame->flags != R_SKIP_DIRS)
	    dirlist = Find_Directories (
		process_this_directory ? mapped_repository : NULL,
		frame->which, entries, repository);
    }
    else
    {
		/* something was passed on the command line */
		if (filelist != NULL && frame->fileproc != NULL)
		{
			/* we will process files, so pre-parse entries */
			if (frame->which & W_LOCAL)
				entries = Entries_Open (frame->aflag, NULL);
		}
    }

    /* process the files (if any) */
    if (process_this_directory && filelist != NULL && frame->fileproc)
    {
	struct file_info finfo_struct;
	struct frame_and_file frfile;

	/* read lock it if necessary */
	if (should_readlock && mapped_repository && Reader_Lock (mapped_repository) != 0)
	    error (1, 0, "read lock failed - giving up");

	/* For the server, we handle notifications in a completely different
	   place (server_notify).  For local, we can't do them here--we don't
	   have writelocks in place, and there is no way to get writelocks
	   here.  */
	if (current_parsed_root->isremote)
	    client_notify_check (repository, update_dir);

	finfo_struct.repository = mapped_repository;
	finfo_struct.update_dir = update_dir;
	finfo_struct.entries = entries;
	finfo_struct.virtual_repository = repository;
	/* do_file_proc will fill in finfo_struct.file.  */

	frfile.finfo = &finfo_struct;
	frfile.frame = frame;

	/* process the files */
	err += walklist (filelist, do_file_proc, &frfile);

	/* unlock it */
	if (should_readlock)
	    Lock_Cleanup_Directory();

	/* clean up */
	if (filelist)
	dellist (&filelist);
    }

    /* call-back files done proc (if any) */
    if (process_this_directory && dodoneproc && frame->filesdoneproc != NULL)
	{
		err = frame->filesdoneproc (frame->callerdat, err, (char*)mapped_repository,
				    (char*)(update_dir[0] ? update_dir : "."),
				    entries);
	}

 skip_directory:
	if(repository && !current_parsed_root->isremote)
	{
		fileattr_write ();
		fileattr_free ();
	}

    /* process the directories (if necessary) */
    if (dirlist != NULL)
    {
		// BUGME!!!
		/* for some reason this code path is not entered some times when it SHOULD be, eg:
		   after a rename!  This means the .direcrory_history file is not created !!!! */
	struct frame_and_entries frent;

	frent.frame = frame;
	frent.entries = entries;
	err += walklist (dirlist, do_dir_proc, (void *) &frent);
    }
	if (dirlist)
    dellist (&dirlist);

    if (entries) 
    {
	Entries_Close (entries);
	entries = NULL;
    }

    /* free the saved copy of the pointer if necessary */
	xfree (srepository);
	xfree (mapped_repository);
	repository = NULL;

    return (err);
}
예제 #26
0
파일: g22.c 프로젝트: 8l/csolve
int lupdate(int upptr){
    int i,c,sn,l,m,grp[4],lnew[4],nlist;
    int g,gnew,ldtmp,s;
    int g2;
    if(mvconn[upptr] != EOL)killist(&mvconn[upptr]);
    if(mvcapt[upptr] != EOL)killist(&mvcapt[upptr]);
    kosave[upptr] = kosquare;
    kosquare = NOSQUARE;
    s = mvs[upptr];
    if(s == PASS){  /* pass */
       return(TRUE);
       }
  
    ++numnodes;
    c = mvcolor[upptr];
    l = 0;
    m = 0;
    nlist = EOL;
    i = fdir[s];
    for(ldtmp = ldir[i]; i < ldtmp; ++i){   /* look at neighbors */
      sn = s + nbr[i];
      ++lnbf[sn][c];
      --lnbn[sn];
      dellist(s,&nblbp[sn]);
      g = board[sn];
      if(g == NOGROUP){   /* empty nbr, add a liberty */
         lnew[m++] = sn;
         }
      else if(grcolor[g] != c){      /* unfriendly neighbor */
         if(dellist(s,&grlbp[g])){
            if(--grlibs[g] == 0){  /* killed enemy group */
               lnew[m++] = sn;
               adflist(g,&mvcapt[upptr]);
               lkilgrp(g);
               }
            else grp[l++] = g; 
            }
         }
      else addlist(g,&nlist);      /* friendly neighbor */
      } 
    if(nlist == EOL){ 		/* create a new group */
         if(maxgr > NUMGROUPS - 2){ 
		    return(FALSE); /* probably need more work here */
            } 
         gnew = maxgr++;
         board[s] = gnew; 
         grsize[gnew] = 1;
         grcolor[gnew] = c;
         grlibs[gnew] = m;

         for(i = 0; i < l; ++i){
            g = grp[i];
            addlist(g,&grnbp[gnew]);
            addlist(gnew,&grnbp[g]);
            }
         for(i = 0; i < m; ++i)addlist(lnew[i],&grlbp[gnew]);
         mvnext[upptr] = -1;
         grpieces[gnew] = upptr;
         if(grlibs[gnew] == 1 && mvcapt[upptr] != EOL &&
            grsize[list[mvcapt[upptr]]] == 1 &&
            links[mvcapt[upptr]] == EOL)
            kosquare = list[grlbp[gnew]];
         }
   else {
      if(links[nlist] == EOL){ /* add stone to group */
         gnew = list[nlist];
         for(i = 0; i < l; ++i){
            g2 = grp[i];
            if(addlist(g2,&grnbp[gnew])){
               addlist(gnew,&grnbp[g2]);
               adflist(g2,&nbply[upptr]);
               }
            }
         for(i = 0; i < m; ++i)if(addlist(lnew[i],&grlbp[gnew])){
            ++grlibs[gnew];
            adflist(lnew[i],&lbply[upptr]);
            }
         }
      else{            /* combine groups */
         gnew = lcombine(nlist,upptr);
         for(i = 0; i < l; ++i){
            g2 = grp[i];
            if(addlist(g2,&grnbp[gnew])){
               addlist(gnew,&grnbp[g2]);
               }
            }
         for(i = 0; i < m; ++i)if(addlist(lnew[i],&grlbp[gnew]))
            ++grlibs[gnew];
         }
      board[s] = gnew;
      ++grsize[gnew];
      mvnext[upptr] = grpieces[gnew];
      grpieces[gnew] = upptr;
      --grlibs[gnew];
      dellist(s,&grlbp[gnew]);
      killist(&nlist);
      }
    if(grlibs[gnew] == 0)return(FALSE);  /* illegal suicide */
    return(TRUE);
    } 
예제 #27
0
파일: find_names.cpp 프로젝트: acml/cvsnt
List *Find_Names (const char *repository, int which, int aflag, List **optentries, const char *virtual_repository)
{
    List *entries;
    List *files;
	const char *regex = NULL;

	if(!current_parsed_root->isremote)
		regex = lookup_regex(virtual_repository);

    /* make a list for the files */
    files = filelist = getlist ();

    /* look at entries (if necessary) */
    if (which & W_LOCAL)
    {
		/* parse the entries file (if it exists) */
		entries = Entries_Open (aflag, NULL);
		if (entries != NULL)
		{
			/* walk the entries file adding elements to the files list */
			(void) walklist (entries, add_entries_proc, NULL);

			/* if our caller wanted the entries list, return it; else free it */
			if (optentries != NULL)
				*optentries = entries;
			else
				Entries_Close (entries);
		}
    }

    if ((which & W_REPOS) && repository && !isreadable (CVSADM_ENTSTAT))
    {
		/* search the repository */
		if (find_rcs (repository, files, regex) != 0)
		{
			error (0, errno, "cannot open directory %s", fn_root(repository));
			goto error_exit;
		}

		/* search the attic too */
		{
			char *dir;
			dir = (char*)xmalloc (strlen (repository) + sizeof (CVSATTIC) + 10);
			(void) sprintf (dir, "%s/%s", repository, CVSATTIC);
			if (find_rcs (dir, files, regex) != 0
			&& !existence_error (errno))
			/* For now keep this a fatal error, seems less useful
			for access control than the case above.  */
			error (1, errno, "cannot open directory %s", fn_root(dir));
			xfree (dir);
		}

		if(find_virtual_rcs (virtual_repository, files) != 0)
		{
			error(1, errno, "find_virtual_rcs failed");
		}

		if(find_rename_rcs(virtual_repository, files) != 0)
		{
			error(1,errno, "find_renames failed");
		}
    }

	xfree(regex);

    /* sort the list into alphabetical order and return it */
    sortlist (files, fsortcmp);
    return (files);
 error_exit:
	xfree(regex);
    dellist (&files);
    return NULL;
}
예제 #28
0
파일: ls.c 프로젝트: gosudream/netbsd-src
static int
ls_proc (int argc, char **argv, char *xwhere, char *mwhere, char *mfile,
         int shorten, int local, char *mname, char *msg)
{
    char *repository;
    int err = 0;
    int which;
    char *where;
    int i;

    if (is_rls)
    {
	char *myargv[2];

	if (!quiet)
	    error (0, 0, "Listing module: `%s'",
	           strcmp (mname, "") ? mname : ".");

	repository = xmalloc (strlen (current_parsed_root->directory)
			      + strlen (argv[0])
			      + (mfile == NULL ? 0 : strlen (mfile) + 1)
			      + 2);
	(void)sprintf (repository, "%s/%s", current_parsed_root->directory,
		       argv[0]);
	where = xmalloc (strlen (argv[0])
			 + (mfile == NULL ? 0 : strlen (mfile) + 1)
			 + 1);
	(void)strcpy (where, argv[0]);

	/* If mfile isn't null, we need to set up to do only part of the
	 * module.
	 */
	if (mfile != NULL)
	{
	    char *cp;
	    char *path;

	    /* If the portion of the module is a path, put the dir part on
	     * repos.
	     */
	    if ((cp = strrchr (mfile, '/')) != NULL)
	    {
		*cp = '\0';
		(void)strcat (repository, "/");
		(void)strcat (repository, mfile);
		(void)strcat (where, "/");
		(void)strcat (where, mfile);
		mfile = cp + 1;
	    }

	    /* take care of the rest */
	    path = Xasprintf ("%s/%s", repository, mfile);
	    if (isdir (path))
	    {
		/* directory means repository gets the dir tacked on */
		(void)strcpy (repository, path);
		(void)strcat (where, "/");
		(void)strcat (where, mfile);
	    }
	    else
	    {
		myargv[1] = mfile;
		argc = 2;
		argv = myargv;
	    }
	    free (path);
	}

	/* cd to the starting repository */
	if (CVS_CHDIR (repository) < 0)
	{
	    error (0, errno, "cannot chdir to %s", repository);
	    free (repository);
	    free (where);
	    return 1;
	}

	which = W_REPOS;
    }
    else /* !is_rls */
    {
        repository = NULL;
        where = NULL;
        which = W_LOCAL | W_REPOS;
    }

    if (show_tag || show_date || show_dead_revs)
	which |= W_ATTIC;

    if (show_tag != NULL && !tag_validated)
    {
	tag_check_valid (show_tag, argc - 1, argv + 1, local, 0, repository,
			 false);
	tag_validated = true;
    }

    /* Loop on argc so that we are guaranteed that any directory passed to
     * ls_direntproc should be processed if its parent is not yet in DIRS.
     */
    if (argc == 1)
    {
	List *dirs = getlist ();
	err = start_recursion (ls_fileproc, NULL, ls_direntproc,
			       ls_dirleaveproc, dirs, 0, NULL, local, which, 0,
			       CVS_LOCK_READ, where, 1, repository);
	walklist (dirs, ls_print_dir, NULL);
	dellist (&dirs);
    }
    else
    {
	for (i = 1; i < argc; i++)
	{
	    List *dirs = getlist ();
	    err = start_recursion (ls_fileproc, NULL, ls_direntproc,
				   NULL, dirs, 1, argv + i, local, which, 0,
				   CVS_LOCK_READ, where, 1, repository);
	    walklist (dirs, ls_print_dir, NULL);
	    dellist (&dirs);
	}
    }

    if (!(which & W_LOCAL)) free (repository);
    if (where) free (where);

    return err;
}
예제 #29
0
파일: param.c 프로젝트: E-LLP/QuIP
static COMMAND_FUNC( do_chng_one )
{
	Param *p;
	const char **pnlist;
	int nlist=0;
	int i=0;
	const char *s;

	p=theptbl;

	/* count the number of parameters */
	while( p->p_type != NULL_P_TYPE ) {
		nlist++;
		p++;
	}

	pnlist = (const char **) getbuf( (nlist+1) * sizeof(char *) );
	if( pnlist == NULL ) mem_err("do_chng_one");

#ifdef HAVE_HISTORY

	if( intractive(SINGLE_QSP_ARG) && IS_TRACKING_HISTORY(THIS_QSP) ){
		List *lp;
		Node *np;

		lp = new_list();
		for(i=0;i<nlist;i++){
			pnlist[i] = theptbl[i].p_name;
			np = mk_node(&theptbl[i]);
			addTail(lp,np);
		}
		pnlist[i]="all";
		np = mk_node(&pnlist[i]);
		addTail(lp,np);

		if( intractive(SINGLE_QSP_ARG) ){
			char pline[LLEN];
			make_prompt(QSP_ARG  pline,PNAME_PMPT);
			new_defs(QSP_ARG  pline);		/* is this needed? */
			init_hist_from_item_list(QSP_ARG  PNAME_PMPT,lp);
		}

		dellist(lp);
	}

#else /* ! HAVE_HISTORY */
	for(i=0;i<nlist;i++)
		pnlist[i] = theptbl[i].p_name;
#endif /* ! HAVE_HISTORY */

	s=NAMEOF(PNAME_PMPT);
	if( !strcmp(s,"all") ){
		p=theptbl;
		while( p->p_type != NULL_P_TYPE ) {
			getparm(QSP_ARG  p);
			showparm(QSP_ARG  p);
			p++;
		}
		return;
	} else if( get_pval(QSP_ARG  s,theptbl) == -1 ){
		sprintf(ERROR_STRING,"Unknown parameter \"%s\"",s);
		WARN(ERROR_STRING);
	}
}
예제 #30
0
파일: ignore.c 프로젝트: aosm/cvs
/*
 * Process the current directory, looking for files not in ILIST and
 * not on the global ignore list for this directory.  If we find one,
 * call PROC passing it the name of the file and the update dir.
 * ENTRIES is the entries list, which is used to identify known
 * directories.  ENTRIES may be NULL, in which case we assume that any
 * directory with a CVS administration directory is known.
 */
void
ignore_files (List *ilist, List *entries, const char *update_dir,
              Ignore_proc proc)
{
    int subdirs;
    DIR *dirp;
    struct dirent *dp;
    struct stat sb;
    char *file;
    const char *xdir;
    List *files;
    Node *p;

    /* Set SUBDIRS if we have subdirectory information in ENTRIES.  */
    if (entries == NULL)
	subdirs = 0;
    else
    {
	struct stickydirtag *sdtp = entries->list->data;

	subdirs = sdtp == NULL || sdtp->subdirs;
    }

    /* we get called with update_dir set to "." sometimes... strip it */
    if (strcmp (update_dir, ".") == 0)
	xdir = "";
    else
	xdir = update_dir;

    dirp = CVS_OPENDIR (".");
    if (dirp == NULL)
    {
	error (0, errno, "cannot open current directory");
	return;
    }

    ign_add_file (CVSDOTIGNORE, 1);
    wrap_add_file (CVSDOTWRAPPER, 1);

    /* Make a list for the files.  */
    files = getlist ();

    while (errno = 0, (dp = CVS_READDIR (dirp)) != NULL)
    {
	file = dp->d_name;
	if (strcmp (file, ".") == 0 || strcmp (file, "..") == 0)
	    continue;
	if (findnode_fn (ilist, file) != NULL)
	    continue;
	if (subdirs)
	{
	    Node *node;

	    node = findnode_fn (entries, file);
	    if (node != NULL
		&& ((Entnode *) node->data)->type == ENT_SUBDIR)
	    {
		char *p;
		int dir;

		/* For consistency with past behaviour, we only ignore
		   this directory if there is a CVS subdirectory.
		   This will normally be the case, but the user may
		   have messed up the working directory somehow.  */
		p = Xasprintf ("%s/%s", file, CVSADM);
		dir = isdir (p);
		free (p);
		if (dir)
		    continue;
	    }
	}

	/* We could be ignoring FIFOs and other files which are neither
	   regular files nor directories here.  */
	if (ign_name (file))
	    continue;

	if (
#ifdef DT_DIR
	    dp->d_type != DT_UNKNOWN ||
#endif
	    lstat (file, &sb) != -1)
	{

	    if (
#ifdef DT_DIR
		dp->d_type == DT_DIR
		|| (dp->d_type == DT_UNKNOWN && S_ISDIR (sb.st_mode))
#else
		S_ISDIR (sb.st_mode)
#endif
		)
	    {
		if (!subdirs)
		{
		    char *temp = Xasprintf ("%s/%s", file, CVSADM);
		    if (isdir (temp))
		    {
			free (temp);
			continue;
		    }
		    free (temp);
		}
	    }
#ifdef S_ISLNK
	    else if (
#ifdef DT_DIR
		     dp->d_type == DT_LNK
		     || (dp->d_type == DT_UNKNOWN && S_ISLNK (sb.st_mode))
#else
		     S_ISLNK (sb.st_mode)
#endif
		     )
	    {
		continue;
	    }
#endif
	}

	p = getnode ();
	p->type = FILES;
	p->key = xstrdup (file);
	(void) addnode (files, p);
    }
    if (errno != 0)
	error (0, errno, "error reading current directory");
    (void) CVS_CLOSEDIR (dirp);

    sortlist (files, fsortcmp);
    for (p = files->list->next; p != files->list; p = p->next)
	(*proc) (p->key, xdir);
    dellist (&files);
}