示例#1
0
文件: reporting.c 项目: dnaeon/core
void ShowContext(void)
{
    Item *ptr;
    char vbuff[CF_BUFSIZE];
    int i;

    /* Text output */

    for (i = 0; i < CF_ALPHABETSIZE; i++)
    {
        ptr = SortItemListNames(VHEAP.list[i]);
        VHEAP.list[i] = ptr;
    }

    if (VERBOSE || DEBUG)
    {
        snprintf(vbuff, CF_BUFSIZE, "Host %s's basic classified context", VFQNAME);
        ReportBanner(vbuff);

        printf("%s>  -> Defined classes = { ", VPREFIX);

        ListAlphaList(stdout, VHEAP, ' ');

        printf("}\n");

        printf("%s>  -> Negated Classes = { ", VPREFIX);

        for (ptr = VNEGHEAP; ptr != NULL; ptr = ptr->next)
        {
            printf("%s ", ptr->name);
        }

        printf("}\n");
    }
}
示例#2
0
文件: cf-know.c 项目: dnaeon/core
void ShowSingletons()
{
    Topic *tp;
    Item *ip, *list = NULL;
    int slot;

    if (VERBOSE || DEBUG)
    {
        for (slot = 0; slot < CF_HASHTABLESIZE; slot++)
        {
            for (tp = TOPICHASH[slot]; tp != NULL; tp = tp->next)
            {
                if (tp->associations == NULL)
                {
                    PrependItem(&list, tp->topic_name, tp->topic_context);
                }
            }
        }

        list = SortItemListNames(list);

        for (ip = list; ip != NULL; ip = ip->next)
        {
            printf(" ! Warning, topic \"%s::%s\" is a singleton with no connection to the map\n", ip->classes,
                   ip->name);
        }
    }
}
示例#3
0
文件: cf-know.c 项目: dnaeon/core
void ShowWords()
{
    Topic *tp;
    Item *ip, *list = NULL;
    int slot;

    if (!WORDS)
    {
        return;
    }

    for (slot = 0; slot < CF_HASHTABLESIZE; slot++)
    {
        for (tp = TOPICHASH[slot]; tp != NULL; tp = tp->next)
        {
            IdempPrependItem(&list, tp->topic_name, tp->topic_context);
        }
    }

    list = SortItemListNames(list);

    for (ip = list; ip != NULL; ip = ip->next)
    {
        printf("%s::%s\n", ip->classes, ip->name);
    }
}
示例#4
0
void test_sort_item_list_names(void **ctx)
{
    Item *head = xcalloc(1, sizeof(Item));
    head->name = "c";
    head->next = xcalloc(1, sizeof(Item));
    head->next->name = "b";
    head->next->next = xcalloc(1, sizeof(Item));
    head->next->next->name = "a";

    Item *sorted = SortItemListNames(head);

    assert_string_equal(sorted->name, "a");
    assert_string_equal(sorted->next->name, "b");
    assert_string_equal(sorted->next->next->name, "c");
    assert_int_equal(sorted->next->next->next, NULL);
}
示例#5
0
int main(int argc, char *argv[])

{ FILE *fin,*fout = NULL;
  struct Item *ip,*contents = NULL;
  char buffer[1024],type[1024],control[1024],data[1024],name[1024];

  if (argc != 2)
  {
      fprintf(stderr, "Usage: build-stdlib <cfengine-stdlib.cf>\n");
      return 1;
  }

if ((fin = fopen(argv[1],"r")) == NULL)
   {
   printf("Could not open the %s file\n", argv[1]);
   return 1;
   }

   
while(!feof(fin))
   {
   buffer[0] = '\0';
   control[0] = '\0';
   data[0] = '\0';
   type[0] = '\0';
   fgets(buffer,1023,fin);

   if (strncmp(buffer,"##",2) == 0)
      {
      continue;
      }
   
   sscanf(buffer,"%s %s %[^(\n]",type,data,control);

   if (strncmp(type,"body",4) == 0 || strncmp(type,"bundle",6) == 0)
      {
      if (fout)
         {
         fclose(fout);
         fout = NULL;
         }

      snprintf(name,1024,"%s_%s_%s.tmp",type,data,control);

      if ((fout = fopen(name,"w")) == NULL)
         {
         printf("Could not open output file %s\n",name);
         return 2;
         }

      fprintf(fout,"%s",buffer);
      PrependItem(&contents,buffer,"");
      }
   else if (fout)
      {
      fprintf(fout,"%s",buffer);
      }
   else
      {
      printf("XXXX %s",buffer);
      }
   }

if (fout)
   {
   fclose(fout);
   fout = NULL;
   }

if ((fout = fopen("CfengineStdLibrary.texinfo","w")) == NULL)
   {
   printf("Could not open the CfengineStdLibrary.texinfo file\n");
   return 3;
   }

IncludeManualFile(fout,"preamble.texinfo");

contents = SortItemListNames(contents);

for (ip = contents; ip != NULL; ip=ip->next)
   {
   sscanf(ip->name,"%s %s %[^(\n]",type,data,control);
   fprintf(fout,"@node %s %s %s\n",type,data,control);
   fprintf(fout,"@section %s\n",ip->name);

   fprintf(fout,"@verbatim\n");
   snprintf(name,1024,"%s_%s_%s.tmp",type,data,control);
   IncludeManualFile(fout,name);
   fprintf(fout,"@end verbatim\n\n");
   }

IncludeManualFile(fout,"postamble.texinfo");

fclose(fin);
fclose(fout);
}