source: git/Singular/ipid.cc @ 8c94ba

spielwiese
Last change on this file since 8c94ba was 2993b2, checked in by Hans Schoenemann <hannes@…>, 13 years ago
git-svn-id: file:///usr/local/Singular/svn/trunk@13930 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 17.4 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id$ */
5
6/*
7* ABSTRACT: identfier handling
8*/
9
10#include <string.h>
11
12#include <kernel/mod2.h>
13#include <Singular/static.h>
14#include <omalloc/omalloc.h>
15#include <Singular/tok.h>
16#include <kernel/options.h>
17#include <Singular/ipshell.h>
18#include <kernel/intvec.h>
19#include <kernel/febase.h>
20#include <kernel/numbers.h>
21#include <kernel/longrat.h>
22#include <kernel/polys.h>
23#include <kernel/ring.h>
24#include <kernel/ideals.h>
25#include <kernel/matpol.h>
26#include <Singular/lists.h>
27#include <Singular/attrib.h>
28#include <Singular/silink.h>
29#include <kernel/syz.h>
30#include <Singular/ipid.h>
31#include <Singular/blackbox.h>
32
33#ifdef HAVE_DYNAMIC_LOADING
34#include <kernel/mod_raw.h>
35#endif /* HAVE_DYNAMIC_LOADING */
36
37omBin sip_command_bin = omGetSpecBin(sizeof(sip_command));
38omBin sip_package_bin = omGetSpecBin(sizeof(sip_package));
39//omBin ip_package_bin = omGetSpecBin(sizeof(ip_package));
40omBin idrec_bin = omGetSpecBin(sizeof(idrec));
41
42proclevel *procstack=NULL;
43#define TEST
44//idhdl idroot = NULL;
45
46idhdl currPackHdl = NULL;
47idhdl basePackHdl = NULL;
48package currPack =NULL;
49package basePack =NULL;
50idhdl currRingHdl = NULL;
51ring  currRing = NULL;
52ideal currQuotient = NULL;
53const char* iiNoName="_";
54
55void paCleanUp(package pack);
56
57/*0 implementation*/
58
59int iiS2I(const char *s)
60{
61  int i;
62  i=s[0];
63  if (s[1]!='\0')
64  {
65    i=(i<<8)+s[1];
66    if (s[2]!='\0')
67    {
68      i=(i<<8)+s[2];
69      if (s[3]!='\0')
70      {
71        i=(i<<8)+s[3];
72      }
73    }
74  }
75  return i;
76}
77
78idhdl idrec::get(const char * s, int lev)
79{
80  assume(s!=NULL);
81  assume((lev>=0) && (lev<=1000)); //not really, but if it isnt in that bounds..
82  idhdl h = this;
83  idhdl found=NULL;
84  int l;
85  const char *id;
86  int i=iiS2I(s);
87  int less4=(i < (1<<24));
88  while (h!=NULL)
89  {
90    omCheckAddr((ADDRESS)IDID(h));
91    l=IDLEV(h);
92    if ((l==0)||(l==lev))
93    {
94      if (i==h->id_i)
95      {
96        id=IDID(h);
97        if (less4 || (0 == strcmp(s+4,id+4)))
98        {
99          if (l==lev) return h;
100          found=h;
101        }
102      }
103    }
104    h = IDNEXT(h);
105  }
106  return found;
107}
108
109//idrec::~idrec()
110//{
111//  if (id!=NULL)
112//  {
113//    omFree((ADDRESS)id);
114//    id=NULL;
115//  }
116//  /* much more !! */
117//}
118
119void *idrecDataInit(int t)
120{
121  switch (t)
122  {
123    //the type with init routines:
124    case INTVEC_CMD:
125    case INTMAT_CMD:
126      return (void *)new intvec();
127    case NUMBER_CMD:
128      return (void *) nInit(0);
129    case BIGINT_CMD:
130      return (void *) nlInit(0, NULL /* dummy for nlInit*/);
131    case IDEAL_CMD:
132    case MODUL_CMD:
133    case MATRIX_CMD:
134      return (void*) idInit(1,1);
135    case MAP_CMD:
136    {
137      map m = (map)idInit(1,1);
138      m->preimage = omStrDup(IDID(currRingHdl));
139      return (void *)m;
140    }
141    case STRING_CMD:
142      return (void *)omAlloc0(1);
143    case LIST_CMD:
144    {
145      lists l=(lists)omAllocBin(slists_bin);
146      l->Init();
147      return (void*)l;
148    }
149    //the types with the standard init: set the struct to zero
150    case LINK_CMD:
151      return (void*) omAlloc0Bin(sip_link_bin);
152    case RING_CMD:
153      return (void*) omAlloc0Bin(sip_sring_bin);
154    case PACKAGE_CMD:
155      return (void*) omAlloc0Bin(sip_package_bin);
156    case PROC_CMD:
157      return (void *) omAlloc0Bin(procinfo_bin);
158    case RESOLUTION_CMD:
159      return  (void *)omAlloc0(sizeof(ssyStrategy));
160    //other types: without init (int,script,poly,def,package)
161    case INT_CMD:
162    case DEF_CMD:
163    case POLY_CMD:
164    case VECTOR_CMD:
165    case QRING_CMD:
166       return (void*)0L;
167    default:
168      {
169        if (t>MAX_TOK)
170        {
171#ifdef BLACKBOX_DEVEL
172          Print("bb-type %d\n",t);
173#endif
174          blackbox *bb=getBlackboxStuff(t);
175          if (bb!=NULL)
176             return (void *)bb->blackbox_Init(bb);
177        }
178        else
179          Werror("unknown type %d",t);
180        break;
181      }
182  }
183  return (void *)0L;
184}
185idhdl idrec::set(const char * s, int lev, int t, BOOLEAN init)
186{
187  //printf("define %s, %x, lev: %d, typ: %d\n", s,s,lev,t);
188  idhdl h = (idrec *)omAlloc0Bin(idrec_bin);
189  IDID(h)   = s;
190  IDTYP(h)  = t;
191  IDLEV(h)  = lev;
192  IDNEXT(h) = this;
193  h->id_i=iiS2I(s);
194  if (init)
195  {
196    if ((t==IDEAL_CMD)||(t==MODUL_CMD))
197      IDFLAG(h) = Sy_bit(FLAG_STD);
198    IDSTRING(h)=(char *)idrecDataInit(t);
199    // additional settings:--------------------------------------
200#if 0
201    // this leads to a memory leak
202    if (t == QRING_CMD)
203    {
204      // IDRING(h)=rCopy(currRing);
205      /* QRING_CMD is ring dep => currRing !=NULL */
206    }
207    else
208#endif
209    if (t == PROC_CMD)
210    {
211      IDPROC(h)->language=LANG_NONE;
212    }
213    else if (t == PACKAGE_CMD)
214    {
215      IDPACKAGE(h)->language=LANG_NONE;
216      IDPACKAGE(h)->loaded = FALSE;
217    }
218  }
219  // --------------------------------------------------------
220  return  h;
221}
222
223char * idrec::String()
224{
225  sleftv tmp;
226  memset(&tmp,0,sizeof(sleftv));
227  tmp.rtyp=IDTYP(this);
228  tmp.data=IDDATA(this);
229  tmp.name=IDID(this);
230  return tmp.String();
231}
232
233idhdl enterid(const char * s, int lev, int t, idhdl* root, BOOLEAN init, BOOLEAN search)
234{
235  idhdl h;
236  s=omStrDup(s);
237  // is it already defined in root ?
238  if ((h=(*root)->get(s,lev))!=NULL)
239  {
240    if (IDLEV(h)==lev)
241    {
242      if ((IDTYP(h) == t)||(t==DEF_CMD))
243      {
244        if ((IDTYP(h)==PACKAGE_CMD)
245        && (strcmp(s,"Top")==0))
246        {
247          goto errlabel;
248        }
249        if (BVERBOSE(V_REDEFINE))
250          Warn("redefining %s **",s);
251        if (s==IDID(h)) IDID(h)=NULL;
252        killhdl2(h,root,currRing);
253      }
254      else
255        goto errlabel;
256    }
257  }
258  // is it already defined in currRing->idroot ?
259  else if (search && (currRing!=NULL)&&((*root) != currRing->idroot))
260  {
261    if ((h=currRing->idroot->get(s,lev))!=NULL)
262    {
263      if (IDLEV(h)==lev)
264      {
265        if ((IDTYP(h) == t)||(t==DEF_CMD))
266        {
267          if (BVERBOSE(V_REDEFINE))
268            Warn("redefining %s **",s);
269          IDID(h)=NULL;
270          killhdl2(h,&currRing->idroot,currRing);
271        }
272        else
273          goto errlabel;
274      }
275    }
276  }
277  // is it already defined in idroot ?
278  else if (search && (*root != IDROOT))
279  {
280    if ((h=IDROOT->get(s,lev))!=NULL)
281    {
282      if (IDLEV(h)==lev)
283      {
284        if ((IDTYP(h) == t)||(t==DEF_CMD))
285        {
286          if (BVERBOSE(V_REDEFINE))
287            Warn("redefining `%s` **",s);
288          if (s==IDID(h)) IDID(h)=NULL;
289          killhdl2(h,&IDROOT,NULL);
290        }
291        else
292          goto errlabel;
293      }
294    }
295  }
296  *root = (*root)->set(s, lev, t, init);
297#ifndef NDEBUG
298  checkall();
299#endif
300  return *root;
301
302  errlabel:
303    //Werror("identifier `%s` in use(lev h=%d,typ=%d,t=%d, curr=%d)",s,IDLEV(h),IDTYP(h),t,lev);
304    Werror("identifier `%s` in use",s);
305    //listall();
306    omFree((ADDRESS)s);
307    return NULL;
308}
309void killid(const char * id, idhdl * ih)
310{
311  if (id!=NULL)
312  {
313    idhdl h = (*ih)->get(id,myynest);
314
315    // id not found in global list, is it defined in current ring ?
316    if (h==NULL)
317    {
318      if ((currRing!=NULL) && (*ih != (currRing->idroot)))
319      {
320        h = currRing->idroot->get(id,myynest);
321        if (h!=NULL)
322        {
323          killhdl2(h,&(currRing->idroot),currRing);
324          return;
325        }
326      }
327      Werror("`%s` is not defined",id);
328      return;
329    }
330    killhdl2(h,ih,currRing);
331  }
332  else
333    Werror("kill what ?");
334}
335
336void killhdl(idhdl h, package proot)
337{
338  int t=IDTYP(h);
339  if (((BEGIN_RING<t) && (t<END_RING) && (t!=QRING_CMD))
340  || ((t==LIST_CMD) && (lRingDependend((lists)IDDATA(h)))))
341    killhdl2(h,&currRing->idroot,currRing);
342  else
343  {
344    if(t==PACKAGE_CMD)
345    {
346      killhdl2(h,&(basePack->idroot),NULL);
347    }
348    else
349    {
350      idhdl s=proot->idroot;
351      while ((s!=h) && (s!=NULL)) s=s->next;
352      if (s!=NULL)
353        killhdl2(h,&(proot->idroot),NULL);
354      else if (basePack!=proot)
355      {
356        idhdl s=basePack->idroot;
357        while ((s!=h) && (s!=NULL)) s=s->next;
358        if (s!=NULL)
359          killhdl2(h,&(basePack->idroot),currRing);
360        else
361          killhdl2(h,&(currRing->idroot),currRing);
362       }
363    }
364  }
365}
366
367void killhdl2(idhdl h, idhdl * ih, ring r)
368{
369  //printf("kill %s, id %x, typ %d lev: %d\n",IDID(h),(int)IDID(h),IDTYP(h),IDLEV(h));
370  idhdl hh;
371
372  if (h->attribute!=NULL)
373  {
374    //at_KillAll(h,r);
375    h->attribute=NULL;
376  }
377  if ((IDTYP(h) == PACKAGE_CMD) && (strcmp(IDID(h),"Top")==0))
378  {
379    WarnS("can not kill `Top`");
380    return;
381  }
382  // ring / qring  --------------------------------------------------------
383  if ((IDTYP(h) == RING_CMD) || (IDTYP(h) == QRING_CMD))
384  {
385    // any objects defined for this ring ? -> done by rKill
386    rKill(h);
387  }
388  // package -------------------------------------------------------------
389  else if (IDTYP(h) == PACKAGE_CMD)
390  {
391    // any objects defined for this package ?
392    if ((IDPACKAGE(h)->ref<=0)  &&  (IDPACKAGE(h)->idroot!=NULL))
393    {
394      if (currPack==IDPACKAGE(h))
395      {
396        currPack=basePack;
397        currPackHdl=NULL;
398      }
399      idhdl * hd = &IDRING(h)->idroot;
400      idhdl  hdh = IDNEXT(*hd);
401      idhdl  temp;
402      while (hdh!=NULL)
403      {
404        temp = IDNEXT(hdh);
405        killhdl2(hdh,&(IDPACKAGE(h)->idroot),NULL);
406        hdh = temp;
407      }
408      killhdl2(*hd,hd,NULL);
409      if (IDPACKAGE(h)->libname!=NULL) omFree((ADDRESS)(IDPACKAGE(h)->libname));
410    }
411    paKill(IDPACKAGE(h));
412    if (currPackHdl==h) currPackHdl=packFindHdl(currPack);
413    iiCheckPack(currPack);
414  }
415  // poly / vector -------------------------------------------------------
416  else if ((IDTYP(h) == POLY_CMD) || (IDTYP(h) == VECTOR_CMD))
417  {
418    assume(r!=NULL);
419    p_Delete(&IDPOLY(h),r);
420  }
421  // ideal / module/ matrix / map ----------------------------------------
422  else if ((IDTYP(h) == IDEAL_CMD)
423           || (IDTYP(h) == MODUL_CMD)
424           || (IDTYP(h) == MATRIX_CMD)
425           || (IDTYP(h) == MAP_CMD))
426  {
427    assume(r!=NULL);
428    ideal iid = IDIDEAL(h);
429    if (IDTYP(h) == MAP_CMD)
430    {
431      map im = IDMAP(h);
432      omFree((ADDRESS)im->preimage);
433    }
434    id_Delete(&iid,r);
435  }
436  // string -------------------------------------------------------------
437  else if (IDTYP(h) == STRING_CMD)
438  {
439    omFree((ADDRESS)IDSTRING(h));
440    //IDSTRING(h)=NULL;
441  }
442  // proc ---------------------------------------------------------------
443  else if (IDTYP(h) == PROC_CMD)
444  {
445    if (piKill(IDPROC(h))) return;
446  }
447  // number -------------------------------------------------------------
448  else if (IDTYP(h) == NUMBER_CMD)
449  {
450    assume(r!=NULL);
451    n_Delete(&IDNUMBER(h),r);
452  }
453  // bigint -------------------------------------------------------------
454  else if (IDTYP(h) == BIGINT_CMD)
455  {
456    nlDelete(&IDNUMBER(h),NULL);
457  }
458  // intvec / intmat  ---------------------------------------------------
459  else if ((IDTYP(h) == INTVEC_CMD)||(IDTYP(h) == INTMAT_CMD))
460  {
461    delete IDINTVEC(h);
462  }
463  // list  -------------------------------------------------------------
464  else if (IDTYP(h)==LIST_CMD)
465  {
466    IDLIST(h)->Clean(r);
467    //IDLIST(h)=NULL;
468  }
469  // link  -------------------------------------------------------------
470  else if (IDTYP(h)==LINK_CMD)
471  {
472    slKill(IDLINK(h));
473  }
474  else if(IDTYP(h)==RESOLUTION_CMD)
475  {
476    assume(r!=NULL);
477    if (IDDATA(h)!=NULL)
478      syKillComputation((syStrategy)IDDATA(h),r);
479  }
480  // blackbox -------------------------------------------------------------
481  else if (IDTYP(h)>MAX_TOK)
482  {
483    blackbox *bb=getBlackboxStuff(IDTYP(h));
484    if (bb!=NULL) bb->blackbox_destroy(bb,IDDATA(h));
485    IDDATA(h)=NULL;
486  }
487#ifdef TEST
488  else if ((IDTYP(h)!= INT_CMD)
489  &&(IDTYP(h)!=DEF_CMD)
490  &&(IDTYP(h)!=ALIAS_CMD)
491  &&(IDTYP(h)!=NONE))
492    Warn("unknown type to kill: %s(%d)",Tok2Cmdname(IDTYP(h)),IDTYP(h));
493#endif
494
495  //  general  -------------------------------------------------------------
496  // now dechain it and delete idrec
497  if (IDID(h)!=NULL) // OB: ?????
498    omFree((ADDRESS)IDID(h));
499  IDID(h)=NULL;
500  IDDATA(h)=NULL;
501  if (h == (*ih))
502  {
503    // h is at the beginning of the list
504    *ih = IDNEXT(h) /* ==*ih */;
505  }
506  else if (ih!=NULL)
507  {
508    // h is somethere in the list:
509    hh = *ih;
510    loop
511    {
512      if (hh==NULL)
513      {
514        PrintS(">>?<< not found for kill\n");
515        return;
516      }
517      idhdl hhh = IDNEXT(hh);
518      if (hhh == h)
519      {
520        IDNEXT(hh) = IDNEXT(hhh);
521        break;
522      }
523      hh = hhh;
524    }
525  }
526  omFreeBin((ADDRESS)h, idrec_bin);
527}
528
529idhdl ggetid(const char *n, BOOLEAN local, idhdl *packhdl)
530{
531  idhdl h = IDROOT->get(n,myynest);
532  idhdl h2=NULL;
533  *packhdl = NULL;
534  if ((currRing!=NULL) && ((h==NULL)||(IDLEV(h)!=myynest)))
535  {
536    h2 = currRing->idroot->get(n,myynest);
537  }
538  if (h2==NULL) return h;
539  return h2;
540}
541
542idhdl ggetid(const char *n)
543{
544  idhdl h = IDROOT->get(n,myynest);
545  if ((h!=NULL)&&(IDLEV(h)==myynest)) return h;
546  idhdl h2=NULL;
547  if (currRing!=NULL)
548  {
549    h2 = currRing->idroot->get(n,myynest);
550  }
551  if (h2!=NULL) return h2;
552  if (h!=NULL) return h;
553  if (basePack!=currPack)
554    return basePack->idroot->get(n,myynest);
555  return NULL;
556}
557
558void ipListFlag(idhdl h)
559{
560  if (hasFlag(h,FLAG_STD)) PrintS(" (SB)");
561#ifdef HAVE_PLURAL
562  if (hasFlag(h,FLAG_TWOSTD)) PrintS(" (2SB)");
563#endif
564}
565
566lists ipNameList(idhdl root)
567{
568  idhdl h=root;
569  /* compute the length */
570  int l=0;
571  while (h!=NULL) { l++; h=IDNEXT(h); }
572  /* allocate list */
573  lists L=(lists)omAllocBin(slists_bin);
574  L->Init(l);
575  /* copy names */
576  h=root;
577  l=0;
578  while (h!=NULL)
579  {
580    /* list is initialized with 0 => no need to clear anything */
581    L->m[l].rtyp=STRING_CMD;
582    L->m[l].data=omStrDup(IDID(h));
583    l++;
584    h=IDNEXT(h);
585  }
586  return L;
587}
588
589/*
590* move 'tomove' from root1 list to root2 list
591*/
592static int ipSwapId(idhdl tomove, idhdl &root1, idhdl &root2)
593{
594  idhdl h;
595  /* search 'tomove' in root2 : if found -> do nothing */
596  h=root2;
597  while ((h!=NULL) && (h!=tomove)) h=IDNEXT(h);
598  if (h!=NULL) return FALSE; /*okay */
599  /* search predecessor of h in root1, remove 'tomove' */
600  h=root1;
601  if (tomove==h)
602  {
603    root1=IDNEXT(h);
604  }
605  else
606  {
607    while ((h!=NULL) && (IDNEXT(h)!=tomove)) h=IDNEXT(h);
608    if (h==NULL) return TRUE; /* not in the list root1 -> do nothing */
609    IDNEXT(h)=IDNEXT(tomove);
610  }
611  /* add to root2 list */
612  IDNEXT(tomove)=root2;
613  root2=tomove;
614  return FALSE;
615}
616
617void  ipMoveId(idhdl tomove)
618{
619  if ((currRing!=NULL)&&(tomove!=NULL))
620  {
621    if (((QRING_CMD!=IDTYP(tomove)) && RingDependend(IDTYP(tomove)))
622    || ((IDTYP(tomove)==LIST_CMD) && (lRingDependend(IDLIST(tomove)))))
623    {
624      /*move 'tomove' to ring id's*/
625      if (ipSwapId(tomove,IDROOT,currRing->idroot))
626      ipSwapId(tomove,basePack->idroot,currRing->idroot);
627    }
628    else
629    {
630      /*move 'tomove' to global id's*/
631      ipSwapId(tomove,currRing->idroot,IDROOT);
632    }
633  }
634}
635
636const char * piProcinfo(procinfov pi, const char *request)
637{
638  if(pi == NULL) return "empty proc";
639  else if (strcmp(request, "libname")  == 0) return pi->libname;
640  else if (strcmp(request, "procname") == 0) return pi->procname;
641  else if (strcmp(request, "type")     == 0)
642  {
643    switch (pi->language)
644    {
645      case LANG_SINGULAR: return "singular"; break;
646      case LANG_C:        return "object";   break;
647      case LANG_NONE:     return "none";     break;
648      default:            return "unknow language";
649    }
650  }
651  else if (strcmp(request, "ref")      == 0)
652  {
653    char p[8];
654    sprintf(p, "%d", pi->ref);
655    return omStrDup(p);  // MEMORY-LEAK
656  }
657  return "??";
658}
659
660void piCleanUp(procinfov pi)
661{
662  (pi->ref)--;
663  if (pi->ref <= 0)
664  {
665    if (pi->libname != NULL) // OB: ????
666      omFree((ADDRESS)pi->libname);
667    if (pi->procname != NULL) // OB: ????
668      omFree((ADDRESS)pi->procname);
669
670    if( pi->language == LANG_SINGULAR)
671    {
672      if (pi->data.s.body != NULL) // OB: ????
673        omFree((ADDRESS)pi->data.s.body);
674    }
675    if( pi->language == LANG_C)
676    {
677    }
678    memset((void *) pi, 0, sizeof(procinfo));
679    pi->language=LANG_NONE;
680  }
681}
682
683BOOLEAN piKill(procinfov pi)
684{
685  Voice *p=currentVoice;
686  while (p!=NULL)
687  {
688    if (p->pi==pi && pi->ref <= 1)
689    {
690      Warn("`%s` in use, can not be killed",pi->procname);
691      return TRUE;
692    }
693    p=p->next;
694  }
695  piCleanUp(pi);
696  if (pi->ref <= 0)
697    omFreeBin((ADDRESS)pi,  procinfo_bin);
698  return FALSE;
699}
700
701void paCleanUp(package pack)
702{
703  (pack->ref)--;
704  if (pack->ref < 0)
705  {
706#ifndef HAVE_STATIC
707    if( pack->language == LANG_C)
708    {
709      Print("//dlclose(%s)\n",pack->libname);
710#ifdef HAVE_DYNAMIC_LOADING
711      dynl_close (pack->handle);
712#endif /* HAVE_DYNAMIC_LOADING */
713    }
714#endif /* HAVE_STATIC */
715    omfree((ADDRESS)pack->libname);
716    memset((void *) pack, 0, sizeof(sip_package));
717    pack->language=LANG_NONE;
718  }
719}
720
721void proclevel::push(char *n)
722{
723  //Print("push %s\n",n);
724  proclevel *p=(proclevel*)omAlloc0(sizeof(proclevel));
725  p->cRing=currRing;
726  p->cRingHdl=currRingHdl;
727  p->name=n;
728  p->cPackHdl=currPackHdl;
729  p->cPack=currPack;
730  p->next=this;
731  procstack=p;
732}
733void proclevel::pop()
734{
735  //Print("pop %s\n",name);
736  //if (currRing!=::currRing) PrintS("currRing wrong\n");;
737  //::currRing=this->currRing;
738  //if (r==NULL) Print("set ring to NULL at lev %d(%s)\n",myynest,name);
739  //::currRingHdl=this->currRingHdl;
740  //if((::currRingHdl==NULL)||(IDRING(::currRingHdl)!=(::currRing)))
741  //  ::currRingHdl=rFindHdl(::currRing,NULL,NULL);
742  //Print("restore pack=%s,1.obj=%s\n",IDID(currPackHdl),IDID(currPack->idroot));
743  currPackHdl=this->cPackHdl;
744  currPack=this->cPack;
745  iiCheckPack(currPack);
746  proclevel *p=this;
747  procstack=next;
748  omFreeSize(p,sizeof(proclevel));
749}
750
751idhdl packFindHdl(package r)
752{
753  idhdl h=basePack->idroot;
754  while (h!=NULL)
755  {
756    if ((IDTYP(h)==PACKAGE_CMD)
757        && (IDPACKAGE(h)==r))
758      return h;
759    h=IDNEXT(h);
760  }
761  return NULL;
762}
Note: See TracBrowser for help on using the repository browser.