home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define LINESIZE 255
- #define TRUE 1
- #define FALSE 0
-
- char file_name[LINESIZE];
- char short_file_name[62];
- int filelength = 0;
- int file_attrib = 0;
- char current[] = "<backup$dir>.next";
- char file_path[] = "<backup$dir>.filepath";
- char *itoa(int n);
- void reverse(char *s);
- void backup(void);
- void changepath(void);
- int filename_len(char *file);
-
- /***
- itoa: convert int 'n' char returning this char pointer. .
- ***/
-
- char *itoa(int n)
- {
- int sign,i,max = FALSE;
- char temp[20];
- char *s = temp;
-
- for(i=0;i<20;i++)
- temp[i] = '\0';
-
- if ((sign = n) < 0){ /*** record sign ***/
- if((n -1) > 0){ /*** if max negative integer ***/
- ++n;
- max = TRUE;
- }
- n = -n;
- }
- do{ /*** generate digits in reverse order ***/
- if(max == TRUE){
- *s++ = n % 10 + '1';
- max = FALSE;
- }
- else
- *s++ = n % 10 + '0';
- } while(( n /= 10) > 0);
- if( sign < 0)
- *s++ = '-';
- reverse(temp);
- return temp;
- }
-
- /***
- reverse: reverses the character string *s, (must be null terminated)
- ***/
- void reverse( char *s)
- {
- int i, mid;
- char *p, *t;
- p = t = s;
- while( *p != '\0')
- p++;
- p--;
- mid = ( (p - t) / 2 ) + 1;
- while( ( (t - s) + 1 ) <= mid ){
- i = *t;
- *t = *p;
- *p = i;
- p--,t++;
- }
- }
-
-