📄 yepp.c
字号:
{ switch (ptr->index) { case YEPP_CONFIG_INDEX: case YEPP_ENCODE_INDEX: case YEPP_DECODE_INDEX: case YEPP_SERIAL_INDEX: break; default: yepp_erase (ptr->index); } ptr = ptr->next; } yepp_dir_free (yd);}#ifdef HIFIintdo_random_size (Files files, Eweid e, int i, struct yepp_dirent *yd){ Flock flock; CFH h; char *a; h = files_open (files, e, O_RDONLY); if (!h) return 1000000000; if (files_is_group (h)) { i += yepp_blocks_to_bytes (yepp_bytes_to_blocks (h->size (h))); flock = files_read_group (h); Obj_Delete (h); e = flock->head; while (e) { i = do_random_size (files, e, i, yd); e = e->next; } Obj_Delete (flock); return i; } a = eweidtoa (e); while (yd) { if (strstr (yd->name, a)) { Obj_Delete (h); return 1000000000; } yd = yd->next; } i += yepp_blocks_to_bytes (yepp_bytes_to_blocks (h->size (h))); Obj_Delete (h); return i;}intdo_random_worker (int where, Files files, Eweid e, char *text, int i){ Flock flock; CFH h; char *r; char buf[1024]; h = files_open (files, e, O_RDONLY); if (files_is_group (h)) { char *a = eweidtoa (e); flock = files_read_group (h); h->seek (h, 0L, SEEK_SET); sprintf (buf, "%s.grp", a); free (a); yepp_hifi_put (where, YEPP_TYPE_DATA, buf, h); Obj_Delete (h); e = flock->head; while (e) { i = do_random_worker (where, files, e, text, i); e = e->next; } Obj_Delete (flock); return i; } r = eweidtoa (e); sprintf (buf, "%s(%d) %s.mp3", text, ++i, r); free (r); yepp_hifi_put (where, YEPP_TYPE_MP3, buf, h); Obj_Delete (h); return i;}intdo_random (Files files, int where, Eweid e, struct yepp_status *ys, struct yepp_dirent *yd){ char *text, *r; CFH h; int i; int spare = 0; if (!ys) return -1; switch (where) { case YEPP_WHERE_BASE: printf (" Base: %d/%d Kbytes free\n", ys->main.free, ys->main.size); spare = ys->main.free; break; case YEPP_WHERE_CARD: printf (" Card: %d/%d Kbytes free\n", ys->card.free, ys->card.size); spare = ys->card.free; break; } spare *= 1024; if (!e) e = files_random_work (); if (!e) { fprintf (stderr, "do_random: no work returned\n"); return 0; } text = eweid_to_text (e); r = eweidtoa (e); printf ("do_random: %s %s\n", r, text); free (r); i = do_random_size (files, e, 0, yd); printf ("\n\ndo_random: collection needs %d bytes player has %d\n", i, spare); if (i > spare) { fprintf (stderr, "do_random: not enough space\n"); free (text); Obj_Delete (e); return 0; } i = do_random_worker (where, files, e, text, 0); printf ("%d songs\n", i); Obj_Delete (e); free (text); return 1;}#endifintmain (int argc, char **argv){ int i, rel = 0; extern int optind; extern char *optarg; FILE *f; int port = 0; printf ("nope: OpenSource Yepp drivers (C) 2001 James McKenzie <james@fishsoup.dhs.org>\n"); printf ("nope: NO WARRANTY EXPRESS OR IMPLIED\n"); printf ("nope: %s\n", rcsid); printf ("\n");#ifdef HIFI { time_t t; time (&t); srand48 (t); }#endif for (i = 1; i < argc; ++i) { if (!strncasecmp (argv[i], "-h", 2)) usage (argv[0]); if (!strncmp (argv[i], "-?", 2)) usage (argv[0]); if (!strncasecmp (argv[i], "-p", 2)) { char *pport = ((i + 1) < argc) ? argv[i + 1] : NULL; if (pport) { sscanf (pport, "%x", &port); } } } if (!yepp_init (port)) { fprintf (stderr, "Couldn't find capable parallel port\n"); exit (1); } if (!yepp_wakeupandping ()) { yepp_release (); fprintf (stderr, "Couldn't wakeup yepp\n"); exit (1); } if (!yepp_ping ()) { yepp_release (); exit (1); } for (i = 1; i < argc; ++i) { if (!strcmp (argv[i], "-u")) { do_upload (YEPP_WHERE_BASE, ((i + 1) < argc) ? argv[i + 1] : NULL, ((i + 2) < argc) ? argv[i + 2] : NULL); } if (!strcmp (argv[i], "-c")) { do_upload (YEPP_WHERE_CARD, ((i + 1) < argc) ? argv[i + 1] : NULL, ((i + 2) < argc) ? argv[i + 2] : NULL); } if (!strcmp (argv[i], "-o")) { do_setorder (argv + (i + 1), argc - (i + 1)); } if (!strcmp (argv[i], "-d")) { do_download (((i + 1) < argc) ? argv[i + 1] : NULL); } if (!strcmp (argv[i], "-e")) { do_erase (((i + 1) < argc) ? argv[i + 1] : NULL); } if (!strcmp (argv[i], "-a")) { do_erase_all (); }#ifdef HIFI if (!strcmp (argv[i], "-w")) { char *s = ((i + 1) < argc) ? argv[i + 1] : NULL; Eweid e; if (s) { e = atoeweid (s); if (e) { struct yepp_status *ys; struct yepp_dirent *yd; Files files = files_user_init (); yd = yepp_dir (); ys = yepp_status (); do_random (files, YEPP_WHERE_BASE, e, ys, yd); Obj_Delete (files); free (ys); yepp_dir_free (yd); } } } if (!strcmp (argv[i], "-W")) { char *s = ((i + 1) < argc) ? argv[i + 1] : NULL; Eweid e; if (s) { e = atoeweid (s); if (e) { struct yepp_status *ys; struct yepp_dirent *yd; Files files = files_user_init (); yd = yepp_dir (); ys = yepp_status (); do_random (files, YEPP_WHERE_CARD, e, ys, yd); Obj_Delete (files); free (ys); yepp_dir_free (yd); } } } if (!strcmp (argv[i], "-z")) { char *ssize = ((i + 1) < argc) ? argv[i + 1] : NULL; int size = 0; if (ssize) size = atoi (ssize); if (size) { struct yepp_status *ys; struct yepp_dirent *yd; Files files = files_user_init (); ys = NULL; do { yd = yepp_dir (); if (ys) free (ys); ys = yepp_status (); if (ys->main.free > size) while (do_random (files, YEPP_WHERE_BASE, NULL, ys, yd) == 0); yepp_dir_free (yd); } while (ys->main.free > size); Obj_Delete (files); } } if (!strcmp (argv[i], "-g")) { struct yepp_status *ys; struct yepp_dirent *yd; Files files = files_user_init (); yd = yepp_dir (); ys = yepp_status (); while (do_random (files, YEPP_WHERE_BASE, NULL, ys, yd) == 0); Obj_Delete (files); free (ys); yepp_dir_free (yd); } if (!strcmp (argv[i], "-G")) { struct yepp_status *ys; struct yepp_dirent *yd; Files files = files_user_init (); yd = yepp_dir (); ys = yepp_status (); while (do_random (files, YEPP_WHERE_CARD, NULL, ys, yd) == 0); Obj_Delete (files); free (ys); yepp_dir_free (yd); }#endif } status (); order (); dir (); for (i = 1; i < argc; ++i) { if (!strncasecmp (argv[i], "-r", 2)) yepp_release (); } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -