Changeset 5189:d2b96cf45a19 in roaraudio


Ignore:
Timestamp:
10/23/11 02:03:03 (12 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added some more protocol IDs

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/roaraudio/client.h

    r4708 r5189  
    4848#define ROAR_PROTO_DCC             12 
    4949#define ROAR_PROTO_ECHO            13 /* for testing and stuff */ 
     50#define ROAR_PROTO_DISCARD         14 /* RFC 863 */ 
     51#define ROAR_PROTO_WHOIS           15 
     52#define ROAR_PROTO_FINGER          16 
     53#define ROAR_PROTO_QUOTE           17 /* RFC 865: Quote of the Day Protocol */ 
     54#define ROAR_PROTO_DAYTIME         18 
    5055 
    5156#define ROAR_BYTEORDER_UNKNOWN      0x00 
  • libroar/ctl.c

    r5148 r5189  
    554554} 
    555555 
     556static struct { 
     557 int id; 
     558 const char * name; 
     559} _proto[] = { 
     560 {ROAR_PROTO_NONE,        "none"}, 
     561 {ROAR_PROTO_ROARAUDIO,   "RoarAudio"}, 
     562 {ROAR_PROTO_ESOUND,      "EsounD"}, 
     563 {ROAR_PROTO_ESOUND,      "ESD"}, // alias 
     564 {ROAR_PROTO_AUTO,        "(auto)"}, 
     565 {ROAR_PROTO_HTTP,        "http"}, 
     566 {ROAR_PROTO_GOPHER,      "gopher"}, 
     567 {ROAR_PROTO_ICY,         "ICY"}, 
     568 {ROAR_PROTO_SIMPLE,      "Simple"}, 
     569 {ROAR_PROTO_RSOUND,      "RSound"}, 
     570 {ROAR_PROTO_RPLAY,       "RPlay"}, 
     571 {ROAR_PROTO_IRC,         "IRC"}, 
     572 {ROAR_PROTO_DCC,         "DCC"}, 
     573 {ROAR_PROTO_ECHO,        "Echo"}, 
     574 {ROAR_PROTO_DISCARD,     "Discard"}, 
     575 {ROAR_PROTO_WHOIS,       "Whois"}, 
     576 {ROAR_PROTO_FINGER,      "Finger"}, 
     577 {ROAR_PROTO_QUOTE,       "quote"}, 
     578 {ROAR_PROTO_DAYTIME,     "daytime"}, 
     579 {-1, NULL} 
     580}; 
     581 
    556582int    roar_str2proto (const char * proto) { 
    557  if ( !strcasecmp(proto, "roar") ) { 
    558   return ROAR_PROTO_ROARAUDIO; 
    559  } else if ( !strcasecmp(proto, "roaraudio") ) { 
    560   return ROAR_PROTO_ROARAUDIO; 
    561  } else if ( !strcasecmp(proto, "esd") ) { 
    562   return ROAR_PROTO_ESOUND; 
    563  } else if ( !strcasecmp(proto, "esound") ) { 
    564   return ROAR_PROTO_ESOUND; 
    565  } else if ( !strcasecmp(proto, "auto") ) { 
    566   return ROAR_PROTO_AUTO; 
    567  } else if ( !strcasecmp(proto, "(auto)") ) { 
    568   return ROAR_PROTO_AUTO; 
    569  } else if ( !strcasecmp(proto, "http") ) { 
    570   return ROAR_PROTO_HTTP; 
    571  } else if ( !strcasecmp(proto, "gopher") ) { 
    572   return ROAR_PROTO_GOPHER; 
    573  } else if ( !strcasecmp(proto, "icy") ) { 
    574   return ROAR_PROTO_ICY; 
    575  } else if ( !strcasecmp(proto, "simple") ) { 
    576   return ROAR_PROTO_SIMPLE; 
    577  } else if ( !strcasecmp(proto, "rsound") ) { 
    578   return ROAR_PROTO_RSOUND; 
    579  } else if ( !strcasecmp(proto, "rplay") ) { 
    580   return ROAR_PROTO_RPLAY; 
    581  } else if ( !strcasecmp(proto, "irc") ) { 
    582   return ROAR_PROTO_IRC; 
    583  } else if ( !strcasecmp(proto, "dcc") ) { 
    584   return ROAR_PROTO_DCC; 
    585  } else if ( !strcasecmp(proto, "echo") ) { 
    586   return ROAR_PROTO_ECHO; 
    587  } 
     583 size_t i; 
     584 
     585 for (i = 0; _proto[i].id != -1; i++) 
     586  if ( !strcasecmp(proto, _proto[i].name) ) 
     587   return _proto[i].id; 
    588588 
    589589 roar_err_set(ROAR_ERROR_NOENT); 
     
    592592 
    593593char * roar_proto2str (const int    proto) { 
    594  switch (proto) { 
    595   case ROAR_PROTO_ROARAUDIO: return "RoarAudio"; break; 
    596   case ROAR_PROTO_ESOUND:    return "EsounD";    break; 
    597   case ROAR_PROTO_AUTO:      return "(auto)";    break; 
    598   case ROAR_PROTO_HTTP:      return "http";      break; 
    599   case ROAR_PROTO_GOPHER:    return "gopher";    break; 
    600   case ROAR_PROTO_ICY:       return "ICY";       break; 
    601   case ROAR_PROTO_SIMPLE:    return "Simple";    break; 
    602   case ROAR_PROTO_RSOUND:    return "RSound";    break; 
    603   case ROAR_PROTO_RPLAY:     return "RPlay";     break; 
    604   case ROAR_PROTO_IRC:       return "IRC";       break; 
    605   case ROAR_PROTO_DCC:       return "DCC";       break; 
    606   case ROAR_PROTO_ECHO:      return "Echo";      break; 
    607   default: 
    608     return "(unknown)"; 
    609  } 
     594 size_t i; 
     595 
     596 roar_err_set(ROAR_ERROR_NONE); 
     597 
     598 for (i = 0; _proto[i].id != -1; i++) 
     599  if ( proto == _proto[i].id ) 
     600   return (char*)_proto[i].name; 
     601 
     602 roar_err_set(ROAR_ERROR_NOENT); 
     603 return "(unknown)"; 
    610604} 
    611605 
Note: See TracChangeset for help on using the changeset viewer.