ref: effe53dedb08022fc45652e44193ba43fb5fbef3
parent: cfe931321aced3c0a2e3c1377737f356b7aa04fa
author: sirjofri <[email protected]>
date: Fri Oct 18 12:39:31 EDT 2024
global export file
--- a/README.md
+++ b/README.md
@@ -16,6 +16,7 @@
/mnt/vcf/
ctl
import
+ export
John_Doe/
export
fn/
@@ -33,10 +34,8 @@
Future plans:
-- Make files writable
- ctl: make commands work
- import: make import work
-- export: make export work
- files: output with newline at the end?
### libvcard
--- a/vcardfs.c
+++ b/vcardfs.c
@@ -24,6 +24,8 @@
- "write" (save file)
/import
- write new vcf file to import
+/ export
+ - read all vcards as vcf
*/
@@ -58,6 +60,7 @@
Qroot,
Qctl,
Qimport,
+ Qgexport,
Qcard,
Qexport,
Qline,
@@ -109,9 +112,20 @@
char *s;
Vcard *tmp;
- if (f->serialized)
+ if (f->level == Qgexport) {
+ if (f->cardfile->serialized)
+ free(f->cardfile->serialized);
+ f->cardfile->serialized = vcmserialize(cards);
+ if (!f->cardfile->serialized) {
+ responderror(r);
+ return;
+ }
goto Readin;
+ }
+ if (f->cardfile->serialized)
+ goto Readin;
+
tmp = f->card->next;
f->card->next = nil;
f->cardfile->serialized = vcmserialize(f->card);
@@ -118,7 +132,7 @@
f->card->next = tmp;
if (!f->cardfile->serialized) {
- respond(r, "unable to serialize");
+ responderror(r);
return;
}
@@ -142,6 +156,9 @@
case Qimport:
respond(r, nil);
return;
+ case Qgexport:
+ readserialized(r, f);
+ return;
case Qexport:
readserialized(r, f);
return;
@@ -456,6 +473,8 @@
void
main(int argc, char **argv)
{
+ Vfile *f;
+
ARGBEGIN{
case 'D':
chatty9p++;
@@ -493,6 +512,9 @@
emkvfile(Qctl, nil, nil, nil, nil));
createfile(fs.tree->root, "import", user, 0666,
emkvfile(Qimport, nil, nil, nil, nil));
+ f = emkvfile(Qgexport, nil, nil, nil, nil);
+ f->cardfile = f;
+ createfile(fs.tree->root, "export", user, 0444, f);
initcardfiles(cards);
postmountsrv(&fs, service, mtpt, MREPL);