char *U8toAs(const char *src, int max_len) { static char *buf[MAX_STATIC_ARRAY]; static u_long idx; char *&cur_buf = buf[idx++ % MAX_STATIC_ARRAY]; if (cur_buf) { delete [] cur_buf; } return (cur_buf = U8toA(src, max_len)); }
/* リンクファイル削除 */ BOOL DeleteLink(LPCSTR path) { char dir[MAX_PATH_U8]; if (!DeleteFileU8(path)) return FALSE; GetParentDirU8(path, dir); ::SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_PATH|SHCNF_FLUSH, U8toA(dir), NULL); return TRUE; }
ULONG MsgMng::MakeMsg(char *buf, int _packetNo, ULONG command, const char *msg, const char *exMsg, int *packet_len) { int cmd = GET_MODE(command); BOOL is_br_cmd = cmd == IPMSG_BR_ENTRY || cmd == IPMSG_BR_EXIT || cmd == IPMSG_BR_ABSENCE || cmd == IPMSG_NOOPERATION ? TRUE : FALSE; BOOL is_utf8 = (command & IPMSG_UTF8OPT); HostSub *host = is_utf8 ? &local : &localA; char *out_buf = NULL; char *out_exbuf = NULL; const char *msg_org = msg; const char *exMsg_org = exMsg; int len = 0; int ex_len = 0; int &pkt_len = packet_len ? *packet_len : len; int max_len = MAX_UDPBUF; BOOL is_ascii; pkt_len = sprintf(buf, "%d:%u:%s:%s:%u:", IPMSG_VERSION, _packetNo, host->userName, host->hostName, command); if (msg) { if (!is_utf8 && IsUTF8(msg, &is_ascii) && !is_ascii) { msg = out_buf = U8toA(msg, TRUE); } } if (exMsg) { if (!is_utf8 && IsUTF8(exMsg, &is_ascii) && !is_ascii) { exMsg = out_exbuf = U8toA(exMsg, TRUE); } ex_len = (int)strlen(exMsg); } if (ex_len + pkt_len + 2 >= MAX_UDPBUF) ex_len = 0; max_len -= ex_len; if (msg) { pkt_len += LocalNewLineToUnix(msg, buf + pkt_len, max_len - pkt_len); } pkt_len++; if (ex_len) { memcpy(buf + pkt_len, exMsg, ex_len); pkt_len += ex_len; } if (is_br_cmd) { buf[pkt_len++] = 0; pkt_len += sprintf(buf + pkt_len, "\nUN:%s\nHN:%s\nNN:%s\nGN:%s", local.userName, local.hostName, msg_org, exMsg_org); } delete [] out_exbuf; delete [] out_buf; return _packetNo; }