! \brief * Returns the statistic associated with 'numerical_code' and 'out_codes'. * Specifically: * * - if out_codes is nonzero, then the stat_var for the number of messages * _sent out_ with the 'numerical_code' will be returned if it exists. * - otherwise, the stat_var for the number of messages _received_ with the * 'numerical_code' will be returned, if the stat exists. */
| 109 | * 'numerical_code' will be returned, if the stat exists. |
| 110 | */ |
| 111 | stat_var *get_stat_var_from_num_code(unsigned int numerical_code, int out_codes) |
| 112 | { |
| 113 | static char msg_code[INT2STR_MAX_LEN+4]; |
| 114 | str stat_name; |
| 115 | |
| 116 | stat_name.s = int2bstr( (unsigned long)numerical_code, msg_code, |
| 117 | &stat_name.len); |
| 118 | stat_name.s[stat_name.len++] = '_'; |
| 119 | |
| 120 | if (out_codes) { |
| 121 | stat_name.s[stat_name.len++] = 'o'; |
| 122 | stat_name.s[stat_name.len++] = 'u'; |
| 123 | stat_name.s[stat_name.len++] = 't'; |
| 124 | } else { |
| 125 | stat_name.s[stat_name.len++] = 'i'; |
| 126 | stat_name.s[stat_name.len++] = 'n'; |
| 127 | } |
| 128 | |
| 129 | return get_stat(&stat_name); |
| 130 | } |
| 131 | |
| 132 | |
| 133 | char *build_stat_name( str* prefix, char *var_name) |
no test coverage detected