home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************/
- /* */
- /* Demo of how to manipulate files from remote, and other */
- /* file access methods. */
- /* */
- /* Copyright 1995 deltaComm Development, Inc. */
- /* */
- /****************************************************************/
-
- main()
- {
-
- str ph_num[10] = "5551234";
- str st[20];
- int fil1, fil2;
- int result;
-
- _up_dir=_down_dir="C:\XILET";
-
- loadfon("telix.fbk");
- result=1;
-
- if (!dial(ph_num, 5, 0)) // Try to dial number
- {
- prints("No connection, trying some more.");
- result = redial(ph_num, 10, 0);
- }
-
- if (result) // Will be true if connected
- {
- waitfor("Name:", 180); // Wait for BBS to request name
- cputs("Ditto"); // Type the name of Jeff's Dog
- cputc("^m"); // and send a Carriage return
-
- waitfor("password:", 30);
- cputs_tr("ILUVTELIX^M"); // Password + CR
- prints();
-
- prints("Connecter to:"); // Display various
- printsc("Dialing Directory: "); // user and BBS
- prints(_entry_name); // information
- printsc("Entry number: "); // on the screen only.
- prints(_entry_enum);
- printsc("Number: ");
- prints(_entry_num);
- printsc("BBS Type: ");
- prints(_entry_bbstype);
- printsc("Logon Name: ");
- prints(_entry_logonname);
- printsc("Password: ");
- prints(_entry_pass);
- printsc("Comments: ");
- prints(_entry_comment);
-
- // Instruct user to go to the file area
- // and initiate download
-
- prints("Enter file area and download test.txt");
-
- waitfor("begin file transfer", 180);
- dos("MkDir c:\XILET", 0); // Execute DOS command to create the DIR
- receive('Z', "test.txt"); // Download a file
-
- fil1=fopen("c:\XILET\test.txt", "r"); // Open Fil1 for reading...
- fil2=fopen("c:\XILET\test2.txt", "w"); // Open Fil2 for writing...
-
- fseek(fil1, 0, 10); // locate ptr 10 bytes into file
- fgets(st, 5, fil1); // Read 5 characters from fil1
- setchr(st, 2, "X"); // Put an 'X' into the string
- setchrs(st, 6, "x", 5); // Add 'x's to the string
- fputs(st, fil2); // Write the string to fil2
- fread(st, 10, fil1); // Get 10 chars from fil1
- fwrite(st, 10, fil2); // Put them in fil2
-
- while (!feof(fil1)) // Loop testing for eof of fil1
- {
- if (ftell(fil2) and 255) // transfer characters from Fil1
- fputs("*|*", fil2); // into FIL2
- fputc(fgetc(fil1), fil2);
-
- }
-
- fflush(fil1); // Flush file I/O buffers
- fflush(fil2);
-
- fclose(fil1); // Close the files
- fclose(fil2);
-
- fdelete("c:\XILET\test.txt"); // Delete original file
-
- frename("c:\XILET\test2.txt", "c:\XILET\test.txt");
- // Rename new file to the old file's name
-
- prints("Now upload test.txt");
- waitfor("begin file transfer", 180);
- send('Z', "test.txt"); // Upload changed file back to BBS
-
- fdelete("c:\XILET\test.txt"); // Delete the new file
- dos("RemDir c:\XILET", 0); // Use DOS to kill work directory
-
- printsc("The operation took ");
- printn(getonlinetime());
- prints(" seconds.");
- }
- }
-