Fórum Converter arquivo no formato dos para unix #5428
07/05/2009
0
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version. // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Additional notes.
//
// The author of the original source code is unknown.
//
// Modified by Clem Dye (clem@bastet.com), December 1998, to compile cleanly
// under Microsoft Visual C/C++ v4.0 (or later) for use on Windows NT. Added
// exit(1) statements in main() to improve error reporting when the program is
// used in batch scripts.
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/utime.h> #ifndef TRUE
# define TRUE (1)
# define FALSE (0)
#endif #define R_CNTRL "rb"
#define W_CNTRL "wb" struct stat s_buf; int dos2u (path)
char *path;
{
FILE *in, *out;
int ch,
rval = FALSE;
char temppath [16];
struct _utimbuf ut_buf;
strcpy (temppath, "./clntmp");
strcat (temppath, "XXXXXX");
mktemp (temppath);
if ((in=fopen (path, R_CNTRL)) == (FILE *) 0)
return TRUE;
if ((out=fopen (temppath, W_CNTRL)) == (FILE *) 0)
{
fclose (in);
return TRUE;
}
while ((ch = getc (in)) != EOF)
if ((ch != '\015' && ch != '\032') &&
(putc (ch, out) == EOF))
{
rval = TRUE;
break;
}
if (fclose (in) == EOF)
{
rval = TRUE;
}
if (fclose (out) == EOF)
{
rval = TRUE;
}
ut_buf.actime = s_buf.st_atime;
ut_buf.modtime = s_buf.st_mtime;
if (_utime (temppath, &ut_buf) == -1)
rval = TRUE;
if (unlink (path) == -1)
rval = TRUE;
if (rval)
{
unlink (temppath);
return TRUE;
}
if (rename (temppath,path) == -1)
{
fprintf (stderr, "Dos2Unix: Problems renaming '%s' to '%s'.\n", temppath, path);
fprintf (stderr, " However, file '%s' remains.\n", temppath);
exit (1);
}
unlink (temppath);
return FALSE;
}
void main (argc, argv)
int argc;
char **argv;
{
char *path;
while (--argc>0)
{
if (stat (path=*++argv, &s_buf) != -1)
{
printf ("Dos2Unix: Processing file %s ...\n", path);
if (dos2u (path))
{
fprintf (stderr, "Dos2Unix: Problems processing file %s.\n", path);
exit (1);
}
}
else
{
fprintf (stderr, "Dos2Unix: Can't stat '%s'.\n", path);
exit (1);
}
}
}
Frigorifico Sa
Curtir tópico
+ 0Posts
07/05/2009
Wesley Yamazack
Bom pelo que estou analisando aqui a única coisa que este programa faz é substituir os caracteres de fim de linha no caso CR. Exemplo #13, #10, muito comuns em integração TXT do Windows. Se for isso mesmo o problema é tranquilo de se resolver, criamos um programa para dar um Replace nos caracter de fim de linha, e teria seu problema resolvido
Att,
Wesley Y
Gostei + 0
07/05/2009
Wesley Yamazack
Bom pelo que estou analisando aqui a única coisa que este programa faz é substituir os caracteres de fim de linha no caso CR. Exemplo #13, #10, muito comuns em integração TXT do Windows. Se for isso mesmo o problema é tranquilo de se resolver, criamos um programa para dar um Replace nos caracter de fim de linha, e teria seu problema resolvido
Att,
Wesley Y
Gostei + 0
10/05/2009
Wesley Yamazack
A duvida sobre o chamado foi esclarecida ? Aguardamos informações para concluirmos o chamado.
Att,
Wesley Y
Gostei + 0
11/05/2009
Frigorifico Sa
Gostei + 0
11/05/2009
Frigorifico Sa
Gostei + 0
11/05/2009
Wesley Yamazack
Segue um codigo abaixo em delphi, para descobrir o caracter ascii de uma tecla.
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
Label1.Caption := Format('O código da tecla pressionada é: %d', [Key]);
end;
Com relação ao 13 este é o enter, o 10 trabalha junto com o 13, quando esta separado, senão me engano seria como se fosse uma quebra de linha parecido com o enter.
Espero que ajude.
Att,
Wesley Y
Gostei + 0
12/05/2009
Frigorifico Sa
Não entendi a questão acima. Tem que substituir os dois CR? O meu arquivo não tinha CR de LF. Como posso resolver esta questão converter arquivos no formato Windows para unix?
Gostei + 0
12/05/2009
Wesley Yamazack
Seria possível enviar uma parte do arquivo para podermos analisar ?
Att,
Wesley Y
Gostei + 0
12/05/2009
Frigorifico Sa
Gostei + 0
13/05/2009
Wesley Yamazack
Me mande o arquivo completo para que eu possa analisar melhor, pois pelo que foi dito anteriormente seria substituir os caracteres de fim de linha e funcionaria, porém pelo visto voce nao achou nenhum caracter de final de linha. Nao conheco os arquivos Unix, tenho que analisar o mesmo e ver se seria somente a substituição para resolver este problema. Fico no aguardo
Att,
Wesley Y
Gostei + 0
14/05/2009
Frigorifico Sa
0 02 021001
0 02 021002
0 26 021003
0 02 021004
0 02 021005
0 02 021006
0 02 021007
0 02 021010
0 03 030800
0 03 033200
0 03 033600
0 03 034300
0 03 035400
0 04 041900
0 05 100400
0 10 100501
0 10 100502
0 10 101200
0 03 101300
0 03 101501
0 10 101600
0 10 101601
0 10 101602
0 03 102001
0 10 102200
0 10 102901
0 03 103201
0 10 103500
0 10 103501
0 10 103502
0 10 103900
0 10 103901
0 10 103902
0 10 103903
0 03 104001
0 03 104002
0 03 104401
0 10 105200
0 10 105300
0 11 110100
0 11 110500
0 11 110700
0 11 111400
0 11 111700
0 11 112100
0 11 112900
0 11 113900
0 11 113901
0 11 114100
0 11 118800
0 03 120400
0 12 120500
0 12 120501
0 12 120502
0 12 120503
0 12 120504
0 12 120505
0 12 120506
0 12 120700
0 12 120701
0 12 121100
0 03 121101
0 12 121200
0 12 121201
0 12 121400
0 12 121600
0 12 121601
0 12 121602
0 12 121603
0 12 121604
0 12 121605
0 12 121606
0 12 121607
0 12 121801
0 03 122001
0 03 122002
0 12 122003
0 12 122004
0 12 122200
0 12 122600
0 12 122900
0 12 122901
0 12 122902
0 12 123000
0 12 123001
0 03 123201
0 12 123500
0 12 123501
0 12 123502
0 12 123503
0 12 123504
0 12 123505
0 12 123506
0 12 123507
0 12 123508
0 03 123700
0 03 123701
0 03 123702
0 12 123800
0 12 123801
0 12 123802
0 12 123803
0 12 123900
0 12 123901
0 12 123902
0 12 123903
0 12 123904
0 12 123905
0 12 123906
0 12 123907
0 12 123908
0 12 123909
0 03 124001
0 03 124002
0 03 124401
0 12 124501
0 12 124502
0 12 124503
0 12 124504
0 03 124901
0 03 124902
0 12 125200
0 12 125201
0 12 125202
0 12 125203
0 12 125300
0 12 125301
0 12 125302
0 12 125600
0 03 125900
0 12 128400
0 03 128500
0 13 130100
0 13 130500
0 13 130700
0 13 131400
0 13 131700
0 13 131701
0 13 132100
0 13 132900
0 13 133900
0 13 133901
0 13 133902
0 13 134100
0 13 138800
0 14 140100
0 14 140500
0 14 140700
0 14 141600
0 14 141601
0 14 141602
0 14 141603
0 14 142200
0 14 142600
0 14 142900
0 14 142901
0 14 143900
0 14 143901
0 14 143902
0 14 143903
0 14 144100
0 14 144500
0 14 145200
0 14 145201
0 20 202801
0 20 202802
0 20 202803
0 20 202804
0 20 202805
0 20 202806
0 20 202807
0 20 202808
0 20 202809
0 20 202810
0 20 202811
0 20 202812
0 20 202813
0 20 202814
0 20 202815
0 20 202816
0 20 202817
0 20 202818
0 20 202819
0 20 202820
0 20 202821
0 20 202822
0 20 202823
0 20 202824
0 20 202825
0 21 210300
0 21 210301
0 21 210302
0 21 210303
0 21 210304
0 21 210305
0 21 210306
0 21 210307
0 21 211400
0 21 211600
0 21 211601
0 21 212200
0 21 212500
0 21 212900
0 21 213200
0 21 213201
0 21 213500
0 21 213900
0 21 213901
0 21 214000
0 21 214001
0 21 214100
0 21 214400
0 21 214401
0 22 220501
0 22 220801
0 22 221601
0 22 221602
0 22 221603
0 22 221801
0 22 222001
0 22 222301
0 22 222701
0 22 222901
0 22 223001
0 22 223200
0 22 223501
0 22 223901
0 22 224001
0 22 224401
0 22 224801
0 22 225201
0 22 225301
0 22 225500
0 22 225501
0 22 225502
0 22 225503
0 22 225504
0 22 225505
0 22 225506
0 22 225507
0 22 225508
0 22 225509
0 26 260400
0 26 260500
0 26 260501
0 26 260800
0 26 261200
0 26 261201
0 26 261600
0 12 261800
0 26 261801
0 26 262000
0 26 262200
0 26 262600
0 26 262700
0 26 262902
0 26 262903
0 26 263000
0 26 263001
0 26 263200
0 26 263500
0 26 263503
0 26 263700
0 26 263901
0 26 263902
0 26 263903
0 26 263904
0 26 264000
0 26 264001
0 26 264200
0 26 264400
0 26 264800
0 26 264900
0 26 265300
0 26 265301
0 26 265302
0 26 269204
0 27 270900
0 27 270901
0 27 270902
0 27 270903
0 27 270904
0 27 270905
0 27 270906
0 27 270907
0 27 270908
0 27 270909
0 27 270910
0 27 270911
0 27 270912
0 27 272600
0 27 272900
0 27 272901
0 27 273400
0 27 273401
0 28 280200
0 28 280201
0 28 285700
0 28 288600
0 28 288601
0 28 288602
0 28 288603
0 29 290600
0 29 290601
0 29 290602
0 29 290603
0 29 292400
0 29 292401
0 29 292402
0 29 292403
0 29 292404
0 29 292405
0 29 292406
0 29 292407
0 29 292408
0 29 298100
0 29 298101
0 29 298200
0 29 298201
0 30 308300
0 30 308301
0 30 308302
0 30 308303
0 30 308304
Windos 0 02 021000
0 02 021001
0 02 021002
0 26 021003
0 02 021004
0 02 021005
0 02 021006
0 02 021007
0 02 021010
0 03 030800
0 03 033200
0 03 033600
0 03 034300
0 03 035400
0 04 041900
0 05 100400
0 10 100501
0 10 100502
0 10 101200
0 03 101300
0 03 101501
0 10 101600
0 10 101601
0 10 101602
0 03 102001
0 10 102200
0 10 102901
0 03 103201
0 10 103500
0 10 103501
0 10 103502
0 10 103900
0 10 103901
0 10 103902
0 10 103903
0 03 104001
0 03 104002
0 03 104401
0 10 105200
0 10 105300
0 11 110100
0 11 110500
0 11 110700
0 11 111400
0 11 111700
0 11 112100
0 11 112900
0 11 113900
0 11 113901
0 11 114100
0 11 118800
0 03 120400
0 12 120500
0 12 120501
0 12 120502
0 12 120503
0 12 120504
0 12 120505
0 12 120506
0 12 120700
0 12 120701
0 12 121100
0 03 121101
0 12 121200
0 12 121201
0 12 121400
0 12 121600
0 12 121601
0 12 121602
0 12 121603
0 12 121604
0 12 121605
0 12 121606
0 12 121607
0 12 121801
0 03 122001
0 03 122002
0 12 122003
0 12 122004
0 12 122200
0 12 122600
0 12 122900
0 12 122901
0 12 122902
0 12 123000
0 12 123001
0 03 123201
0 12 123500
0 12 123501
0 12 123502
0 12 123503
0 12 123504
0 12 123505
0 12 123506
0 12 123507
0 12 123508
0 03 123700
0 03 123701
0 03 123702
0 12 123800
0 12 123801
0 12 123802
0 12 123803
0 12 123900
0 12 123901
0 12 123902
0 12 123903
0 12 123904
0 12 123905
0 12 123906
0 12 123907
0 12 123908
0 12 123909
0 03 124001
0 03 124002
0 03 124401
0 12 124501
0 12 124502
0 12 124503
0 12 124504
0 03 124901
0 03 124902
0 12 125200
0 12 125201
0 12 125202
0 12 125203
0 12 125300
0 12 125301
0 12 125302
0 12 125600
0 03 125900
0 12 128400
0 03 128500
0 13 130100
0 13 130500
0 13 130700
0 13 131400
0 13 131700
0 13 131701
0 13 132100
0 13 132900
0 13 133900
0 13 133901
0 13 133902
0 13 134100
0 13 138800
0 14 140100
0 14 140500
0 14 140700
0 14 141600
0 14 141601
0 14 141602
0 14 141603
0 14 142200
0 14 142600
0 14 142900
0 14 142901
0 14 143900
0 14 143901
0 14 143902
0 14 143903
0 14 144100
0 14 144500
0 14 145200
0 14 145201
0 20 202801
0 20 202802
0 20 202803
0 20 202804
0 20 202805
0 20 202806
0 20 202807
0 20 202808
0 20 202809
0 20 202810
0 20 202811
0 20 202812
0 20 202813
0 20 202814
0 20 202815
0 20 202816
0 20 202817
0 20 202818
0 20 202819
0 20 202820
0 20 202821
0 20 202822
0 20 202823
0 20 202824
0 20 202825
0 21 210300
0 21 210301
0 21 210302
0 21 210303
0 21 210304
0 21 210305
0 21 210306
0 21 210307
0 21 211400
0 21 211600
0 21 211601
0 21 212200
0 21 212500
0 21 212900
0 21 213200
0 21 213201
0 21 213500
0 21 213900
0 21 213901
0 21 214000
0 21 214001
0 21 214100
0 21 214400
0 21 214401
0 22 220501
0 22 220801
0 22 221601
0 22 221602
0 22 221603
0 22 221801
0 22 222001
0 22 222301
0 22 222701
0 22 222901
0 22 223001
0 22 223200
0 22 223501
0 22 223901
0 22 224001
0 22 224401
0 22 224801
0 22 225201
0 22 225301
0 22 225500
0 22 225501
0 22 225502
0 22 225503
0 22 225504
0 22 225505
0 22 225506
0 22 225507
0 22 225508
0 22 225509
0 26 260400
0 26 260500
0 26 260501
0 26 260800
0 26 261200
0 26 261201
0 26 261600
0 12 261800
0 26 261801
0 26 262000
0 26 262200
0 26 262600
0 26 262700
0 26 262902
0 26 262903
0 26 263000
0 26 263001
0 26 263200
0 26 263500
0 26 263503
0 26 263700
0 26 263901
0 26 263902
0 26 263903
0 26 263904
0 26 264000
0 26 264001
0 26 264200
0 26 264400
0 26 264800
0 26 264900
0 26 265300
0 26 265301
0 26 265302
0 26 269204
0 27 270900
0 27 270901
0 27 270902
0 27 270903
0 27 270904
0 27 270905
0 27 270906
0 27 270907
0 27 270908
0 27 270909
0 27 270910
0 27 270911
0 27 270912
0 27 272600
0 27 272900
0 27 272901
0 27 273400
0 27 273401
0 28 280200
0 28 280201
0 28 285700
0 28 288600
0 28 288601
0 28 288602
0 28 288603
0 29 290600
0 29 290601
0 29 290602
0 29 290603
0 29 292400
0 29 292401
0 29 292402
0 29 292403
0 29 292404
0 29 292405
0 29 292406
0 29 292407
0 29 292408
0 29 298100
0 29 298101
0 29 298200
0 29 298201
0 30 308300
0 30 308301
0 30 308302
0 30 308303
0 30 308304
Gostei + 0
18/05/2009
Wesley Yamazack
Fico no aguardo
Att,
Wesley Y
Gostei + 0
18/05/2009
Frigorifico Sa
Gostei + 0
18/05/2009
Frigorifico Sa
Gostei + 0
18/05/2009
Frigorifico Sa
[#VIDEO-115#]
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)