title: building a string with different parameters that is scalable
body: <pre><code>gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1
      c89
  </code></pre>
  
  <p>Just wondering is there a better way to do this with the code I have provided below.</p>
  
  <p>I am building a sdp (session description protocol) string from some parameters.</p>
  
  <p>However, I might need to extend the sdp to include other parameters i.e. video codecs.</p>
  
  <p>However, I don't really want to have another if else to build the complete string I have done below.</p>
  
  <p>I am just wondering is this scalable enough? Is there any technique I could use that is better than what I have done.</p>
  
  <p>I have just copied the function that does the sdp building:</p>
  
  <pre><code>void create_sdp_string(char *sdp_string, char reinvite)
  {
      char session_id[MAX_STRING_LEN];
      char session_version[MAX_STRING_LEN];
      const char *local_ip_addr = "10.10.10.244";
      apr_time_t time_usec = 0;
      char session_identifier[MAX_STRING_LEN];
      char media_transport[MAX_STRING_LEN];
      char connection_info[MAX_STRING_LEN];
      const char *audio_port = "49152";
  
      /* Required sdp attributes */
  #define V_PROTOCOL_VERSION "0"
  #define USERNAME "JOEBLOGGS"
  #define NETTYPE "IN"
  #define ADDR_TYPE "IP4"
  #define S_SESSION_NAME "SIP_CALL"
  #define T_TIME_DESCRIPTION "0 0"
  #define M_MEDIA_NAME_TRANSPORT_ADDR "RTP/AVP 0 8 101"
  #define A_PCMU "rtpmap:0 PCMU/8000"
  #define A_PCMA "rtpmap:8 PCMA/8000"
  #define A_TELEPHONE "rtpmap:101 telephone-event/8000"
  
      /* Get the time in micro seconds to create an unique session id */
      time_usec = apr_time_usec(apr_time_now());
      apr_snprintf(session_id, MAX_STRING_LEN, "%lu", (unsigned long)time_usec);
  
      /* Get the time in micro seconds to create an unique session version */
      time_usec = apr_time_usec(apr_time_now());
      apr_snprintf(session_version, MAX_STRING_LEN, "%lu", (unsigned long)time_usec);
  
      /* Build session identifier */
      apr_snprintf(session_identifier,
                   MAX_STRING_LEN,
                   "o="USERNAME" "NETTYPE" %s %s "ADDR_TYPE" %s\n",
                   session_id,
                   session_version,
                   local_ip_addr);
  
      /* Build media transport */
      apr_snprintf(media_transport,
                   MAX_STRING_LEN,
                   "m=audio %s "M_MEDIA_NAME_TRANSPORT_ADDR"\n",
                   audio_port);
  
      /* Build connection information */
      apr_snprintf(connection_info,
                   MAX_STRING_LEN,
                   "c="NETTYPE" "ADDR_TYPE" %s\n",
                   local_ip_addr);
  
      if(reinvite == FALSE) {
          /* Build complete sdp string for cases that are not reinvite */
          apr_snprintf(sdp_string,
                       MAX_SDP_STRING_LEN,
                       "v="V_PROTOCOL_VERSION"\n"
                       "%s"
                       "s="S_SESSION_NAME"\n"
                       "%s"
                       "t="T_TIME_DESCRIPTION"\n"
                       "%s"
                       "a="A_PCMU"\n"
                       "a="A_PCMA"\n"
                       "a="A_TELEPHONE"\n",
                       session_identifier,
                       connection_info,
                       media_transport);
      }
      else if(reinvite == TRUE) {
          /* Build complete sdp string for cases that are for reinvite 'inactive' */
  #define INACTIVE "inactive"
          apr_snprintf(sdp_string,
                       MAX_SDP_STRING_LEN,
                       "v="V_PROTOCOL_VERSION"\n"
                       "%s"
                       "s="S_SESSION_NAME"\n"
                       "%s"
                       "t="T_TIME_DESCRIPTION"\n"
                       "%s"
                       "a="A_PCMU"\n"
                       "a="A_PCMA"\n"
                       "a="A_TELEPHONE"\n"
                       "a="INACTIVE"\n",
                       session_identifier,
                       connection_info,
                       media_transport);
      }
  }
  </code></pre>