Skip to content
Permalink
Browse files

Use the new network initialize and shutdown functions

  • Loading branch information...
alesliehughes committed Jun 16, 2010
1 parent b6c0c0e commit 0f796c870ba78b5dc712de329851515e48fc1683
Showing with 132 additions and 53 deletions.
  1. +23 −8 blockhost.c
  2. +18 −5 cjob.c
  3. +22 −7 ctask.c
  4. +20 −6 jobfinfo.c
  5. +49 −27 sendjob.cpp
@@ -43,7 +43,14 @@ int main (int argc,char *argv[]) {
struct blocked_host *bh;
uint16_t nblocked;
int i;

int nRet = 0;

if(network_initialize() != 0) {
fprintf (stderr,"Could not initialize the network: %s\n", drerrno_str());
nRet = 1;
goto cleanup;
}

while ((opt = getopt (argc,argv,"lj:a:d:vh")) != -1) {
switch (opt) {
case 'a':
@@ -62,38 +69,43 @@ int main (int argc,char *argv[]) {
break;
case 'v':
show_version (argv);
exit (0);
goto cleanup;
case '?':
case 'h':
usage();
exit (1);
nRet = 1;
goto cleanup;
}
}

if ((ijob == -1) || (action == ACTION_NONE)) {
usage ();
exit (1);
nRet = 1;
goto cleanup;
}

set_default_env();

if (!common_environment_check()) {
fprintf (stderr,"Error checking the environment: %s\n",drerrno_str());
exit (1);
nRet = 1;
goto cleanup;
}

switch (action) {
case ACTION_ADD:
if (!request_job_add_blocked_host ((uint32_t)ijob,(uint32_t)icomp,CLIENT)) {
fprintf (stderr,"ERROR: While trying to add host to block list: %s\n",drerrno_str());
exit (1);
nRet = 1;
goto cleanup;
}
printf ("Host blocked successfully\n");
break;
case ACTION_DEL:
if (!request_job_delete_blocked_host ((uint32_t)ijob,(uint32_t)icomp,CLIENT)) {
fprintf (stderr,"ERROR: While trying to delete host from block list: %s\n",drerrno_str());
exit (1);
nRet = 1;
goto cleanup;
}
printf ("Host unblocked successfully\n");
break;
@@ -105,7 +117,10 @@ int main (int argc,char *argv[]) {
break;
}

exit (0);
cleanup:
network_shutdown();

return nRet;
}

void usage (void) {
23 cjob.c
@@ -42,6 +42,13 @@ int main (int argc,char *argv[]) {
int ijob = -1;
int action = ACTION_NONE;
struct job job;
int nRet = 0;

if(network_initialize() != 0) {
fprintf (stderr,"Could not initialize the network: %s\n", drerrno_str());
nRet = 1;
goto cleanup;
}

while ((opt = getopt (argc,argv,"sdcktj:vh")) != -1) {
switch (opt) {
@@ -65,24 +72,27 @@ int main (int argc,char *argv[]) {
break;
case 'v':
show_version (argv);
exit (0);
goto cleanup;
case '?':
case 'h':
usage();
exit (1);
nRet = 1;
goto cleanup;
}
}

if ((ijob == -1) || (action == ACTION_NONE)) {
usage ();
exit (1);
nRet = 1;
goto cleanup;
}

set_default_env();

if (!common_environment_check()) {
fprintf (stderr,"Error checking the environment: %s\n",drerrno_str());
exit (1);
nRet = 1;
goto cleanup;
}

switch (action) {
@@ -108,7 +118,10 @@ int main (int argc,char *argv[]) {
break;
}

exit (0);
cleanup:
network_shutdown();

return nRet;
}

void usage (void) {
29 ctask.c
@@ -40,6 +40,13 @@ int main (int argc,char *argv[]) {
uint32_t frame = -1;
uint32_t ijob = -1;
int status = STATUS_NONE;
int nRet = 0;

if(network_initialize() != 0) {
fprintf (stderr,"Could not initialize the network: %s\n", drerrno_str());
nRet = 1;
goto cleanup;
}

while ((opt = getopt (argc,argv,"j:f:dervh")) != -1) {
switch (opt) {
@@ -60,32 +67,36 @@ int main (int argc,char *argv[]) {
break;
case 'v':
show_version (argv);
exit (0);
goto cleanup;
case '?':
case 'h':
usage();
exit (1);
nRet = 1;
goto cleanup;
}
}

if ((ijob == -1) || (status == STATUS_NONE)) {
usage ();
exit (1);
nRet = 1;
goto cleanup;
}

set_default_env();

if (!common_environment_check()) {
fprintf (stderr,"Error checking the environment: %s\n",drerrno_str());
exit (1);
nRet = 1;
goto cleanup;
}

switch (status) {
case STATUS_FINISHED:
printf ("Setting frame finished: %i,%i\n",frame,ijob);
if (! request_job_frame_finish (ijob,frame,CLIENT)) {
fprintf (stderr,"ERROR: While trying to set finished: %s\n",drerrno_str());
exit (1);
nRet = 1;
goto cleanup;
}
printf ("Frame set finished successfully\n");
break;
@@ -96,13 +107,17 @@ int main (int argc,char *argv[]) {
printf ("Requeueing frame: %i,%i\n",frame,ijob);
if (! request_job_frame_waiting (ijob,frame,CLIENT)) {
fprintf (stderr,"ERROR: While trying to requeue: %s\n",drerrno_str());
exit (1);
nRet = 1;
goto cleanup;
}
printf ("Frame requeued successfully\n");
break;
}

exit (0);
cleanup:
network_shutdown();

return nRet;
}

void usage (void) {
@@ -46,6 +46,13 @@ int main (int argc,char *argv[]) {
int ijob = -1;
struct frame_info fi;
enum operation op = OP_NONE;
int nRet = 0;

if(network_initialize() != 0) {
fprintf (stderr,"Could not initialize the network: %s\n", drerrno_str());
nRet = 1;
goto cleanup;
}

while ((opt = getopt (argc,argv,"rsj:f:vh")) != -1) {
switch (opt) {
@@ -57,7 +64,7 @@ int main (int argc,char *argv[]) {
break;
case 'v':
show_version (argv);
exit (0);
goto cleanup;
case 'r':
op = OP_REQUEUED;
break;
@@ -67,25 +74,29 @@ int main (int argc,char *argv[]) {
case '?':
case 'h':
usage();
exit (1);
nRet = 1;
goto cleanup;
}
}

if ((frame == -1) || (ijob == -1) || (op == OP_NONE)) {
usage ();
exit (1);
nRet = 1;
goto cleanup;
}

set_default_env();

if (!common_environment_check()) {
fprintf (stderr,"Error checking the environment: %s\n",drerrno_str());
exit (1);
nRet = 1;
goto cleanup;
}

if (!request_job_frame_info ((uint32_t)ijob,(uint32_t)frame,&fi,CLIENT)) {
fprintf (stderr,"ERROR: While trying to request the frame info: %s\n",drerrno_str());
exit (1);
nRet = 1;
goto cleanup;;
}

switch (op) {
@@ -100,7 +111,10 @@ int main (int argc,char *argv[]) {
break;
}

exit (0);
cleanup:
network_shutdown();

return nRet;
}

void usage (void) {
Oops, something went wrong.

0 comments on commit 0f796c8

Please sign in to comment.
You can’t perform that action at this time.