Exemple #1
0
    void printStatus(bool listFilenames,
                     bool failOnStatusType[DiffResource::kStatusCount]
                     [DiffResource::kStatusCount]) {
        typedef DiffResource::Status Status;

        for (int base = 0; base < DiffResource::kStatusCount; ++base) {
            Status baseStatus = static_cast<Status>(base);
            for (int comparison = 0; comparison < DiffResource::kStatusCount; ++comparison) {
                Status comparisonStatus = static_cast<Status>(comparison);
                const FileArray& fileArray = fStatusOfType[base][comparison];
                if (fileArray.count() > 0) {
                    if (failOnStatusType[base][comparison]) {
                        printf("   [*] ");
                    } else {
                        printf("   [_] ");
                    }
                    printContents(fileArray,
                                  DiffResource::getStatusDescription(baseStatus),
                                  DiffResource::getStatusDescription(comparisonStatus),
                                  listFilenames);
                }
            }
        }
    }
Exemple #2
0
 void print(bool listFilenames, bool failOnResultType[DiffRecord::kResultCount],
            bool failOnStatusType[DiffResource::kStatusCount]
            [DiffResource::kStatusCount]) {
     printf("\ncompared %d file pairs:\n", fNumMatches + fNumMismatches);
     for (int resultInt = 0; resultInt < DiffRecord::kResultCount; ++resultInt) {
         DiffRecord::Result result = static_cast<DiffRecord::Result>(resultInt);
         if (failOnResultType[result]) {
             printf("[*] ");
         } else {
             printf("[_] ");
         }
         printContents(fResultsOfType[result], DiffRecord::getResultDescription(result),
                       listFilenames);
         if (DiffRecord::kCouldNotCompare_Result == result) {
             printStatus(listFilenames, failOnStatusType);
         }
     }
     printf("(results marked with [*] will cause nonzero return value)\n");
     printf("\nnumber of mismatching file pairs: %d\n", fNumMismatches);
     if (fNumMismatches > 0) {
         printf("Maximum pixel intensity mismatch %d\n", fMaxMismatchV);
         printf("Largest area mismatch was %.2f%% of pixels\n",fMaxMismatchPercent);
     }
 }
