2
0

convert4-3.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: convert4-3.c /main/1 1996/04/21 19:22:43 drk $ */
  24. /*
  25. * (c) Copyright 1993, 1994 Hewlett-Packard Company
  26. * (c) Copyright 1993, 1994 International Business Machines Corp.
  27. * (c) Copyright 1993, 1994 Novell, Inc.
  28. * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  29. */
  30. #include <EUSCompat.h>
  31. #include <string.h>
  32. #include <stdlib.h>
  33. #include "rtable3.h"
  34. #include "rtable4.h"
  35. #include "convert4-3.h"
  36. /*
  37. * forward declaration of static functions
  38. */
  39. static void free_excpt3(Except_3 *e);
  40. static Abb_Appt_3 * abb4_to_abb3(Abb_Appt_4 *a4);
  41. static void apptid4_to_apptid3(Apptid_4 *from, Apptid_3 *to);
  42. static Reminder_3 * reminder4_to_reminder3(Reminder_4 *r4);
  43. static Table_Res_Type_3 tablerestype4_to_tablerestype3(Table_Res_Type_4 t);
  44. static void tablereslist4_to_tablereslist3(Table_Res_List_4 *from,
  45. Table_Res_List_3 *to);
  46. static void period4_to_period3(Period_4 *p4, Period_3 *p3);
  47. static void assign_tag4to3(Tag_4 *t4, Tag_3 *t3);
  48. static void assign_status4to3(Appt_Status_4 *s4, Appt_Status_3 *s3);
  49. static void assign_privacy4to3(Privacy_Level_4 *p4, Privacy_Level_3 *p3);
  50. static Buffer_3 buffer4_to_buffer3(Buffer_4 b);
  51. static Tag_3 * tag4_to_tag3(Tag_4 *t4);
  52. static Attribute_3 * attr4_to_attr3(Attribute_4 *a4);
  53. static Except_3 * except4_to_except3(Except_4 *e4);
  54. static Table_Args_Type_3 argstag4_to_argstag3(Table_Args_Type_4 t);
  55. static void args4_to_args3(Args_4 *from, Args_3 *to);
  56. static Table_Args_3 * tableargs4_to_tableargs3(Table_Args_4 *a4);
  57. static Registration_3 * reg4_to_reg3(Registration_4 *r4);
  58. static void free_tag3(Tag_3 *t);
  59. /**************** DATA TYPE (4->3) CONVERSION ROUTINES **************/
  60. extern void
  61. _DtCm_id4_to_id3(Id_4 *from, Id_3 *to)
  62. {
  63. if ((from==NULL) || (to==NULL)) return;
  64. to->tick = from->tick;
  65. to->key = from->key;
  66. }
  67. extern Uid_3 *
  68. _DtCm_uid4_to_uid3(Uid_4 *ui4)
  69. {
  70. Uid_3 *ui3, *head, *prev;
  71. prev = head = NULL;
  72. while (ui4 != NULL) {
  73. ui3 = (Uid_3 *)calloc(1, sizeof(Uid_3));
  74. _DtCm_id4_to_id3(&(ui4->appt_id), &(ui3->appt_id));
  75. ui3->next = NULL;
  76. if (head == NULL)
  77. head = ui3;
  78. else
  79. prev->next = ui3;
  80. prev = ui3;
  81. ui4 = ui4->next;
  82. }
  83. return(head);
  84. }
  85. extern Appt_3 *
  86. _DtCm_appt4_to_appt3(Appt_4 *a4)
  87. {
  88. Appt_3 *a3, *head, *prev;
  89. prev = head = NULL;
  90. while (a4 != NULL) {
  91. a3 = (Appt_3 *)calloc(1, sizeof(Appt_3));
  92. _DtCm_id4_to_id3(&(a4->appt_id), &(a3->appt_id));
  93. a3->tag = tag4_to_tag3(a4->tag);
  94. a3->duration = a4->duration;
  95. a3->ntimes = a4->ntimes;
  96. a3->what = buffer4_to_buffer3(a4->what);
  97. period4_to_period3(&(a4->period), &(a3->period));
  98. a3->author = buffer4_to_buffer3(a4->author);
  99. a3->client_data = buffer4_to_buffer3(a4->client_data);
  100. a3->exception = except4_to_except3(a4->exception);
  101. a3->attr = attr4_to_attr3(a4->attr);
  102. assign_status4to3(&a4->appt_status, &a3->appt_status);
  103. assign_privacy4to3(&a4->privacy, &a3->privacy);
  104. a3->next = NULL;
  105. if (head == NULL)
  106. head = a3;
  107. else
  108. prev->next = a3;
  109. prev = a3;
  110. a4 = a4->next;
  111. }
  112. return(head);
  113. }
  114. extern void
  115. _DtCm_free_appt3(Appt_3 *a)
  116. {
  117. Appt_3 *ptr;
  118. while (a != NULL) {
  119. ptr = a->next;
  120. if (a->tag != NULL)
  121. free_tag3(a->tag);
  122. if (a->what != NULL)
  123. free(a->what);
  124. if (a->author != NULL)
  125. free(a->author);
  126. if (a->client_data != NULL)
  127. free(a->client_data);
  128. if (a->attr != NULL)
  129. _DtCm_free_attr3(a->attr);
  130. if (a->exception != NULL)
  131. free_excpt3(a->exception);
  132. free(a);
  133. a = ptr;
  134. }
  135. }
  136. extern void
  137. _DtCm_free_attr3(Attribute_3 *a)
  138. {
  139. Attribute_3 *ptr;
  140. while (a != NULL) {
  141. ptr = a->next;
  142. if (a->attr != NULL)
  143. free(a->attr);
  144. if (a->value != NULL)
  145. free(a->value);
  146. if (a->clientdata != NULL)
  147. free(a->clientdata);
  148. free(a);
  149. a = ptr;
  150. }
  151. }
  152. static void
  153. free_excpt3(Except_3 *e)
  154. {
  155. Except_3 *ptr;
  156. while (e != NULL) {
  157. ptr = e->next;
  158. free(e);
  159. e = ptr;
  160. }
  161. }
  162. static Abb_Appt_3 *
  163. abb4_to_abb3(Abb_Appt_4 *a4)
  164. {
  165. Abb_Appt_3 *a3, *head, *prev;
  166. prev = head = NULL;
  167. while (a4 != NULL) {
  168. a3 = (Abb_Appt_3 *)calloc(1, sizeof(Abb_Appt_3));
  169. _DtCm_id4_to_id3(&(a4->appt_id), &(a3->appt_id));
  170. a3->tag = tag4_to_tag3(a4->tag);
  171. a3->what = buffer4_to_buffer3(a4->what);
  172. a3->duration = a4->duration;
  173. period4_to_period3(&(a4->period), &(a3->period));
  174. assign_status4to3(&a4->appt_status, &a3->appt_status);
  175. assign_privacy4to3(&a4->privacy, &a3->privacy);
  176. a3->next = NULL;
  177. if (head == NULL)
  178. head = a3;
  179. else
  180. prev->next = a3;
  181. prev = a3;
  182. a4 = a4->next;
  183. }
  184. return(head);
  185. }
  186. static void
  187. apptid4_to_apptid3(Apptid_4 *from, Apptid_3 *to)
  188. {
  189. if (from==NULL || to==NULL) return;
  190. _DtCm_id4_to_id3(from->oid, to->oid);
  191. to->new_appt = _DtCm_appt4_to_appt3(from->new_appt);
  192. }
  193. static Reminder_3 *
  194. reminder4_to_reminder3(Reminder_4 *r4)
  195. {
  196. Reminder_3 *r3, *head, *prev;
  197. Attribute_3 *attr3;
  198. prev = head = NULL;
  199. while (r4 != NULL) {
  200. r3 = (Reminder_3 *)calloc(1, sizeof(Reminder_3));
  201. _DtCm_id4_to_id3(&(r4->appt_id), &(r3->appt_id));
  202. r3->tick = r4->tick;
  203. attr3 = attr4_to_attr3(&(r4->attr));
  204. r3->attr = *attr3;
  205. free(attr3);
  206. r3->next = NULL;
  207. if (head == NULL)
  208. head = r3;
  209. else
  210. prev->next = r3;
  211. prev = r3;
  212. r4 = r4->next;
  213. }
  214. return(head);
  215. }
  216. static Table_Res_Type_3
  217. tablerestype4_to_tablerestype3(Table_Res_Type_4 t)
  218. {
  219. switch(t) {
  220. case AP_4:
  221. return(AP_3);
  222. case RM_4:
  223. return(RM_3);
  224. case AB_4:
  225. return(AB_3);
  226. case ID_4:
  227. return(ID_3);
  228. default:
  229. return(AP_3);
  230. }
  231. }
  232. static void
  233. tablereslist4_to_tablereslist3(Table_Res_List_4 *from, Table_Res_List_3 *to)
  234. {
  235. if (from==NULL || to==NULL) return;
  236. to->tag = tablerestype4_to_tablerestype3(from->tag);
  237. switch (from->tag) {
  238. case AP_4:
  239. to->Table_Res_List_3_u.a = _DtCm_appt4_to_appt3(
  240. from->Table_Res_List_4_u.a);
  241. break;
  242. case RM_4:
  243. to->Table_Res_List_3_u.r = reminder4_to_reminder3(
  244. from->Table_Res_List_4_u.r);
  245. break;
  246. case AB_4:
  247. to->Table_Res_List_3_u.b = abb4_to_abb3(
  248. from->Table_Res_List_4_u.b);
  249. break;
  250. case ID_4:
  251. to->Table_Res_List_3_u.i = _DtCm_uid4_to_uid3(
  252. from->Table_Res_List_4_u.i);
  253. default:
  254. return;
  255. }
  256. }
  257. extern Access_Status_3
  258. _DtCm_accstat4_to_accstat3(Access_Status_4 s)
  259. {
  260. switch(s) {
  261. case access_ok_4:
  262. return(access_ok_3);
  263. case access_added_4:
  264. return(access_added_3);
  265. case access_removed_4:
  266. return(access_removed_3);
  267. case access_failed_4:
  268. return(access_failed_3);
  269. case access_exists_4:
  270. return(access_exists_3);
  271. case access_partial_4:
  272. return(access_partial_3);
  273. case access_other_4:
  274. default:
  275. return(access_other_3);
  276. }
  277. }
  278. extern Table_Res_3 *
  279. _DtCm_tableres4_to_tableres3(Table_Res_4 *r4)
  280. {
  281. Table_Res_3 *r3;
  282. if (r4==NULL) return((Table_Res_3 *)NULL);
  283. r3 = (Table_Res_3 *)calloc(1, sizeof(Table_Res_3));
  284. r3->status = _DtCm_accstat4_to_accstat3(r4->status);
  285. tablereslist4_to_tablereslist3(&(r4->res), &(r3->res));
  286. return(r3);
  287. }
  288. extern Access_Entry_3 *
  289. _DtCm_acclist4_to_acclist3(Access_Entry_4 *l4)
  290. {
  291. Access_Entry_3 *l3, *head, *prev;
  292. prev = head = NULL;
  293. while (l4 != NULL) {
  294. l3 = (Access_Entry_3 *)calloc(1, sizeof(Access_Entry_3));
  295. l3->who = buffer4_to_buffer3(l4->who);
  296. l3->access_type = l4->access_type;
  297. l3->next = NULL;
  298. if (head == NULL)
  299. head = l3;
  300. else
  301. prev->next = l3;
  302. prev = l3;
  303. l4 = l4->next;
  304. }
  305. return(head);
  306. }
  307. extern Access_Args_3 *
  308. _DtCm_accargs4_to_accargs3(Access_Args_4 *a4)
  309. {
  310. Access_Args_3 *a3;
  311. if (a4==NULL) return((Access_Args_3 *)NULL);
  312. a3 = (Access_Args_3 *)calloc(1, sizeof(Access_Args_3));
  313. a3->target = buffer4_to_buffer3(a4->target);
  314. a3->access_list = _DtCm_acclist4_to_acclist3(a4->access_list);
  315. return(a3);
  316. }
  317. extern Range_3 *
  318. _DtCm_range4_to_range3(Range_4 *r4)
  319. {
  320. Range_3 *r3, *head, *prev;
  321. prev = head = NULL;
  322. while (r4 != NULL) {
  323. r3 = (Range_3 *)calloc(1, sizeof(Range_3));
  324. r3->key1 = r4->key1;
  325. r3->key2 = r4->key2;
  326. r3->next = NULL;
  327. if (head == NULL)
  328. head = r3;
  329. else
  330. prev->next = r3;
  331. prev = r3;
  332. r4 = r4->next;
  333. }
  334. return(head);
  335. }
  336. extern Keyrange_3 *
  337. _DtCm_keyrange4_to_keyrange3(Keyrange_4 *r4)
  338. {
  339. Keyrange_3 *r3, *head, *prev;
  340. prev = head = NULL;
  341. while (r4 != NULL) {
  342. r3 = (Keyrange_3 *)calloc(1, sizeof(Keyrange_3));
  343. r3->key = r4->key;
  344. r3->tick1 = r4->tick1;
  345. r3->tick2 = r4->tick2;
  346. r3->next = NULL;
  347. if (head == NULL)
  348. head = r3;
  349. else
  350. prev->next = r3;
  351. prev = r3;
  352. r4 = r4->next;
  353. }
  354. return(head);
  355. }
  356. extern Registration_Status_3
  357. _DtCm_regstat4_to_regstat3(Registration_Status_4 s)
  358. {
  359. switch (s) {
  360. case registered_4:
  361. return(registered_3);
  362. case failed_4:
  363. return(failed_3);
  364. case deregistered_4:
  365. return(deregistered_3);
  366. case confused_4:
  367. return(confused_3);
  368. case reg_notable_4:
  369. default:
  370. return(failed_3);
  371. }
  372. }
  373. extern Table_Status_3
  374. _DtCm_tablestat4_to_tablestat3(Table_Status_4 s)
  375. {
  376. switch(s) {
  377. case ok_4:
  378. return(ok_3);
  379. case duplicate_4:
  380. return(duplicate_3);
  381. case badtable_4:
  382. return(badtable_3);
  383. case notable_4:
  384. return(notable_3);
  385. case denied_4:
  386. return(denied_3);
  387. case other_4:
  388. default:
  389. return(other_3);
  390. }
  391. }
  392. extern Uid_3 *
  393. _DtCm_uidopt4_to_uid3(Uidopt_4 *uidopt)
  394. {
  395. Uid_3 *uid3, *head, *prev;
  396. prev = head = NULL;
  397. while (uidopt != NULL) {
  398. uid3 = (Uid_3 *)calloc(1, sizeof(Uid_3));
  399. _DtCm_id4_to_id3(&(uidopt->appt_id), &(uid3->appt_id));
  400. uid3->next = NULL;
  401. if (head == NULL)
  402. head = uid3;
  403. else
  404. prev->next = uid3;
  405. prev = uid3;
  406. uidopt = uidopt->next;
  407. }
  408. return(head);
  409. }
  410. /*
  411. * Repeating event types beyond "yearly" are mapped to "single"
  412. * because the old front end does not recognize any other types
  413. * Worse yet it uses Interval to index into an array which
  414. * contains strings up to "yearly", any period types beyond that
  415. * would index beyond the array and cause the front end to dump core.
  416. */
  417. static void
  418. period4_to_period3(Period_4 *p4, Period_3 *p3)
  419. {
  420. if (p3 == NULL || p4 == NULL) return;
  421. switch (p4->period) {
  422. case single_4: p3->period = single_3;
  423. p3->nth = p4->nth;
  424. break;
  425. case daily_4: p3->period = daily_3;
  426. p3->nth = p4->nth;
  427. break;
  428. case weekly_4: p3->period = weekly_3;
  429. p3->nth = p4->nth;
  430. break;
  431. case biweekly_4: p3->period = biweekly_3;
  432. p3->nth = p4->nth;
  433. break;
  434. case monthly_4: p3->period = monthly_3;
  435. p3->nth = p4->nth;
  436. break;
  437. case yearly_4: p3->period = yearly_3;
  438. p3->nth = p4->nth;
  439. break;
  440. default: p3->period = single_3;
  441. p3->nth = 0;
  442. break;
  443. }
  444. }
  445. static void
  446. assign_tag4to3(Tag_4 *t4, Tag_3 *t3)
  447. {
  448. switch (t4->tag) {
  449. case appointment_4: t3->tag = appointment_3;
  450. break;
  451. case reminder_4: t3->tag = reminder_3;
  452. break;
  453. case otherTag_4: t3->tag = otherTag_3;
  454. break;
  455. case holiday_4: t3->tag = holiday_3;
  456. break;
  457. case toDo_4: t3->tag = toDo_3;
  458. break;
  459. }
  460. }
  461. static void
  462. assign_status4to3(Appt_Status_4 *s4, Appt_Status_3 *s3)
  463. {
  464. switch (*s4) {
  465. case active_4: *s3 = active_3;
  466. break;
  467. case pendingAdd_4: *s3 = pendingAdd_3;
  468. break;
  469. case pendingDelete_4: *s3 = pendingDelete_3;
  470. break;
  471. case committed_4: *s3 = committed_3;
  472. break;
  473. case cancelled_4: *s3 = cancelled_3;
  474. break;
  475. case completed_4: *s3 = completed_3;
  476. break;
  477. }
  478. }
  479. static void
  480. assign_privacy4to3(Privacy_Level_4 *p4, Privacy_Level_3 *p3)
  481. {
  482. switch (*p4) {
  483. case public_4: *p3 = public_3;
  484. break;
  485. case private_4: *p3 = private_3;
  486. break;
  487. case semiprivate_4: *p3 = semiprivate_3;
  488. break;
  489. }
  490. }
  491. static Buffer_3
  492. buffer4_to_buffer3(Buffer_4 b)
  493. {
  494. Buffer_3 copy;
  495. if (b!=NULL)
  496. copy = strdup(b);
  497. else
  498. copy = calloc(1, 1);
  499. return(copy);
  500. }
  501. static Tag_3 *
  502. tag4_to_tag3(Tag_4 *t4)
  503. {
  504. Tag_3 *t3, *head, *prev;
  505. prev = head = NULL;
  506. while (t4 != NULL) {
  507. t3 = (Tag_3 *)calloc(1, sizeof(Tag_3));
  508. assign_tag4to3(t4, t3);
  509. t3->showtime = t4->showtime;
  510. t3->next = NULL;
  511. if (head == NULL)
  512. head = t3;
  513. else
  514. prev->next = t3;
  515. prev = t3;
  516. t4 = t4->next;
  517. }
  518. return(head);
  519. }
  520. static Attribute_3 *
  521. attr4_to_attr3(Attribute_4 *a4)
  522. {
  523. Attribute_3 *a3, *head, *prev;
  524. prev = head = NULL;
  525. while (a4 != NULL) {
  526. a3 = (Attribute_3 *)calloc(1, sizeof(Attribute_3));
  527. a3->next = NULL;
  528. a3->attr = buffer4_to_buffer3(a4->attr);
  529. a3->value = buffer4_to_buffer3(a4->value);
  530. a3->clientdata = buffer4_to_buffer3(a4->clientdata);
  531. if (head == NULL)
  532. head = a3;
  533. else
  534. prev->next = a3;
  535. prev = a3;
  536. a4 = a4->next;
  537. }
  538. return(head);
  539. }
  540. static Except_3 *
  541. except4_to_except3(Except_4 *e4)
  542. {
  543. Except_3 *e3, *head, *prev;
  544. prev = head = NULL;
  545. while (e4 != NULL) {
  546. e3 = (Except_3 *)calloc(1, sizeof(Except_3));
  547. e3->ordinal = e4->ordinal;
  548. e3->next=NULL;
  549. if (head == NULL)
  550. head = e3;
  551. else
  552. prev->next = e3;
  553. prev = e3;
  554. e4 = e4->next;
  555. }
  556. return(head);
  557. }
  558. static Table_Args_Type_3
  559. argstag4_to_argstag3(Table_Args_Type_4 t)
  560. {
  561. switch(t) {
  562. case TICK_4:
  563. return(TICK_3);
  564. case APPTID_4:
  565. return(APPTID_3);
  566. case UID_4:
  567. return(UID_3);
  568. case APPT_4:
  569. return(APPT_3);
  570. case RANGE_4:
  571. return(RANGE_3);
  572. case KEYRANGE_4:
  573. return(KEYRANGE_3);
  574. default:
  575. return(TICK_3);
  576. }
  577. }
  578. static void
  579. args4_to_args3(Args_4 *from, Args_3 *to)
  580. {
  581. if (from==NULL || to==NULL) return;
  582. to->tag = argstag4_to_argstag3(from->tag);
  583. switch(from->tag) {
  584. case TICK_4:
  585. to->Args_3_u.tick = from->Args_4_u.tick;
  586. break;
  587. case APPTID_4:
  588. to->Args_3_u.apptid.oid = (Id_3 *)calloc(1, sizeof(Id_3));
  589. apptid4_to_apptid3(
  590. &(from->Args_4_u.apptid),
  591. &(to->Args_3_u.apptid));
  592. break;
  593. case UID_4:
  594. to->Args_3_u.key = _DtCm_uid4_to_uid3(from->Args_4_u.key);
  595. break;
  596. case APPT_4:
  597. to->Args_3_u.appt = _DtCm_appt4_to_appt3(from->Args_4_u.appt);
  598. break;
  599. case RANGE_4:
  600. to->Args_3_u.range = _DtCm_range4_to_range3(from->Args_4_u.range);
  601. break;
  602. case KEYRANGE_4:
  603. to->Args_3_u.keyrange = _DtCm_keyrange4_to_keyrange3(
  604. from->Args_4_u.keyrange);
  605. default:
  606. break;
  607. }
  608. }
  609. static Table_Args_3 *
  610. tableargs4_to_tableargs3(Table_Args_4 *a4)
  611. {
  612. Table_Args_3 *a3;
  613. if (a4==NULL) return((Table_Args_3 *)NULL);
  614. a3 = (Table_Args_3 *)calloc(1, sizeof(Table_Args_3));
  615. a3->target = buffer4_to_buffer3(a4->target);
  616. args4_to_args3(&(a4->args), &(a3->args));
  617. a3->pid = a4->pid;
  618. return(a3);
  619. }
  620. static Registration_3 *
  621. reg4_to_reg3(Registration_4 *r4)
  622. {
  623. Registration_3 *r3, *head, *prev;
  624. prev = head = NULL;
  625. while (r4 != NULL) {
  626. r3 = (Registration_3 *)calloc(1, sizeof(Registration_3));
  627. r3->target = buffer4_to_buffer3(r4->target);
  628. r3->prognum = r4->prognum;
  629. r3->versnum = r4->versnum;
  630. r3->procnum = r4->procnum;
  631. r3->next = NULL;
  632. r3->pid = r4->pid;
  633. if (head == NULL)
  634. head = r3;
  635. else
  636. prev->next = r3;
  637. prev = r3;
  638. r4 = r4->next;
  639. }
  640. return(head);
  641. }
  642. static void
  643. free_tag3(Tag_3 *t)
  644. {
  645. Tag_3 *ptr;
  646. while (t != NULL) {
  647. ptr = t->next;
  648. free(t);
  649. t = ptr;
  650. }
  651. }