int parse_redirects(char* cmd, int* pos, char* arg, char* in, char* out, char* err, int* app) { int ret; if (strcmp(arg, STR_REDIRECT_IN) == 0) { ret = fill_string(cmd, pos, arg); if (ret != 0) return 1; strcpy_s(in, MAX_PATH_LEN, arg); return 0; } else if (strcmp(arg, STR_REDIRECT_OUT) == 0) { ret = fill_string(cmd, pos, arg); if (ret != 0) return 1; (*app) = 0; strcpy_s(out, MAX_PATH_LEN, arg); return 0; } else if (strcmp(arg, STR_REDIRECT_OUT_APP) == 0) { ret = fill_string(cmd, pos, arg); if (ret != 0) return 1; (*app) = 1; strcpy_s(out, MAX_PATH_LEN, arg); return 0; } else if (strcmp(arg, STR_REDIRECT_ERR) == 0) { ret = fill_string(cmd, pos, arg); if (ret != 0) return 1; strcpy_s(err, MAX_PATH_LEN, arg); return 0; } return 2; }
/*********************************************************************** * * Name : process_jnl_field_trim() * * Description: Processes the JNL_FEED_LAYOUT.jnl_field_trim values. * It calls the trim library function in jnl_aux.c * Inputs : None * Outputs : None * Returns : None * **********************************************************************/ int process_jnl_field_trim(tiny command, char *string, tiny size) { switch(command) { case FIELD_TRIM_TRIM_RIGHT: return(trim_string(TRIM_RIGHT, string, size)); case FIELD_TRIM_TRIM_LEFT: return(trim_string(TRIM_LEFT, string, size)); case FIELD_TRIM_FILL_RIGHT: return(fill_string(FILL_RIGHT, string, size, ' ')); case FIELD_TRIM_FILL_LEFT: return(fill_string(FILL_LEFT, string, size, ' ')); case FIELD_TRIM_FILL_ZERO_RIGHT: return(fill_string(FILL_RIGHT, string, size, '0')); case FIELD_TRIM_FILL_ZERO_LEFT: return(fill_string(FILL_LEFT, string, size, '0')); case FIELD_TRIM_CENTER: return(center_string(string, size)); case FIELD_TRIM_NO_TRIM: break; default: break; } return(FAILURE); }
WORD deleted( VOID ) { int ret; char buffer[14]; rmstarb( fixsrc ); /* remove back slash */ if ( !fixsrc[2] ) /* at the root ? */ return( TRUE ); getlastpath( buffer, fixsrc ); updatbox( buffer ); domore: if ( Ddelete(fixsrc) ) { /* retry */ if ( ( ret = fill_string( fixsrc, CNTDELD ) ) == 2 ) goto domore; else if ( ret == 3 ) /* abort */ { f_abort = 1; return(FALSE); } } else upfdesk( fixsrc, (BYTE*)0 ); if ( opcode == OP_DELETE ) updatnum(NUMDIR, --numdirs); return(TRUE); }
void test_WriteAscii() { HandleScope handle_scope; Persistent<Context> context = Context::New(); Context::Scope context_scope(context); char TEST_STRING[] = "this is a UTF-8 test! This is pi: π"; int TEST_LENGTH = strlen(TEST_STRING); Handle<String> str = String::New(TEST_STRING); char* buf = new char[TEST_LENGTH * 2]; // Iterate over the entire string and use it as the start. int EXPECTED_LENGTH = TEST_LENGTH - 1; // We should drop the UTF-8 char. for (int start = 0; start < TEST_LENGTH; start++) { // Fill the buffer with 'a' to ensure there are no NULLs to start with. fill_string(buf, 'a', TEST_LENGTH * 2); int copied = str->WriteAscii(buf, start, TEST_LENGTH * 2); do_check_eq(copied, EXPECTED_LENGTH - start); do_check_eq(strlen(buf), EXPECTED_LENGTH - start); } delete[] buf; context.Dispose(); }
/* Allocates memory */ string* factor_vm::reallot_string(string* str_, cell capacity) { data_root<string> str(str_, this); if (reallot_string_in_place_p(str.untagged(), capacity)) { str->length = tag_fixnum(capacity); if (to_boolean(str->aux)) { byte_array* aux = untag<byte_array>(str->aux); aux->capacity = tag_fixnum(capacity * 2); } return str.untagged(); } else { cell to_copy = string_capacity(str.untagged()); if (capacity < to_copy) to_copy = capacity; data_root<string> new_str(allot_string_internal(capacity), this); memcpy(new_str->data(), str->data(), to_copy); if (to_boolean(str->aux)) { byte_array* new_aux = allot_uninitialized_array<byte_array>(capacity * 2); new_str->aux = tag<byte_array>(new_aux); write_barrier(&new_str->aux); byte_array* aux = untag<byte_array>(str->aux); memcpy(new_aux->data<uint16_t>(), aux->data<uint16_t>(), to_copy * sizeof(uint16_t)); } fill_string(new_str.untagged(), to_copy, capacity, '\0'); return new_str.untagged(); } }
void test_strdup(char *name, int len) { char *s; s = NULL; s = fill_string(s, len); printf("\n\033[36mTest: [ft_%s] : [%s]\033[00m\n", name, s); printf("\033[36mft_%s return : %s\n\033[00m",name, ft_strdup(s)); printf("\033[36m[ft_%s] -> \033[32m[OK]\033[00m\n", name); }
void test_memset(void*(*mem)(void*, int, size_t), char *name, int len) { char *s; s = NULL; s = fill_string(s, len); printf("\n\033[36mTest: [ft_%s] : [%s]\033[00m\n", name, s); printf("\033[36mft_%s with '1' return : %s\n\033[00m",name, (char*)(*mem)(s, (int)'1', len)); printf("\033[36m[ft_%s] -> \033[32m[OK]\033[00m\n", name); }
void test_strlen(int(*slen)(char*), char *name, int l) { char *s; s = NULL; s = fill_string(s, l); printf("\n\033[36mTest: [ft_%s] : [%s]\033[00m\n", name, s); printf("\033[36mft_%s return : %d\n%s return : %lu\n\033[00m",name, (*slen)(s), name, strlen(s)); printf("\033[36m[%s] -> \033[32m[OK]\033[00m\n", name); }
void nvpair_print_table_header(FILE * s, struct nvpair_header *h) { while(h->name) { char *n = xxmalloc(h->width + 1); fill_string(h->title, n, h->width, h->align); string_toupper(n); printf("%s ", n); free(n); h++; } printf("\n"); }
void test_memcpy(char *name, int l) { char *s; char *s2; s2 = NULL; s2 = fill_string(s2, l); s = NULL; s = (char*)malloc(l + 1); printf("\n\033[36mTest: [ft_%s] : [%s]\033[00m\n", name, s2); printf("\033[36mft_%s return : %s\n\033[00m",name, (char *)ft_memcpy((void *)s, (void *)s2, l + 1)); printf("\033[36m[%s] -> \033[32m[OK]\033[00m\n", name); }
WORD created( char *dir ) { int ret; char *ptr; updatbox(dir); rechkd2: /* update check the dir existing or not */ switch( chkdf( dir, CPDIR ) ) { case QUIT: f_abort = 1; return(FALSE); case SKIP: return(SKIP); case FALSE: return(FALSE); case CHECK: goto rechkd2; case OK: repeat: if (Dcreate(fixdst)) { if ( write_save ) goto ll_1; /* retry */ if ( ( ret = fill_string( fixdst, CNTCRTDR ) ) == 2 ) goto repeat; else if (ret == 3) /* abort */ { f_abort = 1; return(FALSE); } } if ( opcode == OP_MOVE ) { /* fixsrc -> C:\XXX\ */ ptr = r_slash( fixsrc ); *ptr = 0; upfdesk( fixsrc, fixdst ); *ptr = '\\'; } break; /* default */ } ll_1: /* update the number of dir */ updatnum(NUMDIR, --numdirs); return(TRUE); }
static inline int qpnp_vreg_read(struct qpnp_regulator *vreg, u16 addr, u8 *buf, int len) { char str[DEBUG_PRINT_BUFFER_SIZE]; int rc = 0; rc = spmi_ext_register_readl(vreg->spmi_dev->ctrl, vreg->spmi_dev->sid, vreg->base_addr + addr, buf, len); if (!rc && (qpnp_vreg_debug_mask & QPNP_VREG_DEBUG_READS)) { str[0] = '\0'; fill_string(str, DEBUG_PRINT_BUFFER_SIZE, buf, len); pr_info(" %-11s: read(0x%04X), sid=%d, len=%d; %s\n", vreg->rdesc.name, vreg->base_addr + addr, vreg->spmi_dev->sid, len, str); } return rc; }
void test_bzero(void (*bz)(void*, size_t), char *name, int l) { char *s; int i; s = NULL; i = 0; s = fill_string(s, l); printf("\n\033[36mTest: [ft_%s] : [%s]\033[00m\n", name, s); (*bz)((void *)s, (size_t)l); while (i < l) { if (s[i] != '\0') { printf("\033[31mError: ft_%s of s[%d] = %d instead of 0\033[00m\n", name, i, s[i]); free (s); return ; } i++; } printf("\033[36m[%s] -> \033[32m[OK]\033[00m\n", name); free (s); }
void test_WriteUtf8() { HandleScope handle_scope; Persistent<Context> context = Context::New(); Context::Scope context_scope(context); char TEST_STRING[] = "this is a UTF-8 test! This is pi: π"; int TEST_LENGTH = strlen(TEST_STRING); Handle<String> str = String::New(TEST_STRING); char* buf = new char[TEST_LENGTH * 2]; // Fill the buffer with 'a' to ensure there are no NULLs to start with. fill_string(buf, 'a', TEST_LENGTH * 2); int charsWritten; int copied = str->WriteUtf8(buf, TEST_LENGTH * 2, &charsWritten); do_check_eq(copied, TEST_LENGTH + 1); // π is 2 bytes, so strlen (TEST_LENGTH) returns 1 larger than charsWritten do_check_eq(charsWritten, TEST_LENGTH - 1); do_check_eq(strlen(buf), TEST_LENGTH); delete[] buf; context.Dispose(); }
void nvpair_print_table(struct nvpair *n, FILE * s, struct nvpair_header *h) { while(h->name) { const char *text = nvpair_lookup_string(n, h->name); char *aligned = xxmalloc(h->width + 1); char *line; if(!text) { line = xxstrdup("???"); } else if(h->mode == NVPAIR_MODE_METRIC) { line = xxmalloc(10); string_metric(atof(text), -1, line); strcat(line, "B"); } else if(h->mode == NVPAIR_MODE_TIMESTAMP || h->mode == NVPAIR_MODE_TIME) { line = xxmalloc(h->width); timestamp_t ts; int ret = 0; if(sscanf(text, "%" SCNu64, &ts) == 1) { if(h->mode == NVPAIR_MODE_TIME) { ts *= 1000000; } ret = timestamp_fmt(line, h->width, "%R %b %d, %Y", ts); } if(ret == 0) { strcpy(line, "???"); } } else { line = xxmalloc(strlen(text) + 1); strcpy(line, text); } fill_string(line, aligned, h->width, h->align); printf("%s ", aligned); free(line); free(aligned); h++; } printf("\n"); }
/* Allocates memory */ string *factor_vm::allot_string(cell capacity, cell fill) { data_root<string> str(allot_string_internal(capacity),this); fill_string(str.untagged(),0,capacity,fill); return str.untagged(); }
int parse_cmd(char* cmd, run_params* par, run_params* parent_par, int wait) { //printf("*** %s ***\n", cmd); int pos, i; int return_val = 0; char* cmd_itself = (char*)malloc(sizeof(char) * MAX_CMD_LEN); char* input = (char*)malloc(sizeof(char) * MAX_PATH_LEN); char* output = (char*)malloc(sizeof(char) * MAX_PATH_LEN); char* err_output = (char*)malloc(sizeof(char) * MAX_PATH_LEN); int out_append = 0; for (i = 0; i < MAX_PATH_LEN; i++) { input[i] = '\0'; output[i] = '\0'; err_output[i] = '\0'; } char** args = (char**)malloc(sizeof(char*) * MAX_ARGC); char* arg = (char*)malloc(sizeof(char) * MAX_PARAM_LEN); int argc = 0; pos = 0; int ret; ret = fill_string(cmd, &pos, cmd_itself); if (ret != 0) { return_val = 0; // empty command goto end; } while (1) { ret = fill_string(cmd, &pos, arg); if (ret != 0) break; ret = parse_redirects(cmd, &pos, arg, input, output, err_output, &out_append); if (ret == 0) { continue; } else if (ret == 1) { break; } else { if (argc >= MAX_ARGC) { return_val = 2; goto end; } args[argc] = arg; argc++; arg = (char*)malloc(sizeof(char) * MAX_PARAM_LEN); } } run_params* nParams = make_params(par, input, output, err_output, out_append, args, argc, cmd_itself); if (nParams == NULL) return 3; if (strcmp(cmd_itself, "exit") == 0) { if (par->secret_params == 2) { return 1; } if (par->secret_params == 1) { par->in->autoclose = 1; par->err->autoclose = 1; par->out->autoclose = 1; c_run((LPTHREAD_START_ROUTINE)(c_exit), nParams, wait); } } else if (strcmp(cmd_itself, "dir") == 0) { c_run((LPTHREAD_START_ROUTINE)(dir), nParams, wait); } else if (strcmp(cmd_itself, "echo") == 0) { c_run((LPTHREAD_START_ROUTINE)(echo), nParams, wait); } else if (strcmp(cmd_itself, "scan") == 0) { c_run((LPTHREAD_START_ROUTINE)(scan), nParams, wait); } else if (strcmp(cmd_itself, "rand") == 0) { c_run((LPTHREAD_START_ROUTINE)(random), nParams, wait); } else if (strcmp(cmd_itself, "cd") == 0) { cd(nParams, parent_par); } else if (strcmp(cmd_itself, "tree") == 0) { c_run((LPTHREAD_START_ROUTINE)(tree), nParams, wait); } else if (strcmp(cmd_itself, "pipe") == 0) { c_run((LPTHREAD_START_ROUTINE)(c_pipe), nParams, wait); } else if (strcmp(cmd_itself, "type") == 0) { c_run((LPTHREAD_START_ROUTINE)(type), nParams, wait); } else if (strcmp(cmd_itself, "info") == 0) { c_run((LPTHREAD_START_ROUTINE)(info), nParams, wait); } else if (strcmp(cmd_itself, "rm") == 0 || strcmp(cmd_itself, "rd") == 0) { c_run((LPTHREAD_START_ROUTINE)(rm), nParams, wait); } else if (strcmp(cmd_itself, "sort") == 0) { c_run((LPTHREAD_START_ROUTINE)(sort), nParams, wait); } else if (strcmp(cmd_itself, "mkdir") == 0 || strcmp(cmd_itself, "md") == 0) { c_run((LPTHREAD_START_ROUTINE)(mkdir), nParams, wait); } else if (strcmp(cmd_itself, "freq") == 0) { c_run((LPTHREAD_START_ROUTINE)(freq), nParams, wait); } else if (strcmp(cmd_itself, "wc") == 0) { c_run((LPTHREAD_START_ROUTINE)(wc), nParams, wait); } else if (strcmp(cmd_itself, "cmd") == 0) { nParams->secret_params = 2; c_run((LPTHREAD_START_ROUTINE)(c_cmd_run), nParams, wait); } else { c_run((LPTHREAD_START_ROUTINE)(c_non_existent), nParams, wait); } end: return return_val; }
WORD wrfile( char *fstr ) { REG int ret, retmsg; int inhand,outhand; int time[2]; DMABUFFER *mydta, *saved; char *buffer; long copysiz, bufsiz, wrsiz, tmpsiz; int crted,sttime; char buf[2]; crted = 0; sttime = 1; retmsg = TRUE; rename = 0; open: /* open the source file */ if ( ( inhand = (WORD)Fopen(fixsrc, 0) ) < 0 ) { /* seek error or drive not ready */ /* if ( (inhand == E_SEEK) || (inhand == EDRVNR) ) return( FALSE ); */ /* skip */ if ( ( ret = fill_string( fixsrc, CNTOPEN ) ) == 1 ) { updatnum(NUMFILE, --numfiles); return SKIP; } else if (ret == 2) /* retry */ goto open; else /* abort */ goto ww_3; } if ( !ch_undo() || f_cancel ) /* user want to stop */ { Fclose( inhand ); ww_3: f_abort = 1; return( FALSE ); } saved = (DMABUFFER *)Fgetdta(); Fsetdta(mydta=(DMABUFFER *)malloc( (long)sizeof(DMABUFFER))); if ( Fsfirst( fixsrc, 0x37 ) ) { retmsg = SKIP; if ( do1_alert( RDERROR ) == 2 ) /* abort */ { f_abort = 1; retmsg = FALSE; } goto y2; } copysiz = mydta->d_fsize; buffer = (char *)malloc( copysiz ); if ( buffer ) { bufsiz = copysiz; } else { for (bufsiz = 128*1024L; bufsiz >= 1024L; bufsiz /= 2) { if ((buffer = (char *)malloc( bufsiz )) != 0) break; } if (!buffer) goto y2; } Fdatime( &time, inhand, 0 ); /* read the time and date */ rechkd: switch(chkdf(fstr, CPFILE)) { case CHECK: goto rechkd; case SKIP: retmsg = SKIP; goto y1; case QUIT: f_abort = 1; retmsg = FALSE; goto y1; case FALSE: retmsg = FALSE; goto y1; } /* if it is move operation, then try rename first */ if ( opcode == OP_MOVE ) { /* if same name and path, don't do it */ if ( strcmp( fixsrc, fixdst ) ) goto y22; Fclose( inhand ); if ( Frename(0, fixsrc, fixdst) >= 0 ) { inhand = (WORD)Fopen( fixdst, 0 ); if ( !p_timedate ) /* get the new time and date */ { time[0] = Tgettime(); time[1] = Tgetdate(); Fdatime( &time, inhand, 1 ); } y22: rename = 1; goto y1; } else inhand = (WORD)Fopen( fixsrc, 0 ); } while ( copysiz >= 0 ) /* let it passes through for zero file */ { tmpsiz = (copysiz > bufsiz) ? bufsiz : copysiz; if (Fread(inhand, tmpsiz, buffer) < 0) { retmsg = SKIP; if ( crted ) Fdelete( fixdst ); if (do1_alert( RDERROR ) == 2) { /* abort */ f_abort = 1; retmsg = FALSE; } goto y1; /* skip */ } create: if ( sttime ) { sttime = 0; if ((outhand = (WORD)Fcreate(fixdst, mydta->d_fattr&7)) < 0) { if ( ( ret = fill_string( fixdst, CNTCRTFL ) ) == 2 ) goto create; else if (ret == 3) /* abort */ { f_abort = 1; retmsg = FALSE; } else retmsg = SKIP; goto y1; } crted = 1; } if ((wrsiz = Fwrite(outhand, tmpsiz, buffer)) < 0) { retmsg = SKIP; Fclose(outhand); Fdelete(fixdst); if (do1_alert( WRERROR ) == 2) { /* abort */ f_abort = 1; retmsg = FALSE; } goto y1; } /* check if there are sufficent memory */ if (wrsiz != tmpsiz) { /* not sufficent memory ??*/ f_abort = 1; retmsg = FALSE; Fclose(outhand); Fdelete(fixdst); buf[0] = *fixdst; buf[1] = 0; fill_string( buf, STDISKFU ); goto y1; } copysiz -= tmpsiz; if ( !copysiz ) break; } if ( p_timedate ) Fdatime( &time, outhand, 1 ); y0: Fclose(outhand); y1: free(buffer); y2: updatnum(NUMFILE, --numfiles); Fsetdta(saved); y3: Fclose(inhand); free(mydta); if ( ( opcode == OP_MOVE ) && ( retmsg == TRUE ) ) upfdesk( fixsrc, fixdst ); return(retmsg); }
int doact( VOID ) { /* char *saved; */ DMABUFFER *dumb, * saved; REG int ret, retmsg; int error; if ( f_level >= ( COPYMAXDEPTH + 1 ) ) { act_1: do1_alert( STFO8DEE ); return( FALSE ); } /* changed CHAR * to DMABUFFER * in expression below - JTT */ if ( !( dumb = (DMABUFFER *)malloc( (LONG)sizeof( DMABUFFER ) ) ) ) goto act_1; f_level++; retmsg = TRUE; saved = (DMABUFFER *)Fgetdta(); Fsetdta( dumb ); strcat(getall, fixsrc); if ( !( error = Fsfirst(fixsrc, 0x37) ) ) { do { if ( !ch_undo( ) || f_cancel ) /* user want to abort */ { f_abort = 1; retmsg = FALSE; goto mvend; } if (dumb->d_fname[0] != HOME) { if (SUBDIR & dumb->d_fattr) { chkbuf(srclen, srcbuf, &fixsrc); /* check buf size */ addfile(fixsrc, dumb->d_fname); /* add a dir into the path */ strcat(bckslsh, fixsrc); if (opcode != OP_DELETE) { chkbuf(dstlen, dstbuf, &fixdst); /* check buf size */ strcat(dumb->d_fname, fixdst); } else goto dorec; updatbox(dumb->d_fname); rechkd1: /* update check the dir existing or not */ switch( chkdf( dumb->d_fname, CPDIR ) ) { case QUIT: f_abort = 1; retmsg = FALSE; goto mvend; case SKIP: backdir(fixsrc); backdir(fixdst); updatnum(NUMDIR, --numdirs); srclen -= FILE_LEN; /* subtract the add lenth */ dstlen -= FILE_LEN; /* subtract the add lenth */ retmsg = TRUE; continue; case FALSE: goto mvend; case CHECK: goto rechkd1; case OK: recrtd: if (Dcreate(fixdst)) { if ( write_save ) goto kk_1; switch( fill_string( fixdst, CNTCRTDR ) ) { case 1: /* skip */ backdir(fixsrc); backdir(fixdst); updatnum(NUMDIR, --numdirs); srclen -= FILE_LEN; /* subtract the add lenth */ dstlen -= FILE_LEN; /* subtract the add lenth */ continue; case 2: /* retry */ goto recrtd; default: /* quit */ f_abort = 1; retmsg = FALSE; goto mvend; }/* switch */ }/* if recrtd */ break; } kk_1: updatnum(NUMDIR, --numdirs); strcat(bckslsh, fixdst); dorec: if (!doact()) /* do the recursion */ { retmsg = FALSE; goto mvend; } if (opcode == OP_COPY) goto clndir; rmstarb(fixsrc); /* after call, -> c:\d1\ */ if (opcode == OP_DELETE) { getlastpath(filestr, fixsrc); updatbox(filestr); } remvd: if (Ddelete(fixsrc)) { /* delete a dir */ if ( ( ret = fill_string( fixsrc, CNTDELD ) ) == 2 ) goto remvd; /* retry */ else if (ret == 3) { /* abort */ f_abort = 1; retmsg = FALSE; goto mvend; } } else /* No error */ upfdesk( fixsrc, (BYTE*)0 ); clndir: backdir(fixsrc); /* back one dir */ srclen -= FILE_LEN; /* subtract the add lenth */ if (opcode == OP_DELETE) updatnum(NUMDIR, --numdirs); else { backdir(fixdst); /* back one dir */ dstlen -= FILE_LEN; /* subtract the add lenth */ } } else { getlastpath(filestr, fixdst); updatname(CPDIR, filestr); /* update the dir */ updatname( CPFILE, dumb->d_fname ); /* update the file */ chkbuf(srclen, srcbuf, &fixsrc); /* check buf size */ addfile(fixsrc, dumb->d_fname); if (opcode != OP_DELETE) { chkbuf(dstlen, dstbuf, &fixdst); /* check buf size */ addfile(fixdst, dumb->d_fname); rename = 0; if (!(retmsg = wrfile(dumb->d_fname))) goto mvend; if ((rename) || (retmsg == SKIP)) goto clnfile; } if (opcode == OP_COPY) goto clnfile; remvf: if (ret = (WORD)(Fdelete(fixsrc))) /* rm the file from source */ { /* seek error or drive not ready */ /* if ((ret == E_SEEK) || (ret == EDRVNR)) { retmsg = FALSE; goto mvend; } */ /* retry */ if ( ( ret = fill_string( fixsrc, CNTDELF ) ) == 2 ) goto remvf; else if ( ret == 3 ) { /* abort */ f_abort = 1; retmsg = FALSE; goto mvend; } } else upfdesk( fixsrc, (BYTE*)0 ); clnfile: backdir(fixsrc); /* back one dir */ srclen -= FILE_LEN; /* subtract the add lenth */ if (opcode == OP_DELETE) updatnum(NUMFILE, --numfiles); else { backdir(fixdst); /* back one dir */ dstlen -= FILE_LEN; /* subtract the add lenth */ } } } } while (!Fsnext()); } else { if ( error != EFILNF ) /* if not file not found */ retmsg = FALSE; /* then return error */ } mvend: Fsetdta( saved ); f_level--; free( dumb ); return( retmsg ); }
WORD doright( int flag ) { REG int ret,retmsg; char *temp, buf[14]; retmsg = TRUE; if (opcode == OP_DELETE) { temp = fixdst; fixdst = fixsrc; } if (flag == DTOD) { if (!(retmsg=doact())) goto endright; if (opcode != OP_COPY) retmsg = deleted(); /* rm the first folder */ } else /* file to file */ { getlastpath(filestr, fixdst); backdir(fixdst); getlastpath(buf, fixdst); strcat(filestr, fixdst); updatname(CPFILE, filestr); updatname(CPDIR, buf); if ( opcode != OP_DELETE ) if ((!(retmsg = wrfile(filestr)))||(rename)||(retmsg == SKIP)) goto endright; if (opcode != OP_COPY) { redel: if ( (ret = (WORD)Fdelete(fixsrc)) ) { /* seek error or drive not ready */ /* if ( (ret == E_SEEK) || (ret == EDRVNR) ) { retmsg = FALSE; goto endright; } */ if ( ( ret = fill_string( fixsrc, CNTDELF ) ) == 2 ) goto redel; if ( ret == 1 ) /* skip */ retmsg = SKIP; else { f_abort = 1; retmsg = FALSE; } goto endright; /* error */ } else { if (opcode == OP_DELETE) updatnum(NUMFILE, --numfiles); } } if ( retmsg == TRUE ) { /* if ( opcode == OP_MOVE ) upfdesk( fixsrc, fixdst ); */ if ( opcode == OP_DELETE ) upfdesk( fixsrc, (BYTE*)0 ); } } endright: free(fixsrc); if (opcode == OP_DELETE) free(temp); else free(fixdst); return(retmsg); }
WORD dofiles( BYTE *s, BYTE *d, WORD code, LONG *ndirs, LONG *nfiles, LONG *tsize, WORD type, WORD multiple, WORD handle) { WORD ret; /*trash; */ BYTE buffer[2]; if ( *d == 'c' ) return( FALSE ); /* desk_mice( HOURGLASS ); */ /* get the dialog box string */ whandle = handle; cpbox = get_tree( CPBOX ); f_cancel = 0; f_level = 0; /* the current depth of the directory path */ f_abort = 0; /* No abortion */ rename = 0; buffer[1] = 0; ret = FALSE; if ( (opcode = code) == OP_COUNT ) { numfiles = 0x0L; /* the number of files show in the dialog box */ numdirs = 0x0L; /* the number of directories */ tolsize = 0x0L; /* the total size of all files in the path */ } else { numdirs = *ndirs; numfiles = *nfiles; tolsize = *tsize; } do { if ( *s == 'c' ) /* skip cartridge */ goto cc_4; buffer[0] = *s; if ( ( d_display ) && ( code != OP_COUNT ) ) { inf_sset( (LONG)cpbox, CSDRIVE, buffer ); wind_update( 1 ); w_draw_fld( handle, cpbox, CSDRIVE ); wind_update( 0 ); } /* do the counting only */ if (code == OP_COUNT) { if ( !(ret = count( s ) ) ) goto clnup; /* error */ } else /* do the actual operation */ { if ( !ch_undo() || f_cancel ) /* check for undo key */ { f_abort = 1; goto clnup; } /* delete the whole disk */ if ( ( type == DISK ) && ( code == OP_DELETE ) ) { if ( fill_string( buffer, DELDISK ) != 1 ) goto cc_4; } if ( ( code == OP_COPY ) || ( code == OP_MOVE ) ) { if ( ( type == SUBDIR ) || ( type == XDIR ) || ( type == DISK ) ) { if ( !chk_par( s, d ) ) /* illegal */ { if ( do1_alert( NODIRCOP ) == 2 ) goto clnup; /* abort */ else { ret = TRUE; goto cc_3; /* go to next one */ } } } } if (!(ret = getinfo(s, d))) goto clnup; if ( ret == SKIP ) continue; if (!(ret = doright(ret))) goto clnup; if ( ret == SKIP ) continue; } cc_3: if ( code != OP_COUNT ) x_deselect(); /* deselect object */ if ( ( code == OP_DELETE ) || ( code == OP_MOVE ) ) dr[ *s - 'A' ] = 1; if ( ( code == OP_COPY ) || ( code == OP_MOVE ) ) dr[ *d - 'A' ] = 1; cc_4: if ( !multiple ) /* do only one device */ break; }while( x_next( &s, &type ) ); *ndirs = numdirs; *nfiles = numfiles; *tsize = tolsize; clnup: /* deselect object */ if ( ( code == OP_DELETE ) || ( code == OP_MOVE ) ) { if ( *s != 'c' ) dr[ *s - 'A' ] = 1; } if ( ( code == OP_COPY ) || ( code == OP_MOVE ) ) dr[ *d - 'A' ] = 1; /* desk_mice( ARROW ); */ if ( f_abort ) return( TRUE ); return( ret ); }