C++ (Cpp) exit Examples

C++ (Cpp) exit - 30 examples found. These are the top rated real world C++ (Cpp) examples of exit extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
static void
initFiles(void)
{
    char buf[BUFSIZ];

    snprintf(buf,BUFSIZ,"%s%s_%d.json", dirpath, prefix, queryid);
    tachojson= fopen(buf,"w");
    if( tachojson == NULL) {
        fprintf(stderr,"Could not create %s\n",buf);
        exit(-1);
    }
    snprintf(buf,BUFSIZ,"%s%s_%d_mal.csv",dirpath, prefix, queryid);
    tachomal= fopen(buf,"w");
    if( tachomal == NULL) {
        fprintf(stderr,"Could not create %s\n",buf);
        exit(-1);
    }
    snprintf(buf,BUFSIZ,"%s%s_%d_stmt.csv", dirpath, prefix, queryid);
    tachostmt= fopen(buf,"w");
    if( tachostmt == NULL) {
        fprintf(stderr,"Could not create %s\n",buf);
        exit(-1);
    }
    snprintf(buf,BUFSIZ,"%s%s_%d.trace", dirpath, prefix, queryid);
    tachotrace= fopen(buf,"w");
    if( tachotrace == NULL) {
        fprintf(stderr,"Could not create %s\n",buf);
        exit(-1);
    }
}
Example #2
0
void setup_every_copy()
{
    /* Initialize test dir and file names */
    sprintf(pathname, "openattestdir%d", getpid());
    sprintf(testfile, "openattestfile%d.txt", getpid());
    sprintf(testfile2, "openattestfile%d_2.txt", getpid());
    sprintf(testfile3, "/tmp/openattestfile%d.txt", getpid());

    ret = mkdir(pathname, 0600);
    if (ret < 0) {
        perror("mkdir: ");
        exit(-1);
    }

    dirfd = open(pathname, O_DIRECTORY);
    if (dirfd < 0) {
        perror("open: ");
        exit(-1);
    }

    fd = open(testfile2, O_CREAT | O_RDWR, 0600);
    if (fd < 0) {
        perror("open: ");
        exit(-1);
    }
    fds[0] = fds[1] = dirfd;
    fds[2] = fd;
    fds[3] = 100;
    fds[4] = AT_FDCWD;

    filenames[0] = filenames[3] = filenames[4] = testfile;
    filenames[1] = testfile3;
    filenames[2] = testfile2;
}
// GPIO #54 - timepulse pin on MAX-6Q GPS
void set_gpio_input(void)
{
    int exportfd, directionfd;

    printf("GPIO-Input-Setting\n");

    // The GPIO has to be exported to be able to see it
    // in sysfs

    exportfd = open("/sys/class/gpio/export", O_WRONLY);
    if (exportfd < 0)
    {
        printf("Cannot open GPIO to export it\n");
        exit(1);
    }

    write(exportfd, "54", 3);
    close(exportfd);

    printf("GPIO exported successfully\n");

    // Update the direction of the GPIO to be an output

    directionfd = open("/sys/class/gpio/gpio54/direction", O_RDWR);
    if (directionfd < 0)
    {
        printf("Cannot open GPIO direction it\n");
        exit(1);
    }

    write(directionfd, "in", 3);
    close(directionfd);

    printf("GPIO direction set as input successfully\n");
}
game::vector game::polygon::point(int num)
{
    if(num == 0)
    {
        if(points_.size() > 0)
        {
            return originPoint_;
        } else
        {
            fprintf(stderr, "Attempted to get point from uninitialized polygon\n");
            exit(EXIT_FAILURE);
        }
    } else
    {
        if(num > points_.size())
        {
            fprintf(stderr, "Attempted to get point beyond polygon points\n");
            exit(EXIT_FAILURE);
        }
        --num;
        if(points_.size() == 0)
        {
            fprintf(stderr, "Attempted to get point from uninitialized polygon\n");
            exit(EXIT_FAILURE);
        }
        return points_.at(num);
    }
}
Example #5
0
static void
load_module(void)
{
    FILE *fp;
    char line[8192];

    if (!module_loaded()) {
        if (verbose)
            fprintf(stderr, "Loading Flashcache Module\n");
        system("modprobe flashcache");
        if (!module_loaded()) {
            fprintf(stderr, "Could not load Flashcache Module\n");
            exit(1);
        }
    } else if (verbose)
        fprintf(stderr, "Flashcache Module already loaded\n");
    fp = fopen("/proc/flashcache_version", "ro");
    fgets(line, 8190, fp);
    if (fgets(line, 8190, fp)) {
        if (verbose)
            fprintf(stderr, "version string \"%s\"\n", line);
#ifdef COMMIT_REV
        if (!strstr(line, COMMIT_REV)) {
            fprintf(stderr, "Flashcache revision doesn't match tool revision.\n");
            exit(1);
        }
#endif
    }
    fclose(fp);
}
Example #6
0
int main(int argc, char **argv, char **envp) {

    void *handle;
    char *(*fh)(int, int);
    char *error;

    handle = dlopen ("", RTLD_LAZY);
    if (!handle) {
        fprintf (stderr, "%s\n", dlerror());
        exit(1);
    }
    dlerror();

    /* Lookup undefined symbol */
    fh = dlsym(handle, "method1");
    if ((error = dlerror()) != NULL)  {
        fprintf (stderr, "%s\n", error);
        exit(1);
    }

    if (global_old == 1
            && global == 2
            && global1 == 3
            && method_old(1) == 1
            && method(1,2) == 2
            /* Default versions */
            && method1(1,2) == 3
            && (long)fh(0,0) == 3) {
        printf("\nTest \"versioning\" successful.\n\n");
    } else {
        printf("\nTest \"versioning\" failed.\n\n");
    }

    return 0;
}