httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@hyperreal.org
Subject cvs commit: apache-2.0/mpm/src/ap ap_hooks.c
Date Sun, 01 Aug 1999 20:26:31 GMT
ben         99/08/01 13:26:31

  Modified:    mpm/src/ap ap_hooks.c
  Log:
  Reformat according to style guide.
  
  Revision  Changes    Path
  1.4       +54 -65    apache-2.0/mpm/src/ap/ap_hooks.c
  
  Index: ap_hooks.c
  ===================================================================
  RCS file: /export/home/cvs/apache-2.0/mpm/src/ap/ap_hooks.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ap_hooks.c	1999/07/19 06:50:10	1.3
  +++ ap_hooks.c	1999/08/01 20:26:31	1.4
  @@ -8,53 +8,51 @@
   
   /* NB: This must echo the LINK_##name structure */
   typedef struct
  -    {
  +{
       void (*dummy)(void *);
       const char *szName;
       const char * const *aszPredecessors;
       const char * const *aszSuccessors;
       int nOrder;
  -    } TSortData;
  +} TSortData;
   
   typedef struct tsort_
  -    {
  +{
       void *pData;
       int nPredecessors;
       struct tsort_ **ppPredecessors;
       struct tsort_ *pNext;
  -    } TSort;
  +} TSort;
   
   static int crude_order(const void *a_,const void *b_)
  -    {
  +{
       const TSortData *a=a_;
       const TSortData *b=b_;
   
       return a->nOrder-b->nOrder;
  -    }
  +}
   
   static TSort *prepare(pool *p,TSortData *pItems,int nItems)
  -    {
  +{
       TSort *pData=ap_palloc(p,nItems*sizeof *pData);
       int n;
  -
  +    
       qsort(pItems,nItems,sizeof *pItems,crude_order);
  -    for(n=0 ; n < nItems ; ++n)
  -	{
  +    for(n=0 ; n < nItems ; ++n) {
   	pData[n].nPredecessors=0;
   	pData[n].ppPredecessors=ap_palloc(p,nItems*sizeof *pData[n].ppPredecessors);
   	pData[n].pNext=NULL;
   	pData[n].pData=&pItems[n];
  -	}
  +    }
   
  -    for(n=0 ; n < nItems ; ++n)
  -	{
  +    for(n=0 ; n < nItems ; ++n) {
   	int i,k;
   
   	for(i=0 ; pItems[n].aszPredecessors && pItems[n].aszPredecessors[i] ; ++i)
   	    for(k=0 ; k < nItems ; ++k)
  -		if(!strcmp(pItems[k].szName,pItems[n].aszPredecessors[i]))
  -		    {
  +		if(!strcmp(pItems[k].szName,pItems[n].aszPredecessors[i])) {
   		    int l;
  +
   		    for(l=0 ; l < pData[n].nPredecessors ; ++l)
   			if(pData[n].ppPredecessors[l] == &pData[k])
   			    goto got_it;
  @@ -62,12 +60,12 @@
   		    ++pData[n].nPredecessors;
   		got_it:
   		    break;
  -		    }
  +		}
   	for(i=0 ; pItems[n].aszSuccessors && pItems[n].aszSuccessors[i] ; ++i)
   	    for(k=0 ; k < nItems ; ++k)
  -		if(!strcmp(pItems[k].szName,pItems[n].aszSuccessors[i]))
  -		    {
  +		if(!strcmp(pItems[k].szName,pItems[n].aszSuccessors[i])) {
   		    int l;
  +
   		    for(l=0 ; l < pData[k].nPredecessors ; ++l)
   			if(pData[k].ppPredecessors[l] == &pData[n])
   			    goto got_it2;
  @@ -75,29 +73,27 @@
   		    ++pData[k].nPredecessors;
   		got_it2:
   		    break;
  -		    }
  -	}
  +		}
  +    }
   
       return pData;
  -    }
  +}
   
   static TSort *tsort(TSort *pData,int nItems)
  -    {
  +{
       int nTotal;
       TSort *pHead=NULL;
       TSort *pTail=NULL;
   
  -    for(nTotal=0 ; nTotal < nItems ; ++nTotal)
  -	{
  +    for(nTotal=0 ; nTotal < nItems ; ++nTotal) {
   	int n,i,k;
   
  -	for(n=0 ; ; ++n)
  -	    {
  +	for(n=0 ; ; ++n) {
   	    if(n == nItems)
   		assert(0);      /* // we have a loop... */
   	    if(!pData[n].pNext && !pData[n].nPredecessors)
   		break;
  -	    }
  +	}
   	if(pTail)
   	    pTail->pNext=&pData[n];
   	else
  @@ -106,18 +102,17 @@
   	pTail->pNext=pTail;     /* // fudge it so it looks linked */
   	for(i=0 ; i < nItems ; ++i)
   	    for(k=0 ; pData[i].ppPredecessors[k] ; ++k)
  -		if(pData[i].ppPredecessors[k] == &pData[n])
  -		    {
  +		if(pData[i].ppPredecessors[k] == &pData[n]) {
   		    --pData[i].nPredecessors;
   		    break;
  -		    }
  -	}
  +		}
  +    }
       pTail->pNext=NULL;  /* // unfudge the tail */
       return pHead;
  -    }
  +}
   
   static array_header *sort_hook(array_header *pHooks,const char *szName)
  -    {
  +{
       pool *p=ap_make_sub_pool(g_pHookPool);
       TSort *pSort;
       array_header *pNew;
  @@ -128,29 +123,28 @@
       pNew=ap_make_array(g_pHookPool,pHooks->nelts,sizeof(TSortData));
       if(g_bDebugHooks)
   	printf("Sorting %s:",szName);
  -    for(n=0 ; pSort ; pSort=pSort->pNext,++n)
  -	{
  +    for(n=0 ; pSort ; pSort=pSort->pNext,++n) {
   	TSortData *pHook;
   	assert(n < pHooks->nelts);
   	pHook=ap_push_array(pNew);
   	memcpy(pHook,pSort->pData,sizeof *pHook);
   	if(g_bDebugHooks)
   	    printf(" %s",pHook->szName);
  -	}
  +    }
       if(g_bDebugHooks)
   	fputc('\n',stdout);
       return pNew;
  -    }
  +}
   
   static array_header *s_aHooksToSort;
   typedef struct
  -    {
  +{
       const char *szHookName;
       array_header **paHooks;
  -    } HookSortEntry;
  +} HookSortEntry;
   
   void ap_hook_sort_register(const char *szHookName,array_header **paHooks)
  -    {
  +{
       HookSortEntry *pEntry;
   
       if(!s_aHooksToSort)
  @@ -158,68 +152,63 @@
       pEntry=ap_push_array(s_aHooksToSort);
       pEntry->szHookName=szHookName;
       pEntry->paHooks=paHooks;
  -    }
  +}
   
   void ap_sort_hooks()
  -    {
  +{
       int n;
   
  -    for(n=0 ; n < s_aHooksToSort->nelts ; ++n)
  -	{
  +    for(n=0 ; n < s_aHooksToSort->nelts ; ++n) {
   	HookSortEntry *pEntry=&((HookSortEntry *)s_aHooksToSort->elts)[n];
   	*pEntry->paHooks=sort_hook(*pEntry->paHooks,pEntry->szHookName);
  -	}
       }
  +}
   
   void ap_show_hook(const char *szName,const char * const *aszPre,
   		  const char * const *aszSucc)
  -    {
  +{
       int nFirst;
   
       printf("  Hooked %s",szName);
  -    if(aszPre)
  -	{
  +    if(aszPre) {
   	fputs(" pre(",stdout);
   	nFirst=1;
  -	while(*aszPre)
  -	    {
  +	while(*aszPre) {
   	    if(!nFirst)
   		fputc(',',stdout);
   	    nFirst=0;
   	    fputs(*aszPre,stdout);
   	    ++aszPre;
  -	    }
  -	fputc(')',stdout);
   	}
  -    if(aszSucc)
  -	{
  +	fputc(')',stdout);
  +    }
  +    if(aszSucc) {
   	fputs(" succ(",stdout);
   	nFirst=1;
  -	while(*aszSucc)
  -	    {
  +	while(*aszSucc) {
   	    if(!nFirst)
   		fputc(',',stdout);
   	    nFirst=0;
   	    fputs(*aszSucc,stdout);
   	    ++aszSucc;
  -	    }
  -	fputc(')',stdout);
   	}
  -    fputc('\n',stdout);
  +	fputc(')',stdout);
       }
  +    fputc('\n',stdout);
  +}
   
   #if 0
   void main()
  -    {
  +{
       const char *aszAPre[]={"b","c",NULL};
       const char *aszBPost[]={"a",NULL};
       const char *aszCPost[]={"b",NULL};
       TSortData t1[]=
  -	{
  +    {
   	{ "a",aszAPre,NULL },
  -	    { "b",NULL,aszBPost },
  -	    { "c",NULL,aszCPost }
  -	};
  +	{ "b",NULL,aszBPost },
  +	{ "c",NULL,aszCPost }
  +    };
       TSort *pResult;
   
       pResult=prepare(t1,3);
  @@ -227,5 +216,5 @@
   
       for( ; pResult ; pResult=pResult->pNext)
   	printf("%s\n",pResult->pData->szName);
  -    }
  +}
   #endif
  
  
  

Mime
View raw message