📄 yepp.c
字号:
/************************************************* * nope - open source drivers for the yepp(tm) * *************************************************/ /* Copyright (c) 2001, James McKenzie. * All rights reserved * * By using this file, you agree to the terms and conditions set * forth in the LICENCE file which can be found at the top level of * the nope distribution. Neither James McKenzie nor anybody else * warranties that it is legal to use this software - that is your * problem. * * yepp is a trademark of Samsung. * *//* * yepp.c: * * Copyright (c) 2001 James McKenzie <james@fishsoup.dhs.org>, * All rights reserved. * */static char rcsid[] = "$Id: yepp.c,v 1.29 2001/05/15 10:02:41 root Exp root $";/* * $Log: yepp.c,v $ * Revision 1.29 2001/05/15 10:02:41 root * # * * Revision 1.28 2001/05/09 10:43:21 root * # * * Revision 1.27 2001/05/07 17:42:58 root * # * * Revision 1.26 2001/05/07 17:34:10 root * # * * Revision 1.25 2001/05/07 00:08:37 root * # * * Revision 1.24 2001/05/07 00:08:12 root * # * * Revision 1.23 2001/01/07 22:36:20 root * # * * Revision 1.22 2001/01/07 22:26:43 root * # * * Revision 1.21 2001/01/07 17:34:54 root * # * * Revision 1.20 2001/01/07 15:58:38 root * # * * Revision 1.19 2001/01/07 15:58:09 root * # * * Revision 1.18 2001/01/07 15:14:43 root * # * * Revision 1.17 2001/01/07 04:49:58 root * # * * Revision 1.16 2001/01/07 03:48:47 root * # * * Revision 1.15 2001/01/06 18:11:44 root * # * * Revision 1.14 2001/01/06 18:11:23 root * # * * Revision 1.13 2001/01/06 16:51:57 root * # * * Revision 1.12 2001/01/05 03:41:34 root * # * * Revision 1.11 2001/01/04 22:27:59 root * # * */#include "project.h"voidusage (char *name){ printf ("Usage:\n"); printf ("%s -a [-c file [type]] [-d num] [-e num] ", name);#ifdef HIFI printf ("[-g] [-G] ");#endif printf ("[-p port] [-r] [-u file [type]]");#ifdef HIFI printf (" [-w eweid] [-W eweid] [-z size] ");#endif printf ("\n"); printf (" -a Erase all files with index>4\n"); printf (" -c file [type] Upload file into card memory\n"); printf (" -d num Download file index num from the player\n"); printf (" -e num Erase file index num from the player\n");#ifdef HIFI printf (" -g Upload random song group from database to base\n"); printf (" -G Upload random song group from database to card\n");#endif printf (" -p iobase set the base address of the parallel port to use\n"); printf (" -r releive control of player\n"); printf (" -u file [type] Upload file into base memory\n");#ifdef HIFI printf (" -w eweid Upload eweid to base\n"); printf (" -W eweid Upload eweid to card\n"); printf (" -z size Keep doing -g until freesize<size Kb\n");#endif printf (" where type is one of\n"); printf (" sc4 mp3 tel data\n"); exit (1);}voiddir (void){ struct yepp_dirent *yd; struct yepp_dirent *ptr; unsigned char *order, *optr; int i; optr = order = yepp_getorder (); if (!order) return; i = YEPP_ORDER_LEN; ptr = yd = yepp_dir (); if (!yd) return; printf ("Indx Type Size Attr Name \n"); printf ("-------------------------------------------------\n"); while (i--) { if (!*optr) break; ptr = yd; while (ptr) { if (ptr->index == *optr) { printf ("%4d 0x%02x %14d 0x%02x %s\n", ptr->index, ptr->type, ptr->size, ptr->attr, ptr->name); ptr->user = 1; } ptr = ptr->next; } optr++; } ptr = yd; while (ptr) { if (!ptr->user) { printf ("%4d 0x%02x %14d 0x%02x %s\n", ptr->index, ptr->type, ptr->size, ptr->attr, ptr->name); } ptr = ptr->next; } yepp_dir_free (yd); printf ("\n"); free (order);}voidstatus (void){ struct yepp_status *ys; ys = yepp_status (); if (!ys) return; printf ("Status:\n"); printf (" Base: %d/%d Kbytes free\n", ys->main.free, ys->main.size); printf (" Card: %d/%d Kbytes free\n", ys->card.free, ys->card.size); free (ys);}voidorder (void){ unsigned char *order, *ptr; int i; ptr = order = yepp_getorder (); if (!order) return; i = YEPP_ORDER_LEN; printf ("Playorder:"); while (i--) { printf (" %d", *(ptr++)); if (!*ptr) break; } printf ("\n"); free (order);}voiddo_setorder (char **list, int n){ unsigned char order[YEPP_ORDER_LEN], *ptr; int i; ptr = order; bzero (order, sizeof (order)); while (n--) { if ((*list)[0] == '-') break; *(ptr++) = atoi (*list); list++; } yepp_putorder (order);}intdo_erase (char *which){ int i; if (which && (which[0] == '-')) return 0; i = atoi (which); return yepp_erase (i);}intdo_download (char *which){ int i; FILE *f; char *name; if (which && (which[0] == '-')) return 0; i = atoi (which); name = yepp_getnamebyindex (i); if (!name) { fprintf (stderr, "download: can't find index %d\n", i); return 0; } fprintf (stderr, "download: index %d is %s\n", i, name); f = fopen (name, "w"); if (!f) { fprintf (stderr, "download: can't open %s\n", name); return 0; } i = yepp_get (i, f); fclose (f); return i;}intdo_upload (int where, char *fname, char *ftype){ int type = YEPP_TYPE_MP3; FILE *f; if (fname && (fname[0] == '-')) fname = NULL; if (ftype && (ftype[0] == '-')) ftype = NULL; if (ftype) { do { if (!strcasecmp (ftype, "mp3")) { type = YEPP_TYPE_MP3; break; } if (!strcasecmp (ftype, "sc4")) { type = YEPP_TYPE_SC4; break; } if (!strcasecmp (ftype, "tel")) { type = YEPP_TYPE_TEL; break; } if (!strcasecmp (ftype, "data")) { type = YEPP_TYPE_DATA; break; } fprintf (stderr, "upload: Unknown file type \"%s\" assuming mp3\n", ftype); } while (0); } f = fopen (fname, "r"); if (!f) { fprintf (stderr, "upload: can't open \"%s\"\n", fname); return 0; } yepp_put (where, type, fname, f); fclose (f); return 1;}voiddo_erase_all (void){ struct yepp_dirent *yd, *ptr; int happy = 0; ptr = yd = yepp_dir (); if (!yd) return; while (ptr) { switch (ptr->index) { case YEPP_CONFIG_INDEX: if (!strcmp (ptr->name, "config.dat")) happy++; break; case YEPP_ENCODE_INDEX: if (!strcmp (ptr->name, "encode.mas")) happy++; break; case YEPP_DECODE_INDEX: if (!strcmp (ptr->name, "decode.mas")) happy++; break; case YEPP_SERIAL_INDEX: if (!strcmp (ptr->name, "serial.dat")) happy++; break; } ptr = ptr->next; } if (happy != 4) { fprintf (stderr, "do_erase_all: not happy - aborting\n"); yepp_dir_free (yd); return; } ptr = yd; while (ptr)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -