aaa
Some checks failed
pyrite-dev/taiga/pipeline/head There was a failure building this commit

This commit is contained in:
Nishi 2026-03-02 01:08:36 +09:00
commit 110a170af4
Signed by: nishi
GPG key ID: 27EF69B208EB9343
5 changed files with 41 additions and 2 deletions

View file

@ -20,6 +20,9 @@ src/src_help.o: src/help.c
OBJS += src/src_main.o
src/src_main.o: src/main.c
$(CC) $(CFLAGS) -c -o $@ src/main.c
OBJS += src/src_process.o
src/src_process.o: src/process.c
$(CC) $(CFLAGS) -c -o $@ src/process.c
OBJS += src/src_seed.o
src/src_seed.o: src/seed.c
$(CC) $(CFLAGS) -c -o $@ src/seed.c

View file

@ -29,10 +29,28 @@ int action_seed(int argc, char** argv){
fprintf(f, "</skinconfig>\n");
fclose(f);
if((f = fopen("site/content/index.xml", "w")) == NULL){
fprintf(stderr, "Failed to open site/content/index.xml\n");
return 1;
}
fprintf(f, "<?xml version=\"1.0\"?>\n");
fprintf(f, "<document>\n");
fprintf(f, " <header>\n");
fprintf(f, " <title>Welcome to template</title>\n");
fprintf(f, " </header>\n");
fprintf(f, " <body>\n");
fprintf(f, " <section id=\"status\">\n");
fprintf(f, " <title>Congratulations</title>\n");
fprintf(f, " </section>\n");
fprintf(f, " </body>\n");
fprintf(f, "</document>\n");
fclose(f);
printf("Template project created!\n");
printf("\n");
printf("Here is an outline of the generated files:\n");
describe("site/skinconf.xml", "Skin configuration");
describe("site/content/index.xml", "Example index file");
return 0;
}

View file

@ -5,6 +5,7 @@ static void scan(const char* path){
char* out = u_strvacat("build/", path, NULL);
IO_DIR* dir;
io_mkdir(out, 0755);
if((dir = io_opendir(in)) != NULL){
struct io_dirent* d;
@ -14,10 +15,15 @@ static void scan(const char* path){
if(strcmp(d->d_name, ".") == 0 || strcmp(d->d_name, "..") == 0) continue;
p = u_strvacat(in, d->d_name, "/", NULL);
p = u_strvacat(in, d->d_name, NULL);
if(io_stat(p, &s) == 0){
if(IO_S_ISDIR(s.st_mode)){
scan(p);
char* p2 = u_strvacat(d->d_name, "/", NULL);
scan(p2);
free(p2);
}else if(strcmp(d->d_name, "index.xml") == 0){
process(out, p);
printf("%s\n", p);
}
}
free(p);

View file

@ -46,5 +46,9 @@ int action_seed(int argc, char** argv);
/* util.c */
char* u_strvacat(const char* str, ...);
char* u_strdup(const char* str);
/* process.c */
void process(const char* out, const char* full);
#endif

View file

@ -20,3 +20,11 @@ char* u_strvacat(const char* str, ...){
return r;
}
char* u_strdup(const char* str){
char* s = malloc(strlen(str) + 1);
strcpy(s, str);
return s;
}