static void GetPasswordText(wchar *Str,uint MaxLength) { if (MaxLength==0) return; #ifdef _WIN_ALL HANDLE hConIn=GetStdHandle(STD_INPUT_HANDLE); HANDLE hConOut=GetStdHandle(STD_OUTPUT_HANDLE); DWORD ConInMode,ConOutMode; DWORD Read=0; GetConsoleMode(hConIn,&ConInMode); GetConsoleMode(hConOut,&ConOutMode); SetConsoleMode(hConIn,ENABLE_LINE_INPUT); SetConsoleMode(hConOut,ENABLE_PROCESSED_OUTPUT|ENABLE_WRAP_AT_EOL_OUTPUT); ReadConsole(hConIn,Str,MaxLength-1,&Read,NULL); Str[Read]=0; SetConsoleMode(hConIn,ConInMode); SetConsoleMode(hConOut,ConOutMode); #else char StrA[MAXPASSWORD]; #if defined(_EMX) || defined (__VMS) || defined(__AROS__) fgets(StrA,ASIZE(StrA)-1,stdin); #elif defined(__sun) strncpyz(StrA,getpassphrase(""),ASIZE(StrA)); #else strncpyz(StrA,getpass(""),ASIZE(StrA)); #endif CharToWide(StrA,Str,MaxLength); cleandata(StrA,sizeof(StrA)); #endif Str[MaxLength-1]=0; RemoveLF(Str); }
int strnicomp(const char *Str1,const char *Str2,size_t N) { char S1[NM*2],S2[NM*2]; strncpyz(S1,Str1,ASIZE(S1)); strncpyz(S2,Str2,ASIZE(S2)); return(strncmp(strupper(S1),strupper(S2),N)); }
static void SoftwareList_EnteringItem(HWND hwndSoftwareList, int nItem) { LPCSTR pszFullName; LPCSTR pszFileName; int drvindex = 0; HWND hwndList; hwndList = GetDlgItem(GetMainWindow(), IDC_LIST); if (!s_bIgnoreSoftwarePickerNotifies) { drvindex = Picker_GetSelectedItem(hwndList); // Get the fullname and partialname for this file pszFileName = SoftwareList_LookupFilename(hwndSoftwareList, nItem); // to run the software pszFullName = SoftwareList_LookupFullname(hwndSoftwareList, nItem); // for the screenshot strncpyz(g_szSelectedSoftware, pszFileName, ARRAY_LENGTH(g_szSelectedSoftware)); strncpyz(g_szSelectedDevice, SoftwareList_LookupDevice(hwndSoftwareList, nItem), ARRAY_LENGTH(g_szSelectedDevice)); // Set up s_szSelecteItem, for the benefit of UpdateScreenShot() strncpyz(g_szSelectedItem, pszFullName, ARRAY_LENGTH(g_szSelectedItem)); UpdateScreenShot(); } drvindex++; }
static int tcl_boot(ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) { char who[NOTENAMELEN + 1]; int i, ok = 0; BADARGS(2, 3, " user@bot ?reason?"); strncpyz(who, argv[1], sizeof who); if (strchr(who, '@') != NULL) { char whonick[HANDLEN + 1]; splitc(whonick, who, '@'); whonick[HANDLEN] = 0; if (!egg_strcasecmp(who, botnetnick)) strncpyz(who, whonick, sizeof who); else if (remote_boots > 0) { i = nextbot(who); if (i < 0) return TCL_OK; botnet_send_reject(i, botnetnick, NULL, whonick, who, argv[2] ? argv[2] : ""); } else return TCL_OK; } for (i = 0; i < dcc_total; i++) if (!ok && (dcc[i].type->flags & DCT_CANBOOT) && !egg_strcasecmp(dcc[i].nick, who)) { do_boot(i, botnetnick, argv[2] ? argv[2] : ""); ok = 1; } return TCL_OK; }
void ProcessALineByCmp(void) { strncpyz(gOutputLine,gSrcLine,9); // starting 9 chars in. char *srcLine=&gSrcLine[9]; char *cmpLine=&gCmpLine[9]; // starting 9 chars in. int pos=0,sum=0; char cmpDigs[4]; while(pos<strlen(srcLine)-2) { // strcpy(oldSrcDigs,srcDigs); // copy previous. strncpyz(srcDigs,&srcLine[pos],2); strncpyz(cmpDigs,&cmpLine[pos],2); if(strcmp(srcDigs,cmpDigs)!=0) { // they're different. printf("%d %s ",pos,srcLine); printf(" %s, %s, %s.\n",oldSrcDigs,srcDigs,cmpDigs); if(pos==0) { // it's a special case. gPrevLine[strlen(gPrevLine)-2]='\0'; // truncate. strcat(gPrevLine,srcDigs); strcat(gOutputLine,oldSrcDigs); } else { // easy case, just swap. gOutputLine[strlen(gOutputLine)-2]='\0'; // truncate. strcat(gOutputLine,srcDigs); strcat(gOutputLine,oldSrcDigs); } } else strcat(gOutputLine,srcDigs); pos+=2; } printf("Done the line.\n"); CatCheckSum(); }
void LoginHandler::SaveToGlobals() { strncpyz(gszToken, token_, sizeof(gszToken)); strncpyz(gszPassword, password_, sizeof(gszPassword)); strncpyz(gszUsername, username_, sizeof(gszUsername)); gfAnonymous = anonymous_; ggame.SavePreferences(); }
dword LoginHandler::GetToken() { // Wipe out the current token, if there is one token_[0] = 0; // Don't send a request for a token if the user has no password if (password_[0] == 0) { return knGetTokenResultNoPassword; } // Ask the authentication server for an auth token. Use https // so ok to send password cleartext. Encode base64 to avoid // url encoding parameters. const char *s = base::Format::ToString("%s#%s", username_, password_); char input[sizeof(username_) + sizeof(password_)]; strncpyz(input, s, sizeof(input)); int cchInput = (int)strlen(input); input[strlen(username_)] = 0; char output[(sizeof(username_) + sizeof(password_)) * 2]; int cb = base::base64encode((const byte *)input, cchInput, (byte *)output, sizeof(output)); if (cb == -1) { return knGetTokenResultCreateRequestError; } output[cb] = 0; // Submit a simple blocking request to get the token SimpleRequest req(gphttp); const char *url = base::Format::ToString("%s?a=%s&d=%s", kszAuthUrl, output, gszDeviceId); req.SetTimeout(60); char result[kcbTokenMax]; if (!req.Get(url, result, sizeof(result))) { return knGetTokenResultServiceUnavailable; } int cchResult = (int)strlen(result); // Strip whitespace from the start and end. char *start = result; for (; start < &result[cchResult]; start++) { if (!isspace(*start)) { break; } } char *end = &result[cchResult - 1]; for (; end > start; end--) { if (!isspace(*end)) { end++; break; } } if (end <= start) { return knGetTokenResultTokenInvalid; } strncpyz(token_, start, (int)(end - start + 1)); return knGetTokenResultSuccess; }
int msp430_adc_find_inputs(struct adc_channels_t* channels, struct moption_t* opt) { const char delim1[] = ","; const char delim2[] = ":"; char *str1,*str2; char *token,*subtoken; char *saveptr1,*saveptr2; char *filename; char name[MAX_FILENAME]; int j; int id; strncpyz(name, opt->value, MAX_FILENAME); /* --msp430_adc=1:file,2:file,3:file ... */ for (j = 1, str1 = name; ; j++, str1 = NULL) { token = strtok_r(str1, delim1, &saveptr1); if (token == NULL) break; HW_DMSG_ADC("msp430:adc:%d: %s\n", j, token); str2 = token; subtoken = strtok_r(str2, delim2, &saveptr2); if (subtoken == NULL) { ERROR("msp430:adc: wrong channel id \n"); return 1; } id = atoi(subtoken); if ((id < 0) || (id >= ADC_CHANNELS)) { ERROR("msp430:adc: wrong channel id %s (%d)\n",subtoken,id); return 1; } subtoken = strtok_r(NULL, delim2, &saveptr2); filename = subtoken; if (subtoken == NULL) { ERROR("msp430:adc: wrong channel filename\n"); return 1; } subtoken = strtok_r(NULL, delim2, &saveptr2); if (subtoken != NULL) { ERROR("msp430:adc: wrong channel filename trailer %s\n",subtoken); return 1; } HW_DMSG_ADC("msp430:adc: channel %02d = %s\n",id, filename); channels->channels_valid[id] = ADC_CHANN_PTR; strncpyz(channels->channels_name[id], filename, MAX_FILENAME); } return 0; }
static int u_delinvite(struct chanset_t *c, char *who, int doit) { int j, i = 0; maskrec *t; maskrec **u = c ? &(c->invites) : &global_invites; char temp[256]; if (!strchr(who, '!') && str_isdigit(who)) { j = atoi(who); j--; for (; (*u) && j; u = &((*u)->next), j--); if (*u) { strncpyz(temp, (*u)->mask, sizeof temp); i = 1; } else return -j - 1; } else { /* Find matching host, if there is one */ for (; *u && !i; u = &((*u)->next)) if (!rfc_casecmp((*u)->mask, who)) { strncpyz(temp, who, sizeof temp); i = 1; break; } if (!*u) return 0; } if (i && doit) { if (!noshare) { char *mask = str_escape(temp, ':', '\\'); if (mask) { /* Distribute chan invites differently */ if (c) shareout(c, "-invc %s %s\n", c->dname, mask); else shareout(NULL, "-inv %s\n", mask); nfree(mask); } } if (lastdeletedmask) nfree(lastdeletedmask); lastdeletedmask = nmalloc(strlen((*u)->mask) + 1); strcpy(lastdeletedmask, (*u)->mask); nfree((*u)->mask); if ((*u)->desc) nfree((*u)->desc); if ((*u)->user) nfree((*u)->user); t = *u; *u = (*u)->next; nfree(t); } return i; }
BOOL OpenFileDlg::Exec(char *target, int targ_size, char *title, char *filter, char *defaultDir, char *defaultExt) { if (targ_size <= 1) return FALSE; OPENFILENAME ofn; U8str fileName(targ_size); U8str dirName(targ_size); char *fname = NULL; if (*target && GetFullPathNameU8(target, targ_size, dirName.Buf(), &fname) != 0 && fname) { *(fname -1) = 0; strncpyz(fileName.Buf(), fname, targ_size); } else if (defaultDir) { strncpyz(dirName.Buf(), defaultDir, targ_size); } memset(&ofn, 0, sizeof(ofn)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = parent ? parent->hWnd : NULL; ofn.lpstrFilter = filter; ofn.nFilterIndex = filter ? 1 : 0; ofn.lpstrFile = fileName.Buf(); ofn.lpstrDefExt = defaultExt; ofn.nMaxFile = targ_size; ofn.lpstrTitle = title; ofn.lpstrInitialDir = dirName.Buf(); ofn.lpfnHook = hook; ofn.Flags = OFN_HIDEREADONLY|OFN_EXPLORER|(hook ? OFN_ENABLEHOOK : 0); if (mode == OPEN || mode == MULTI_OPEN) ofn.Flags |= OFN_FILEMUSTEXIST | (mode == MULTI_OPEN ? OFN_ALLOWMULTISELECT : 0); else ofn.Flags |= (mode == NODEREF_SAVE ? OFN_NODEREFERENCELINKS : 0); ofn.Flags |= flags; U8str dirNameBak(targ_size); GetCurrentDirectoryU8(targ_size, dirNameBak.Buf()); BOOL ret = (mode == OPEN || mode == MULTI_OPEN) ? GetOpenFileNameU8(&ofn) : GetSaveFileNameU8(&ofn); SetCurrentDirectoryU8(dirNameBak.Buf()); if (ret) { if (mode == MULTI_OPEN) { memcpy(target, fileName.Buf(), targ_size); } else { strncpyz(target, ofn.lpstrFile, targ_size); } if (defaultDir) strncpyz(defaultDir, ofn.lpstrFile, ofn.nFileOffset); } return ret; }
void LoginHandler::GetPlayerName(char *psz, int cb) { if (anonymous_) { if (gptra != NULL) { strncpyz(psz, gptra->GetAnonymousUsername(), cb); } else { strncpyz(psz, "anonymous", cb); } } else { strncpyz(psz, username_, cb); } }
int main(int argc, char **argv) { char pbuffer[64000]; struct pk_conn pkc; struct pk_parser* pkp; struct pk_pagekite kite; struct pk_kite_request kite_r; struct pk_kite_request* kite_rp; SSL_CTX* ctx; if (argc < 3) { usage(); exit(1); } pks_global_init(PK_LOG_ALL); pk_state.log_file = NULL; PKS_SSL_INIT(ctx); kite_r.kite = &kite; strcpy(kite.protocol, "http"); strncpyz(kite.public_domain, argv[1], PK_DOMAIN_LENGTH); kite.public_port = 0; strncpyz(kite.auth_secret, argv[2], PK_SECRET_LENGTH); kite_r.bsalt[0] = '\0'; kite_r.fsalt[0] = '\0'; kite_rp = &kite_r; srand(time(0) ^ getpid()); if (0 > pk_connect(&pkc, argv[1], 443, 1, &kite_r, NULL, ctx)) { pk_perror(argv[1]); usage(); return 1; } pkp = pk_parser_init(sizeof(pbuffer), pbuffer, &handle_request, &pkc); if (NULL == pkp) { pk_perror(argv[1]); usage(); return 1; } fprintf(stderr, "*** Connected! ***\n"); while (pkc_wait(&pkc, -1)) { pkc_read(&pkc); pk_parser_parse(pkp, pkc.in_buffer_pos, (char *) pkc.in_buffer); pkc.in_buffer_pos = 0; } pkc_reset_conn(&pkc, 0); return 0; }
static void do_arg(char *s) { char x[512], *z = x; int i; if (s[0] == '-') for (i = 1; i < strlen(s); i++) { switch (s[i]) { case 'n': backgrd = 0; break; case 'c': con_chan = 1; term_z = 0; break; case 't': con_chan = 0; term_z = 1; break; case 'm': make_userfile = 1; break; case 'v': strncpyz(x, egg_version, sizeof x); newsplit(&z); newsplit(&z); printf("%s\n", version); if (z[0]) printf(" (patches: %s)\n", z); printf("Configured with: " EGG_AC_ARGS "\n"); printf("Compiled with: "); #ifdef IPV6 printf("IPv6, "); #endif #ifdef TLS printf("TLS, "); #endif printf("handlen=%d\n", HANDLEN); bg_send_quit(BG_ABORT); exit(0); break; /* this should never be reached */ case 'h': printf("\n%s\n\n", version); printf(EGG_USAGE); printf("\n"); bg_send_quit(BG_ABORT); exit(0); break; /* this should never be reached */ } } else strncpyz(configfile, s, sizeof configfile); }
RRDSET *rrdset_find_bytype(const char *type, const char *id) { debug(D_RRD_CALLS, "rrdset_find_bytype() for chart %s.%s", type, id); char buf[RRD_ID_LENGTH_MAX + 1]; strncpyz(buf, type, RRD_ID_LENGTH_MAX - 1); strcat(buf, "."); int len = (int) strlen(buf); strncpyz(&buf[len], id, (size_t) (RRD_ID_LENGTH_MAX - len)); return(rrdset_find(buf)); }
static uLong renameparse (void *rppbv, const char *devname, const char *filname, OZ_Handle h_iochan) { Rppb *rppb; if (h_iochan != 0) { oz_sys_io_fs_printf (oz_util_h_error, "%s: can't rename to an I/O channel\n", pn); return (OZ_BADPARAM); } rppb = rppbv; strncpyz (rppb -> devname, devname, sizeof rppb -> devname); strncpyz (rppb -> filname, filname, sizeof rppb -> filname); return (OZ_SUCCESS); }
/*-----------------------------------------------------------------*/ void deallocParms (value * val) { value *lval; for (lval = val; lval; lval = lval->next) { /* unmark is myparm */ lval->sym->ismyparm = 0; /* delete it from the symbol table */ deleteSym (SymbolTab, lval->sym, lval->sym->name); if (!lval->sym->isref) { lval->sym->allocreq = 0; werror (W_NO_REFERENCE, currFunc ? currFunc->name : "(unknown)", "function argument", lval->sym->name); } /* move the rname if any to the name for both val & sym */ /* and leave a copy of it in the symbol table */ if (lval->sym->rname[0]) { char buffer[SDCC_NAME_MAX]; symbol * argsym = lval->sym; strncpyz (buffer, lval->sym->rname, sizeof(buffer)); lval->sym = copySymbol (lval->sym); strncpyz (lval->sym->rname, buffer, sizeof(lval->sym->rname)); strncpyz (lval->sym->name, buffer, sizeof(lval->sym->name)); /* need to keep the original name for inlining to work */ /*strncpyz (lval->name, buffer, sizeof(lval->name)); */ addSym (SymbolTab, lval->sym, lval->sym->name, lval->sym->level, lval->sym->block, 1); lval->sym->_isparm = 1; if (!isinSet (operKeyReset, lval->sym)) { addSet(&operKeyReset, lval->sym); } /* restore the original symbol */ lval->sym = argsym; } } return; }
/* 2byte文字系でもきちんと動作させるためのルーチン (*strrchr(path, "\\")=0 だと '表'などで問題を起すため) */ BOOL PathToDir(const char *org_path, char *target_dir) { char path[MAX_BUF], *fname=NULL; if (GetFullPathNameU8(org_path, sizeof(path), path, &fname) == 0 || fname == NULL) return strncpyz(target_dir, org_path, MAX_PATH_U8), FALSE; if (fname - path > 3 || path[1] != ':') *(fname - 1) = 0; else *fname = 0; // C:\ の場合 strncpyz(target_dir, path, MAX_PATH_U8); return TRUE; }
/* Called from the ContextNote macro. */ void eggContextNote(const char *file, int line, const char *module, const char *note) { char x[31], *p; p = strrchr(file, '/'); if (!module) strncpyz(x, p ? p + 1 : file, sizeof x); else egg_snprintf(x, 31, "%s:%s", module, p ? p + 1 : file); cx_ptr = ((cx_ptr + 1) & 15); strcpy(cx_file[cx_ptr], x); cx_line[cx_ptr] = line; strncpyz(cx_note[cx_ptr], note, sizeof cx_note[cx_ptr]); }
void oz_knl_thread_cpuinit (void) { OZ_Datebin now; OZ_Thread *thread; oz_hw_smplock_init (sizeof smplock_tc, &smplock_tc, OZ_SMPLOCK_LEVEL_TC); thread = OZ_KNL_NPPMALLOC (sizeof *thread); memset (thread, 0, sizeof *thread); thread -> objtype = OZ_OBJTYPE_THREAD; thread -> refcount = 2; thread -> state = OZ_THREAD_STATE_RUN; now = oz_hw_tod_getnow (); if (now != 0) { thread -> tisinitted = 1; thread -> timeinstate[OZ_THREAD_STATE_RUN] -= now; } strncpyz (thread -> name, "main", sizeof thread -> name); oz_hw_thread_initctx (thread -> hwctx, 0, NULL, NULL, NULL, thread); thread -> next = NULL; allthreads = thread; curthread = thread; }
static void SoftwarePicker_EnteringItem(HWND hwndSoftwarePicker, int nItem) { LPCSTR pszFullName; LPCSTR pszName; const char* tmp; LPSTR s; int drvindex = 0; HWND hwndList; hwndList = GetDlgItem(GetMainWindow(), IDC_LIST); if (!s_bIgnoreSoftwarePickerNotifies) { drvindex = Picker_GetSelectedItem(hwndList); // Get the fullname and partialname for this file pszFullName = SoftwarePicker_LookupFilename(hwndSoftwarePicker, nItem); tmp = strrchr(pszFullName, '\\'); pszName = tmp ? tmp + 1 : pszFullName; // Do the dirty work MessSpecifyImage(drvindex, NULL, pszFullName); // Set up g_szSelectedItem, for the benefit of UpdateScreenShot() strncpyz(g_szSelectedItem, pszName, ARRAY_LENGTH(g_szSelectedItem)); s = strrchr(g_szSelectedItem, '.'); if (s) *s = '\0'; UpdateScreenShot(); } }
void reaffirm_owners() { char *p, *q, s[121]; struct userrec *u; /* Please stop breaking this function. */ if (owner[0]) { q = owner; p = strchr(q, ','); while (p) { strncpyz(s, q, (p - q) + 1); rmspace(s); u = get_user_by_handle(userlist, s); if (u) u->flags = sanity_check(u->flags | USER_OWNER); q = p + 1; p = strchr(q, ','); } strcpy(s, q); rmspace(s); u = get_user_by_handle(userlist, s); if (u) u->flags = sanity_check(u->flags | USER_OWNER); } }
static int tcl_control(ClientData cd, Tcl_Interp *irp, int argc, char *argv[]) { int idx; void *hold; BADARGS(3, 3, " idx command"); idx = findidx(atoi(argv[1])); if (idx < 0) { Tcl_AppendResult(irp, "invalid idx", NULL); return TCL_ERROR; } if (dcc[idx].type->flags & DCT_CHAT) { if (dcc[idx].u.chat->channel >= 0) { chanout_but(idx, dcc[idx].u.chat->channel, "*** %s has gone.\n", dcc[idx].nick); check_tcl_chpt(botnetnick, dcc[idx].nick, dcc[idx].sock, dcc[idx].u.chat->channel); botnet_send_part_idx(idx, "gone"); } check_tcl_chof(dcc[idx].nick, dcc[idx].sock); } hold = dcc[idx].u.other; dcc[idx].u.script = get_data_ptr(sizeof(struct script_info)); dcc[idx].u.script->u.other = hold; dcc[idx].u.script->type = dcc[idx].type; dcc[idx].type = &DCC_SCRIPT; /* Do not buffer data anymore. All received and stored data is passed * over to the dcc functions from now on. */ sockoptions(dcc[idx].sock, EGG_OPTION_UNSET, SOCK_BUFFER); strncpyz(dcc[idx].u.script->command, argv[2], 120); return TCL_OK; }
int rtRegisterScope(const char *name, int n, int ID ) { int i; int nscope; rt_sched_lock(); nscope = NSCOPE++; rt_sched_unlock(); if( nscope>= MAX_SCOPES ){ fprintf(stderr,"Error: Scopes exceed %d \n",MAX_SCOPES); return -1; } if ( ID <= 0 ) fprintf(stderr,"Warning: scopes ID must be positive\n"); for (i = 0; i < MAX_SCOPES; i++) { if (rtaiScope[i].ID == ID) fprintf(stderr,"Warning: two or more scopes have the same ID(%d)\n",ID); } sprintf(rtaiScope[nscope].MBXname, "%s%d", TargetMbxID, nscope); rtaiScope[nscope].ntraces = n; rtaiScope[nscope].ID = ID; rtaiScope[nscope].mbx= (MBX *) RT_typed_named_mbx_init(0,0,rtaiScope[nscope].MBXname,(MBX_RTAI_SCOPE_SIZE/((n+1)*sizeof(float)))*((n+1)*sizeof(float)),FIFO_Q); if(rtaiScope[nscope].mbx == NULL) { fprintf(stderr, "Cannot init mailbox\n"); exit_on_error(); } strncpyz(rtaiScope[nscope].name, name, MAX_NAME_SIZE); return 0; }
static RRDDIM *rrddim_index_find(RRDSET *st, const char *id, uint32_t hash) { RRDDIM tmp; strncpyz(tmp.id, id, RRD_ID_LENGTH_MAX); tmp.hash = (hash)?hash:simple_hash(tmp.id); return (RRDDIM *)avl_search_lock(&(st->dimensions_index), (avl *) &tmp); }
static RRDSET *rrdset_index_find(const char *id, uint32_t hash) { RRDSET tmp; strncpyz(tmp.id, id, RRD_ID_LENGTH_MAX); tmp.hash = (hash)?hash:simple_hash(tmp.id); return (RRDSET *)avl_search_lock(&(rrdset_root_index), (avl *) &tmp); }
int rtRegisterLed(const char *name, int n, int ID ) { int i; int nled; rt_sched_lock(); nled = NLEDS++; rt_sched_unlock(); if( nled >= MAX_LEDS ){ fprintf(stderr,"Error: Leds exceed %d \n",MAX_LEDS); return -1; } if ( ID <= 0 ) fprintf(stderr,"Warning: leds ID must be positive\n"); for (i = 0; i < MAX_LEDS; i++) { if (rtaiLed[i].ID == ID) fprintf(stderr,"Warning: two or more leds have the same ID(%d)\n",ID); } sprintf(rtaiLed[nled].MBXname, "%s%d", TargetLedMbxID, nled); rtaiLed[nled].nleds= n; rtaiLed[nled].ID = ID; rtaiLed[nled].mbx= (MBX *) RT_typed_named_mbx_init(0,0,rtaiLed[nled].MBXname,(MBX_RTAI_LED_SIZE/((n+1)*sizeof(float)))*((n+1)*sizeof(float)),FIFO_Q); if(rtaiLed[nled].mbx == NULL) { fprintf(stderr, "Cannot init mailbox\n"); exit_on_error(); } strncpyz(rtaiLed[nled].name, name, MAX_NAME_SIZE); return 0; }
int rtRegisterMeter(const char *name, int n, int ID ) { int i; int nmeter; rt_sched_lock(); nmeter = NMETERS++; rt_sched_unlock(); if( nmeter >= MAX_METERS ){ fprintf(stderr,"Error: Meters exceed %d \n",MAX_METERS); return -1; } if ( ID <= 0 ) fprintf(stderr,"Warning: meters ID must be positive\n"); for (i = 0; i < MAX_METERS; i++) { if (rtaiMeter[i].ID == ID) fprintf(stderr,"Warning: two or more meters have the same ID(%d)\n",ID); } sprintf(rtaiMeter[nmeter].MBXname, "%s%d", TargetMeterMbxID, nmeter); rtaiMeter[nmeter].ntraces = n; rtaiMeter[nmeter].ID = ID; rtaiMeter[nmeter].mbx= (MBX *) RT_typed_named_mbx_init(0,0,rtaiMeter[nmeter].MBXname,(MBX_RTAI_METER_SIZE/((n+1)*sizeof(float)))*((n+1)*sizeof(float)),FIFO_Q); if(rtaiMeter[nmeter].mbx == NULL) { fprintf(stderr, "Cannot init mailbox\n"); exit_on_error(); } strncpyz(rtaiMeter[nmeter].name, name, MAX_NAME_SIZE); return 0; }
FileInfo *ShareMng::SetFileInfo(char *fname) { WIN32_FIND_DATA_U8 fdat; if (!GetFileInfomationU8(fname, &fdat)) return FALSE; FileInfo *info = new FileInfo; UINT attr = (fdat.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? IPMSG_FILE_DIR : IPMSG_FILE_REGULAR; attr |= (fdat.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? IPMSG_FILE_RONLYOPT : 0; attr |= (fdat.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) ? IPMSG_FILE_SYSTEMOPT : 0; info->SetAttr(attr); info->SetFname(fname); if (GET_MODE(info->Attr()) == IPMSG_FILE_DIR) { info->SetSize(0); strncpyz(cfg->lastOpenDir, fname, MAX_PATH_U8); } else { info->SetSize((_int64)fdat.nFileSizeHigh << 32 | fdat.nFileSizeLow); PathToDir(fname, cfg->lastOpenDir); } info->SetMtime(FileTime2UnixTime(&fdat.ftLastWriteTime)); info->SetCrtime(FileTime2UnixTime(&fdat.ftCreationTime)); info->SetAtime(FileTime2UnixTime(&fdat.ftLastAccessTime)); return info; }
BOOL ShareMng::AddHostShare(ShareInfo *info, SendEntry *entry, int entryNum) { info->host = new Host *[info->hostCnt = entryNum]; info->transStat = new char [info->hostCnt * info->fileCnt]; memset(info->transStat, TRANS_INIT, info->hostCnt * info->fileCnt); for (int i=0; i < entryNum; i++) { info->host[i] = (Host *)cfg->fileHosts.GetHostByNameAddr(&entry[i].Host()->hostSub); if (info->host[i] == NULL) { info->host[i] = new Host; info->host[i]->hostSub = entry[i].Host()->hostSub; info->host[i]->hostStatus = entry[i].Host()->hostStatus; info->host[i]->updateTime = entry[i].Host()->updateTime; info->host[i]->priority = entry[i].Host()->priority; strncpyz(info->host[i]->nickName, entry[i].Host()->nickName, MAX_NAMEBUF); cfg->fileHosts.AddHost(info->host[i]); } else info->host[i]->RefCnt(1); } SYSTEMTIME st; ::GetSystemTime(&st); ::SystemTimeToFileTime(&st, &info->attachTime); statDlg->Refresh(); return TRUE; }
/*========================================================================= パス合成(ANSI 版) =========================================================================*/ int MakePath(char *dest, const char *dir, const char *file, int max_len) { if (!dir) { dir = dest; } int len; if (dest == dir) { len = (int)strlen(dir); } else { len = strcpyz(dest, dir); } if (len > 0) { bool need_sep = (dest[len -1] != '\\'); if (len >= 2 && !need_sep) { // 表などで終端の場合は sep必要 BYTE *p = (BYTE *)dest; while (*p) { if (IsDBCSLeadByte(*p) && *(p+1)) { p += 2; if (!*p) { need_sep = true; } } else { p++; } } } if (need_sep) { dest[len++] = '\\'; } } return len + strncpyz(dest + len, file, max_len - len); }