Exemple #3
0
int main(int argc, char** argv)
{
	struct lNode *head;
	FILE *readfile;
	int value; 
	char type; 
	char buffer[100];

	head = NULL; 

	if(argc < 2 || argc > 2)
	{
		printf("%s", "Incorrect Number of Arguments");
		return(0);
	}

	  

	readfile = fopen(argv[1], "r"); 

	if(readfile == NULL)
	{
		printf("%s", "error\n"); 
		return(0);
	}

	while(fgets(buffer, 100, readfile) != NULL) 
	{
		if(sscanf(buffer, "%c %d",&type, &value ) != 2)
		{
			printf("%s", "error\n");
			return(0);
		}

		if(type == 'i')
		{
			
			head = addNode(head,value); 
		
		}
		if(type == 'd')
		{
			
			head = removeNode(head,value);
		}

		
		if(type != 'i' && type != 'd')
		{
			printf("%s", "error\n");
			return(0);
		}
	}
	printContents(head);
	fclose(readfile);
	free(head);
	
	return(0);




}
Exemple #4
0
//-------------------------------------------------------------------
int main(int argc, char *argv[])
{
  xmlDocPtr doc;
  xmlNodePtr cur;

  //Checks for the .xml file name
  if (argc==1)
  {
    fprintf(stderr, "No file name passed.");
    return -1;
  }
  //Opens the .xml file given as an argument
  doc = xmlParseFile(argv[1]);
  //Catches an error in parsing the file
  if (doc == NULL )
  {
    fprintf(stderr,"Document not parsed successfully. \n");
    return -1;
  }

  cur = xmlDocGetRootElement(doc);

  //Catches the error of passing a blank document
  if (cur == NULL)
  {
    fprintf(stderr,"Empty document.\n");
    xmlFreeDoc(doc);
    return -1;
  }

  //Catches the error of passing a document with a different root tag
  if (!tagNameIs("help",cur))
  {
    fprintf(stderr,"Document id of the wrong type, "
            "the root node is not help.\n");
    xmlFreeDoc(doc);
    return -1;
  }

  if (argc==2)
    printf("No output specified.\nOutput will be sent to output.html.\n");
  FILE *outFile;
  outFile=fopen(argc>2?argv[2]:"output.html", "w");

  cur=cur->xmlChildrenNode;

  fprintf(outFile,
          "<html>\n<body>\n<basefont face=\"sans-serif\"></basefont>\n");

  int exampleNum=1;
  //Outputs the file
  while (cur != NULL)
  {
    //Outputs the arugments of the file
    if (tagNameIs("arguments",cur)||tagNameIs("outputs",cur))
    {
      xmlNodePtr argumentType;
      argumentType=(tagNameIs("arguments",cur))?cur->xmlChildrenNode:cur;
      while (argumentType!=NULL)
      {
        if (!tagNameIs("text",argumentType))
        {
          printName(argumentType,outFile);
          if (tagNameIs("arguments",cur))
            fprintf(outFile," ARGUMENTS");
          fprintf(outFile,"</h1>");
          xmlNodePtr argumentElement;
          argumentElement=argumentType->xmlChildrenNode;
          int first=1, justIntro=0, justArg=0;
          // fprintf (outFile,"\n<table border=\"3\">\n");
          while (1)
          {
            if (!tagNameIs("text",argumentElement))
            {
              if ((first||justIntro)&&!tagNameIs("intro",argumentElement))
                fprintf (outFile,
                         "\n<table border=\"3\">\n<tr><th>%s</th><th>"
                         "Explanation</th></tr>\n",
                         (tagNameIs("arguments",cur))?"Argument":"Output");

              if (justArg)
              {
                if (tagNameIs("argument",argumentElement)||
                    tagNameIs("output",argumentElement))
                  fprintf(outFile, "<td>&nbsp;</td>\n");
                justArg=0;
              }
              else if (tagNameIs("explanation",argumentElement))
                fprintf(outFile, "</tr>\n<tr>\n<td>&nbsp;</td>\n");
              if (tagNameIs("argument",argumentElement)||
                  tagNameIs("output",argumentElement))
                justArg=1;
              if (tagNameIs("intro",argumentElement))
              {
                char *c, *intro;
                c= (char *)xmlNodeListGetString
                  (doc,
                   argumentElement->xmlChildrenNode, 1);
                if (first)
                {
                  intro= malloc(strlen("\n<h3>")+strlen(c)+1);
                  strcpy(intro,"\n<h3>");
                  first=0;
                }
                else
                {
                  intro= malloc(strlen("</tr>\n</table>\n<h3>")+strlen(c)+1);
                  strcpy(intro,"</tr>\n</table>\n<h3>");
                }
                intro=strcat(intro,c);
                free(c);
                while (tagNameIs("intro",argumentElement->next)||
                       tagNameIs("text",argumentElement->next))
                {
                  if (!tagNameIs("text",argumentElement->next))
                  {
                    char *content;
                    content= (char *)xmlNodeListGetString
                      (doc, argumentElement->next->xmlChildrenNode, 1);
                    char *secondHalf=
                      malloc(strlen("<br />") +strlen(content)+ 1);
                    strcpy(secondHalf,"<br />");
                    secondHalf=strcat(secondHalf,content);
                    char *temp= malloc(strlen(intro)+strlen(secondHalf)+1);
                    strcpy(temp,intro);
                    temp=strcat(temp,secondHalf);
                    free(intro);
                    intro=temp;
                  }
                  argumentElement=argumentElement->next;
                }
                char *temp= malloc(strlen(intro)+strlen("</h3>\n"+1));
                strcpy(temp,intro);
                temp=strcat(temp,"</h3>");
                free(intro);
                intro=temp;
                fprintf(outFile,"%s\n",intro);
                free(intro);
                justIntro=1;
              }
              else
              {
                if (first)
                  first=0;
                else if ((tagNameIs("argument",argumentElement)||
                          tagNameIs("output",argumentElement))&&!justIntro)
                  fprintf(outFile, "</tr>\n");

                justIntro=0;
                printTableContents(doc,argumentElement,outFile);
              }
            }
            argumentElement= argumentElement->next;
            if (argumentElement==NULL)
            {
              if (!justIntro)
                fprintf (outFile,"</tr>\n</table>\n");
              break;
            }
          }
        }
        if (!tagNameIs("arguments",cur))
          break;
        argumentType=argumentType->next;
      }
    }
    //Outputs all the other tags
    else if (!tagNameIs("text",cur))
    {
      printName(cur,outFile);
      if (tagNameIs("EXAMPLE",cur))
        fprintf(outFile," %d",exampleNum++);
      fprintf(outFile,"</h1>");
      printContents(doc,cur,outFile);
    }
    cur=cur->next;
  }

  fprintf(outFile,"</html>\n</body>\n");

  return EXIT_SUCCESS;
}