int main() { /*llNode * test_node = malloc(sizeof(llNode)); test_node->value = 1; test_node->next = malloc(sizeof(llNode)); test_node->next->value = 2; test_node->next->next = malloc(sizeof(llNode)); test_node->next->next->value = 3; test_node->next->next->next = NULL; printList(test_node); printf("Hello world!\n"); push(test_node, 0); printList(test_node); length(test_node);*/ //llNode * llist = malloc(sizeof(llNode)); llNode * llist = createHead(4); push(llist, 2); push(llist, 1); addAfter(llist, 2, 3); printList(llist); printf("Going to remove one!\n"); removeByLoc(llist, 4); printList(llist); return 0; }
void Compressor::compress(string from, string to) { fromFile = from; toFile = to; createHead(); createBody(); }
bool KImGalleryPlugin::createHtml(const KURL& url, const QString& sourceDirName, int recursionLevel, const QString& imageFormat) { if(m_cancelled) return false; if( !parent() || !parent()->inherits("KonqDirPart")) return false; KonqDirPart * part = static_cast<KonqDirPart *>(parent()); QStringList subDirList; if (m_recurseSubDirectories && (recursionLevel >= 0)) { //recursionLevel == 0 means endless QDir toplevel_dir = QDir( sourceDirName ); toplevel_dir.setFilter( QDir::Dirs | QDir::Readable | QDir::Writable ); subDirList = toplevel_dir.entryList(); for (QStringList::ConstIterator it = subDirList.begin(); it != subDirList.end() && !m_cancelled; it++) { const QString currentDir = *it; if (currentDir == "." || currentDir == "..") { continue;} //disregard the "." and ".." directories QDir subDir = QDir( url.directory() + "/" + currentDir ); if (!subDir.exists()) { subDir.setPath( url.directory() ); if (!(subDir.mkdir(currentDir, false))) { KMessageBox::sorry(part->widget(), i18n("Couldn't create folder: %1").arg(subDir.path())); continue; } else { subDir.setPath( url.directory() + "/" + currentDir ); } } if(!createHtml( KURL( subDir.path() + "/" + url.fileName() ), sourceDirName + "/" + currentDir, recursionLevel > 1 ? recursionLevel - 1 : 0, imageFormat)) { return false; } } } if (m_useCommentFile) { loadCommentFile(); } kdDebug(90170) << "sourceDirName: " << sourceDirName << endl; //We're interested in only the patterns, so look for the first | //#### perhaps an accessor should be added to KImageIO instead? QString filter = KImageIO::pattern(KImageIO::Reading).section('|', 0, 0); QDir imageDir( sourceDirName, filter.latin1(), QDir::Name|QDir::IgnoreCase, QDir::Files|QDir::Readable); const QString imgGalleryDir = url.directory(); kdDebug(90170) << "imgGalleryDir: " << imgGalleryDir << endl; // Create the "thumbs" subdirectory if necessary QDir thumb_dir( imgGalleryDir + QString::fromLatin1("/thumbs/")); if (createDirectory(thumb_dir, imgGalleryDir, "thumbs") == false) return false; // Create the "images" subdirectory if necessary QDir images_dir( imgGalleryDir + QString::fromLatin1("/images/")); if (m_copyFiles) { if (createDirectory(images_dir, imgGalleryDir, "images") == false) return false; } QFile file( url.path() ); kdDebug(90170) << "url.path(): " << url.path() << ", thumb_dir: "<< thumb_dir.path() << ", imageDir: "<< imageDir.path() << endl; if ( imageDir.exists() && file.open(IO_WriteOnly) ) { QTextStream stream(&file); stream.setEncoding(QTextStream::Locale); createHead(stream); createBody(stream, sourceDirName, subDirList, imageDir, url, imageFormat); //ugly file.close(); return !m_cancelled; } else { KMessageBox::sorry(m_part->widget(),i18n("Couldn't open file: %1").arg(url.path(+1))); return false; } }
node * createTBT() { node * head; node *n; node *p; int flag; char ch; head = createHead(); do { //create a node n = (node*) malloc(sizeof(node)); //scan data for it printf("\n enter data for node "); scanf("%d", &n->data); //connect if(head->left == head) {//connect as root //set the left of n n->left = head->left; n->lThread = 'y'; //connect head and n head->left = n; head->lThread = 'n'; //set the right of n; n->right = head->right; n->rThread = 'y'; } else {//connect as successor p = head->left;//root flag = 1; //loop control while(flag == 1) { printf("\n l : connect to left of %d ", p->data); printf("\n r : connect to right of %d ", p->data); printf("\n enter choice "); fflush(stdin); scanf("%c", &ch); if(ch == 'l' || ch == 'L') {//left if(p->lThread == 'y') {//no child on left, connect //set the left of n n->left = p->left; n->lThread = 'y'; //connect p and n p->left = n; p->lThread = 'n'; //set the right of n n->right = p; n->rThread = 'y'; flag = 0; } else//traverse p = p->left; } else if(ch == 'r' || ch == 'R') {//right if(p->rThread == 'y') {//no child on right, connect //set the right of n n->right = p->right; n->rThread = 'y'; //connect p and n p->right = n; p->rThread = 'n'; //set the left of n n->left = p; n->lThread = 'y'; flag = 0; } else //traverse p = p->right; } }//while }//else //cycle printf("\n add more nodes (y/n) ? "); fflush(stdin); scanf("%c", &ch); }while(ch == 'y' || ch == 'Y'); return head; }
void *NclStructureParser::parseHead( DOMElement *parentElement, void *objGrandParent) { void *parentObject = NULL; DOMNodeList *elementNodeList; int i, size; DOMNode *node; void *elementObject = NULL; parentObject = createHead(parentElement, objGrandParent); if (parentObject == NULL) { return NULL; } elementNodeList = parentElement->getChildNodes(); size = elementNodeList->getLength(); for (i = 0; i < size; i++) { node = elementNodeList->item(i); if (node->getNodeType()==DOMNode::ELEMENT_NODE && XMLString::compareIString( ((DOMElement*)node)->getTagName(), XMLString::transcode("importedDocumentBase")) == 0) { elementObject = getImportParser()-> parseImportedDocumentBase( (DOMElement*)node, parentObject); if (elementObject != NULL) { addImportedDocumentBaseToHead( parentObject, elementObject); break; } } } for (i = 0; i < size; i++) { node = elementNodeList->item(i); if (node->getNodeType()==DOMNode::ELEMENT_NODE && XMLString::compareIString( ((DOMElement*)node)->getTagName(), XMLString::transcode("regionBase") )==0) { elementObject = getLayoutParser()-> parseRegionBase((DOMElement*)node, parentObject); if (elementObject != NULL) { addRegionBaseToHead(parentObject, elementObject); } } } for (i = 0; i < size; i++) { node = elementNodeList->item(i); if (node->getNodeType()==DOMNode::ELEMENT_NODE && XMLString::compareIString( ((DOMElement*)node)->getTagName(), XMLString::transcode("ruleBase") )==0){ elementObject = getPresentationControlParser()-> parseRuleBase((DOMElement*)node, parentObject); if (elementObject != NULL) { addRuleBaseToHead(parentObject, elementObject); break; } } } for (i = 0; i < size; i++) { node = elementNodeList->item(i); if (node->getNodeType()==DOMNode::ELEMENT_NODE && XMLString::compareIString( ((DOMElement*)node)->getTagName(), XMLString::transcode("transitionBase") )==0) { wclog << "NclStructureParser::parseHead "; wclog << "transitionBase i = '" << i << "'" << endl; elementObject = getTransitionParser()-> parseTransitionBase((DOMElement*)node, parentObject); if (elementObject != NULL) { addTransitionBaseToHead(parentObject, elementObject); break; } } } for (i = 0; i < size; i++) { node = elementNodeList->item(i); if (node->getNodeType()==DOMNode::ELEMENT_NODE && XMLString::compareIString( ((DOMElement*)node)->getTagName(), XMLString::transcode("descriptorBase") )==0) { elementObject = getPresentationSpecificationParser()-> parseDescriptorBase((DOMElement*)node, parentObject); if (elementObject != NULL) { addDescriptorBaseToHead(parentObject, elementObject); break; } } } for (i = 0; i < size; i++) { node = elementNodeList->item(i); if (node->getNodeType()==DOMNode::ELEMENT_NODE && XMLString::compareIString( ((DOMElement*)node)->getTagName(), XMLString::transcode("connectorBase") )==0) { elementObject = getConnectorsParser()->parseConnectorBase( (DOMElement*)node, parentObject); if (elementObject != NULL) { addConnectorBaseToHead(parentObject, elementObject); break; } } } for (i = 0; i < size; i++) { node = elementNodeList->item(i); if (node->getNodeType()==DOMNode::ELEMENT_NODE && XMLString::compareIString( ((DOMElement*)node)->getTagName(), XMLString::transcode("meta") )==0) { elementObject = getMetainformationParser()-> parseMeta((DOMElement*)node, parentObject); if (elementObject != NULL) { addMetaToHead(parentObject, elementObject); break; } } } for (i = 0; i < size; i++) { node = elementNodeList->item(i); if (node->getNodeType()==DOMNode::ELEMENT_NODE && XMLString::compareIString( ((DOMElement*)node)->getTagName(), XMLString::transcode("metadata") )==0) { elementObject = getMetainformationParser()-> parseMetadata((DOMElement*)node, parentObject); if (elementObject != NULL) { addMetadataToHead(parentObject, elementObject); break; } } } return parentObject; }