windows to unix


/***************************************************************************
 *                                                                         *
 *     File:           DOS to UNIX  TEXT  CONVERT                          *
 *     Function:  This program demostrating text convert managment         *
 *                                                                         *
 *     Author:               Long Yun Liang                                *
 *     Copyright (c) 12,26,1996       All rights reserved                  *
 *                                                                         *
 ***************************************************************************/

#include <stdio.h>
//#include <prototypes.h>

FILE * infile;
FILE * outfile;
char infilename  [128];
char outfilename [128];
int  mode = 1;

void filter ()
{
     int  ok = 1;
     int  ch;
     long fsize;

     do
    {
        ok = 1;
        printf ("\n\nSource text filename : ");
        if (mode) scanf ("%s",infilename); else printf ("%s\n",infilename);
        if ((infile = fopen (infilename,"rb")) == NULL)
       {
           printf ("Can't open %s\n",infilename);
           ok = 0;
           mode = 1;
       }
    }
     while (!ok) ;

     do
    {
        ok = 1;
        printf ("\nTarget text filename : ");
        if (mode) scanf ("%s",outfilename); else printf ("%s\n",outfilename);
        if ((outfile = fopen (outfilename,"rb+")) == NULL)
       {
           printf ("Can't open %s\n",outfilename);
           ok = 0;
           mode = 1;
       }
    }
     while (!ok) ;

     fsize=0;
     while ((ch=fgetc (infile))!= EOF)
         {
         if (ch=='\x0d')  continue;
         else fputc (ch,outfile);
         fsize++;
         }
     chsize (fileno(outfile),fsize);
     fclose (infile);
     fclose (outfile);
     printf ("\nFinished .\n\n");
}

void main (int argc,char *argv[])
{
     int choice;

     if (argc>3)  {
         printf ("Text Convert Utility  Version 1.20\n");
         printf ("Copyright (c) Software Engineering 1994-1996.  All rights reserved.\n\n");
         printf ("Usage:  CODE InputFile OutputFile\n");
         return ;
     }
     else if (argc==2)  {
         strcpy (infilename,argv[1]);
         strcpy (outfilename,argv[1]);
         mode = 0;
     }
     else if (argc==3)  {
         strcpy (infilename,argv[1]);
         strcpy (outfilename,argv[2]);
         mode = 0;
     }
     else mode = 1;
     printf ("DOS to UNIX Text Convert Utility  Version 1.20\n");
     printf ("Copyright (c) Software Engineering 1996.  All rights reserved.");
     filter ();
}

 

echo "DOS to UNIX Text Convert Utility  Version 1.20"
echo "Copyright (c) Software Engineering 1996 .\n"
if test $# -lt 1
then
    echo "Usage:   D2U FileName\n "
elif test -r $1
then
    dos2unix $1 temp$$
    mv temp$$ $1
    echo "Finished .\n"
else
    echo "File not found .\n"
fi

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值