/contrib/other/kpm/7z/7zVersion.h |
---|
File deleted |
/contrib/other/kpm/7z/7zAlloc.c |
---|
File deleted |
/contrib/other/kpm/7z/7zStream.c |
---|
File deleted |
/contrib/other/kpm/7z/Compiler.h |
---|
File deleted |
/contrib/other/kpm/7z/7zAlloc.h |
---|
File deleted |
/contrib/other/kpm/7z/Bcj2.c |
---|
File deleted |
/contrib/other/kpm/7z/Bra86.c |
---|
File deleted |
/contrib/other/kpm/7z/Bcj2.h |
---|
File deleted |
/contrib/other/kpm/7z/7zCrc.c |
---|
File deleted |
/contrib/other/kpm/7z/Delta.c |
---|
File deleted |
/contrib/other/kpm/7z/7zTypes.h |
---|
File deleted |
/contrib/other/kpm/7z/Alloc.c |
---|
File deleted |
/contrib/other/kpm/7z/7zCrc.h |
---|
File deleted |
/contrib/other/kpm/7z/Delta.h |
---|
File deleted |
/contrib/other/kpm/7z/Alloc.h |
---|
File deleted |
/contrib/other/kpm/7z/7zFile.c |
---|
File deleted |
/contrib/other/kpm/7z/7z.c |
---|
File deleted |
/contrib/other/kpm/7z/Lzma2Dec.c |
---|
File deleted |
/contrib/other/kpm/7z/Bra.c |
---|
File deleted |
/contrib/other/kpm/7z/7zFile.h |
---|
File deleted |
/contrib/other/kpm/7z/7z.h |
---|
File deleted |
/contrib/other/kpm/7z/Lzma2Dec.h |
---|
File deleted |
/contrib/other/kpm/7z/Bra.h |
---|
File deleted |
/contrib/other/kpm/7z/Precomp.h |
---|
File deleted |
/contrib/other/kpm/7z/7zCrcOpt.c |
---|
File deleted |
/contrib/other/kpm/7z/7zDec.c |
---|
File deleted |
/contrib/other/kpm/7z/7zArcIn.c |
---|
File deleted |
/contrib/other/kpm/7z/LzmaDec.c |
---|
File deleted |
/contrib/other/kpm/7z/LzmaDec.h |
---|
File deleted |
/contrib/other/kpm/7z/CpuArch.c |
---|
File deleted |
/contrib/other/kpm/7z/BraIA64.c |
---|
File deleted |
/contrib/other/kpm/7z/CpuArch.h |
---|
File deleted |
/contrib/other/kpm/7z/7zBuf.c |
---|
File deleted |
/contrib/other/kpm/7z/7zBuf.h |
---|
File deleted |
/contrib/other/kpm/package.h |
---|
File deleted |
/contrib/other/kpm/collection.cpp |
---|
1,5 → 1,6 |
#include "tinyxml/tinyxml.h" |
#include "package.h" |
#include "collection.h" |
#include <sys/kos_io.h> |
const char *key_collection = "collection"; |
const char *key_package = "package"; |
23,8 → 24,6 |
package_t *pkg; |
pkg = (package_t*)malloc(sizeof(package_t)); |
INIT_LIST_HEAD(&pkg->file_list); |
pkg->id = package_id++; |
pkg->name = strdup(xmlpkg->Attribute(key_name)); |
pkg->version = strdup(xmlpkg->Attribute(key_version)); |
72,4 → 71,56 |
return collection; |
} |
int build_install_list(list_t *list, collection_t *collection) |
{ |
pkg_group_t *gr; |
int count = 0; |
list_for_each_entry(gr, &collection->groups, list) |
{ |
package_t *pkg, *tmp; |
list_for_each_entry(tmp, &gr->packages, list) |
{ |
pkg = (package_t*)malloc(sizeof(package_t)); |
pkg->id = tmp->id; |
pkg->name = strdup(tmp->name); |
pkg->version = strdup(tmp->version); |
pkg->filename = strdup(tmp->filename); |
pkg->description = strdup(tmp->description); |
list_add_tail(&pkg->list, list); |
// printf("add package %s-%s\n", pkg->name, pkg->version); |
count++; |
} |
}; |
return count; |
} |
int build_download_list(list_t *download, list_t *src) |
{ |
int count = 0; |
char *cache_path; |
package_t *pkg, *tmp; |
fileinfo_t info; |
list_for_each_entry(tmp, src, list) |
{ |
cache_path = make_cache_path(tmp->filename); |
if( get_fileinfo(cache_path, &info) != 0) |
{ |
pkg = (package_t*)malloc(sizeof(package_t)); |
pkg->id = tmp->id; |
pkg->name = strdup(tmp->name); |
pkg->version = strdup(tmp->version); |
pkg->filename = strdup(tmp->filename); |
pkg->description = strdup(tmp->description); |
list_add_tail(&pkg->list, download); |
count++; |
printf("add package %s-%s\n", pkg->name, pkg->version); |
}; |
} |
return count; |
}; |
/contrib/other/kpm/collection.h |
---|
0,0 → 1,43 |
#ifndef __COLLECTION_H__ |
#ifdef __cplusplus |
extern "C" { |
#endif |
#include "list.h" |
typedef struct |
{ |
list_t groups; |
char *issue; |
}collection_t; |
typedef struct |
{ |
list_t list; |
list_t packages; |
char *name; |
}pkg_group_t; |
typedef struct package |
{ |
list_t list; |
int id; |
char *name; |
char *version; |
char *filename; |
char *description; |
}package_t; |
collection_t* load_collection_file(const char *name); |
collection_t* load_collection_buffer(const char *buffer); |
int build_install_list(list_t *list, collection_t *collection); |
int build_download_list(list_t *download, list_t *src); |
char *make_cache_path(const char *path); |
#ifdef __cplusplus |
} |
#endif |
#endif /* __COLLECTION_H__ */ |
/contrib/other/kpm/kpm.c |
---|
1,4 → 1,3 |
#include <stdlib.h> |
#include <stdio.h> |
#include <string.h> |
#include <sys/stat.h> |
5,9 → 4,7 |
#include <sys/unistd.h> |
#include <fcntl.h> |
#include <kos32sys.h> |
#include <sys/kos_io.h> |
#include "package.h" |
#include "collection.h" |
#include "http.h" |
#define BUFFSIZE (64*1024) |
147,108 → 144,21 |
if(collection && build_install_list(&install_list, collection)) |
{ |
if(build_download_list(&download_list, &install_list)) |
do_download(&download_list); |
if(!list_empty(&download_list)) |
remove_packages(&install_list, &download_list); |
list_for_each_entry(pkg, &install_list, list) |
printf("install package %s-%s\n", pkg->name, pkg->version); |
}; |
} |
return 0; |
err_init: |
printf("HTTP library initialization failed\n"); |
return -1; |
} |
int build_install_list(list_t *list, collection_t *collection) |
{ |
pkg_group_t *gr; |
int count = 0; |
list_for_each_entry(gr, &collection->groups, list) |
list_for_each_entry(pkg, &download_list, list) |
{ |
package_t *pkg, *tmp; |
list_for_each_entry(tmp, &gr->packages, list) |
{ |
pkg = (package_t*)malloc(sizeof(package_t)); |
INIT_LIST_HEAD(&pkg->file_list); |
pkg->id = tmp->id; |
pkg->name = strdup(tmp->name); |
pkg->version = strdup(tmp->version); |
pkg->filename = strdup(tmp->filename); |
pkg->description = strdup(tmp->description); |
list_add_tail(&pkg->list, list); |
count++; |
} |
}; |
return count; |
} |
int build_download_list(list_t *download, list_t *src) |
{ |
int count = 0; |
char *cache_path; |
package_t *pkg, *tmp; |
fileinfo_t info; |
list_for_each_entry(tmp, src, list) |
{ |
cache_path = make_cache_path(tmp->filename); |
if( get_fileinfo(cache_path, &info) != 0) |
{ |
pkg = (package_t*)malloc(sizeof(package_t)); |
INIT_LIST_HEAD(&pkg->file_list); |
pkg->id = tmp->id; |
pkg->name = strdup(tmp->name); |
pkg->version = strdup(tmp->version); |
pkg->filename = strdup(tmp->filename); |
pkg->description = strdup(tmp->description); |
list_add_tail(&pkg->list, download); |
count++; |
}; |
} |
return count; |
}; |
void do_download(list_t *download_list) |
{ |
package_t *pkg, *tmp; |
char *cache_path; |
int count; |
list_for_each_entry_safe(pkg, tmp, download_list, list) |
{ |
printf("package %s-%s\n", pkg->name, pkg->version); |
cache_path = make_cache_path(pkg->filename); |
count = http_load_file(cache_path, make_url(pkg->filename)); |
printf("%s loaded %d bytes\n",cache_path, count); |
if( !test_archive(cache_path)) |
list_del_pkg(pkg); |
else /*delete file*/; |
}; |
}; |
}; |
} |
void remove_packages(list_t *install, list_t *missed) |
{ |
package_t *mpkg, *mtmp, *ipkg, *itmp; |
return 0; |
list_for_each_entry_safe(mpkg, mtmp, missed, list) |
{ |
list_for_each_entry_safe(ipkg, itmp, install, list) |
{ |
if(ipkg->id == mpkg->id) |
{ |
printf("skip missed package %s-%s\n", ipkg->name, ipkg->version); |
list_del_pkg(ipkg); |
}; |
err_init: |
printf("HTTP library initialization failed\n"); |
return -1; |
} |
list_del_pkg(mpkg); |
}; |
}; |
/contrib/other/kpm/Makefile |
---|
33,24 → 33,6 |
tinyxml/tinystr.cpp \ |
tinyxml/tinyxmlparser.cpp \ |
tinyxml/tinyxmlerror.cpp \ |
7z/7z.c \ |
7z/7zFile.c \ |
7z/7zStream.c \ |
7z/7zCrc.c \ |
7z/7zCrcOpt.c \ |
7z/CpuArch.c \ |
7z/7zArcIn.c \ |
7z/7zBuf.c \ |
7z/7zDec.c \ |
7z/LzmaDec.c \ |
7z/Lzma2Dec.c \ |
7z/Bcj2.c \ |
7z/Delta.c \ |
7z/Bra.c \ |
7z/Bra86.c \ |
7z/BraIA64.c \ |
7z/7zAlloc.c \ |
7z/Alloc.c \ |
$(NULL) |
OBJECTS = $(patsubst %.asm, %.o, $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SOURCES)))) |
/contrib/other/kpm/list.h |
---|
165,15 → 165,14 |
#define container_of(ptr, type, member) ({ \ |
const typeof( ((type *)0)->member ) *__mptr = (ptr); \ |
(type *)( (char *)__mptr - offsetof(type,member) );}) |
(type *)( (char *)__mptr - __builtin_offsetof(type,member) );}) |
/** |
* list_entry - get the struct for this entry |
* @ptr: the &struct list_head pointer. |
* @type: the type of the struct this is embedded in. |
* @member: the name of the list_head within the struct. |
* @member: the name of the list_struct within the struct. |
*/ |
#define list_entry(ptr, type, member) \ |
container_of(ptr, type, member) |
182,7 → 181,7 |
* list_first_entry - get the first element from a list |
* @ptr: the list head to take the element from. |
* @type: the type of the struct this is embedded in. |
* @member: the name of the list_head within the struct. |
* @member: the name of the list_struct within the struct. |
* |
* Note, that list is expected to be not empty. |
*/ |
190,44 → 189,6 |
list_entry((ptr)->next, type, member) |
/** |
* list_last_entry - get the last element from a list |
* @ptr: the list head to take the element from. |
* @type: the type of the struct this is embedded in. |
* @member: the name of the list_head within the struct. |
* |
* Note, that list is expected to be not empty. |
*/ |
#define list_last_entry(ptr, type, member) \ |
list_entry((ptr)->prev, type, member) |
/** |
* list_first_entry_or_null - get the first element from a list |
* @ptr: the list head to take the element from. |
* @type: the type of the struct this is embedded in. |
* @member: the name of the list_head within the struct. |
* |
* Note that if the list is empty, it returns NULL. |
*/ |
#define list_first_entry_or_null(ptr, type, member) \ |
(!list_empty(ptr) ? list_first_entry(ptr, type, member) : NULL) |
/** |
* list_next_entry - get the next element in list |
* @pos: the type * to cursor |
* @member: the name of the list_head within the struct. |
*/ |
#define list_next_entry(pos, member) \ |
list_entry((pos)->member.next, typeof(*(pos)), member) |
/** |
* list_prev_entry - get the prev element in list |
* @pos: the type * to cursor |
* @member: the name of the list_head within the struct. |
*/ |
#define list_prev_entry(pos, member) \ |
list_entry((pos)->member.prev, typeof(*(pos)), member) |
/** |
* list_for_each - iterate over a list |
* @pos: the &struct list_head to use as a loop cursor. |
* @head: the head for your list. |
235,6 → 196,7 |
#define list_for_each(pos, head) \ |
for (pos = (head)->next; pos != (head); pos = pos->next) |
/** |
* list_for_each_prev - iterate over a list backwards |
* @pos: the &struct list_head to use as a loop cursor. |
268,47 → 230,24 |
* list_for_each_entry - iterate over list of given type |
* @pos: the type * to use as a loop cursor. |
* @head: the head for your list. |
* @member: the name of the list_head within the struct. |
* @member: the name of the list_struct within the struct. |
*/ |
#define list_for_each_entry(pos, head, member) \ |
for (pos = list_first_entry(head, typeof(*pos), member); \ |
for (pos = list_entry((head)->next, typeof(*pos), member); \ |
&pos->member != (head); \ |
pos = list_next_entry(pos, member)) |
pos = list_entry(pos->member.next, typeof(*pos), member)) |
/** |
* list_for_each_entry_reverse - iterate backwards over list of given type. |
* @pos: the type * to use as a loop cursor. |
* @head: the head for your list. |
* @member: the name of the list_head within the struct. |
* @member: the name of the list_struct within the struct. |
*/ |
#define list_for_each_entry_reverse(pos, head, member) \ |
for (pos = list_last_entry(head, typeof(*pos), member); \ |
for (pos = list_entry((head)->prev, typeof(*pos), member); \ |
&pos->member != (head); \ |
pos = list_prev_entry(pos, member)) |
pos = list_entry(pos->member.prev, typeof(*pos), member)) |
/** |
* list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue() |
* @pos: the type * to use as a start point |
* @head: the head of the list |
* @member: the name of the list_head within the struct. |
* |
* Prepares a pos entry for use as a start point in list_for_each_entry_continue(). |
*/ |
#define list_prepare_entry(pos, head, member) \ |
((pos) ? : list_entry(head, typeof(*pos), member)) |
/** |
* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry |
* @pos: the type * to use as a loop cursor. |
* @n: another type * to use as temporary storage |
* @head: the head for your list. |
* @member: the name of the list_head within the struct. |
*/ |
#define list_for_each_entry_safe(pos, n, head, member) \ |
for (pos = list_first_entry(head, typeof(*pos), member), \ |
n = list_next_entry(pos, member); \ |
&pos->member != (head); \ |
pos = n, n = list_next_entry(n, member)) |
#endif |