Merge CV, ver=5.1; ops/methods from HV, and interface from CV where possible
[goodguy/history.git] / cinelerra-5.1 / db / utils / clip_del.C
1 #include<stdio.h>
2 #include<stdarg.h>
3 #include<time.h>
4
5 #include "tdb.h"
6 #include "s.C"
7
8 int del_clip_set(theDb *db, int clip_id)
9 {
10         if( db->clip_set.FindId(clip_id) ) return 1;
11         db->clip_set.Destruct();
12         db->clip_set.Deallocate();
13
14         if( Clip_viewsLoc::ikey_Clip_access(db->clip_views,clip_id).Find() ) return 1;
15         db->clip_views.Destruct();
16         db->clip_views.Deallocate();
17
18         while( !TimelineLoc::ikey_Sequences(db->timeline,clip_id,0).Locate() ) {
19                 if( clip_id != (int)db->timeline.Clip_id() ) break;
20                 int frame_id = db->timeline.Frame_id();
21                 db->timeline.Destruct();
22                 db->timeline.Deallocate();
23                 if( !TimelineLoc::ikey_Timelines(db->timeline, frame_id).Locate() &&
24                         frame_id == (int)db->timeline.Frame_id() ) continue;
25                 if( db->video_frame.FindId(frame_id) ) continue;
26                 db->video_frame.Destruct();
27                 db->video_frame.Deallocate();
28         }
29         return 0;
30 }
31
32 int main(int ac, char **av)
33 {
34   setbuf(stdout,0);
35   theDb db;
36   db.open(av[1]);
37   //db.access(av[1], 34543, 0);
38   if( !db.opened() || db.error() ) exit(1);
39
40   del_clip_set(&db,atoi(av[2]));
41
42   db.commit();
43   db.close();
44   return 0;
45 }
46