/* * AOL Instant Messanger Module for BitchX * * By Nadeem Riaz (nads@bleh.org) * * util.c * * utility/misc functions */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "toc.h" #include "aim.h" void statusprintf(char *fmt, ...) { char data[MAX_STATUS_MSG_LEN]; char *sfmt, *prompt; va_list ptr; /* Tack on prompt */ prompt = get_dllstring_var("aim_prompt"); sfmt = (char *) malloc(strlen(prompt) + strlen(fmt)+5); strcpy(sfmt,prompt); strcat(sfmt," "); strcat(sfmt,fmt); va_start(ptr, fmt); vsnprintf(data, MAX_STATUS_MSG_LEN - 1 , sfmt, ptr); va_end(ptr); free(sfmt); statusput(LOG_CRAP,data); return; } void statusput(int log_type, char *buf) { int lastlog_level; lastlog_level = set_lastlog_msg_level(log_type); if (get_dllint_var("aim_window") > 0) if (!(target_window = get_window_by_name("AIM"))) target_window = current_window; if (window_display && buf) { add_to_log(irclog_fp, 0, buf, 0); add_to_screen(buf); } target_window = NULL; set_lastlog_msg_level(lastlog_level); return; } void msgprintf(char *fmt, ...) { char data[MAX_STATUS_MSG_LEN]; va_list ptr; va_start(ptr, fmt); vsnprintf(data, MAX_STATUS_MSG_LEN - 1 , fmt, ptr); va_end(ptr); statusput(LOG_CRAP,data); return; } void debug_printf(char *fmt, ...) { #ifdef DEBUG_AIM FILE *fp; char data[MAX_OUTPUT_MSG_LEN]; va_list ptr; if ( ! (fp=fopen(AIM_DEBUG_LOG,"a")) ) { perror("ERROR couldn't open debug log file!@$\n"); } va_start(ptr, fmt); vsnprintf(data, MAX_OUTPUT_MSG_LEN - 1 , fmt, ptr); va_end(ptr); fprintf(fp,"%s\n",data); fflush(fp); fclose(fp); return; #endif } char *rm_space(char *s) { char *rs; int x,y; rs = (char *) malloc(strlen(s) + 1); x = y = 0; for (x =0; x