/*quick sort of words */ void qwordsort(struct word * strarray, int begin, int end) { if(begin >= end) return; struct word * item = &strarray[begin]; int low = begin, high = end; //print("a=%s, b=%s\n",strarray[begin].vp, strarray[end].vp); while( low < high) { while(low < high && strcmp(item->vp, strarray[high].vp) <= 0) high--; while(low < high && strcmp(item->vp, strarray[low].vp) >= 0) low++; strswap(&strarray[low],&strarray[high]); } if(low!=begin) strswap(&strarray[low],item); qwordsort(strarray,begin, low-1 ); qwordsort(strarray,low+1, end ); }
/** * @brief Read and parse a skin. * * @param sname name of the skin * * @return 0 (ok), -1 (skin file not found or not readable) or -2 (parsing error) */ int skinRead(char *sname) { char *skinfname; FILE *skinfile; unsigned char line[256]; unsigned char item[32]; unsigned char param[256]; unsigned int i; skinfname = setname(skinDirInHome, sname); if ((skinfile = fopen(skinfname, "rt")) == NULL) { skinfname = setname(skinMPlayerDir, sname); if ((skinfile = fopen(skinfname, "rt")) == NULL) { mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_SKIN_SkinFileNotFound, skinfname); return -1; } } mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[skin] configuration file: %s\n", skinfname); appFreeStruct(); skin = NULL; currWinName[0] = 0; linenumber = 0; while (fgetstr(line, sizeof(line), skinfile)) { linenumber++; strswap(line, '\t', ' '); trim(line); decomment(line); if (!*line) continue; cutItem(line, item, '=', 0); cutItem(line, param, '=', 1); strlower(item); for (i = 0; i < FF_ARRAY_ELEMS(skinItem); i++) { if (!strcmp(item, skinItem[i].name)) { if (skinItem[i].func(param) != 0) return -2; else break; } } if (i == FF_ARRAY_ELEMS(skinItem)) { skin_error(MSGTR_SKIN_UNKNOWN_ITEM, item); return -2; } } if (linenumber == 0) { mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_SKIN_SkinFileNotReadable, skinfname); return -1; } return 0; }
int skinRead( char * dname ) { unsigned char tmp[255]; unsigned char * ptmp; unsigned char command[32]; unsigned char param[256]; int c,i; setname( skinDirInHome,dname ); if ( ( skinFile = fopen( fn,"rt" ) ) == NULL ) { setname( skinMPlayerDir,dname ); if ( ( skinFile = fopen( fn,"rt" ) ) == NULL ) { setname( skinDirInHome_obsolete,dname ); if ( ( skinFile = fopen( fn,"rt" ) ) == NULL ) { setname( skinMPlayerDir_obsolete,dname ); if ( ( skinFile = fopen( fn,"rt" ) ) == NULL ) { setname( skinMPlayerDir,dname ); mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_SkinFileNotFound,fn ); return -1; } } } } mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin] file: %s\n",fn ); appInitStruct( skinAppMPlayer ); linenumber=0; while (fgets(tmp, 255, skinFile)) { linenumber++; c=tmp[ strlen( tmp ) - 1 ]; if ( c == '\n' || c == '\r' ) tmp[ strlen( tmp ) - 1 ]=0; c=tmp[ strlen( tmp ) - 1 ]; if ( c == '\n' || c == '\r' ) tmp[ strlen( tmp ) - 1 ]=0; for ( c=0;c<(int)strlen( tmp );c++ ) if ( tmp[c] == ';' ) { tmp[c]=0; break; } if ( strlen( tmp ) == 0 ) continue; ptmp=trimleft( tmp ); if ( strlen( ptmp ) == 0 ) continue; ptmp=strswap( ptmp,'\t',' ' ); ptmp=trim( ptmp ); cutItem( ptmp,command,'=',0 ); cutItem( ptmp,param,'=',1 ); strlower( command ); for( i=0;i<ITEMS;i++ ) if ( !strcmp( command,skinItem[i].name ) ) if ( skinItem[i].func( param ) ) return -2; } if (linenumber == 0) { mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_SKIN_SkinFileNotReadable, fn); return -1; } return 0; }