src/mn-masterd/main.c
const char*
load_hooks()
{
    int     x;
    FILE  *fp;
    size_t length;

    for (x=0; x<NUM_HOOKS; x++) {
        if (opt_vals.hooks[x]) {
            if (!(fp = fopen(opt_vals.hooks[x], "r")))
                return "could not open hook script";
            fseek(fp, 0, SEEK_END);
            length = (int)ftell(fp);
            rewind(fp);

            if (!(srv.hooks[x].buf = malloc(length)))
                return "out of mem";
            srv.hooks[x].sz = length;
            fread(srv.hooks[x].buf, 1, length, fp);
            fclose(fp);
        }
    }

    return 0;
}
/** 
 * load all set hooks into memory, so we can send them to 
 * connecting slaves
 *
 * return 0 or a static char buffer describing the error
 **/
load all set hooks into memory, so we can send them to
connecting slaves

return 0 or a static char buffer describing the error
load all set hooks into memory so we can send them to connecting slaves return 0 or a static char buffer describing the error
const char*
load_hooks()
{
    int     x;
    FILE  *fp;
    size_t length;
    for (x=0; x<NUM_HOOKS; x++) {
        if (opt_vals.hooks[x]) {
            if (!(fp = fopen(opt_vals.hooks[x], "r")))
                return "could not open hook script";
            fseek(fp, 0, SEEK_END);
            length = (int)ftell(fp);
            rewind(fp);
            if (!(srv.hooks[x].buf = malloc(length)))
                return "out of mem";
            srv.hooks[x].sz = length;
            fread(srv.hooks[x].buf, 1, length, fp);
            fclose(fp);
        }
    }
    return 0;
}
const char * load_hooks ( ) { int x ; FILE * fp ; size_t length ; for ( x = 0 ; x < NUM_HOOKS ; x ++ ) { if ( opt_vals . hooks [ x ] ) { if ( ! ( fp = fopen ( opt_vals . hooks [ x ] , " " ) ) ) return " " ; fseek ( fp , 0 , SEEK_END ) ; length = ( int ) ftell ( fp ) ; rewind ( fp ) ; if ( ! ( srv . hooks [ x ] . buf = malloc ( length ) ) ) return " " ; srv . hooks [ x ] . sz = length ; fread ( srv . hooks [ x ] . buf , 1 , length , fp ) ; fclose ( fp ) ; } } return 0 ; }
load all set hooks into memory, so we can send them to
 connecting slaves
load all set hooks into memory so we can send them to connecting slaves