static bRC newPlugin(bpContext *ctx) { exchange_fd_context_t *context; bRC retval = bRC_OK; DWORD size; int JobId = 0; ctx->pContext = new exchange_fd_context_t; context = (exchange_fd_context_t *)ctx->pContext; context->bpContext = ctx; context->job_since = 0; context->notrunconfull_option = false; bfuncs->getBaculaValue(ctx, bVarJobId, (void *)&JobId); _DebugMessage(0, "newPlugin JobId=%d\n", JobId); bfuncs->registerBaculaEvents(ctx, 1, 2, 0); size = MAX_COMPUTERNAME_LENGTH + 1; context->computer_name = new WCHAR[size]; /* GetComputerNameW(context->computer_name, &size); */ GetComputerNameExW(ComputerNameNetBIOS, context->computer_name, &size); context->current_node = NULL; context->root_node = NULL; return retval; }
COMPILER_RT_VISIBILITY int lprofGetHostName(char *Name, int Len) { WCHAR Buffer[COMPILER_RT_MAX_HOSTLEN]; DWORD BufferSize = sizeof(Buffer); BOOL Result = GetComputerNameExW(ComputerNameDnsFullyQualified, Buffer, &BufferSize); if (!Result) return -1; if (WideCharToMultiByte(CP_UTF8, 0, Buffer, -1, Name, Len, NULL, NULL) == 0) return -1; return 0; }
static DNS_STATUS dns_get_hostname_w( COMPUTER_NAME_FORMAT format, PWSTR buffer, PDWORD len ) { WCHAR name[256]; DWORD size = sizeof(name); if (!GetComputerNameExW( format, name, &size )) return DNS_ERROR_NAME_DOES_NOT_EXIST; if (!buffer || (size = lstrlenW( name ) + 1) > *len) { *len = size; return ERROR_INSUFFICIENT_BUFFER; } lstrcpyW( buffer, name ); return ERROR_SUCCESS; }