static void set_time(void) { if (tflag) { store_time(); stb_update_clock(stb); tflag = 0; } stb_start_clock(stb); }
int main(int argc, char* argv[]) { int res = -1; if (argc != 2) { ALOGI("usage: timekeep store|restore"); return res; } // Keep CAP_SYS_TIME and drop to system user if (strcmp(argv[1], "store") == 0) { res = store_time(); } if (strcmp(argv[1], "restore") == 0) { res = restore_time(); } return res; }
LONG EXPENTRY standardEvt(MIDIFILE * mf) { register UCHAR chr; register USHORT val; /* Store the Time of this event in MIDIFILE's Time field */ mf->Time = TrkPtr->Time; /* Get the Status for this event */ chr = mf->Status = TrkPtr->Status; /* Is this a Meta-Event? (ie, we use meta's Type for the status, and these values are always less than 0x80) */ if ( !(chr & 0x80) ) { /* Set Status to 0xFF */ mf->Status = 0xFF; /* Set Data[0] = Type */ mf->Data[0] = chr; switch (chr) { /* NOTE: MIDIFILE.DLL sets Data[1] to the proper length for the fixed length meta types (ie, 0x00, 0x2F, 0x51, 0x54, 0x58, and 0x59). */ /* ------- Sequence # ------- */ /* NOTE: If we use a MetaSeqNum callback, we wouldn't write out a Meta-Event here, and so this case wouldn't be needed. */ case 0x00: /* Note the recasting of the EVENT and the MIDIFILE structures to the versions appropriate for a SEQUENCE NUMBER Meta-Event. */ store_seq( (SEQEVENT *)TrkPtr, (METASEQ *)mf ); break; /* ------- Set Tempo -------- */ case 0x51: store_tempo( (TEMPOEVENT *)TrkPtr, (METATEMPO *)mf ); break; /* --------- SMPTE --------- */ case 0x54: /* Right now, let's ignore SMPTE events. This was too much of a hassle since there are too many data bytes to fit into the 8 bytes that I use to express events internally in this program. */ break; /* ------- End of Track ------ */ case 0x2F: printf("Closing track #%ld...\r\n", mf->TrackNum); break; /* ------ Time Signature ----- */ case 0x58: store_time( (TIMEEVENT *)TrkPtr, (METATIME *)mf ); break; /* ------ Key Signature ------ */ case 0x59: store_key( (KEYEVENT *)TrkPtr, (METAKEY *)mf ); break; /* Must be a variable length Meta-Event (ie, type is 0x01 to 0x0F, or 0x7F) */ default: store_meta( (TXTEVENT *)TrkPtr, (METATXT *)mf ); } } /* Must be a real MIDI event (as opposed to a MetaEvent) */ else switch ( chr ) { /* SYSEX (0xF0) or SYSEX CONTINUATION (0xF7) */ case 0xF0: case 0xF7: store_sysex( (XEVENT *)TrkPtr, (METATXT *)mf ); break; /* For other MIDI messages, they're all fixed length, and will fit into the MIDIFILE structure, so we copy 2 more data bytes to the MIDIFILE (whether those data bytes are valid or not -- the DLL takes care of writing the message out properly). */ default: mf->Data[0] = TrkPtr->Data1; mf->Data[1] = TrkPtr->Data2; } /* Advance the ptr to the next event (ie, for the next call to this function) */ TrkPtr++; return(0); }