home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / sharew / accs / clipbord / scraplib / scraplib.c < prev    next >
Encoding:
C/C++ Source or Header  |  1985-07-19  |  2.3 KB  |  111 lines

  1. #include "ccport.h"
  2.  
  3.  
  4.  
  5. /* +-----------------------------------------------------------------------+ */
  6. /* | KLEMMBRETT INITIALISIEREN                           | */
  7. /* +-----------------------------------------------------------------------+ */
  8.  
  9. word    scrp_init(pfad)
  10.     byte *pfad;
  11.  
  12. {
  13.     byte scrap[64];
  14.     long handle;
  15.  
  16.     scrp_read(scrap);
  17.     if(scrap[0]==0)
  18.     {    strcpy(scrap,pfad);
  19.         scrp_write(scrap);
  20.         {    handle = Dcreate(scrap);
  21.             if((handle<0)&&(handle!=-36))
  22.             {    scrp_write("");
  23.                 form_error(1);
  24.                 return(0);
  25.             }
  26.         }
  27.     }
  28.     return(1);
  29. }
  30.  
  31.  
  32.  
  33. /* +-----------------------------------------------------------------------+ */
  34. /* | DATEIEN IM SCRAP-DIRECTORY LÖSCHEN                       | */
  35. /* +-----------------------------------------------------------------------+ */
  36.  
  37. void    scrp_clear()
  38.  
  39. {    char xpfad[ FMSIZE],gesammtpfad[ FMSIZE],xname[ FMSIZE],scrap[256];
  40.     struct FILEINFO file;
  41.     int ret;
  42.  
  43.     scrp_read(scrap);
  44.     strmfp(xpfad,scrap,"SCRAP.*");
  45.     ret=dfind(&file,xpfad,0);
  46.     while(ret==0L)
  47.     {    stcgfp(gesammtpfad,xpfad);
  48.         strmfp(xname,gesammtpfad,file.name);
  49.         remove(xname);
  50.         ret=dnext(&file);
  51.     }
  52.  
  53. }
  54.  
  55.  
  56.  
  57. /* +-----------------------------------------------------------------------+ */
  58. /* | LÄNGE DES KLEMMBRETT-INHALTS ALS WORD IN KYBTES LIEFERN           | */
  59. /* +-----------------------------------------------------------------------+ */
  60.  
  61. word    scrp_length()
  62.  
  63. {
  64.     byte name[ FMSIZE], filename[ FMSIZE];
  65.     struct FILEINFO dta;
  66.     long length = 0;
  67.  
  68.     scrp_read(filename);
  69.     strmfp(name,filename,"SCRAP.*");
  70.  
  71.     if(!dfind(&dta,name,0))
  72.         do
  73.             length += dta.size;
  74.         while(!dnext(&dta));
  75.     else
  76.         return(0);
  77.  
  78.     return((word)(length/1024));
  79. }
  80.  
  81.  
  82.  
  83. /* +-----------------------------------------------------------------------+ */
  84. /* | EINE ROUTINE, DIE ZU EINER GEGEBENEN EXTENSION DAS CLIPFILE LIEFERT   | */
  85. /* +-----------------------------------------------------------------------+ */
  86.  
  87. word    scrp_find(extension,filename)
  88.     byte *extension,*filename;
  89.  
  90. {
  91.     byte datei[ FMSIZE];
  92.     byte scrap[256];
  93.     word c = 0;
  94.     struct FILEINFO dta;
  95.  
  96.     scrp_read(scrap);
  97.     strcpy(datei,scrap);
  98.     strcat(datei,"\\SCRAP.");
  99.     strcat(datei,extension);
  100.     if(!dfind(&dta,datei,0))
  101.     {
  102.         c++;
  103.         strcpy(datei,scrap);
  104.         strmfp(filename,datei,dta.name);
  105.         while(!dnext(&dta));
  106.             c++;
  107.         return(c);
  108.     }
  109.     return(0);
  110. }
  111.