Ejemplo n.º 1
0
	/****************************************************************
	 * TclDirectoryTag:
	 * Perform directory of all of the tags
	 ****************************************************************/
int TclDirectoryTag()
   {
    int   sub_total;
    int   grand_total;
    char  *nodename;
    char  *tagnam;
    char  text[40];
    void  *ctx;
    static DYNAMIC_DESCRIPTOR(dsc_tagnam);
    static DYNAMIC_DESCRIPTOR(dsc_outLine);

    sub_total = grand_total = 0;
    while (cli_get_value("TAG",&dsc_tagnam) & 1)
       {
        tagnam = dsc_tagnam.dscA_pointer;
        l2u(tagnam,0);
        ctx = 0;
        sub_total = 0;
        TclTextOut(" ");
        sprintf(text,"Tag listing for %s",tagnam);
        TclTextOut(text);
        TclTextOut(" ");
        while ((nodename = TreeFindTagWild(tagnam,0,&ctx)))
           {
            TclTextOut(nodename);
            sub_total++;
           }
        TreeFindTagEnd(&ctx);
        grand_total += sub_total;
        sprintf(text,"Total of %d tags\n",sub_total);
        TclTextOut(text);
       }
    if (grand_total != sub_total)
       {
        sprintf(text,"Grand Total of %d tags\n",sub_total);
        TclTextOut(text);
       }
    return 1;
   }
Ejemplo n.º 2
0
int       _TreeCreatePulseFile(void *dbid, int shotid, int numnids_in, int *nids_in)
{
  PINO_DATABASE *dblist = (PINO_DATABASE *)dbid;
  int       status = 1;
  int       retstatus;
  int       num;
  int       nids[256];
  int       i;
  int       j;
  int       shot;
  int source_shot;

/* Make sure tree is open */

  if ((status = _TreeIsOpen(dblist)) != TreeOPEN)
    return status;

  source_shot = dblist->shotid;
  if (numnids_in == 0)
  {
    void       *ctx = 0;
    nids[0]=0;
    for (num = 1; num < 256 && (_TreeFindNodeWild(dbid, "***", &nids[num], &ctx,(1 << TreeUSAGE_SUBTREE)) & 1); num++);
    TreeFindTagEnd(&ctx);
  }
  else
  {
    num = 0;
    for (i = 0; i < numnids_in; i++)
    {
      for (j = 0; j < num; j++)
	if (nids[j] == nids_in[i])
	  break;
      if (j == num)
	nids[num++] = nids_in[i];
    }
  }
  if (dblist->remote)
    return CreatePulseFileRemote(dblist, shotid, nids, num);
  if (shotid)
    shot = shotid;
  else
    shot = TreeGetCurrentShotId(dblist->experiment);

  retstatus = status;
  if (status & 1)
  {
    for (i = 0; i < num && (retstatus & 1); i++)
    {
      int skip=0;
      char name[13];
      if (nids[i])
      {
	int flags;
        NCI_ITM itmlst[] = {{sizeof(name)-1, NciNODE_NAME, 0, 0}, {4, NciGET_FLAGS,&flags,0},{0, NciEND_OF_LIST, 0, 0}};
        itmlst[0].pointer = name;
        status = _TreeGetNci(dbid, nids[i], itmlst);
	if (numnids_in == 0)
	  skip = (flags & NciM_INCLUDE_IN_PULSE) == 0;
        name[12] = 0;
        for (j=11;j>0;j--) if (name[j] == 0x20) name[j] = '\0';
      }
      else
      {
        strcpy(name,dblist->experiment);
      }
      if (status & 1 && !(skip))
        status = TreeCreateTreeFiles(name, shot, source_shot);
      if (!(status & 1) && (i==0))
        retstatus = status;
    }
  }
  return retstatus;
}
Ejemplo n.º 3
0
char *_TreeFindTagWild(void *dbid, char *wild, int *nidout, void **ctx_inout)
{
    PINO_DATABASE *dblist = (PINO_DATABASE *)dbid;
    /***************************
      check that there is a tree
      open.
     ****************************/
    if (!IS_OPEN(dblist))
        return NULL;
    if (dblist->remote)
        return FindTagWildRemote(dblist,wild,nidout,ctx_inout);
    else
    {
        NID *nid_ptr = (NID *)nidout;
        TAG_SEARCH **ctx = (TAG_SEARCH **)ctx_inout;
        int       status = 1;
        unsigned char found,done;
        static char answer[128];

        /**********************************
        If this is the first time then
        allocate a context block and fill
        it in with a parse of the tagname.
        ***********************************/
        if (*ctx == (TAG_SEARCH *) 0)
        {
            *ctx = NewTagSearch(wild);
            if (*ctx == (TAG_SEARCH *) 0)
                status = TreeNMT;
            else
                status = NextTagTree(dblist, *ctx);
        }

        /*************************************
         Loop looking for a tag that matches
        **************************************/
        for (found = 0, done = 0; (status & 1) && !found && !done;)
        {

            /*************************************
              if out of tags in this tree then
              see if there is another one
            **************************************/
            if ((*ctx)->next_tag >= (*ctx)->this_tree_info->header->tags)
            {
                status = NextTagTree(dblist, *ctx);
                if (status & 1)
                    (*ctx)->next_tag = -1;
                else
                {
                    done = 1;
                    break;
                }
            }
            else
            {

                /**********************************************
                  else if this is the first time for this tree
                try to return the \TOP tag.
                otherwise - move on to next tag for next
                time through the loop.
                ***********************************************/
                if ((*ctx)->next_tag == -1)
                {
                    if ((*ctx)->top_match)
                    {
                        done = 1;
                        found = 1;
                    }
                    else
                        ((*ctx)->next_tag)++;
                }
                else
                {

                    /****************************************
                    Else
                       loop looking for a tag that matches
                        *****************************************/
                    for (; !done && ((*ctx)->next_tag < (*ctx)->this_tree_info->header->tags);)
                    {
                        unsigned short len;
                        static struct descriptor_s s_tag_dsc = { sizeof(TAG_NAME), DTYPE_T, CLASS_S, 0};
                        static struct descriptor_d tag_dsc = {0, DTYPE_T, CLASS_D, 0};
                        s_tag_dsc.pointer =
                            (char *) (*ctx)->this_tree_info->tag_info[swapint((char *)&(*ctx)->this_tree_info->tags[(*ctx)->next_tag])].name;
                        StrTrim(&tag_dsc, &s_tag_dsc,&len);
                        if (StrMatchWild(&tag_dsc, &((*ctx)->search_tag)) & 1)
                        {
                            done = 1;
                            found = 1;
                        }
                        else
                            ((*ctx)->next_tag)++;
                    }
                }
            }
        }
        /********************************************
          If done and found then fill in the answer
        *********************************************/
        if (found)
        {
            NODE     *nptr = (*ctx)->this_tree_info->node;
            static char tagname[sizeof(TAG_NAME)+1];
            if ((*ctx)->next_tag != -1)
            {
                static struct descriptor_s s_tag_name = {sizeof(TAG_NAME), DTYPE_T, CLASS_S, 0};
                static struct descriptor_s tag_name =  {sizeof(TAG_NAME), DTYPE_T, CLASS_S, tagname};
                unsigned short len;
                s_tag_name.pointer =
                    (char *) (*ctx)->this_tree_info->tag_info[swapint((char *)&(*ctx)->this_tree_info->tags[(*ctx)->next_tag])].name;
                StrTrim(&tag_name, &s_tag_name,&len);
                tagname[len]='\0';
                nptr += swapint(&(*ctx)->this_tree_info->tag_info[swapint((char *)&(*ctx)->this_tree_info->tags[(*ctx)->next_tag])].node_idx);
            }
            else
                strcpy(tagname,"TOP");
            strcpy(answer,"\\");
            strcat(answer,(*ctx)->this_tree_info->treenam);
            strcat(answer,"::");
            strcat(answer,tagname);
            if (nid_ptr)
                node_to_nid(dblist, nptr, nid_ptr);
            ((*ctx)->next_tag)++;
            status = 1;
        }
        else
        {
            TreeFindTagEnd(ctx_inout);
            status = TreeNMT;
        }
        return (status & 1) ? answer : NULL;
    }
}