/* a parser that is composed of the previous parsers to get a number out of the input string. * it succeeds iff the input line contains a floating point number. if successful, the result * is given in res, if fails, the error is given in error and return value is NULL.*/ char* getInteger(char*p, int* res, int* err) { char* e; char t; /* do we have anything to work on? */ if (p==NULL || *p == '\0') return NULL; /* a nice trick by using or parser */ e = allDigits(or(oneOf(p, "+-"), p)); /* at the end of the previous 4 lines, we could have numbers in the following format -1, 1, +1 */ /* if any of the above parsers had failed, return failure */ if (e == NULL) return e; /* remove leading whitespace */ e = strip(e, " "); /* if after removing all whitespaces we didnt hit either ',', end-of-line, or nothing was consumed at all, * then the input that was given is wrong! fail this parser!*/ if ((!oneOf(e, "\n\r,"))||e==p) { *err = NUMBER_ERR; return NULL; } /* if everything succeeded up till now, then e points to the rest of the input AFTER the valid float number, * so we use a little trick to make it a float number:*/ t = *e; /* save the end of the consumed string */ *e = '\0'; /* mark it as end of line */ *res = (float)atoi(p); /* use atof to transform the original input string (p) into the number */ *e=t; /* set the end of consumed string back to its original value */ return e; /* return the pointer to the rest of the unconsumed string */ }
void setup(GtkWidget *widget) { GtkWidgetProps props(widget); if (widget && GTK_IS_SCROLLED_WINDOW(widget) && !props->scrolledWindowHacked) { GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(widget); GtkWidget *child; if ((child = gtk_scrolled_window_get_hscrollbar(scrolledWindow))) { setupConnections(child, widget); } if ((child = gtk_scrolled_window_get_vscrollbar(scrolledWindow))) { setupConnections(child, widget); } if ((child = gtk_bin_get_child(GTK_BIN(widget)))) { if (GTK_IS_TREE_VIEW(child) || GTK_IS_TEXT_VIEW(child) || GTK_IS_ICON_VIEW(child)) { setupConnections(child, widget); } else if (oneOf(gTypeName(child), "ExoIconView", "FMIconContainer")) { setupConnections(child, widget); } } props->scrolledWindowHacked = true; } }
/* A helper function for removing newlines, used for error reporting */ char* trimNewline(char* line) { int l = strlen(line); int i=0; if (oneOf(&line[l-1],"\r\n")) { i++; if (charIs(&line[l-2],'\r')) i++; } line[l-i]='\0'; return line; }
void setup(GtkWidget *widget) { QTC_RET_IF_FAIL(widget); GtkWidget *parent = nullptr; if (GTK_IS_WINDOW(widget) && !gtk_window_get_decorated(GTK_WINDOW(widget))) { return; } if (GTK_IS_EVENT_BOX(widget) && gtk_event_box_get_above_child(GTK_EVENT_BOX(widget))) return; parent = gtk_widget_get_parent(widget); // widgets used in tabs also must be ignored (happens, unfortunately) if (GTK_IS_NOTEBOOK(parent) && Tab::isLabel(GTK_NOTEBOOK(parent), widget)) return; /* check event mask (for now we only need to do that for GtkWindow) The idea is that if the window has been set to receive button_press and button_release events (which is not done by default), it likely means that it does something with such events, in which case we should not use them for grabbing */ if (oneOf(gTypeName(widget), "GtkWindow") && (gtk_widget_get_events(widget) & (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK))) return; GtkWidgetProps props(widget); if (!isFakeGtk() && !props->wmMoveHacked) { props->wmMoveHacked = true; gtk_widget_add_events(widget, GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON1_MOTION_MASK); registerBtnReleaseHook(); props->wmMoveDestroy.conn("destroy-event", destroy); props->wmMoveStyleSet.conn("style-set", styleSet); props->wmMoveMotion.conn("motion-notify-event", motion); props->wmMoveLeave.conn("leave-notify-event", leave); props->wmMoveButtonPress.conn("button-press-event", buttonPress); } }
int main (int argc, char **argv, char **environ) { char *queue = NULL, *host = NULL, *jobName = NULL, *user = NULL; LS_LONG_INT jobId; int options; struct jobInfoEnt *jInfo; char *outFile; char fflag = FALSE; int cc; int rc; rc = _i18n_init (I18N_CAT_MIN); if (lsb_init (argv[0]) < 0) { lsb_perror ("lsb_init"); exit (-1); } while ((cc = getopt (argc, argv, "Vhfq:m:J:")) != EOF) { switch (cc) { case 'q': if (queue || host || jobName) oneOf (argv[0]); queue = optarg; break; case 'm': if (queue || host || jobName) oneOf (argv[0]); host = optarg; break; case 'J': if (queue || host || jobName) oneOf (argv[0]); jobName = optarg; break; case 'V': fputs (_LS_VERSION_, stderr); exit (0); case 'f': fflag = TRUE; break; case 'h': default: usage (argv[0]); } } jobId = 0; options = LAST_JOB; if (argc >= optind + 1) { if (queue || host || jobName) { oneOf (argv[0]); } else if ((argc > 2 && !fflag) || (argc > 3 && fflag)) usage (argv[0]); if (getOneJobId (argv[optind], &jobId, 0)) { usage (argv[0]); } options = 0; } if (lsb_openjobinfo (jobId, jobName, NULL, queue, host, options) < 0 || (jInfo = lsb_readjobinfo (NULL)) == NULL) { if (jobId != 0 || jobName != NULL) { user = ALL_USERS; if (lsb_openjobinfo (jobId, jobName, user, queue, host, options) < 0 || (jInfo = lsb_readjobinfo (NULL)) == NULL) { jobInfoErr (jobId, jobName, NULL, queue, host, options); exit (-1); } } else { jobInfoErr (jobId, jobName, NULL, queue, host, options); exit (-1); } } lsb_closejobinfo (); if (jobId && jInfo->jobId != jobId) { lsberrno = LSBE_JOB_ARRAY; lsb_perror ("bpeek"); exit (-1); } if ((jInfo->submit.options & SUB_INTERACTIVE) && !(jInfo->submit.options & (SUB_OUT_FILE | SUB_ERR_FILE))) { fprintf (stderr, _i18n_msg_get (ls_catd, NL_SETN, 2456, "Job <%s> : Cannot bpeek an interactive job.\n"), /* catgets 2456 */ lsb_jobid2str (jInfo->jobId)); exit (-1); } if (IS_PEND (jInfo->status) || jInfo->execUsername[0] == '\0') { fprintf (stderr, _i18n_msg_get (ls_catd, NL_SETN, 2454, "Job <%s> : Not yet started.\n"), /* catgets 2454 */ lsb_jobid2str (jInfo->jobId)); exit (-1); } if (IS_FINISH (jInfo->status)) { fprintf (stderr, _i18n_msg_get (ls_catd, NL_SETN, 2455, "Job <%s> : Already finished.\n"), /* catgets 2455 */ lsb_jobid2str (jInfo->jobId)); exit (-1); } if ((outFile = lsb_peekjob (jInfo->jobId)) == NULL) { char msg[50]; sprintf (msg, "%s <%s>", I18N_Job, lsb_jobid2str (jInfo->jobId)); lsb_perror (msg); exit (-1); } displayOutput (outFile, jInfo, fflag, environ); _i18n_end (ls_catd); exit (0); }
/* This method makes sure the string m is matched within the beginning of string p, and that it ends with either * a whitespace or a carriage return, but on success it returns the string containing that last letter. */ char* matchWordD(char* p, char* m) { char* e; return oneOf((e=matchWord(p, m)), "\r\n ") ? e : NULL; }