static int _thr_setparam(pthread_t tid, int policy, int prio) { ulwp_t *ulwp; id_t cid; int error = 0; if ((ulwp = find_lwp(tid)) == NULL) { error = ESRCH; } else { if (policy == ulwp->ul_policy && (policy == SCHED_FIFO || policy == SCHED_RR) && ulwp->ul_epri != 0) { /* * Don't change the ceiling priority, * just the base priority. */ if (prio > ulwp->ul_epri) error = EPERM; else ulwp->ul_pri = prio; } else if ((cid = setparam(P_LWPID, tid, policy, prio)) == -1) { error = errno; } else { if (policy == SCHED_FIFO || policy == SCHED_RR) ulwp->ul_rtclassid = cid; ulwp->ul_cid = cid; ulwp->ul_pri = prio; membar_producer(); ulwp->ul_policy = policy; } ulwp_unlock(ulwp, curthread->ul_uberdata); } return (error); }
/*----------------------------------------------------- Parameters: Returns value: Description ------------------------------------------------------*/ int ImageFWrite(IMAGE *I, FILE *fp, const char*fname) { byte *image ; int ecode, type, frame; char buf[100] ; if (!fname) fname = "ImageFWrite" ; strcpy(buf, fname) ; /* don't destroy callers string */ ImageUnpackFileName(buf, &frame, &type, buf) ; switch (type) { case RGBI_IMAGE: RGBwrite(I, buf, frame) ; break ; case TIFF_IMAGE: TiffWriteImage(I, buf, frame) ; break ; default: case JPEG_IMAGE: JPEGWriteImage(I, buf, frame); break; case PGM_IMAGE: PGMWriteImage(I, buf, frame); break; case PPM_IMAGE: PPMWriteImage(I, buf, frame); break; case HIPS_IMAGE: if (endian == END_UNDEF) endian = FindMachineEndian(); if (findparam(I,"endian")) clearparam(I,"endian"); /* Clear any existing endian parameter */ setparam(I, "endian", PFBYTE, 1, endian); ecode = fwrite_header(fp,I,"fwrite") ; if (ecode != HIPS_OK) ErrorExit(ERROR_NO_FILE,"ImageFWrite: fwrite_header failed (%d)\n",ecode); image = I->image ; for (frame = 0 ; frame < I->num_frame ; frame++) { ecode = fwrite_image(fp, I, frame, "fwrite") ; if (ecode != HIPS_OK) ErrorExit(ERROR_NO_FILE, "ImageFWrite: fwrite_image frame %d failed (%d)\n",ecode,frame); I->image += I->sizeimage ; /* next frame */ } I->image = image ; break ; } return(0) ; }
void MainWindow::restart() { itemList.clear(); setparam(); setGame(); }
STATIC void options(int cmdline) { char *p; int val; int c; if (cmdline) minusc = NULL; while ((p = *argptr) != NULL) { argptr++; if ((c = *p++) == '-') { val = 1; if (p[0] == '\0' || (p[0] == '-' && p[1] == '\0')) { if (!cmdline) { /* "-" means turn off -x and -v */ if (p[0] == '\0') xflag = vflag = 0; /* "--" means reset params */ else if (*argptr == NULL) setparam(argptr); } break; /* "-" or "--" terminates options */ } } else if (c == '+') { val = 0; } else { argptr--; break; } while ((c = *p++) != '\0') { if (c == 'c' && cmdline) { char *q; #ifdef NOHACK /* removing this code allows sh -ce 'foo' for compat */ if (*p == '\0') #endif q = *argptr++; if (q == NULL || minusc != NULL) error("Bad -c option"); minusc = q; #ifdef NOHACK break; #endif } else if (c == 'o') { minus_o(*argptr, val); if (*argptr) argptr++; } else { if (c == 'p' && !val && privileged) { (void) setuid(getuid()); (void) setgid(getgid()); } setoption(c, val); } } } }
void MainWindow::showEvent(QShowEvent *) { setparam(); setGame(); // Timer connect(&timer,SIGNAL(timeout()),this,SLOT(tick())); connect(this,SIGNAL(quitGame()),this,SLOT(QUITSLOT())); timer.start(100/6); }
static ssize_t zoran_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) { #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) struct zoran *zr = PDE(file->f_dentry->d_inode)->data; #else struct zoran *zr = PDE(file->f_path.dentry->d_inode)->data; #endif char *string, *sp; char *line, *ldelim, *varname, *svar, *tdelim; if (count > 32768) /* Stupidity filter */ return -EINVAL; string = sp = vmalloc(count + 1); if (!string) { dprintk(1, KERN_ERR "%s: write_proc: can not allocate memory\n", ZR_DEVNAME(zr)); return -ENOMEM; } if (copy_from_user(string, buffer, count)) { vfree (string); return -EFAULT; } string[count] = 0; #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) dprintk(4, KERN_INFO "%s: write_proc: name=%s count=%zu zr=%p\n", ZR_DEVNAME(zr), file->f_dentry->d_name.name, count, zr); #else dprintk(4, KERN_INFO "%s: write_proc: name=%s count=%zu zr=%p\n", ZR_DEVNAME(zr), file->f_path.dentry->d_name.name, count, zr); #endif ldelim = " \t\n"; tdelim = "="; line = strpbrk(sp, ldelim); while (line) { *line = 0; svar = strpbrk(sp, tdelim); if (svar) { *svar = 0; varname = sp; svar++; setparam(zr, varname, svar); } sp = line + 1; line = strpbrk(sp, ldelim); } vfree(string); return count; }
int setcmd(int argc, char **argv) { if (argc == 1) return showvars(nullstr, 0, VUNSET); INTOFF; options(0); optschanged(); if (*argptr != NULL) { setparam(argptr); } INTON; return 0; }
int setcmd(int argc, char **argv) { if (argc == 1) return showvarscmd(argc, argv); INTOFF; options(0); optschanged(); if (*argptr != NULL) { setparam(argc - (argptr - argv), argptr); } INTON; return 0; }
static int perform_flag_actions(spawn_attr_t *sap) { int sig; struct sigaction action; if (sap->sa_psflags & POSIX_SPAWN_SETSIGMASK) { (void) __lwp_sigmask(SIG_SETMASK, &sap->sa_sigmask); } if (sap->sa_psflags & POSIX_SPAWN_SETSIGIGN_NP) { (void) memset(&action, 0, sizeof (action)); action.sa_handler = SIG_IGN; for (sig = 1; sig < NSIG; sig++) { if (sigismember(&sap->sa_sigignore, sig)) (void) __sigaction(sig, &action, NULL); } } if (sap->sa_psflags & POSIX_SPAWN_SETSIGDEF) { (void) memset(&action, 0, sizeof (action)); action.sa_handler = SIG_DFL; for (sig = 1; sig < NSIG; sig++) { if (sigismember(&sap->sa_sigdefault, sig)) (void) __sigaction(sig, &action, NULL); } } if (sap->sa_psflags & POSIX_SPAWN_RESETIDS) { if (setgid(getgid()) != 0 || setuid(getuid()) != 0) return (errno); } if (sap->sa_psflags & POSIX_SPAWN_SETPGROUP) { if (setpgid(0, sap->sa_pgroup) != 0) return (errno); } if (sap->sa_psflags & POSIX_SPAWN_SETSCHEDULER) { if (setparam(P_LWPID, P_MYID, sap->sa_schedpolicy, sap->sa_priority) == -1) return (errno); } else if (sap->sa_psflags & POSIX_SPAWN_SETSCHEDPARAM) { if (setprio(P_LWPID, P_MYID, sap->sa_priority, NULL) == -1) return (errno); } return (0); }
STATIC int options(int cmdline) { char *p; int val; int c; int login = 0; if (cmdline) minusc = NULL; while ((p = *argptr) != NULL) { argptr++; if ((c = *p++) == '-') { val = 1; if (p[0] == '\0' || (p[0] == '-' && p[1] == '\0')) { if (!cmdline) { /* "-" means turn off -x and -v */ if (p[0] == '\0') xflag = vflag = 0; /* "--" means reset params */ else if (*argptr == NULL) setparam(argptr); } break; /* "-" or "--" terminates options */ } } else if (c == '+') { val = 0; } else { argptr--; break; } while ((c = *p++) != '\0') { if (c == 'c' && cmdline) { minusc = p; /* command is after shell args*/ } else if (c == 'l' && cmdline) { login = 1; } else if (c == 'o') { minus_o(*argptr, val); if (*argptr) argptr++; } else { setoption(c, val); } } } return login; }
static void tryexec(char *cmd, char **argv, char **envp) { int e; execve(cmd, argv, envp); e = errno; if (e == ENOEXEC) { initshellproc(); setinputfile(cmd, 0); commandname = arg0 = savestr(argv[0]); setparam(argv + 1); exraise(EXSHELLPROC); /*NOTREACHED*/ } errno = e; }
static int zoran_write_proc (struct file *file, const char *buffer, unsigned long count, void *data) { char *string, *sp; char *line, *ldelim, *varname, *svar, *tdelim; struct zoran *zr; zr = (struct zoran *) data; string = sp = vmalloc(count + 1); if (!string) { dprintk(1, KERN_ERR "%s: write_proc: can not allocate memory\n", ZR_DEVNAME(zr)); return -ENOMEM; } if (copy_from_user(string, buffer, count)) { vfree (string); return -EFAULT; } string[count] = 0; dprintk(4, KERN_INFO "%s: write_proc: name=%s count=%lu data=%x\n", ZR_DEVNAME(zr), file->f_dentry->d_name.name, count, (int) data); ldelim = " \t\n"; tdelim = "="; line = strpbrk(sp, ldelim); while (line) { *line = 0; svar = strpbrk(sp, tdelim); if (svar) { *svar = 0; varname = sp; svar++; setparam(zr, varname, svar); } sp = line + 1; line = strpbrk(sp, ldelim); } vfree(string); return count; }
static int zoran_write_proc(struct file *file, const char *buffer, unsigned long count, void *data) { #ifdef CONFIG_PROC_FS char *string, *sp; char *line, *ldelim, *varname, *svar, *tdelim; struct zoran *zr; zr = (struct zoran *) data; string = sp = vmalloc(count + 1); if (!string) { printk(KERN_ERR "%s: write_proc: can not allocate memory\n", zr->name); return -ENOMEM; } memcpy(string, buffer, count); string[count] = 0; DEBUG2(printk(KERN_INFO "%s: write_proc: name=%s count=%lu data=%x\n", zr->name, file->f_dentry->d_name.name, count, (int) data)); ldelim = " \t\n"; tdelim = "="; line = strpbrk(sp, ldelim); while (line) { *line = 0; svar = strpbrk(sp, tdelim); if (svar) { *svar = 0; varname = sp; svar++; setparam(zr, varname, svar); } sp = line + 1; line = strpbrk(sp, ldelim); } vfree(string); #endif return count; }
gint a_uibuilder_properties_factory ( const gchar *dialog_name, GtkWindow *parent, VikLayerParam *params, guint16 params_count, gchar **groups, guint8 groups_count, gboolean (*setparam) (gpointer,guint16,VikLayerParamData,gpointer,gboolean), gpointer pass_along1, gpointer pass_along2, VikLayerParamData (*getparam) (gpointer,guint16,gboolean), gpointer pass_along_getparam ) /* pass_along1 and pass_along2 are for set_param first and last params */ { guint16 i, j, widget_count = 0; gboolean must_redraw = FALSE; if ( ! params ) return 1; /* no params == no options, so all is good */ for ( i = 0; i < params_count; i++ ) if ( params[i].group != VIK_LAYER_NOT_IN_PROPERTIES ) widget_count++; if ( widget_count == 0) return 0; /* TODO -- should be one? */ else { /* create widgets and titles; place in table */ GtkWidget *dialog = gtk_dialog_new_with_buttons ( dialog_name, parent, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL ); gtk_dialog_set_default_response ( GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT ); GtkWidget *response_w = NULL; #if GTK_CHECK_VERSION (2, 20, 0) response_w = gtk_dialog_get_widget_for_response ( GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT ); #endif gint resp; GtkWidget *table = NULL; GtkWidget **tables = NULL; /* for more than one group */ GtkWidget *notebook = NULL; GtkWidget **widgets = g_malloc ( sizeof(GtkWidget *) * widget_count ); if ( groups && groups_count > 1 ) { guint8 current_group; guint16 tab_widget_count; notebook = gtk_notebook_new (); // Switch to vertical notebook mode when many groups if ( groups_count > 4 ) gtk_notebook_set_tab_pos ( GTK_NOTEBOOK(notebook), GTK_POS_LEFT ); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), notebook, FALSE, FALSE, 0); tables = g_malloc ( sizeof(GtkWidget *) * groups_count ); for ( current_group = 0; current_group < groups_count; current_group++ ) { tab_widget_count = 0; for ( j = 0; j < params_count; j ++ ) if ( params[j].group == current_group ) tab_widget_count++; if ( tab_widget_count ) { tables[current_group] = gtk_table_new ( tab_widget_count, 1, FALSE ); gtk_notebook_append_page ( GTK_NOTEBOOK(notebook), tables[current_group], gtk_label_new(groups[current_group]) ); } } } else { table = gtk_table_new( widget_count, 1, FALSE ); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), table, FALSE, FALSE, 0); } for ( i = 0, j = 0; i < params_count; i++ ) { if ( params[i].group != VIK_LAYER_NOT_IN_PROPERTIES ) { if ( tables ) table = tables[MAX(0, params[i].group)]; /* round up NOT_IN_GROUP, that's not reasonable here */ widgets[j] = a_uibuilder_new_widget ( &(params[i]), getparam ( pass_along_getparam, i, FALSE ) ); if ( widgets[j] ) { gtk_table_attach ( GTK_TABLE(table), gtk_label_new(_(params[i].title)), 0, 1, j, j+1, 0, 0, 0, 0 ); gtk_table_attach ( GTK_TABLE(table), widgets[j], 1, 2, j, j+1, GTK_EXPAND | GTK_FILL, 0, 2, 2 ); } j++; } } if ( response_w ) gtk_widget_grab_focus ( response_w ); gtk_widget_show_all ( dialog ); resp = gtk_dialog_run (GTK_DIALOG (dialog)); if ( resp == GTK_RESPONSE_ACCEPT ) { for ( i = 0, j = 0; i < params_count; i++ ) { if ( params[i].group != VIK_LAYER_NOT_IN_PROPERTIES ) { if ( setparam ( pass_along1, i, a_uibuilder_widget_get_value ( widgets[j], &(params[i]) ), pass_along2, FALSE ) ) must_redraw = TRUE; j++; } } gtk_widget_destroy ( dialog ); /* hide before redrawing. */ g_free ( widgets ); if ( tables ) g_free ( tables ); return must_redraw ? 2 : 3; /* user clicked OK */ } if ( tables ) g_free ( tables ); gtk_widget_destroy ( dialog ); g_free ( widgets ); return 0; } }
static void options(int cmdline) { char *kp, *p; int val; int c; if (cmdline) minusc = NULL; while ((p = *argptr) != NULL) { argptr++; if ((c = *p++) == '-') { val = 1; /* A "-" or "--" terminates options */ if (p[0] == '\0') goto end_options1; if (p[0] == '-' && p[1] == '\0') goto end_options2; /** * For the benefit of `#!' lines in shell scripts, * treat a string of '-- *#.*' the same as '--'. * This is needed so that a script starting with: * #!/bin/sh -- # -*- perl -*- * will continue to work after a change is made to * kern/imgact_shell.c to NOT token-ize the options * specified on a '#!' line. A bit of a kludge, * but that trick is recommended in documentation * for some scripting languages, and we might as * well continue to support it. */ if (p[0] == '-') { kp = p + 1; while (*kp == ' ' || *kp == '\t') kp++; if (*kp == '#' || *kp == '\0') goto end_options2; } } else if (c == '+') { val = 0; } else { argptr--; break; } while ((c = *p++) != '\0') { if (c == 'c' && cmdline) { char *q; #ifdef NOHACK /* removing this code allows sh -ce 'foo' for compat */ if (*p == '\0') #endif q = *argptr++; if (q == NULL || minusc != NULL) error("Bad -c option"); minusc = q; #ifdef NOHACK break; #endif } else if (c == 'o') { minus_o(*argptr, val); if (*argptr) argptr++; } else setoption(c, val); } } return; /* When processing `set', a single "-" means turn off -x and -v */ end_options1: if (!cmdline) { xflag = vflag = 0; return; } /* * When processing `set', a "--" means the remaining arguments * replace the positional parameters in the active shell. If * there are no remaining options, then all the positional * parameters are cleared (equivalent to doing ``shift $#''). */ end_options2: if (!cmdline) { if (*argptr == NULL) setparam(argptr); return; } /* * At this point we are processing options given to 'sh' on a command * line. If an end-of-options marker ("-" or "--") is followed by an * arg of "#", then skip over all remaining arguments. Some scripting * languages (e.g.: perl) document that /bin/sh will implement this * behavior, and they recommend that users take advantage of it to * solve certain issues that can come up when writing a perl script. * Yes, this feature is in /bin/sh to help users write perl scripts. */ p = *argptr; if (p != NULL && p[0] == '#' && p[1] == '\0') { while (*argptr != NULL) argptr++; /* We need to keep the final argument */ argptr--; } }
//static void draw_to_image_file_total_area_cb (GtkSpinButton *spinbutton, gpointer *pass_along) gint a_uibuilder_properties_factory ( const gchar *dialog_name, GtkWindow *parent, VikLayerParam *params, guint16 params_count, gchar **groups, guint8 groups_count, gboolean (*setparam) (gpointer,guint16,VikLayerParamData,gpointer,gboolean), gpointer pass_along1, gpointer pass_along2, VikLayerParamData (*getparam) (gpointer,guint16,gboolean), gpointer pass_along_getparam, void (*changeparam) (GtkWidget*, ui_change_values) ) /* pass_along1 and pass_along2 are for set_param first and last params */ { guint16 i, j, widget_count = 0; gboolean must_redraw = FALSE; if ( ! params ) return 1; /* no params == no options, so all is good */ for ( i = 0; i < params_count; i++ ) if ( params[i].group != VIK_LAYER_NOT_IN_PROPERTIES ) widget_count++; if ( widget_count == 0) return 0; /* TODO -- should be one? */ else { /* create widgets and titles; place in table */ GtkWidget *dialog = gtk_dialog_new_with_buttons ( dialog_name, parent, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL ); gtk_dialog_set_default_response ( GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT ); GtkWidget *response_w = NULL; #if GTK_CHECK_VERSION (2, 20, 0) response_w = gtk_dialog_get_widget_for_response ( GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT ); #endif gint resp; GtkWidget *table = NULL; GtkWidget **tables = NULL; /* for more than one group */ GtkWidget *notebook = NULL; GtkWidget **labels = g_malloc ( sizeof(GtkWidget *) * widget_count ); GtkWidget **widgets = g_malloc ( sizeof(GtkWidget *) * widget_count ); ui_change_values *change_values = g_malloc ( sizeof(ui_change_values) * widget_count ); if ( groups && groups_count > 1 ) { guint8 current_group; guint16 tab_widget_count; notebook = gtk_notebook_new (); // Switch to vertical notebook mode when many groups if ( groups_count > 4 ) gtk_notebook_set_tab_pos ( GTK_NOTEBOOK(notebook), GTK_POS_LEFT ); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), notebook, FALSE, FALSE, 0); tables = g_malloc ( sizeof(GtkWidget *) * groups_count ); for ( current_group = 0; current_group < groups_count; current_group++ ) { tab_widget_count = 0; for ( j = 0; j < params_count; j ++ ) if ( params[j].group == current_group ) tab_widget_count++; if ( tab_widget_count ) { tables[current_group] = gtk_table_new ( tab_widget_count, 1, FALSE ); gtk_notebook_append_page ( GTK_NOTEBOOK(notebook), tables[current_group], gtk_label_new(groups[current_group]) ); } } } else { table = gtk_table_new( widget_count, 1, FALSE ); gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), table, FALSE, FALSE, 0); } for ( i = 0, j = 0; i < params_count; i++ ) { if ( params[i].group != VIK_LAYER_NOT_IN_PROPERTIES ) { if ( tables ) table = tables[MAX(0, params[i].group)]; /* round up NOT_IN_GROUP, that's not reasonable here */ widgets[j] = a_uibuilder_new_widget ( &(params[i]), getparam ( pass_along_getparam, i, FALSE ) ); if ( widgets[j] ) { labels[j] = gtk_label_new(_(params[i].title)); gtk_table_attach ( GTK_TABLE(table), labels[j], 0, 1, j, j+1, 0, 0, 0, 0 ); gtk_table_attach ( GTK_TABLE(table), widgets[j], 1, 2, j, j+1, GTK_EXPAND | GTK_FILL, 0, 2, 2 ); if ( changeparam ) { change_values[j][UI_CHG_LAYER] = pass_along1; change_values[j][UI_CHG_PARAM] = ¶ms[i]; change_values[j][UI_CHG_PARAM_ID] = GINT_TO_POINTER((gint)i); change_values[j][UI_CHG_WIDGETS] = widgets; change_values[j][UI_CHG_LABELS] = labels; switch ( params[i].widget_type ) { // Change conditions for other widget types can be added when needed case VIK_LAYER_WIDGET_COMBOBOX: g_signal_connect ( G_OBJECT(widgets[j]), "changed", G_CALLBACK(changeparam), change_values[j] ); break; case VIK_LAYER_WIDGET_CHECKBUTTON: g_signal_connect ( G_OBJECT(widgets[j]), "toggled", G_CALLBACK(changeparam), change_values[j] ); break; default: break; } } } j++; } } // Repeat run through to force changeparam callbacks now that the widgets have been created // This primarily so the widget sensitivities get set up if ( changeparam ) { for ( i = 0, j = 0; i < params_count; i++ ) { if ( params[i].group != VIK_LAYER_NOT_IN_PROPERTIES ) { if ( widgets[j] ) { changeparam ( widgets[j], change_values[j] ); } j++; } } } if ( response_w ) gtk_widget_grab_focus ( response_w ); gtk_widget_show_all ( dialog ); resp = gtk_dialog_run (GTK_DIALOG (dialog)); if ( resp == GTK_RESPONSE_ACCEPT ) { for ( i = 0, j = 0; i < params_count; i++ ) { if ( params[i].group != VIK_LAYER_NOT_IN_PROPERTIES ) { if ( setparam ( pass_along1, i, a_uibuilder_widget_get_value ( widgets[j], &(params[i]) ), pass_along2, FALSE ) ) must_redraw = TRUE; j++; } } g_free ( widgets ); g_free ( labels ); g_free ( change_values ); if ( tables ) g_free ( tables ); gtk_widget_destroy ( dialog ); /* hide before redrawing. */ return must_redraw ? 2 : 3; /* user clicked OK */ } g_free ( widgets ); g_free ( labels ); g_free ( change_values ); if ( tables ) g_free ( tables ); gtk_widget_destroy ( dialog ); return 0; } }