예제 #1
0
int main(int argc, char **argv)
{
    if (argc < 3) {
        // ###### Note: please consider adding new tests to karchivetest (so that they can be automated)
        // rather than here (interactive)
        printf("\n"
               " Usage :\n"
               " ./kziptest list /path/to/existing_file.zip       tests listing an existing zip\n"
               " ./kziptest print-all file.zip                    prints contents of all files.\n"
               " ./kziptest print file.zip filename               prints contents of one file.\n"
               " ./kziptest update file.zip filename              update filename in file.zip.\n"
               " ./kziptest save file.zip                         save file.\n"
               " ./kziptest load file.zip                         load file.\n"
               " ./kziptest write file.bz2                        write compressed file.\n"
               " ./kziptest read file.bz2                         read uncompressed file.\n"
              );
        return 1;
    }
    QCoreApplication app(argc, argv);
    QString command = argv[1];
    if (command == QLatin1String("list")) {
        return doList(QFile::decodeName(argv[2]));
    } else if (command == QLatin1String("print-all")) {
        return doPrintAll(QFile::decodeName(argv[2]));
    } else if (command == QLatin1String("print")) {
        if (argc != 4) {
            printf("usage: kziptest print archivename filename");
            return 1;
        }
        return doPrint(QFile::decodeName(argv[2]), argv[3]);
    } else if (command == QLatin1String("save")) {
        return doSave(QFile::decodeName(argv[2]));
    } else if (command == QLatin1String("load")) {
        return doLoad(QFile::decodeName(argv[2]));
    } else if (command == QLatin1String("write")) {
        return doCompress(QFile::decodeName(argv[2]));
    } else if (command == QLatin1String("read")) {
        return doUncompress(QFile::decodeName(argv[2]));
    } else if (command == QLatin1String("update")) {
        if (argc != 4) {
            printf("usage: kziptest update archivename filename");
            return 1;
        }
        return doUpdate(QFile::decodeName(argv[2]), QFile::decodeName(argv[3]));
    } else if (command == QLatin1String("transfer")) {
        if (argc != 4) {
            printf("usage: kziptest transfer sourcefile destfile");
            return 1;
        }
        return doTransfer(QFile::decodeName(argv[2]), QFile::decodeName(argv[3]));
    } else {
        printf("Unknown command\n");
    }
}
예제 #2
0
파일: Contract.c 프로젝트: feng7/RC-Trees
///////////////////////////////////////////////////////////////////
// basic function that determines what to do with all nodes
//////////////////////////////////////////////////////////////////
void runNode(node* thisNode, Queue* q)
{
  int lindex,rindex;
  scar *lscar, *rscar;
  node *left=NULL,*right=NULL;

  deprintf("The degree is %d\n", thisNode->degree); 
  deprintf("The cluster is %p\n",thisNode->data);
  deprintf("The node is %p\n", thisNode);
  
  switch (contractCheck(thisNode)) {
  case DO_END:
    setupVertexCluster(thisNode,END_EVENT, currentTree, &oldRootList); //end event the event to end them all!
    thisNode->vertex->cl->affected = IS_AFFECTED;  
    deleteNode(thisNode);
    insertCluster(thisNode->vertex->cl,&newRootList);
    break;
  case DO_RAKE: 
    morework =1;
    lindex = thisNode->left;
    lscar = thisNode->scars[lindex].backscar;
    left  = GET_NEIGHBOR(lscar);
    doRake(thisNode,left,lindex);
    insertQueue(left->descendant,q);
    deleteNode(thisNode);
    break;

  case DO_COMPRESS: 
    morework =1;
    lindex = thisNode->left;
    rindex = thisNode->right;
    lscar = thisNode->scars[lindex].backscar;
    rscar = thisNode->scars[rindex].backscar;
    left  = GET_NEIGHBOR(lscar);
    right = GET_NEIGHBOR(rscar);

    doCompress(thisNode, left, right, lindex, rindex);    
    insertQueue(left->descendant,q);
    insertQueue(right->descendant,q);
    deleteNode(thisNode);    
    break;

  case DO_LIVE: {
    morework = 1;
    node *desc = thisNode->descendant;
    int old_degree = desc->degree;
    
    doLive(thisNode);
    
    // Queue all affected nodes. 
    insertQueue(desc,q);
    deprintf("Check Undeleted \n"); 
    // check if thisNode is un-deleted, queue neighbors if so
    checkUndelete(thisNode,desc);
    deprintf("Leaf status change \n"); 
      // Check if leaf status of the descendant changes and queue neighbors if so
    checkLeafStatusChange(old_degree,desc);
    
    //  Allocate a new node for the next round if needed
    if(!desc->descendant) {
      deprintf("Allocated new node \n");
      desc -> descendant = copyVertex (desc,currentTree->nodeList);
    }
    
  } break;
  default: printf ("Error in runNode"); exit (-9);
  }

}