home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / graphics / degas2ps / dialps.c < prev    next >
C/C++ Source or Header  |  1989-06-20  |  3KB  |  102 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <osbind.h>
  4. #include <obdefs.h>
  5. #include <gemdefs.h>
  6.  
  7. /* --- */
  8.  
  9. #define TRUE        1
  10. #define FALSE        0
  11.  
  12. extern OBJECT *dial[];
  13. #include "new_stps.h"
  14. extern char *messages[];
  15. extern int date[2];
  16. extern long taille;
  17. extern char chaine[];
  18. int hand;
  19. char *point;
  20.  
  21. /* --- */
  22.  
  23. /*    PROCEDURE D'OBTENTION DES DESCRIPTEURS DES FICHIERS    */
  24. /*    SOURCE ET DESTINATION                                */
  25. /*                                                        */
  26. /*    Rend istr (fd fichier source, entree)                */
  27. /*                ostr (fd fichier destination, sortie)    */
  28. /*        nom du fichier source                            */
  29. /*            1 si OK, -1 si non OK                        */
  30.  
  31. int dialogue(istr,source,deja_ouvert)
  32. FILE **istr;
  33. char *source;
  34. int deja_ouvert;
  35. {
  36.     int buffer[8];
  37.     char nomfich[80];
  38.     char inpath[80];                /* chemin d'acces  */
  39.     char insel[80];                    /* selection document */
  40.     int bouton,drive,i;
  41.     FILE *fd;
  42.  
  43.     /*    Obtention du nom du fichier source                */
  44.     /*    On affiche les fichiers *.* dans le repertoire    */
  45.     /*    courant, sur le drive actif                        */
  46.  
  47.     drive=Dgetdrv();
  48.     inpath[0]=drive+'A';
  49.     inpath[1]=NULL;
  50.     strcat(inpath,":");
  51.     if(Dgetpath(&inpath[2],drive+1)<0) form_alert(1,messages[3]);
  52.     strcat(inpath,"\\*.*");
  53.     insel[0]=NULL;
  54.     dial[MESSAGES][ROOT].ob_x=(640-dial[MESSAGES][ROOT].ob_width)/2;
  55.     dial[MESSAGES][ROOT].ob_y=24;
  56.     dial[MESSAGES][BOXMOUSE].ob_flags|=HIDETREE;
  57.     dial[MESSAGES][ROOT].ob_height=dial[MESSAGES][BOXCHAIN].ob_height;
  58.     strcpy(((TEDINFO *)dial[MESSAGES][CHAINE].ob_spec)->te_ptext,"FICHIER A TRADUIRE");
  59.     ouvre_form(buffer,dial[MESSAGES],FALSE,FALSE);
  60.     fsel_input(inpath,insel,&bouton);
  61.     ferme_form(buffer,FALSE);
  62.     if(!bouton) return(-2);
  63.  
  64.     /* sauvegarde du chemin d'acces et constitution */
  65.     /* du nom complet du fichier d'entree           */
  66.  
  67.     strcpy(nomfich,inpath);
  68.     strcpy(rindex(nomfich,'\\')+1,insel);
  69.  
  70.     /* Ouverture en lecture du fichier d'entree */
  71.  
  72.     if ((fd = fopen(nomfich,"r")) == NULL )
  73.     {
  74.            sprintf(nomfich,messages[4],insel);
  75.            form_alert(1,nomfich);
  76.            return(-1);
  77.     }
  78.     if (deja_ouvert) fclose(*istr);
  79.     *istr=fd;
  80.     strcpy(source,nomfich);
  81.  
  82. /* -- Lecture Date, heure et taille -- */
  83.  
  84.     fseek(*istr,0L,2);
  85.     taille=ftell(*istr);
  86.     rewind(*istr);
  87.     hand=open(source,0);
  88.     Fdatime(date,hand,0);
  89.     close(hand);
  90.     point=((TEDINFO *)dial[DOCFIRST][DATE].ob_spec)->te_ptext;
  91.     sprintf(point,"%02d/%02d/%2d",date[1] & 31,(date[1]>>5) & 15,80+
  92.         ((date[1]>>9) & 127));
  93.     *(point+8)=0;
  94.     point=((TEDINFO *)dial[DOCFIRST][HEURE].ob_spec)->te_ptext;
  95.     sprintf(point,"%02d:%02d:%02d",(date[0]>>11) & 31,(date[0]>>5) & 63,
  96.         (date[0] & 31)*2);
  97.     *(point+8)=0;
  98.     sprintf(((TEDINFO *)dial[DOCFIRST][TAILLE].ob_spec)->te_ptext,
  99.         "%lu",taille);
  100.     return(1);
  101. }
  102.