int fce_register_new_file( struct path *path ) { int ret = AFP_OK; if (path == NULL) return AFPERR_PARAM; if (!(fce_ev_enabled & (1 << FCE_FILE_CREATE))) return ret; ret = register_fce( path->u_name, FALSE, FCE_FILE_CREATE ); return ret; }
int fce_register_delete_dir( char *name ) { int ret = AFP_OK; if (name == NULL) return AFPERR_PARAM; if (!(fce_ev_enabled & (1 << FCE_DIR_DELETE))) return ret; ret = register_fce( name, TRUE, FCE_DIR_DELETE); return ret; }
int fce_register_delete_file( struct path *path ) { int ret = AFP_OK; if (path == NULL) return AFPERR_PARAM; if (!(fce_ev_enabled & (1 << FCE_FILE_DELETE))) return ret; ret = register_fce( path->u_name, false, FCE_FILE_DELETE ); return ret; }
int fce_register_tm_size(const char *vol, size_t used) { int ret = AFP_OK; if (vol == NULL) return AFPERR_PARAM; if (!(fce_ev_enabled & (1 << FCE_TM_SIZE))) return ret; tm_used = used; /* oh what a hack */ ret = register_fce(vol, FALSE, FCE_TM_SIZE); return ret; }
int fce_register_file_modification( struct ofork *ofork ) { char *u_name = NULL; struct vol *vol; int ret = AFP_OK; if (ofork == NULL || ofork->of_vol == NULL) return AFPERR_PARAM; if (!(fce_ev_enabled & (1 << FCE_FILE_MODIFY))) return ret; vol = ofork->of_vol; if (NULL == (u_name = mtoupath(vol, of_name(ofork), ofork->of_did, utf8_encoding()))) { return AFPERR_MISC; } ret = register_fce( u_name, FALSE, FCE_FILE_MODIFY ); return ret; }
int main( int argc, char*argv[] ) { int c,ret; char *port = FCE_DEFAULT_PORT_STRING; char *host = "localhost"; int delay_between_events = 1000; int event_code = FCE_FILE_MODIFY; char pathbuff[1024]; int duration_in_seconds = 0; // TILL ETERNITY char target[256]; char *path = getcwd( pathbuff, sizeof(pathbuff) ); // FULLSPEED TEST IS "-s 1001" -> delay is 0 -> send packets without pause while ((c = getopt(argc, argv, "d:e:h:p:P:s:")) != -1) { switch(c) { case '?': fprintf(stdout, "%s: [ -p Port -h Listener1 [ -h Listener2 ...] -P path -s Delay_between_events_in_us -e event_code -d Duration ]\n", argv[0]); exit(1); break; case 'd': duration_in_seconds = atoi(optarg); break; case 'e': event_code = atoi(optarg); break; case 'h': host = strdup(optarg); break; case 'p': port = strdup(optarg); break; case 'P': path = strdup(optarg); break; case 's': delay_between_events = atoi(optarg); break; } } sprintf(target, "%s:%s", host, port); if (fce_add_udp_socket(target) != 0) return 1; int ev_cnt = 0; time_t start_time = time(NULL); time_t end_time = 0; if (duration_in_seconds) end_time = start_time + duration_in_seconds; while (1) { time_t now = time(NULL); if (now > start_time) { start_time = now; fprintf( stdout, "%d events/s\n", ev_cnt ); ev_cnt = 0; } if (end_time && now >= end_time) break; register_fce( path, 0, event_code ); ev_cnt++; shortsleep( delay_between_events ); } }