home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: Multimed
/
Multimed.zip
/
loadds7.zip
/
main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-10-06
|
3KB
|
126 lines
/*
* main.c - âüâCâôâïü[â`âô
* loadds7 by Romy, 1997
*/
#include <stdio.h>
#include <stdlib.h>
#define INCL_DOS
#include <os2.h>
#include "serial.h"
#include "ds7.h"
#include "messages.h"
int
main( int argc, char* argv[] )
/* ê°é½Éö: argv[1]..COMâ|ü[âgö╘ìå, argv[2]..â{ü[âîü[âg,
argv[3]-..ĵéΦì₧é▐ëµæ£ö╘ìå */
{
HFILE hFile;
CHAR sTmp[80];
INT i, nImages;
USHORT usBaud = 9600; /*Åëè·Æ╩ÉMæ¼ôxé═9600â{ü[*/
CHAR *asFilename;
/*âoü[âWâçâôò\Ī*/
fprintf( stderr, msg_Version );
if( argc < 2 ){
/*âwâïâvò\Ī*/
fprintf( stderr, msg_Usage, argv[0] );
return 0;
}
/*COMâ|ü[âgé╠Åëè·ë╗*/
if( COM_Init(atoi(argv[1]), &hFile) != 0 ){
fprintf( stderr, msg_CantOpenCom, atoi(argv[1]) );
return -1;
}
/*É┌æ▒ùvïü*/
if( StartConnection( hFile ) != 0 || Resp(hFile) != ACK ){
fprintf( stderr, msg_CantStartConn );
COM_Close( hFile );
return -1;
}
SendACK( hFile );
/*âJâüâëÅεò±é╠ĵô╛*/
if( GetCameraInfo( hFile, sTmp ) != 0 ){
fprintf( stderr, msg_CantGetCamInfo );
EndConnection( hFile );
COM_Close( hFile );
return -1;
}
/*ïLÿ^ûçÉöé╠ĵô╛*/
nImages = GetRecordInfo( hFile );
if( nImages == 0 ){
/*ëµæ£é¬â[âìé╚éτÅIù╣*/
fprintf( stderr, msg_CantGetImageNum );
EndConnection( hFile );
COM_Close( hFile );
return -1;
}
else if( nImages < 0 ){
/*ëµæ£ûçÉöé¬Äµô╛é┼é½é╚é»éΩé╬ÅIù╣*/
fprintf( stderr, msg_CantGetImageNum );
EndConnection( hFile );
COM_Close( hFile );
return -1;
}
fprintf( stderr, msg_CamInfo, sTmp+5, nImages );
/*Æ╩ÉMæ¼ôxâIâvâVâçâôé╠ô╟é▌ĵéΦ*/
if( argc > 2 ){
usBaud = atoi( argv[2] );
}
/*Æ╩ÉMæ¼ôxÉ▌ÆΦ*/
if( ChangeBaudrate( hFile, usBaud ) != 0 ){
fprintf( stderr, msg_CantChangeBaud );
EndConnection( hFile );
COM_Close( hFile );
return -1;
}
/*ëµæ£ö╘ìåÄwÆΦé¬éáéΩé╬ëµæ£Ä≤ÉM*/
if( argc > 3 ){
/*ê°Éöé┼ÄwÆΦé│éΩé╜ö╘ìåé╠ëµæ£é≡Åçé╔Ä≤ÉM*/
for( i = 3; i < argc; i++ ){
if( atoi(argv[i]) > 0 ){
if( GetImageName( hFile, atoi(argv[i]), sTmp ) == 0 ){
fprintf( stdout, msg_Receiving, atoi(argv[i]), sTmp );
if( GetImage( hFile, atoi(argv[i]), sTmp ) != 0 ){
fprintf( stderr, msg_CantGetImage, atoi(argv[i]) );
}
}
}
}
}
/*ëµæ£ö╘ìåÄwÆΦé¬é╚é»éΩé╬ëµæ£âtâ@âCâïû╝ò\Ī*/
else{
asFilename = (CHAR*)malloc( 13*nImages );
for( i = 1; i <= nImages; i++ ){
fprintf( stderr, "%d\r", i );
if( GetImageName( hFile, i, sTmp ) == 0 ){
strcpy( asFilename+13*(i-1), sTmp );
}
else{
strcpy( asFilename+13*(i-1), "N/A" );
}
}
for( i = 0; i < nImages; i++ ){
fprintf( stdout, "No.%2d:%s\n", i+1,asFilename+13*i );
}
free( asFilename );
}
EndConnection( hFile );
COM_Close( hFile );
return 0;
}