/* * The following is a macro-like function that uses kitten instead of directly doing printf */ void kitten_printf(short x, short y, char *fmt, ...) { va_list args; va_start(args, fmt); #ifndef NO_KITTEN vprintf(kittengets(x,y,fmt), args); #else #ifdef __TURBOC__ if(x||y); #endif vprintf(fmt, args); #endif }
int main(int argc, char *argv[]) { char *s; printf("kitten test with dev86/bcc\r\n\r\n"); kittenopen("KIT_TEST.DE"); s = kittengets(1, 1, "Hello World!"); printf("opening KIT_TEST.DE, message 1.1: '%s'\r\n", s); kittenclose(); return 0; }
static void prepare_move(char *src_filename, char *dest_filename) { struct stat src_statbuf; struct dfree disktable; unsigned long free_diskspace; char input[5]; #ifndef USE_KITTEN char ch; #endif if (src_filename[strlen(src_filename)-1] == '.') src_filename[strlen(src_filename)-1] = 0; if (dest_filename[strlen(dest_filename)-1] == '.') dest_filename[strlen(dest_filename)-1] = 0; if (strcmpi(src_filename, dest_filename) == 0) { #ifdef USE_KITTEN error(1,11,"File cannot be copied onto itself"); #else error("File cannot be copied onto itself"); #endif return; } if (access(dest_filename, 0) == 0) { if (!dir_exists(src_filename) && (dir_exists(dest_filename))) { #ifdef USE_KITTEN error(1,12,"Cannot move a file to a directory"); #else error("Cannot move a file to a directory"); #endif return; } if (opt_prompt == ASK) { do { /* Ask for confirmation to create file. */ #ifdef USE_KITTEN printf("%s %s", dest_filename, kittengets(1,1,"already exists!")); printf(" %s [%s/%s/%s/%s]? ", kittengets(1,2,"Overwrite file"), kittengets(2,0,"Y"), kittengets(2,1,"N"), kittengets(2,2,"All"), kittengets(2,3,"None")); #else printf("%s already exists!", dest_filename); printf(" Overwrite file [Y/N/All/None]? "); #endif scanf("%4s", &input); puts(""); fflush(stdin); if (strlen(input) == 1) { #ifdef USE_KITTEN if (stricmp(input, kittengets(2,1,"N")) == 0) #else ch=toupper(input[0]); if (ch == 'N') /* No-skip file. */ #endif { return; } /* end if. */ } else { #ifdef USE_KITTEN if (stricmp(input, kittengets(2,2,"All")) == 0) #else ch = 0; if (stricmp(input, "ALL") == 0) #endif { opt_prompt = OVERWRITE; } #ifdef USE_KITTEN if (stricmp(input, kittengets(2,3,"None")) == 0) #else if (stricmp(input, "NONE") == 0) #endif { opt_prompt = SKIP; return; } } #ifdef USE_KITTEN } while ((stricmp(input, kittengets(2,0,"Y")) != 0) && (stricmp(input, kittengets(2,2,"All")) != 0)); #else } while ((ch != 'Y') && (stricmp(input, "ALL") != 0)); #endif } else if (opt_prompt == SKIP) { #ifdef USE_KITTEN error(1,13,"File already exists"); #else error("File already exists"); #endif return; } }
static void move_files(const char *src_pathname, const char *src_filename, const char *dest_pathname, const char *dest_filename, int movedirs) { char filepattern[MAXPATH],src_path_filename[MAXPATH],dest_path_filename[MAXPATH]; char tmp_filename[MAXFILE+MAXEXT],tmp_pathname[MAXPATH]; struct ffblk fileblock; int fileattrib, done; fileattrib=FA_RDONLY+FA_ARCH+FA_SYSTEM; if (movedirs || !ContainsWildCards(src_filename)) fileattrib +=FA_DIREC; /* Find first source file. */ strmcpy(filepattern, src_pathname, sizeof(filepattern)); strmcat(filepattern, src_filename, sizeof(filepattern)); done=findfirst(filepattern, &fileblock, fileattrib); while ((!done) && (fileblock.ff_name[0] == '.')) done = findnext(&fileblock); if (done) { char buffer[80]; #ifdef USE_KITTEN sprintf(buffer, "%s%s %s", src_pathname, src_filename, kittengets(1,0,"does not exist!")); #else sprintf(buffer, "%s%s does not exist!", src_pathname, src_filename); #endif /* error */ fprintf(stderr, " [%s]\n", buffer); } /* Check if destination directory has to be created. */ if ((!done) && !dir_exists(dest_pathname)) { strmcpy(tmp_pathname, dest_pathname, sizeof(tmp_pathname)); if (makedir(tmp_pathname) != 0) { #ifdef USE_KITTEN error(1,10,"Unable to create directory"); kittenclose(); #else error("Unable to create directory"); #endif exit(4); } /* end if. */ } /* end if. */ /* Copy files. */ while (!done) { /* Build source filename including path. */ strmcpy(src_path_filename, src_pathname, sizeof(src_path_filename)); strmcat(src_path_filename, fileblock.ff_name, sizeof(src_path_filename)); /* Build destination filename including path. */ strmcpy(dest_path_filename, dest_pathname, sizeof(dest_path_filename)); build_filename(tmp_filename, fileblock.ff_name, dest_filename); strmcat(dest_path_filename, tmp_filename, sizeof(dest_path_filename)); prepare_move(src_path_filename, dest_path_filename); do { done = findnext(&fileblock); } while ((!done) && (fileblock.ff_name[0] == '.')); } /* end while. */ } /* end move_files. */