Logo Search packages:      
Sourcecode: rapple version File versions  Download package

rpl_str_t rpl_message_get ( rpl_c_str_t  label,

Return the message corresponding to label (if the label does not return a standard messages then label prepended with "!" consists the returned message). Calls to get_message must be terminated by EOM. This function has refactored to include code derived original from the strutil:concat function in order to reduce the number of implicit memory leaks.

msg.tptr is what we use for subsequent calls. Assume messages are not that important that we should 1) keep them all around 2) Risk memory leaks for them. If they are so important, or thread safety becomes an issue, a mutex and a strncpy should keep them. Note : message_init() and message_done() is a must for the proper working of this. DO NOT TRY TO FREE THE RETURNED PTR!!!

label message identifier.
This function has a variable argument list. Calls must be terminated by EOM.
message corresponding to label.

Definition at line 176 of file messages.c.

References rpl_msg_global_s::init, rpl_msg_global_s::ns_prefix, rpl_me_free(), rpl_me_malloc(), rpl_msg_global_s::size, and rpl_msg_global_s::tptr.

Referenced by config_missing_file_error(), fs_create_dir(), fs_dir_stat(), http_parse_multipart_query(), http_parse_multipart_string(), open_logfile(), rpl_cfg_parse(), rpl_db_connect(), rpl_db_init(), rpl_db_query(), rpl_digest_parse(), rpl_digest_set_buffer_size(), rpl_fs_f2str(), rpl_fs_file_exists(), rpl_fs_get_cwd(), rpl_fs_recurse(), rpl_fs_remove(), rpl_fs_resolve_paths(), rpl_fs_str2f(), rpl_http_get_remote_user(), rpl_http_parse_query(), rpl_log_close_logfile(), rpl_me_malloc(), rpl_mod_db_process(), rpl_mod_index_process(), rpl_mod_init_process(), rpl_mod_link_cleanup(), rpl_mod_link_init(), rpl_mod_link_process(), rpl_mod_parse_process(), rpl_mod_tidy_init(), rpl_mod_tidy_process(), rpl_mod_xslt_init(), rpl_mod_xslt_process(), rpl_parse(), and start().

    int i;
    rpl_str_t sp; //, msg = RPL_STR_NUL;
    size_t length;
    va_list argp;

    assert(label != NULL);

    /* No init - no messages... */
    if (0 == msg_global.init) {
        return NULL;

    if (msg_global.tptr != NULL) {

    /* ascertain whether this is a standard or a custom message. */
    for(i = 0; i < msg_global.size; i++)
        if(strcmp(label, messages[i].label) == 0)

    /* determine the memory allocation required to hold the message */
    length = (i<msg_global.size) ? strlen(messages[i].message) + 1 : strlen(label) + 2;
    va_start(argp, label);
    while((sp = va_arg(argp, rpl_str_t)) != NULL)
        length += strlen(sp);
    msg_global.tptr = (rpl_str_t)rpl_me_malloc(length + 1);

    /* create the message by concatenating the necessary strings */
    if(i<msg_global.size) {
        /* standard message */
        strcpy(msg_global.tptr, messages[i].message);
    } else {
        /* custom message */
        strcpy(msg_global.tptr, msg_global.ns_prefix);
        strcat(msg_global.tptr, label);
    va_start(argp, label);
    while((sp=va_arg(argp, rpl_str_t)) != NULL)
       strcat(msg_global.tptr, sp);

    return msg_global.tptr;

Generated by  Doxygen 1.6.0   Back to index